1import{u as e,w as a,g as t,q as s,h as l,o as n,m as o,k as i,p as r,L as c,s as p,S as d}from"./2c1ab0fe.B2yRRyAW.js";import{c as u,c2 as m,a6 as b,c3 as v,aQ as h,z as f}from"./4b4bc88f.JFrEI7LU.js";import{S as y,cl as _,I as P,cm as j,cn as S,X as g,bg as w,b as A,f as k,L,j as C,B as E,aH as z,a1 as N,H as x,M as H,a as M,co as Y,cp as B,r as I,s as W}from"./164ad2e3.-hfWY9cN.js";import{A as q}from"./d4ea2faa.BWUhdW6Q.js";import{T as R}from"./7b0c98ea.DsQmemn7.js";import{S as O,d as F}from"./e3e348f2.CUB8gYam.js";import{c as Q}from"./31cc568e.95lmLO5k.js";import{e as T}from"./c6c0cbda.AqWWc50G.js";import{s as U}from"./dffdfb34.CA8WE4ll.js";import"./app.C_W8kcQ4.js";import"./d0bb51ec.CiN57OqX.js";import"./f67abd2c.Boj0gJpa.js";import"./60a453ce.aSs2kW8G.js";import"./e12db40c.ZpKYxNRe.js";import"./9dba8418.BqWu-Ch9.js";import"./71ae3d5c.BTocP6cf.js";import"./3ca8ef7e.CGmhNbCs.js";import"./1f5e7811.PrD3cLrR.js";import"./2fdb3dd3.CAXoTPkz.js";import"./22345fd4.CQJ0n-1P.js";import"./0e67bd3b.DYIAHGYe.js";import"./74835653.B3C9_9vV.js";import"./2495faa4.B5RDSEV2.js";import"./a9fa9fda.DtwHg2w5.js";import"./ca3e798e.j1SNghYW.js";import"./47b970b2.B55cGlxq.js";import"./064f6ac1.CZOb24JP.js";import"./efa0389a.DgBvBH2e.js";import"./4b1c22b7.BOiV_1od.js";import"./17425706.ozCo4ACy.js";import"./55098bf1.OVeEjE2R.js";import"./cb5cf153.BGCuT8HB.js";import"./cb38e5c2.6itoXFFb.js";import"./78ab3dd0.CxYXHIAF.js";import"./ed9f2238.DoGJCDiA.js";import"./6fb6f9d8.D5bv4loK.js";import"./1444e6bd.m8JEnfnf.js";import"./0b8657b8.-bvTvyc8.js";import"./a422df8c.p_hgP_ap.js";import"./79974aab.Du4uYIZv.js";import"./d22d2b80.Bn2GBJa_.js";import"./f49d4216.Dq3WwT1N.js";function X({body:a}){return e(j,{children:e(P,{dangerouslySetInnerHTML:{__html:a.value??""},scrollableContent:"all"})})}function J({body:t,loading:s,error:l}){const{i18n:n}=u();return e(a,{when:l,fallback:e(a,{when:s,fallback:e(X,{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:n.translate("bad_request.title")})}const V="JtAjb",Z="otCH1";function D({id:i,canConfirm:r,onConfirm:c,onHide:p,onShow:d}){const{i18n:b,shop:v,checkout:{negotiator:h}}=u(),{checkoutProtocolModalEventSignal:f}=h.context,_=b.translate("payment.purchase_options_cancellation_policy_label"),P=v.merchantPolicies.find(({handle:e})=>e===O),j={handle:O,shopId:v.id,shopName:v.name,squareLogo:v.brandSettings?.squareLogo,name:_,url:P?.url??""},M=m(S,{defaultPolicy:j,policies:[j]}),Y=t(!1),B=s(()=>{Y.current&&"applePaySubscriptionConsent"===f.value&&(f.value="none"),Y.current=!1},[f]);l(()=>B,[B]);const I=n(!1),W=n(!1),q=t(null),T=g(),U=w(I.value,"slow"),X=I.value||W.value,D=!I.value||W.value,G=s(e=>{q.current=e,e&&(e.dataset.inertSupported=String("inert"in e))},[]),K=b.translate("wallets.continue_with",{walletName:b.translate("brand.apple_pay")}),$=I.value?Q(_):b.translate("payment.purchase_options_subscription_confirmation_title"),ee=s(()=>{M.show(),I.value=!0},[M,I]),ae=s(()=>{M.hide(),I.value=!1},[M,I]),te=s(()=>{W.value=!0,M.hide(),B(),p()},[W,M,B,p]),se=s(()=>{I.value=!1,W.value=!1,Y.current=!0,f.value="applePaySubscriptionConsent",d()},[I,W,f,d]);return e(H,{id:i,heading:e(y,{direction:"inline",alignItems:"center",gap:"base",children:[e(a,{when:I,children:e(z,{type:"button",padding:"small-400",borderRadius:"base",accessibilityLabel:b.translate("account_management.back"),onClick:ae,children:e(N,{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:K}),children:e(A,{className:"VqsW7",children:e(R,{contentRef:q,children:e(A,{ref:G,className:"c1X76",padding:"small-200",overflow:"hidden",children:[e(a,{when:()=>T?!I.value:"entered"!==U,children:e(A,{className:o(V,I.value&&Z),"data-side":"backward","data-visible":!I.value&&(T||"exit"!==U),position:I.value?"absolute":"relative",inert:X,children:e(k,{children:e(F,{buttonLabel:K,cancellationPolicyLink:P?e(L,{tone:"monochrome",onClick:ee,children:e(C,{children:_})}):void 0})})})}),e(a,{when:()=>T?I.value:"exited"!==U,children:e(A,{className:o(V,!I.value&&Z),"data-side":"forward","data-visible":I.value&&(T||"enter"!==U),position:I.value?"relative":"absolute",inert:D,children:e(J,{body:M.policyBody,loading:M.loading,error:M.error})})})]})})})})}const G=W("ApplePaySubscriptionConsentModal");function K({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"}})}),l(()=>()=>{j.value===w.current&&(j.value={status:"not_rendered"})},[j]);const A=M(),k=t(null),{observability:L,i18n:C,checkout:E}=u(),{wallets:z}=E,N=p(Y()),x=i(()=>v({hasSubscription:h({checkout:E}),isApplePayAvailable:_.value.some(({name:e})=>
1"APPLE_PAY"===e),variant:N.value})),{showOverlay:H,hideOverlay:W}=B(),R=I(void 0,G),O=n(!1),F=s(()=>{O.value=!0,L.log("apple_pay_subscription_consent_modal_opened","Apple Pay subscription consent modal opened")},[O,L]),Q=s((e="dismissed")=>{O.value&&(O.value=!1,L.log("apple_pay_subscription_consent_modal_closed","Apple Pay subscription consent modal closed",{reason:e}))},[O,L]),X=()=>{L.log("apple_pay_button_clicked_while_loading","Apple Pay button clicked while already loading the payment sheet. Ignoring click.")},J=()=>{L.error(new q("Apple Pay button clicked without a ready session handler."))},V=e=>{const a=z.activeSession.value;if("APPLE_PAY"===a?.wallet)return void X();const t=g.value;if(t)try{t.openApplePayPaymentSheet(t.createSession({supportedNetworks:m,...e&&{subscriptionConsent:e}}).session),"explicit_modal"===e&&"APPLE_PAY"===z.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"===z.activeSession.value?.wallet&&z.clearActiveSession({invokingWallet:"APPLE_PAY"})}else J()},Z=i(()=>"explicit_modal"===x.value),K=i(()=>O.value&&Z.value&&null!=g.value&&null==z.activeSession.value);r(()=>{O.value&&(!Z.value||null==g.value||null!=z.activeSession.value)&&(Q("invalidated"),W(R))});const $=null!=g.value;return e(d,{children:[e("button",{ref:e=>{k.current=e,A("apple_pay")(e)},className:o(U.ApplePayButton,U[y],T.borderRadius,f({focusRing:"base"})),lang:C.locale,disabled:!$,onClick:()=>{const e=z.activeSession.value;if("APPLE_PAY"===e?.wallet)return void X();const a=x.value;if(Z.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 H(R)):void J();V(a)},type:"button","aria-label":C.translate("brand.apple_pay"),"aria-haspopup":Z.value?"dialog":void 0}),e(a,{when:()=>Z.value||O.value,children:e(D,{id:R,canConfirm:K,onShow:F,onHide:Q,onConfirm:()=>{K.value&&(L.log("apple_pay_subscription_consent_confirmed","Apple Pay subscription consent confirmed"),Q("confirmed"),W(R),V("explicit_modal"))}})})]})}export{K 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.