1import{u as e,z as a,g as t,q as s,h as n,o as l,m as o,k as i,p as r,M as c,s as p,S as d}from"./2c1ab0fe.qpvfywqb.js";import{e as u,c9 as m,aa as b,ca as v,aW as f,C as h}from"./4b4bc88f.DkycdxSK.js";import{S as y,cn as _,D as P,co as j,cp as S,X as g,bk as w,b as A,f as k,L,j as C,B as E,aM as N,a1 as z,H as x,M,a as H,cq as Y,cr as q,r as I,s as W}from"./164ad2e3.DcJn775M.js";import{A as B}from"./d4ea2faa.Bh5JwQU0.js";import{T as R}from"./7b0c98ea.B8saOsP6.js";import{S as F,d as T}from"./e3e348f2.qdNJPs68.js";import{c as X}from"./31cc568e.95lmLO5k.js";import{e as J}from"./1d34c07e.h4dJAaCz.js";import{s as O}from"./dffdfb34.DKxh4eql.js";import"./app.DH8n-1bp.js";import"./d0bb51ec.CWfbNPnY.js";import"./f67abd2c.CNaB0QaR.js";import"./e12db40c.DhbHW8sF.js";import"./9dba8418.4R19B40l.js";import"./60a453ce.DBFo6PRx.js";import"./71ae3d5c.ChDO3fdz.js";import"./3ca8ef7e.DgXbCH_R.js";import"./1f5e7811.DBGnR3_R.js";import"./2fdb3dd3.BI5ol3i8.js";import"./22345fd4.Bc95vVsB.js";import"./0e67bd3b.BulkkgyN.js";import"./74835653.Cr7sKbVy.js";import"./2495faa4.DgGNI16D.js";import"./a9fa9fda.BO9gwssW.js";import"./ca3e798e.XLlup-KR.js";import"./47b970b2.Bc5Vmfq5.js";import"./064f6ac1.BoVb1opw.js";import"./efa0389a.BiVLFqoF.js";import"./4b1c22b7.zkM5jsqa.js";import"./17425706.DtdfKQJ3.js";import"./55098bf1.CjSE9kMx.js";import"./cb5cf153.CNHN3NCG.js";import"./cb38e5c2.k1ouuKLe.js";import"./78ab3dd0.DsAxQUAi.js";import"./89e2d30a.C7YQuTRu.js";import"./ed9f2238.Brwxl8Yi.js";import"./6fb6f9d8.BoDxvz0l.js";import"./1444e6bd.DTqbRn9m.js";import"./0b8657b8.CeR0nGry.js";import"./a422df8c.CDURsRjM.js";import"./f49d4216.Che8BnjU.js";import"./d22d2b80.BRIhtVxA.js";import"./f58f39d8.z0CUAjnp.js";import"./e03065ab.V1fBuv4e.js";import"./79974aab.Cl0DLekt.js";function V({body:a}){return e(j,{children:e(P,{dangerouslySetInnerHTML:{__html:a.value??""},scrollableContent:"all"})})}function D({body:t,loading:s,error:n}){const{i18n:l}=u();return e(a,{when:n,fallback:e(a,{when:s,fallback:e(V,{body:t}),children:e(y,{gap:"base",children:[e(_,{lines:2,lastLineSize:"large"}),e(_,{lines:3,lastLineSize:"small"}),e(_,{lines:2,lastLineSize:"base"}),e(_,{size:"extraLarge",lastLineSize:"large",lines:1}),e(_,{lines:7,lastLineSize:"small"}),e(_,{lines:3,lastLineSize:"base"})]})}),children:l.translate("bad_request.title")})}const G="JtAjb",K="otCH1";function Q({id:i,canConfirm:r,onConfirm:c,onHide:p,onShow:d}){const{i18n:b,shop:v,checkout:{negotiator:f}}=u(),{checkoutProtocolModalEventSignal:h}=f.context,_=b.translate("payment.purchase_options_cancellation_policy_label"),P=v.merchantPolicies.find(({handle:e})=>e===F),j={handle:F,shopId:v.id,shopName:v.name,squareLogo:v.brandSettings?.squareLogo,name:_,url:P?.url??""},H=m(S,{defaultPolicy:j,policies:[j]}),Y=t(!1),q=s(()=>{Y.current&&"applePaySubscriptionConsent"===h.value&&(h.value="none"),Y.current=!1},[h]);n(()=>q,[q]);const I=l(!1),W=l(!1),B=t(null),J=g(),O=w(I.value,"slow"),V=I.value||W.value,Q=!I.value||W.value,U=s(e=>{B.current=e,e&&(e.dataset.inertSupported=String("inert"in e))},[]),Z=b.translate("wallets.continue_with",{walletName:b.translate("brand.apple_pay")}),$=I.value?X(_):b.translate("payment.purchase_options_subscription_confirmation_title"),ee=s(()=>{H.show(),I.value=!0},[H,I]),ae=s(()=>{H.hide(),I.value=!1},[H,I]),te=s(()=>{W.value=!0,H.hide(),q(),p()},[W,H,q,p]),se=s(()=>{I.value=!1,W.value=!1,Y.current=!0,h.value="applePaySubscriptionConsent",d()},[I,W,h,d]);return e(M,{id:i,heading:e(y,{direction:"inline",alignItems:"center",gap:"base",children:[e(a,{when:I,children:e(N,{type:"button",padding:"small-400",borderRadius:"base",accessibilityLabel:b.translate("account_management.back"),onClick:ae,children:e(z,{type:"arrow-left",size:"base"})})}),e(x,{level:1,autoFocus:!0,children:$},I.value?"policy":"consent")]}),accessibilityLabel:$,onShow:se,onHide:te,actionLayout:"stacked",primaryAction:e(E,{variant:"primary",type:"button",inlineSize:"fill",disabled:!r.value,onClick:c,children:Z}),children:e(A,{className:"VqsW7",children:e(R,{contentRef:B,children:e(A,{ref:U,className:"c1X76",padding:"small-200",overflow:"hidden",children:[e(a,{when:()=>J?!I.value:"entered"!==O,children:e(A,{className:o(G,I.value&&K),"data-side":"backward","data-visible":!I.value&&(J||"exit"!==O),position:I.value?"absolute":"relative",inert:V,children:e(k,{children:e(T,{buttonLabel:Z,cancellationPolicyLink:P?e(L,{tone:"monochrome",onClick:ee,children:e(C,{children:_})}):void 0})})})}),e(a,{when:()=>J?I.value:"exited"!==O,children:e(A,{className:o(G,!I.value&&K),"data-side":"forward","data-visible":I.value&&(J||"enter"!==O),position:I.value?"relative":"absolute",inert:Q,children:e(D,{body:H.policyBody,loading:H.loading,error:H.error})})})]})})})})}const U=W("ApplePaySubscriptionConsentModal");function Z({supportedNetworks:m,color:y}){const{acceleratedWalletPaymentMethods:_,applePaySessionHandler:P,inMemoryApplePayParts:{buttonStatus:j,paymentSheetError:S}}=b(),g=i(()=>{const e=P.value;return null==e?.createSession||null==e.showApplePayPaymentSheet?null:{createSession:e.createSession,openApplePayPaymentSheet:e.showApplePayPaymentSheet}}),w=t({status:"rendered"});r(()=>{const e=null!=g.value,a=j.value;e&&"not_rendered"===a.status?c(()=>{j.value=w.current}):e||a!==w.current||c(()=>{j.value={status:"not_rendered"}})}),n(()=>()=>{j.value===w.current&&(j.value={status:"not_rendered"})},[j]);const A=H(),k=t(null),{observability:L,i18n:C,checkout:E}=u(),{wallets:N}=E,z=p(Y()),x=i(()=>v({hasSubscription:f({checkout:E}),isApplePayAvailable:_.value.some(({name:e})=>
1"APPLE_PAY"===e),variant:z.value})),{showOverlay:M,hideOverlay:W}=q(),R=I(void 0,U),F=l(!1),T=s(()=>{F.value=!0,L.log("apple_pay_subscription_consent_modal_opened","Apple Pay subscription consent modal opened")},[F,L]),X=s((e="dismissed")=>{F.value&&(F.value=!1,L.log("apple_pay_subscription_consent_modal_closed","Apple Pay subscription consent modal closed",{reason:e}))},[F,L]),V=()=>{L.log("apple_pay_button_clicked_while_loading","Apple Pay button clicked while already loading the payment sheet. Ignoring click.")},D=()=>{L.error(new B("Apple Pay button clicked without a ready session handler."))},G=e=>{const a=N.activeSession.value;if("APPLE_PAY"===a?.wallet)return void V();const t=g.value;if(t)try{t.openApplePayPaymentSheet(t.createSession({supportedNetworks:m,...e&&{subscriptionConsent:e}}).session),"explicit_modal"===e&&"APPLE_PAY"===N.activeSession.value?.wallet&&L.log("apple_pay_subscription_consent_session_started","Apple Pay session started after subscription consent")}catch(s){const e={error:s,errorName:s instanceof Error?s.name:"Unknown",errorMessage:s instanceof Error?s.message:String(s),...s instanceof Error&&s.stack&&{errorStack:s.stack}};L.leaveErrorBreadcrumb("Failed to create Apple Pay session",e),S.value={type:"failed_to_create_session"},"APPLE_PAY"===N.activeSession.value?.wallet&&N.clearActiveSession({invokingWallet:"APPLE_PAY"})}else D()},K=i(()=>"explicit_modal"===x.value),Z=i(()=>F.value&&K.value&&null!=g.value&&null==N.activeSession.value);r(()=>{F.value&&(!K.value||null==g.value||null!=N.activeSession.value)&&(X("invalidated"),W(R))});const $=null!=g.value;return e(d,{children:[e("button",{ref:e=>{k.current=e,A("apple_pay")(e)}
1,className:o(O.ApplePayButton,O[y],J.borderRadius,h({focusRing:"base"})),lang:C.locale,disabled:!$,onClick:()=>{const e=N.activeSession.value;if("APPLE_PAY"===e?.wallet)return void V();const a=x.value;if(K.value)return e?void L.log("apple_pay_subscription_consent_blocked_by_active_wallet","Apple Pay subscription consent blocked by another active wallet.",{activeWallet:e.wallet,requestedWallet:"APPLE_PAY"}):g.value?(k.current?.focus({preventScroll:!0}),void M(R)):void D();G(a)},type:"button","aria-label":C.translate("brand.apple_pay"),"aria-haspopup":K.value?"dialog":void 0}),e(a,{when:()=>K.value||F.value,children:e(Q,{id:R,canConfirm:Z,onShow:T,onHide:X,onConfirm:()=>{Z.value&&(L.log("apple_pay_subscription_consent_confirmed","Apple Pay subscription consent confirmed"),X("confirmed"),W(R),G("explicit_modal"))}})})]})}export{Z as ApplePayButton};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.