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