import{u as e,M as t,t as a,w as n,m as o,D as i,T as r,h as l,o as s,G as u,v as c}from"./2c1ab0fe.Dbn2KvkT.js";import{Q as d,k as p,cL as m,l as h,af as y,ag as b,d as g,bZ as v,dp as f,a as k,df as S,im as P,B as w,b as _,aJ as N,io as x,ad as L,ae as A,gs as C,ip as z,bH as B,Z as T,g as I,aV as E,a7 as F,b1 as R,iq as D,ap as M,S as j,L as O,M as $,f as H}from"./164ad2e3.FTBuhkTQ.js";import{d as q,a4 as V,bp as W,bb as G,oz as J,oi as Q}from"./4b4bc88f.z1yoAwwH.js";import{u as U,j as X,g as Z,h as K}from"./e3e348f2.DlRIwDFx.js";import{a as Y}from"./78ab3dd0.UjAWxVn0.js";import{A as ee}from"./d4ea2faa.CFmOkqFN.js";import{u as te}from"./fe885b80.D6XeXzR1.js";import{u as ae}from"./f78726c8.COms9s2w.js";function ne({children:a,size:n="medium",ignoreBranding:o=!1}){const{primaryButton:{typography:{size:i}={}}}=d();return n&&!i||o?e(p,{size:n,children:a}):e(t,{children:a})}function oe(e){const t=document.getElementById(e);t&&t.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}))}function ie(){const a=U().value,n=X(),{i18n:o,checkout:i}=q(),r=i.configuration.layout.isOnePage.value,l=m(),{currentPage:s}=h().value,u="review"===s?.id,c="payPal"===i.identity.current.value;if(r&&!c)return null;if(!r&&l.value&&!u)return null;if(!n.value||!a)return null;const d=o.translate("payment_errors.paypal_over_capture",{walletName:o.translate("brand.paypal")});return e(t,{children:[e(y,{errorType:b.PaymentError,tone:"info",children:d}),r&&e(g,{blockSize:"large-200"})]})}function re(){const e=q(),{shopPay:t,mobileCheckoutSdk:a}=e,{isAppLayout:n}=v();if(t.visibility.shouldRenderFloatingShopPayButton)return"floating";const o=a.variant.isPartner(),i=function({identity:e},{isPartnerSdkEnabled:t,isAppLayout:a}){return"shopPay"===e.current.value&&!t&&a}(e.checkout,{isPartnerSdkEnabled:o,isAppLayout:n});return i?"sticky":"inline"}function le(){return"inline"!==re()}function se({disabled:t=!1,loading:r=!1,pixelId:l,setRef:s,buttonContent:u}){const c=f(),d=le(),p=k(),m=S(),h=a(e=>{l&&p(l)(e),s?.(e)},[l,p,s]),{i18n:y,checkout:b,observability:g}=q(),v=b.configuration.layout.isOnePage.value,{applePaySessionHandler:x,inMemoryApplePayParts:{isLoadingPaymentSheet:L,sessionLoadFailed:A}}=V(),C=n(t),z=n(r),B=o(()=>x.value?.onClickHandler),T=o(()=>null==B.value);Z([{walletName:Y.ApplePay,isRendered:()=>null!=B.value,isLoading:()=>null==B.value&&!A.value,onTimeout:()=>{A.value=!0}}],P());const I=o(()=>L.value||z.value),E=o(()=>L.value||C.value||T.value),F=v?v&&d&&c?.id?()=>oe(c.id):void 0:()=>{const e=B.value;null!=e?e({disabled:C.value,isMountedRef:m}):g.error(new ee("Pay with Apple Pay button clicked without a ready session handler."))},R=function(){if(u)return u;const t=y.translate("general.pay_now_button_label");return v?e(ne,{children:t}):t}(),D=T.value;return e(_,{className:"SJwrb",inert:D||void 0,children:[e(w,{variant:"primary",size:v?"base":"large",type:v?"submit":"button",inlineSize:"fill",loading:I.value,loadingMode:"extended",disabled:E.value,ref:h,onClick:F,className:D?"NIOCQ":void 0,children:R}),e(i,{when:T,children:e(_,{className:"_20EXH",children:e(N,{contentDisplay:"block",inlineSize:"100%",blockSize:"100%"})})})]})}const ue={base:{blockSize:`calc(${W.button.primary.blockPadding} * 2 + ${W.fontSize.medium} * ${W.lineHeight.base})`,className:"Ts0Nw"},large:{blockSize:`calc(${W.button.primary.blockPadding} * 2 * 1.5 + ${W.fontSize.base} * ${W.lineHeight.base})`}};function ce({isLoading:t,showSkeleton:a,hidden:n=!1,setRef:o,children:r}){const{source:l,checkout:u}=q(),c=u.configuration.layout.isOnePage.value,d="simulated"===l.type,p=a.value;let m;return!n&&p&&c&&(m=ue.base.className),e(_,{ref:o,className:s("RTmkG",m,c&&"h1pXK",t&&"E4OHT",n&&"vnCpz"),inert:d||p,children:[r,e(i,{when:a,children:e(_,{className:"NFpbC",children:e(N,{contentDisplay:"block",inlineSize:"100%",blockSize:"100%"})})})]})}function de({disabled:t,loading:a,hidden:i=!1,setRef:s}){const{checkout:u,i18n:c}=q(),d=r(null),p=u.configuration.layout.isOnePage.value,m=x(),h=L(),{inMemoryPayPalParts:y,inMemoryVenmoParts:b}=V(),g=A(h),v=g?b.buttonStatus:y.payWithPayPalButtonStatus,{checkoutProtocolModalEventSignal:f}=u.negotiator.context;l(()=>(f.value=i?"none":"paypal",()=>{f.value="none"}),[i,f]),Z([{walletName:Y.PayPalV6,isRendered:()=>"rendered"===v.value.status,isLoading:()=>"not_rendered"===v.value.status,onTimeout:()=>{v.value={status:"error"}}}],P());const k=n(i),S=o(()=>!k.value&&"rendered"!==v.value.status&&"error"!==v.value.status&&"not_eligible"!==v.value.status),N={buttonLabel:"pay",isPayWithPayPalFlow:!0,progressToNextPage:!0,buttonColor:"blue",isDisabled:m.value||t||!1,fundingSource:g?"venmo":"paypal",sizingButtonRef:p?void 0:d},C=m.value||a||!1;return e(ce,{isLoading:C,showSkeleton:S,hidden:i,setRef:s,children:[!p&&e(_,{inert:!0,children:e(w,{ref:d,className:"_8Flfy",variant:"primary",size:"large",inlineSize:"fill",type:"button",children:c.translate("general.pay_now_button_label")})}),e(K,{...N})]})}const pe={CheckoutExitPayButton:"IuA5i"},me='[aria-invalid="true"], [data-card-field-invalid="true"]',he={visibleAlertPresent:"unknown",visibleNoticePresent:"unknown",visibleInvalidFieldPresent:"unknown",invalidFieldFocused:"unknown",buttonBusy:"unknown",buttonDisabled:"unknown"};function ye(e){try{const t=e.defaultView;if(!t)return{...he,feedbackSnapshotStatus:"unavailable"};if("visible"!==e.visibilityState)return{...he,feedbackSnapshotStatus:"document_hidden"};if(t.top!==t.self)return{...he,feedbackSnapshotStatus:"embedded"};const a=e.getElementById(C);return{feedbackSnapshotStatus:"observed",visibleAlertPresent:Array.from(e.querySelectorAll('[role="alert"]')).some(e=>Boolean(e.textContent?.trim())&&be(e,t)),visibleNoticePresent:Array.from(e.querySelectorAll('[role="status"], [data-checkout-feedback="true"], #error-for-checkout-captcha')).some(e=>Boolean(e.textContent?.trim())&&be(e,t)),visibleInvalidFieldPresent:Array.from(e.querySelectorAll(me)).some(e=>be(e,t)),invalidFieldFocused:Boolean(e.activeElement?.closest(me)),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{...he,feedbackSnapshotStatus:"unavailable"}}}function be(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 ge({children:t}){const{observability:a,checkout:{wallets:n,identity:o,negotiator:i,validation:l}}=q(),s=z(),u=h(),c=i.current.fields.buyerIdentity,d=r(),p=r(),m=r();return B(e=>{m.current={type:e.type,stage:"negotiationStage"in e?e.negotiationStage:void 0,timestamp:Date.now()},d.current=void 0,p.current=void 0,"violations"in e&&(d.current=e.violations.map(e=>({code:e.code,type:e.__typename,target:"target"in e?e.target:void 0}))),"reasons"in e&&(p.current=e.reasons)}),e("div",{onClickCapture:function(e){if(e.detail>2){const e=i.parts.paymentLines.value.map(e=>"wallet"===e.method.type||"walletsPlatformPaymentMethod"===e.method.type?e.method.name:e.method.type),t=u.value.currentDetour?.type??u.value.currentPage?.id??"unknown",r={identity:o.current.value,activeWallet:n.activeSession.value?.wallet??null,asPaymentMethod:n.activeSession.value?.asPaymentMethod??!1,journeyStep:t,primaryPaymentLine:e.at(0),...ye(document)};a.counter({name:"pay_now_rage_click",value:1,attributes:r}),a.log("rage_click_capture_pay_now_rage_click_detected","pay_now_rage_click",{customerProfile:c.value?.customerProfile?.__typename,numberOfErrors:s?.numberOfErrors()??"unknown",validationErrorCount:Object.values(l.errors.value).reduce((e,t)=>e+t.length,0),lastInterceptionReasons:p.current,lastViolations:d.current?.map(({code:e})=>e),lastViolationDetails:d.current,lastNegotiationType:m.current?.type,lastNegotiationStage:m.current?.stage,lastNegotiationAgeMs:m.current?Date.now()-m.current.timestamp:void 0,blocked:i.isBlocked.value,paymentLineNames:e,...r})}},children:t})}function ve({shopId:t,shopName:a,shopLogo:n,amount:o,showDivider:i,isLocalShop:r}){const[l,s]=u(!1),{i18n:c}=q();return e(j,{gap:"base",children:[e(T,{gridAutoFlow:"column",gridTemplateColumns:"minmax(auto, max-content) minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",children:[e(_,{children:e(I,{size:"small",src:n,alt:a})}),e(_,{blockAlignment:"center",children:[e(E,{"aria-expanded":l,"aria-controls":`separate-payments-collapsible-${t}`,onClick:()=>s(e=>!e),children:e(T,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr) minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"base",children:[e(p,{type:"strong",children:a}),e(T,{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&&e(p,{type:"strong",children:c.formatCurrency(o.amount,{currency:o.currencyCode,form:"short"})}),e(F,{type:l?"chevron-up":"chevron-down",size:"small-200"})]})]})}),e(R,{open:l,id:`separate-payments-collapsible-${t}`,children:[e(g,{blockSize:"small-200"}),e(D,{shopId:t,isLocalShop:r})]})]})]}),i&&e(M,{direction:"inline",borderWidth:"base"})]})}function fe(){const{i18n:a,shop:{name:n,id:o,brandSettings:i,remoteShopsConfigMap:r}}=q(),l=G("remoteMerchandiseDetails").value,s=ae().value,u=J(),d=te(),p=c(()=>{const e=[];for(const[t,a]of u.value){if(!a)continue;if(d.value&&t===o){e.push({shopName:n,shopLogo:i?.squareLogo?.url,shopId:o,amount:a});continue}const l=r?.get(t);l&&e.push({shopName:l.name,shopId:t,shopLogo:l.brandSettings?.squareLogo?.url,amount:a})}return e},[u.value,o,n,i?.squareLogo?.url,r,d.value]);if(l||!s)return null;const m=e(t,{children:[e(O,{textDecoration:"none",commandFor:"separate-payments-modal",children:a.translate("payment.separate_payments_text")}),e($,{id:"separate-payments-modal",heading:a.translate("payment.payments"),children:e(j,{gap:"base",children:p.map((t,a)=>e(ve,{shopId:t.shopId,shopName:t.shopName,shopLogo:t.shopLogo,amount:t.amount,showDivider:a!==p.length-1,isLocalShop:t.shopId===o},t.shopId))})})]});return e(H,{color:"subdued",children:a.translate("payment.separate_payments_label",{separate_payments_link:m})})}function ke(){const{i18n:t,shop:a,checkout:{negotiator:n}}=q(),o=n.parts.paymentLines.value;return a.vaultForPaymentLater&&Q(o)?e(H,{color:"subdued",children:t.translate("payment.vault_for_payment_later.notice")}):null}function Se(){const{checkout:{negotiator:e}}=q(),t=e.current.fields.captcha;return o(()=>Boolean(t.value))}export{de as P,ge as R,fe as S,ke as V,se as a,ie as b,ue as c,ne as d,re as e,le as f,pe as p,oe as t,Se as u};