import{Ft as e,It as t,Jt as a,Pt as n,Qt as o,Wt as r,Xt as l,Zt as i,dt as s,en as u,ft as c,jt as d,mt as m,nn as p,pt as h,yt as y,zt as v}from"./630ba094.L_X-5TXi.js";import{$y as f,AO as b,Bl as g,Eg as k,Em as P,Gg as w,Hd as S,Kg as _,Ky as x,MA as A,Op as N,Oy as C,Qf as L,Ry as R,Tb as B,UA as T,W as j,Wd as F,Xf as I,Xg as E,Yf as M,Yg as O,Zd as D,_b as W,_p as z,an as q,ef as H,fh as K,gb as V,hh as X,hm as G,ip as Q,jO as U,jy as $,lk as Y,oc as J,ok as Z,ps as ee,qg as te,rf as ae,rj as ne,tg as oe,th as re,tt as le,vA as ie,vv as se,wb as ue,xO as ce}from"./6ec9a0fa.rdcQt2v8.js";import{t as de}from"./0be192b6.rG-iHLkS.js";import{n as me}from"./82d59f8f.CMkmnfJF.js";import{f as pe,h as he,i as ye,r as ve,t as fe}from"./928dbd30.BIHpBIaB.js";import{i as be,r as ge,t as ke}from"./2692118b.BQ5RAfJh.js";import{t as Pe}from"./5d5cabdf.3d9fziXo.js";import{t as we}from"./a8202753.DJdQDh63.js";import{t as Se}from"./c4303b96.BMKrSP28.js";import{t as _e}from"./7ee3a05c.CyndcFun.js";var xe='[aria-invalid="true"], [data-card-field-invalid="true"]',Ae={visibleAlertPresent:"unknown",visibleNoticePresent:"unknown",visibleInvalidFieldPresent:"unknown",invalidFieldFocused:"unknown",buttonBusy:"unknown",buttonDisabled:"unknown"};function Ne(e){try{const t=e.defaultView;if(!t)return{...Ae,feedbackSnapshotStatus:"unavailable"};if("visible"!==e.visibilityState)return{...Ae,feedbackSnapshotStatus:"document_hidden"};if(t.top!==t.self)return{...Ae,feedbackSnapshotStatus:"embedded"};const a=e.getElementById(q);return{feedbackSnapshotStatus:"observed",visibleAlertPresent:Array.from(e.querySelectorAll('[role="alert"]')).some(e=>Boolean(e.textContent?.trim())&&Ce(e,t)),visibleNoticePresent:Array.from(e.querySelectorAll('[role="status"], [data-checkout-feedback="true"], #error-for-checkout-captcha')).some(e=>Boolean(e.textContent?.trim())&&Ce(e,t)),visibleInvalidFieldPresent:Array.from(e.querySelectorAll(xe)).some(e=>Ce(e,t)),invalidFieldFocused:Boolean(e.activeElement?.closest(xe)),buttonBusy:"BUTTON"===a?.tagName?"true"===a.getAttribute("aria-busy"):"unknown",buttonDisabled:"BUTTON"===a?.tagName?a.matches(":disabled")||"true"===a.getAttribute("aria-disabled"):"unknown"}}catch{return{...Ae,feedbackSnapshotStatus:"unavailable"}}}function Ce(e,t){const a=e.getBoundingClientRect();if(a.width<=0||a.height<=0||a.bottom<=0||a.right<=0||a.top>=t.innerHeight||a.left>=t.innerWidth)return!1;for(let n=e;n;n=n.parentElement){const e=t.getComputedStyle(n),a=("absolute"===e.position||"fixed"===e.position)&&"rect(0px, 0px, 0px, 0px)"===e.clip;if(n.hasAttribute("hidden")||"none"===e.display||"hidden"===e.visibility||"collapse"===e.visibility||"0"===e.opacity||a)return!1}return!0}function Le({children:e}){const{observability:t,checkout:{wallets:n,identity:o,negotiator:r,journey:l,validation:i}}=ce(),s=A(),u=r.current.fields.buyerIdentity,c=a(),d=a(),m=a();return oe(e=>{m.current={type:e.type,stage:"negotiationStage"in e?e.negotiationStage:void 0,timestamp:Date.now()},c.current=void 0,d.current=void 0,"violations"in e&&(c.current=e.violations.map(e=>({code:e.code,type:e.__typename,target:"target"in e?e.target:void 0}))),"reasons"in e&&(d.current=e.reasons)}),y("div",{onClickCapture:function(e){if(e.detail>2){const e=r.parts.paymentLines.value.map(e=>"wallet"===e.method.type||"walletsPlatformPaymentMethod"===e.method.type?e.method.name:e.method.type),a=l.currentDetour.value?.type??l.currentPage.value?.id??"unknown",p={identity:o.current.value,activeWallet:n.activeSession.value?.wallet??null,asPaymentMethod:n.activeSession.value?.asPaymentMethod??!1,journeyStep:a,primaryPaymentLine:e.at(0),...Ne(document)};t.counter({name:"pay_now_rage_click",value:1,attributes:p}),t.log("rage_click_capture_pay_now_rage_click_detected","pay_now_rage_click",{customerProfile:u.value?.customerProfile?.__typename,numberOfErrors:s?.numberOfErrors()??"unknown",validationErrorCount:Object.values(i.errors.value).reduce((e,t)=>e+t.length,0),lastInterceptionReasons:d.current,lastViolations:c.current?.map(({code:e})=>e),lastViolationDetails:c.current,lastNegotiationType:m.current?.type,lastNegotiationStage:m.current?.stage,lastNegotiationAgeMs:m.current?Date.now()-m.current.timestamp:void 0,blocked:r.isBlocked.value,paymentLineNames:e,...p})}},children:e})}function Re({shopId:e,shopName:t,shopLogo:a,amount:n,showDivider:o,isLocalShop:r}){const[l,s]=i(!1),{i18n:u}=ce();return y(w,{gap:"base",children:[y(U,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",children:[y(E,{children:y(I,{size:"small",src:a,alt:t})}),y(E,{blockAlignment:"center",children:[y(C,{"aria-expanded":l,"aria-controls":`separate-payments-collapsible-${e}`,onClick:()=>s(e=>!e),children:y(U,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",children:[y(b,{type:"strong",children:t}),y(U,{gridAutoFlow:"column",gridAutoColumns:"minmax(auto, max-content)",gridTemplateColumns:"minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-200",alignItems:"center",alignContent:"center",children:[!l&&y(b,{type:"strong",children:u.formatCurrency(n.amount,{currency:n.currencyCode,form:"short"})}),y(Y,{type:l?"chevron-up":"chevron-down",size:"small-200"})]})]})}),y(ie,{open:l,id:`separate-payments-collapsible-${e}`,children:[y(z,{blockSize:"small-200"}),y(le,{shopId:e,isLocalShop:r})]})]})]}),o&&y(Q,{direction:"inline",borderWidth:"base"})]})}function Be(){const{i18n:e,shop:{name:t,id:a,brandSettings:o,remoteShopsConfigMap:r}}=ce(),l=ue("remoteMerchandiseDetails"),i=_e(),s=se(),u=Se(),c=n(()=>l.value||!i.value),d=n(()=>{const e=[];for(const[n,l]of s.value){if(!l)continue;if(u.value&&n===a){e.push({shopName:t,shopLogo:o?.squareLogo?.url,shopId:a,amount:l});continue}const i=r?.get(n);i&&e.push({shopName:i.name,shopId:n,shopLogo:i.brandSettings?.squareLogo?.url,amount:l})}return e});if(c.value)return null;const h=y(p,{children:[y(_,{textDecoration:"none",commandFor:"separate-payments-modal",children:e.translate("payment.separate_payments_text")}),y(L,{id:"separate-payments-modal",heading:e.translate("payment.payments"),children:y(w,{gap:"base",children:y(m,{each:d,getKey:e=>e.shopId,children:(e,t)=>y(Re,{shopId:e.shopId,shopName:e.shopName,shopLogo:e.shopLogo,amount:e.amount,showDivider:t!==d.value.length-1,isLocalShop:e.shopId===a})})})})]});return y(M,{color:"subdued",children:e.translate("payment.separate_payments_label",{separate_payments_link:h})})}var Te=W("StickyPayButtonFixedContext");function je(){const e=o(Te);return n(()=>e?.value??!1)}function Fe(){const{i18n:e,shop:t,checkout:{negotiator:a}}=ce(),n=a.parts.paymentLines.value;return t.vaultForPaymentLater&&P(n)?y(M,{color:"subdued",children:e.translate("payment.vault_for_payment_later.notice")}):null}function Ie(){const{checkout:{negotiator:e}}=ce(),t=e.current.fields.captcha;return n(()=>Boolean(t.value))}function Ee({label:a,total:n}){const o=re(ce().checkout),{wrapperRef:r,textWrapperRef:l,textRef:i,totalWrapperRef:u,fitScale:c}=function(){const a=e(1),n=s(null),o=s(null),r=s(null),l=s(null);return t(()=>{const e=n.value,t=r.value,i=o.value,s=l.value;if(e&&t&&i&&s)return be({container:e,textWrapper:t,text:i,totalWrapper:s},()=>a.peek(),e=>{a.value=e})}),{wrapperRef:n,textWrapperRef:r,textRef:o,totalWrapperRef:l,fitScale:a}}();return n?y("span",{className:d("ajaiU",n.revealed.value&&"SqqPj"),style:{"--fit-scale":c.value},ref:r,children:[y("span",{className:"CnPyG",ref:l,children:y("span",{ref:i,children:a})}),y("span",{className:d("l1fQC","notranslate"),translate:"no",ref:u,children:y("span",{className:"gppcl",children:y("span",{className:"AwhXh",children:y(ee,{formatted:n.formatted,money:n.money,priceReductionAnimation:o.orderSummary.value.priceReductionAnimation})})})})]}):y(Pe,{children:a})}function Me({formattedAmount:e,label:t}){const{isAppLayout:a}=g();return e?y(U,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",children:[y(Pe,{ignoreBranding:a,children:t}),y(Q,{direction:"block"}),y(Pe,{ignoreBranding:a,children:e})]}):y(Pe,{ignoreBranding:a,children:t})}function Oe({checkout:e,i18n:t},{nextPageLabel:a,shouldOverrideLabel:n,isRedirectMethod:o}){return"shopPay"===e.identity.current.value&&o?t.translate("payment_ux.continue_to_payment"):n?t.translate("general.pay_now_button_label"):a}function De({identity:e},{paymentRequiredMethod:t,managedByMarketsPro:a,isCryptoPayment:n}){return"shopPay"===e.current.value&&(X({managedByMarketsPro:a})&&"IDEAL"===t||void 0!==t&&J.has(t)&&!n)}function We({i18n:e},t){return t?e.formatCurrency(t.amount,{currency:t.currencyCode,form:"short"}):null}function ze({i18n:e,mobileCheckoutSdk:t,embed:a},{isAppLayout:n,paymentDue:o,buttonLabel:r}){return t.enabled&&t.variant.isStandard()||a?.isCheckoutKit()?null:n&&o&&r===e.translate("general.pay_now_button_label")?We({i18n:e},o):null}function qe({checkout:e,mobileCheckoutSdk:t,shopPay:a,embed:n}){return"shopPay"!==e.identity.current.value?"dynamic":t.enabled||n?.isCheckoutKit()||K(a.app.config)?"static":"dynamic"}function He(){const e=ce(),{enabled:t,formatted:a,money:o}=function(){const{i18n:e,checkout:t}=ce(),a=B();return{enabled:n(()=>"visible"===re(t).payButton.value?.embeddedTotal&&null!=a.value&&a.value.amount>0),formatted:n(()=>{const t=a.value;return t?e.formatCurrency(t.amount,{currency:t.currencyCode,form:"short"}):""}),money:n(()=>a.value??{amount:0,currencyCode:""})}}(),r=je();return"static"===qe(e)?{mode:"static"}:t.value?{mode:"dynamic",total:{formatted:a,money:o,revealed:r}}:{mode:"dynamic"}}function Ke({label:e,formattedAmount:t}){const a=He();return"static"===a.mode?y(Me,{label:e,formattedAmount:t}):y(Ee,{label:e,total:a.total})}function Ve(){const e=pe().value,t=he(),a=ae(),{i18n:n,checkout:{configuration:o,journey:r,identity:l}}=ce(),i=o.layout.isOnePage.value,s=G(),u="review"===r.currentPage.value?.id,c=function(e){return"payPal"===e.current.value}(l);if(i&&!c)return null;if(!i&&s.value&&!u)return null;if(!t.value||!e)return null;const d=n.translate("payment_errors.paypal_over_capture",{walletName:D(a)?n.translate("brand.venmo"):n.translate("brand.paypal")});return y(p,{children:[y(S,{errorType:F.PaymentError,tone:"info",children:d}),i&&y(z,{blockSize:"large-200"})]})}function Xe(e){const t=document.getElementById(e);t&&t.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))}var Ge="iVSCK";function Qe({disabled:o=!1,loading:r=!1,hidden:i=!1,pixelId:s,setRef:m,payButtonLabel:p}){const b=Z(),g=j(),P=O(),w=de(),S=l(e=>{s&&P(s)(e),m?.(e)},[s,P,m]),{i18n:_,checkout:A,observability:C}=ce(),L=function(e){const t=He(),n=a(),o=function(e,t){if(!e)return;if("static"===t.mode)return{label:e.label,...e.formattedAmount?{total:{kind:"static",amount:e.formattedAmount}}:{}};const{total:a}=t;return a?{label:e.label,total:{kind:"dynamic",amount:a.formatted.value,revealed:a.revealed.value,money:a.money.value}}:{label:e.label}}(e,t);return k(n.current,o)||(n.current=o),n.current}(p),B=A.configuration.layout.isOnePage.value,F=a(null),I=_.translate("general.pay_now_button_label"),M=u(()=>({label:I}),[I]),{applePaySessionHandler:D,inMemoryApplePayParts:{isLoadingPaymentSheet:W,sessionLoadFailed:z}}=V(),q=we({isPayWithApplePayFlow:!0}),H=$(),K=c(o),X=c(r),G=c(i),Q=n(()=>H&&!G.value&&"not_rendered"===q.value.status),U=e(!Q.peek());t(()=>{Q.value&&(U.value=!1)});const Y=n(()=>Q.value||!U.value);t(()=>{if(Q.value)return v(()=>T({content:_.translate("payment.loading"),role:"status"}))});const J=n(()=>D.value?.onClickHandler),ee=n(()=>null==J.value);ye(H?[{walletName:me.ApplePay,isLoading:()=>"not_rendered"===q.value.status,onTimeout:()=>{q.value={status:"error"}}}]:[{walletName:me.ApplePay,isLoading:()=>null==J.value&&!z.value,onTimeout:()=>{z.value=!0}}],x());const ae=n(()=>W.value||X.value),ne=n(()=>W.value||K.value||ee.value),oe=f(),re=A.negotiator.current.fields.paymentMethods?.value?.find(e=>"wallet"===e.type&&"APPLE_PAY"===e.name),le=p?y(Ke,{...p}):y(Pe,{children:_.translate("general.pay_now_button_label")});if(H){const e=Q.value;return y(E,{ref:i?void 0:S,className:d("HhGel",i&&"_6Hpgs",e&&ke.className),inert:e,children:[y(h,{when:Y,children:y(E,{className:d(Ge,!e&&"FEXSH"),inert:!0,children:y(te,{variant:"primary",type:"button",inlineSize:"fill",disabled:!0,children:le})})}),y(E,{className:d("y1cbu",e&&"rj9D0"),onTransitionEnd:e=>{e.target!==e.currentTarget||Q.peek()||(U.value=!0)},children:[!B&&y(ge,{labelRef:F}),y(ve,{isPayWithApplePayFlow:!0,supportedNetworks:re?.supportedNetworks??[],color:oe,disabled:o,loading:r,hidden:i,labelState:L??(B?void 0:M),sizingButtonRef:B?void 0:F})]})]})}if(i)return null;const ie=B&&g&&b?.id&&!b.nested?()=>Xe(b.id):void 0,se=B?ie:()=>{const e=J.value;null!=e?e({disabled:K.value,isMountedRef:w}):C.error(new R("Pay with Apple Pay button clicked without a ready session handler."))},ue=ee.value;return y(E,{className:"SJwrb",inert:ue||void 0,children:[y(te,{variant:"primary",type:B?"submit":"button",inlineSize:"fill",loading:ae.value,loadingMode:"extended",disabled:ne.value,ref:S,onClick:se,className:ue?"NIOCQ":void 0,children:le}),y(h,{when:ee,children:y(E,{className:Ge,children:y(N,{contentDisplay:"block",inlineSize:"100%",blockSize:"100%"})})})]})}function Ue({isLoading:e,showSkeleton:t,hidden:a=!1,setRef:n,children:o}){const{source:r,checkout:l}=ce(),i=l.configuration.layout.isOnePage.value,s="simulated"===r.type,u=t.value;let c;return!a&&u&&i&&(c=ke.className),y(E,{ref:n,className:d("RTmkG",c,i&&"h1pXK",e&&"E4OHT",a&&"vnCpz"),inert:s||u,children:[o,y(h,{when:t,children:y(E,{className:"NFpbC",children:y(N,{contentDisplay:"block",inlineSize:"100%",blockSize:"100%"})})})]})}function $e({disabled:e,loading:t,hidden:o=!1,setRef:l}){const{checkout:i}=ce(),s=a(null),u=i.configuration.layout.isOnePage.value,d=H(),m=ae(),{inMemoryPayPalParts:p,inMemoryVenmoParts:h}=V(),v=D(m),f=v?h.buttonStatus:p.payWithPayPalButtonStatus,{checkoutProtocolModalEventSignal:b}=i.negotiator.context;r(()=>(b.value=o?"none":"paypal",()=>{b.value="none"}),[o,b]),ye([{walletName:me.PayPalV6,isLoading:()=>"not_rendered"===f.value.status,onTimeout:()=>{f.value={status:"error"}}}],x());const g=c(o),k=n(()=>!g.value&&"rendered"!==f.value.status&&"error"!==f.value.status&&"not_eligible"!==f.value.status),P={buttonLabel:"pay",isPayWithPayPalFlow:!0,progressToNextPage:!0,isDisabled:d.value||e||!1,fundingSource:v?"venmo":"paypal",sizingButtonRef:u?void 0:s},w=d.value||t||!1;return y(Ue,{isLoading:w,showSkeleton:k,hidden:o,setRef:l,children:[!u&&y(ge,{labelRef:s}),y(fe,{...P})]})}var Ye={CheckoutExitPayButton:"IuA5i","checkout-pay-button-exit":"h1dlI"};export{Be as _,Ve as a,Oe as c,ze as d,Me as f,je as g,Te as h,Xe as i,De as l,Fe as m,$e as n,Ke as o,Ie as p,Qe as r,We as s,Ye as t,qe as u,Le as v};