import{o as b,dv as de,G as w,eE as pe,U as F,Y as L,a2 as he,gl as me,q as B,a as t,gm as ge,gn as Pe,a4 as U,aQ as Se,go as ye,gp as q,N as Q,gq as J,gr as fe,bL as E,C as ke,Q as W,gs as _,dR as Z,gt as j,gu as be,gv as Ee,dy as Ce,gw as _e,gx as ve,gy as Ae,gz as We,gA as v,d0 as ee,gB as Le,gC as T,gD as Be,fU as S,B as te,b6 as ae,aC as D,bf as Me,bx as se,X as De,gE as z,gF as xe,gG as Te,fQ as we,y as M,gH as Y,aV as Re,al as Oe,bH as Ie,gI as Ne,k as He,n as A,gJ as Ge,aR as Fe,a$ as Ue,I as ze,au as Ye,aS as ne,gK as Ve,T as Xe,gL as Ke,gM as $e,gN as qe,gO as Qe,ag as Je,gP as Ze,gQ as je,gR as et,cJ as oe,E as tt,gS as at,R as st,aA as nt,gT as ot,gU as rt,gV as it,gW as re,gX as lt,gY as ct,l as ut,S as V,gZ as dt,b8 as pt,ac as ht,A as mt,g_ as gt,d7 as Pt,g$ as St}from"./app.B46ok1sD.js";import{u as yt,a as ie,S as ft}from"./useEditorShopPayNavigation.CePpaa9N.js";import{P as kt}from"./VaultedPayment.B9qZpD2h.js";function pa(){const e=b(),a=de(),{shopPayEnabled:n}=w(),{value:s}=pe(),o=F().rememberMe,l=!!s?.rememberMe||o.value,[r,i]=L(l),{negotiate:u}=he(),p=me()?.saveShippingAddressCheckboxEnabled??!0,y=!!a,f=F().shippingAddress.value,P=!n&&p&&!y&&!f.oneTimeUse,m=B(k=>{i(k),o.value=k,u({})},[u,o]);return P?t(ge,{id:"save_shipping_information",name:"save_shipping_information",checked:r,onChange:m,children:e("customer_account.save_my_information_label")}):null}const bt=["GooglePay","PayPal","Venmo"];function ha({id:e}){return Pe({id:e,stage:({pendingComponents:a})=>bt.some(s=>a.has(s))?U.Usable:U.Complete}),null}const Et="vT2w7",Ct="f1x20",_t="hKWGx",X={ApplePayButton:Et,dark:Ct,light:_t};function vt({supportedNetworks:e,color:a}){const n=b(),{locale:s}=Se().i18n,o=ye(),l=q(),r=Q(J),i=fe(),{paymentSheetError:u}=E().inMemoryApplePayParts,h=ke(),p=()=>{try{i(o({supportedNetworks:e}).session)}catch(y){h.leaveBreadcrumb("Failed to create Apple Pay session",{error:y}),u.value={type:"failed_to_create_session"}}};return t("button",{ref:l("apple_pay"),className:W(X.ApplePayButton,X[a],_.borderRadius,_.focusOutline,{[_.shadow]:r}),lang:s,onClick:p,type:"button","aria-label":n("brand.apple_pay")})}const At="Xicuw",K={Button:At,"Button--contrast":"oHCaH"},Wt="shop-pay-button";function Lt(){const e=Z(),{id:a}=w(),n=j(),s=yt({foregroundColor:be}),o=Ee(),l=Ce(),r=_e(o,l),{telemetry:{lastClickedWallet:i}}=E(),u=ve(Ae.DirectCheckoutCheckout),h=q(),p=Q(J),y=We(v.ShopifyPay),{setEditorShopPay:f}=ie(),P=B(()=>{const d=parseInt(ee(a),10),C=Le(v.ShopifyPay,T.Success,d,n);e?.record(C),y(),i.value="SHOP_PAY"},[a,e,n,i,y]),m=B(d=>{if(f){d.preventDefault(),f(!0);return}P()},[P,f]),k=W(K.Button,{[K["Button--contrast"]]:!s&&!r},_.borderRadius,_.focusOutline,{[_.shadow]:p});return t("a",{id:Wt,href:u,ref:h("shop_pay"),className:k,"aria-label":"Shop Pay",onClick:m,children:t(ft,{size:"medium"})})}const Bt="o1z23",Mt="_4aXW0",Dt="DUnBb",xt="kTI19",Tt="JH5oc",wt="pUo2R",Rt="_5SdgT",Ot="RKgRy",It="iRnuh",Nt="QKTth",Ht="Pnahu",Gt="OTERX",Ft="WTXfy",Ut="qLVAT",zt="XHLFs",c={Header:Bt,Text:Mt,Layout:Dt,StackWrapper:xt,SkeletonWrapper:Tt,ButtonWrapper:wt,loading:Rt,subsequentLoad:Ot,Stack:It,SimulatedWalletStack:Nt,ShopPayEmphasis:Ht,Container:Gt,DrawerLink:Ft,InnerDrawerLink:Ut,DrawerHideButtons:zt};function Yt(){const e=E();return Be.map(n=>Vt(e,n)).some(Boolean)}function Vt(e,a){const n=!!e.acceleratedWalletPaymentMethods.find(o=>o.name===a),s=(()=>{switch(a){case"PAYPAL_EXPRESS":return e.inMemoryPayPalParts.acceleratedCheckoutButtonStatus.peek();case"GOOGLE_PAY":return e.inMemoryGooglePayParts.buttonStatus.peek();case S.AmazonPay:case S.BuyWithPrime:return e.inMemoryAmazonPayParts.buttonStatus.peek();default:return}})();return n&&s?.status==="not_rendered"}function Xt(){const e=b();return t(Me,{open:!0,blocking:!0,accessibilityLabel:e("wallets.payment_in_progress_title"),padding:"none",children:t(te,{spacing:"loose",padding:"large200",children:[t(ae,{level:1,children:e("wallets.payment_in_progress_title")}),t(D,{children:e("wallets.payment_in_progress_body")})]})})}function Kt(){const e=se(),a=De(),{walletUsedForSubmissionSignal:n,receiptErrorSignal:s,inMemoryApplePayParts:{asPaymentMethod:o}}=E(),l=z(xe()),r=z(Te()),i=we(a?.status==="failed"&&a.failure.type==="payment"&&e?a?.failure:void 0);M(()=>{if(a?.status==="processing"||a?.status==="polling_for_order")return;const u=n.value;if(u){if(a?.status!=="failed"){s.value=void 0;return}u==="APPLE_PAY"&&r.current(),a.failure.type==="payment"&&u&&!o.value&&l.current(),(u==="APPLE_PAY"&&!o.value||u==="GOOGLE_PAY")&&(s.value=i)}},[a,s,n,o,r,i,l]),M(()=>function(){s.value=void 0},[s])}const $t="express-checkout-wallets-wrapper",qt=/(iPhone|iPod|iPad|Mac OS)/i,Qt=/((iPhone|iPod|iPad).*AppleWebKit(?!.*(Safari|instagram|FBAV|FB_IAB)))/i,Jt=/(ShopifyCheckoutSDK|CheckoutSheetProtocol)/i;function Zt(){const{userAgent:e}=Ve(),a=Qt.test(e);return!(qt.test(e)&&Jt.test(e)||a)}function jt(){const{inMemoryPayPalParts:e,inMemoryVenmoParts:a,inMemoryGooglePayParts:n,inMemoryAmazonPayParts:s,acceleratedWalletPaymentMethods:o}=E(),l=Xe(()=>o.flatMap(r=>{switch(r.name){case"PAYPAL_EXPRESS":{const i=[{name:v.PayPalV6,buttonStatusSignal:e.acceleratedCheckoutButtonStatus}];return r.venmoEnabled&&i.push({name:v.Venmo,buttonStatusSignal:a.buttonStatus}),i}case"GOOGLE_PAY":return{name:v.GooglePay,buttonStatusSignal:n.buttonStatus};case S.AmazonPay:return{name:S.AmazonPay,buttonStatusSignal:s.buttonStatus};case S.BuyWithPrime:return{name:S.BuyWithPrime,buttonStatusSignal:s.buttonStatus};default:return[]}}),[o,n.buttonStatus,s.buttonStatus,e.acceleratedCheckoutButtonStatus,a.buttonStatus]);Ke(l,$e)}function ea({buttonCount:e,children:a,waitUntilLoaded:n=!0,walletPaymentMethods:s}){const[o,l]=L(Y()),[r,i]=L(!0),u=Zt(),h=Re(),p=b(),{inMemoryApplePayParts:{paymentSheetError:y}}=E(),f=Yt();jt();const P=n?f:!1,[m,k]=L(!1),d=Oe(),{id:C}=w(),R=Z(),O=j(),I=Ie();Ne(s,e);const N=B((g,x)=>{const ce=parseInt(ee(C),10),ue=Qe({state:x,shopId:ce,nascarData:{...g,walletsRenderedCount:e},paymentMethods:s});R?.record(ue)},[C,R,e,s]),H=s.some(g=>g.name==="SHOP_PAY")&&u;Kt(),!P&&!m&&(k(!0),l(g=>Y()-g)),M(()=>{m&&I.histogram({name:"wallets_container_render_time",value:o,attributes:{PCIv4:s.some(g=>g.name===S.AmazonPay||g.name===S.BuyWithPrime||g.name==="GOOGLE_PAY"||g.name==="PAYPAL_EXPRESS")}})},[m,I,o]);const G=p("alternative_payment_method_banner.express_checkout"),le=He("worker-version")!=="fast";return t(ne,{accessibilityLabel:G,children:[t(A,{className:c.Container,"data-count":e,children:[t("div",{className:c.Header,children:t(Ge,{className:c.Text,children:G})}),t("div",{className:c.StackWrapper,children:[t("div",{className:c.Layout,children:[t(ta,{loading:P||!h,hideWallets:r,shopPayEmphasis:H,children:[...Array(e).keys()].filter((g,x)=>x<=3).map(g=>t(Fe,{delay:le},g))}),t("div",{id:$t,className:W(c.Stack,c.ButtonWrapper,{[c.loading]:P,[c.subsequentLoad]:P&&m,[c.DrawerHideButtons]:r,[c.ShopPayEmphasis]:H}),children:h&&a})]}),t("div",{className:c.DrawerLink,children:t(Ue,{accessibilityLive:"polite",textDecoration:"none",onClick:()=>{r?(i(!1),N(O,T.NascarDrawerOpen)):(i(!0),N(O,T.NascarDrawerClose))},children:t("div",{className:c.InnerDrawerLink,children:[t(D,{children:p(r?"alternative_payment_method_banner.show_more_options":"alternative_payment_method_banner.hide_more_options")}),t(ze,{type:r?"chevron-down":"chevron-up",size:"small-200"})]})})}),d&&t(Ye,{isForExpressCheckout:!0})]})]}),y?.value?.type==="payment_cancelled_while_processing"&&t(Xt,{})]})}function ta({children:e,loading:a=!1,hideWallets:n,shopPayEmphasis:s}){return qe(a,"base")==="exited"?null:t("div",{className:W(c.Stack,c.SkeletonWrapper,{[c.ShopPayEmphasis]:s,[c.DrawerHideButtons]:n}),children:e})}const aa="_2SmAP",sa="eFu6h",$={MessageWrapper:aa,SimulatedWalletWrapper:sa},na=e=>e;function ma(){const e=Je("simulated"),a=b(),{inMemoryVenmoParts:{buttonStatus:n},acceleratedWalletPaymentMethods:s,buttonCount:o}=E(),l=Ze(),r=je(),{setEditorShopPay:i}=ie(),u=et(s,n.value),{expressCheckout:{button:{cornerRadius:h}={}}}=oe(),p=tt("Checkout::Dynamic::Render","WALLETS1"),y=at(),f=e&&y&&!s.length;if(!r)return null;const P=!e;let m=s.map(d=>t(ra,{method:d,triggerProgression:l},d.name));if(u){const d=ia({triggerProgression:l});m=[...m,d]}const k=f?t(A,{padding:"large200",cornerRadius:"base",blockAlignment:"center",inlineAlignment:"center",minInlineSize:"fill",className:$.MessageWrapper,children:t(D,{color:"subdued",children:a("payment.simulated_express_checkout")})}):m.map((d,C)=>d.key==="VENMO"?null:d.key==="SHOP_PAY"&&i?d:t(A,{className:$.SimulatedWalletWrapper,children:t(A,{className:W([c.walletButton,c.Stack,c.SimulatedWalletStack]),inert:!0,children:d})},d.key??C));return t("div",{style:{...oa(h)},children:[t(st,{extensions:p,spacing:"large200",render:na}),p.length>0&&t(nt,{spacing:"large200"}),t(ea,{buttonCount:f?1:o,waitUntilLoaded:P,walletPaymentMethods:s,children:e?k:m})]})}function oa(e){return e&&{"--x-express-checkout-button-border-radius":lt(ct.borderRadius)(e)}}function ra({method:e,triggerProgression:a}){const n=ot();switch(e.name){case"APPLE_PAY":return t(vt,{supportedNetworks:e.supportedNetworks,color:n});case"PAYPAL_EXPRESS":return t(re,{progressToNextPage:a});case"SHOP_PAY":return t(Lt,{});case"GOOGLE_PAY":return t(it,{});case S.AmazonPay:return t(rt,{});case S.BuyWithPrime:return t(kt,{wallet:S.BuyWithPrime});default:return null}}function ia({triggerProgression:e}){return t(re,{fundingSource:"venmo",buttonColor:"blue",progressToNextPage:e},"VENMO")}function ga(){const e=b(),{divider:{borderStyle:a,borderWidth:n}}=ut(),{main:{divider:{borderStyle:s=a,borderWidth:o=n}={},section:l,spacing:r}}=oe(),i=V.default(["large100","none","large300","none"]),h=dt(l)?V.default([r??"base","none"]).when({viewportInlineSize:{min:"extraSmall"}},[r??"large200","none"]):i;return t(A,{padding:h,children:t(pt,{borderStyle:s,borderWidth:o,children:t(ht,{textAlign:"center",children:t(D,{color:"subdued",children:e("alternative_payment_method_banner.or")})})})})}function Pa(e){const a=mt(null),{expressCheckoutHeightSignal:n,expressCheckoutFirstLoadsSignal:s}=gt(),o=n.value,l=Pt(),r=s.value;return M(()=>{const i=a.current?.clientHeight,u=i!==void 0&&i!==o&&!r,h=e.map(p=>p.name);u&&l("expressCheckoutSetChange",{timestamp:new Date,paymentMethods:h}),s.value=!1,n.value=i||0},[o,e,l,r,s,n]),a}function Sa(){const a=b()("contact.delivery_option_title"),n=St(),s=se();return n?t(ne,{accessibilityLabel:a,children:t(te,{children:[s?null:t(ae,{level:1,children:a}),n]})}):null}export{Sa as D,ma as E,ha as P,pa as S,ga as a,Pa as u};