import{Ft as e,Gt as t,It as n,Jt as r,Pt as i,Wt as o,Xt as a,bt as s,en as c,ft as u,jt as l,nn as d,pt as m,yt as p}from"./630ba094.L_X-5TXi.js";import{c as h,s as v}from"./app.BAntcNCf.js";import{Ad as f,Ap as y,Gg as g,Io as b,Js as w,NO as S,T as k,Tp as E,Uf as C,X as L,Xd as A,Xg as M,Y as T,an as _,hb as P,ho as j,is as x,jp as N,kn as I,kp as O,l_ as F,ok as R,ro as B,xO as z}from"./6ec9a0fa.rdcQt2v8.js";import{n as H}from"./9a493f3d.BU4_4NVs.js";import{a as D,c as Y,n as X,o as K,s as q,u as G,v as J}from"./b2ef26e8.DM1tmxzK.js";import{A as U,P as V,r as W}from"./0e3247a0.Csj0q_SF.js";import{c as Q}from"./674595ba.CBCkPO6g.js";import{t as $}from"./e29daa9a.GYMR20KQ.js";import{i as Z,n as ee,t as te}from"./5a1effbb.kKDKeey4.js";import{a as ne,i as re,o as ie,s as oe}from"./4205169c.D52g_3ca.js";import{l as ae,s as se}from"./74e5a557.CRSHWf3c.js";import{a as ce,i as ue,r as le}from"./bdb60128.SdcL5BFE.js";import{n as de,r as me,t as pe}from"./4bb32466.BUEK88nz.js";function he(e,t,n){const r=fe(e,t?.at),i=fe(e,n?.at),o=void 0!==r&&r<1500;return void 0!==i&&i<1500&&(!o||i<=r)?n.reductions?"enter_reductions":"enter_other":o?t.onPay?"pointer_pay":"pointer_other":"none"}function ve(e,t){return e?t(e)?"pay_button":"other":"none"}function fe(e,t){return void 0===t?void 0:Math.max(0,Math.round(e-t))}function ye(e,t){return e instanceof Element?e.closest(t):null}function ge(e){return e instanceof HTMLElement?e.getAttribute("name")||e.id||e.tagName.toLowerCase():""}function be({submitRef:e}){const{checkout:{journey:n}}=z(),i=ce(),s=a(()=>{void 0!==i.value.isCompletionStep?n.progression.progress({id:"one-page-form-submit",kind:i.value.skipToCompletion?"completion":"progression"}):n.progression.progress({id:"one-page-form-submit",kind:"primaryAction"})},[n,i]),c=le(s);return function(){const{observability:e,client:t,checkout:n}=z(),i=R()?.id,a="shopPay"===n.identity.current.value,s=ue(),{payNowButtonElement:c}=I(),u=r({});o(()=>{if(!a||!i||s)return;const n=window.visualViewport,r=u.current,o=e=>function(e,t){return e instanceof Element&&(null!==e.closest("#checkout-pay-button")||(t?.contains(e)??!1))}(e,c.value),l=e=>{r.pointer={at:e.timeStamp,onPay:o(e.target),eventName:ye(e.target,"[data-event-name]")?.getAttribute("data-event-name")??"",cancelled:!1}},d=()=>{r.pointer&&(r.pointer.cancelled=!0)},m=e=>{ye(e.target,'[data-event-name="apply_discount"]')&&(r.applyAt=e.timeStamp),o(e.target)&&(r.payClick={at:e.timeStamp,trusted:e.isTrusted})},p=e=>{var t;"Enter"!==e.key||e.isComposing||(r.enter={at:e.timeStamp,reductions:(t=e.target,t instanceof HTMLInputElement&&"reductions"===t.name),field:ge(e.target)})},h=e=>{e.target!==document&&e.target!==n||(r.scrollAt=e.timeStamp)},v=n=>{const a=n.target;if(!(a instanceof HTMLFormElement)||a.id!==i)return;let s;try{s=T(a)}catch{return}const{reductionsEmpty:c,reductionsInputOwner:u,reductionsInputCount:l}=s,d=n.timeStamp,m=n.submitter??null,p=fe(d,r.applyAt),h=fe(d,r.scrollAt),v=fe(d,r.payClick?.at),f=void 0!==v&&v<1500,y=r.pointer?.cancelled??!1,g={submitter:ve(m,o),trigger:he(d,r.pointer,r.enter),afterApply:void 0!==p&&p<5e3,duringScroll:void 0!==h&&h<1e3,mobile:t.userAgentDetails.isMobile,reductionsEmpty:c,reductionsInputOwner:u},b="pointer_pay"!==g.trigger||y||"other"===g.submitter||"none"===g.submitter&&!f||g.afterApply||"checkout"===u||"other"===u||void 0!==h&&h<250,w=b?{exportImmediately:!0,requiresKeepalive:!0}:{requiresKeepalive:!0};e.counter({name:"one_page_submit_trigger",value:1,attributes:g,...w}),b&&e.log("one_page_submit_trigger_suspect","one_page_submit.trigger_suspect",{...g,reductionsInputCount:l,synthetic:!n.isTrusted,submitterEventName:m?.dataset.eventName??"",submitterHidden:"true"===m?.getAttribute("aria-hidden"),payClick:f,payClickTrusted:f&&(r.payClick?.trusted??!1),pointerEventName:r.pointer?.eventName??"",pointerCancelled:y,enterField:r.enter?.field??"",msSinceApply:p??-1,msSinceScroll:h??-1,msSincePointer:fe(d,r.pointer?.at)??-1},w)},f={capture:!0,passive:!0};return document.addEventListener("pointerdown",l,f),document.addEventListener("pointercancel",d,f),document.addEventListener("click",m,f),document.addEventListener("keydown",p,f),document.addEventListener("scroll",h,f),n?.addEventListener("scroll",h,f),document.addEventListener("submit",v,!0),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("pointercancel",d,!0),document.removeEventListener("click",m,!0),document.removeEventListener("keydown",p,!0),document.removeEventListener("scroll",h,!0),n?.removeEventListener("scroll",h,!0),document.removeEventListener("submit",v,!0)}},[a,i,s,t,e,c])}(),t(()=>(e.current=c,()=>{e.current=void 0}),[e,c]),null}function we({children:e,mobileOrderSummary:t,showMobileOrderSummary:n,mobileOrderSummaryDrawn:r,summaryBeforeCluster:o=!1,padBlockStartFromMedium:a}){const{checkout:s}=z(),{shell:c}=s.configuration.branding,u=i(()=>{const{main:e,reductions:t}=c.configurationSignal.value;return"base"===t.position?"large-200":n.value&&(r?.value??!0)&&null!=e.spacing?E(e.spacing)??"base":"base"}),l=i(()=>a?.value?`@media (inline-size >= medium) ${u.value}, none`:void 0),h=p(m,{when:n,children:t});return p(d,{children:[o&&h,p(g,{gap:u.value,paddingBlockStart:l.value,"data-testid":"onepage-pay-button-cluster",children:[!o&&h,e]})]})}function Se(){const e=B();return ne(),p(te,{ineligibilityReason:e})}function ke(){const e=k().value,t=j().value,n=F("Checkout::Dynamic::Render","PAYMENT1"),r=F("Checkout::Dynamic::Render","PAYMENT2"),i=F("Checkout::Dynamic::Render","PAYMENT3");return"inContext"===t||"hidden"===t||"afterPayment"===t&&e?{billingSelector:[],paymentMethodList:n,afterTips:e?r:[],end:e?i:[...r,...i]}:{billingSelector:r,paymentMethodList:n,afterTips:e?i:[],end:e||"afterPayment"!==t?[]:i}}function Ee({selectorShowsTiles:n,children:i}){const{checkout:{negotiator:o}}=z(),{buyerHasActedSignal:a}=o.context,s=Y(),c=r(null),u=r(null),d=r(!1),m=S(n.value&&a.value),f=e(null);t(()=>{const e=u.current;if(!e||"undefined"==typeof MutationObserver)return;const t=new MutationObserver(t=>{if(!e.hasChildNodes())return d.current=!1,void(f.value=null);t.some(e=>e.addedNodes.length>0)&&m.current&&h()&&(d.current=!0,f.value={from:v(),withMotion:s.loaded})});return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()},[f,m,s]),t(()=>{if(d.current){d.current=!1;for(const e of[c.current,u.current])for(const t of e?.getAnimations?.()??[])t.cancel(),t.play()}});const y=null!==f.value&&f.value.withMotion;return p("div",{ref:c,className:l("OiIKz",y&&"_5YCEU",y&&"payment-transition-extensions-clip"),children:p("div",{ref:u,className:l("dwA7y",y&&q[f.value?.from??"end"]),children:i})})}var Ce=e=>p(M,{children:e});function Le({customizations:e,selectorShowsTiles:t}){return 0===e.length?null:p(d,{children:e.map(e=>"uiExtension"===e.kind?p(Ee,{selectorShowsTiles:t,children:p(y,{extension:e.extension,render:Ce})},e.extension.id):p(N,{field:e.field},e.field.key))})}var Ae=s(function({renderExtensionSlot:t}){const{checkout:n}=z(),r=de(),o=i(()=>function({identity:e}){switch(e.current.value){case"guest":case"customerAccount":case"shopPay":return!0;default:return!1}}({identity:n.identity})),a=ae(),{billingSelector:s,paymentMethodList:u}=ke(),l=F("purchase.checkout.payment-method-list.render-after"),d=e(!1),h=c(()=>function(e){return t=>p(Ee,{selectorShowsTiles:e,children:t})}(d),[d]);return p(ee,{dynamicPaymentExtensions:s,children:[p(Z,{selectorShowsTiles:d,renderVaultingAgreementInline:!1,afterPaymentSelector:p(m,{when:a,children:p(se,{})})}),p(m,{when:r,children:p(pe,{})}),p(Le,{customizations:l,selectorShowsTiles:d}),p(Le,{customizations:u,selectorShowsTiles:d}),t?.("purchase.checkout.payment-method-list.render-after",{wrap:h}),p(m,{when:o,children:p(U,{})})]})});function Me(){const{shop:e}=z(),t=x();return i(()=>e.discountCodesEnabled&&t.value)}function Te(){const{i18n:e}=z(),{afterTips:t,end:n}=ke(),r=Me();return p(d,{children:[p(O,{customizations:t}),p(O,{customizations:n}),p(m,{when:r,children:p(L,{targetSelector:'input[name="reductions"]',icon:"discount",label:e.translate("order_summary.discount_discovery.add_code")})})]})}var _e=s(function({renderExtensionSlot:e,tips:t}){const{checkout:r}=z();V(),function(){const{checkout:{negotiator:e}}=z(),{payment:t,directPaymentFieldsFilled:r}=e.context,{paymentLines:i,directPaymentErrors:o}=e.parts,a=re();n(()=>{const e=a.value||(n=o,Object.keys(n).filter(e=>"paymentMethodIdentifier"!==e).some(e=>null!=n[e].value));var n,s,c;t.value=(s=i.value,c=r.value,s.some(e=>"direct"!==e.method.type||Boolean(e.method.sessionId)||c)&&!e)})}();const o=w(),a=i(()=>o.value&&!P({paymentLines:r.negotiator.parts.paymentLines.value,paymentMethods:r.negotiator.current.fields.paymentMethods.value})),s=i(()=>r.installments.isSupported.value),c=F("purchase.checkout.payment-method-list.render-before");return p(A,{target:"cart.paymentLines[0]",children:p(g,{accessibilityRole:"group",accessibilityLabelledBy:"payment",gap:"base",children:[p(je,{}),p(O,{customizations:c}),e?.("purchase.checkout.payment-method-list.render-before",{}),p(H,{}),p(ie,{}),p(m,{when:r.configuration.visibility.showStoreCreditRedemption,children:p(Pe,{belowBillingForm:!1})}),p(m,{when:s,children:p(Se,{})}),p(C,{children:p(g,{gap:"large-300",children:[p(Ae,{renderExtensionSlot:e}),p(m,{when:r.configuration.visibility.showStoreCreditRedemption,children:p(Pe,{belowBillingForm:!0})}),p(m,{when:a,children:p($,{})}),p(m,{when:r.configuration.visibility.showPurchaseOrderNumberField,children:p(X,{showHeading:!1})}),t,p(Te,{})]})})]})})});function Pe({belowBillingForm:e}){const t=function(){const{checkout:e}=z(),{displayedPaymentMethods:t}=J(),n=D(t),r=j(),o=f(),a=Q(),s=b();return i(()=>{const t=null!==G(e.identity,s.value)||a.value.freeOrder||a.value.giftCard||a.value.storeCredit||a.value.redeemables,i=!o.value&&("inContext"===r.value||"afterPayment"===r.value);return e.configuration.visibility.showStoreCreditRedemption.value&&!t&&"singlePaymentMethodCreditCard"===n.value.mode&&i})}(),n=u(e),r=i(()=>t.value===n.value);return p(m,{when:r,children:p(W,{})})}function je(){const{router:e}=z(),t="payment",n=i(()=>oe(e,t));return p(me,{headingId:t,autoFocus:n.value})}export{be as i,Me as n,we as r,_e as t};