1import{u as h,S as x,f as m,q as g,T as I,l as w}from"./esnext-vendor.7EcvH7tF.js";import{P as M,l as W,dZ as q,a0 as K,B as k,d_ as Y,d$ as $,b_ as U,e0 as J,bA as V,e1 as j,e2 as H,n as X,K as F,f as Z,bt as z}from"./hydrate.CvWSYK3c.js";import{Q as c,a2 as Q,S as A,cL as ee,bG as te,dw as O,dx as ne,a1 as oe,ci as se,dy as re,ac as B,aq as ae,ax as ie,aw as le,dz as ue,b4 as ce,dA as E,dB as pe}from"./utilities-previous.BNOUhCqt.js";import{S as de}from"./Switch.D-WpCwGP.js";import{u as he,c as Pe,d as ye,e as me}from"./hooks-useWalletsTimeout.CvRsT5TD.js";import{E as T}from"./addresses-is-address-empty.ChTbY4tb.js";import{s as ge}from"./PayButton-helpers.0kfxXOqw.js";import{a as fe}from"./app.9pOKhaB_.js";import{g as _e,a as Se,b as be}from"./helpers-credit-card-disabled.Cg-Vgf-8.js";import{v as ve,a as Ee,u as ke}from"./useShopPayButtonClassName.D12YSXlR.js";import{u as Ce}from"./AddressPresenter.mAxMJOkn.js";import{u as Ie,a as L}from"./hooks-payment-button.B5qLPYk5.js";function It({line:e}){const{i18n:t,source:o}=c(),n=o.type==="paymentCollection",{title:s,lineAmount:r}=e,a=r.amount===0?t.translate("shipping.free_rate_label"):t.formatCurrency(r.amount,{currency:r.currencyCode,form:"short"}),i=r.amount===0?"uppercase":void 0;return h(M,{children:[s,n?null:h(x,{children:[" · ",h(W,{type:"strong",letterCase:i,children:a})]})]},s)}const C="shop-pay-hsa-details",N=`${C}-description`;function Ae(){const{checkout:e,shop:t,shopPay:o}=c(),n=Q().paymentMethods,{paymentLines:s}=A();return m(()=>{if(!(t.hasFlagEnabled(ee)&&Be({identity:e.identity})&&te(n.value))||o.session.isInstallmentsSelected.value)return!1;const a=o.session.selectedPaymentMethod.value;if(a)return a.paymentMethod==="CREDIT_CARD";const i=s.value[0]?.method,u=i?.type==="wallet"&&i.name==="SHOP_PAY"?i.walletContent:void 0,l=u!=null&&"paymentMethod"in u&&u.paymentMethod==="CREDIT_CARD";return i?.type==="direct"||l})}function Be({identity:e}){return e.current.value==="shopPay"}function At(){const{shopPay:e}=c(),t=Ae();return m(()=>t.value&&e.session.hsaRequested.value)}function Bt(){const{i18n:e,shopPay:t}=c(),o=m(()=>t.session.hsaRequested.value),n=e.translate("payment.shop_pay_hsa.description"),s=g(r=>{t.session.unstable_setHsaRequested(r)},[t.session]);return h(k,{background:"base",colorLayer:"control",border:"base",borderRadius:"base",children:[h("span",{id:N,hidden:!0,children:n}),h(q,{id:C,open:o.value,summary:h(k,{padding:"base",children:h(de,{label:e.translate("payment.shop_pay_hsa.label"),checked:o.value,onChange:s,icon:"none","aria-controls":`${C}-content`,"aria-describedby":N})}),content:h(x,{children:[h(K,{}),h(k,{padding:"base",children:h(M,{type:"small",color:"subdued",children:n})})]})})]})}function Rt(e){return I(()=>e.some(t=>{if(t.kind==="customField")return O(t).required.peek();const o=O(t);return o.behaviors.peek().blockProgress&&o.capabilities.blockProgress}),[e])}function Re(){const{shop:e,shopPay:{user:t}}=c();return e.hasFlagEnabled(ne)?!1:t.getExperimentAssignment(T)===T.variants.treatment}function D(){const e=c(),{shop:t}=e,o=he(),n=oe(),s=t.hasFlagEnabled(se);return m(()=>re(e.checkout,{showPayWithApplePayButton:o.value,paymentFullyCoveredByRedeemablesAndGiftCards:n.value,isApplePayInShopPayKillswitched:s}))}function we(){return Y()?.config?.payActionType==="NATIVE"}function Oe(){const{persistedGooglePaySignal:e}=B(),{checkout:t}=c();return m(()=>{const o=e.value?.receiptIdForPaymentFailure,n=t.latestReceipt.value;return!!(n?.status==="failed"&&n?.failure?.type==="payment"&&o&&n?.id===o)})}function Te(){const{checkout:{identity:e}}=c(),{paymentLines:t}=A(),{inMemoryGooglePayParts:{paymentSheetOpenPromise:o}}=B(),n=Oe();return m(()=>e.current.value!=="googlePay"||!ae(t.value,"GOOGLE_PAY")?!1:o?.value!==void 0?!0:n.value)}function Ne(){const e=c(),{checkout:t,shopPay:o}=e,n=t.identity.current.value==="shopPay",s=Pe().value,r=Te().value,a=ye().value,i=!n&&s&&!a,u=!n&&r,{showApplePay:l,isApplePayInShopPay:p}=D().value,y=me(),d=we(),f=$(),_=Re();return{kind:ge(t,{showPayWithPayPal:i,showApplePay:l&&!a,showPayWithGooglePay:u,isEmbeddedCheckout:y,shouldRenderCheckoutProtocolButton:d,isInstallmentsSupported:f!=null,isInstallmentsSelected:o.session.isInstallmentsSelected.value,isInstallmentsUkHoldoutTreatment:_}),showPayWithPayPal:i,isApplePayInShopPay:p,shouldDeferWalletToReview:a}}function xe(){const{source:e,checkout:t,shop:o,shopPay:n,observability:s,userEvents:r}=c(),a=n.installments,i=n.user.installments;return g(()=>{i.isRejected.value&&!i.isRetryable.value||(a.unstable_setModalOpen(!0,"checkout_button"),s.log("installments_modal_opened","[Installments] Modal opened"),r.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...ie(e,t,o),action:"continue_with_installments"}}))},[a,i,s,r,e,t,o])}function Me({existing:e,scope:t,next:o}){return[...e.filter(n=>!Ue(n.target,t)),...o]}function Ue(e,t){return e?e===t||e.startsWith(`${t}.`):!1}var P=(e=>(e.BlankEmail="blank_email",e.BlankPhone="blank_phone",e.InvalidEmail="invalid_email",e.InvalidPhone="invalid_phone",e.ShopAccountsInvali
1dEmail="shop_accounts_invalid_email",e.ShopAccountsInvalidPhone="shop_accounts_invalid_phone",e.ShopAccountsPhoneLimitReached="shop_accounts_phone_limit_reached",e))(P||{});function He(){const{email:e}=A(),{shopPay:t}=c();return m(()=>{const o=e.value.trim(),n=t.userVerification.value,s=ve(o,P.BlankEmail),r=Ee(o,P.InvalidEmail),a=n.status==="invalid"&&n.email===o?P.InvalidEmail:void 0;return{email:o,emailError:s||r||a}})}const Fe=()=>{const{shopPay:e}=c(),t=e.signup.phoneNumber,o=e.signup.phoneCountryCode,n=Ce(),s=w(n.isPhoneNumberUtilLoaded),r=w(n.validatePhoneNumber),a=e.user.isAuthenticatedUser;return m(()=>({missingRequiredMobilePhoneNumber:!!(!a.value&&(!t.value||s.value&&!r.value(t.value,o.value,!0)))}))},Le="Mobile phone number is missing or invalid";function De(){const e=He(),{source:{checkoutSessionIdentifier:t},url:o,shopPay:n}=c(),s=n.user.phoneNumber,r=n.user.unstable_setPhoneNumber,{transactionParams:a}=n.config,i=n.user.isAuthenticatedUser,u=Fe(),l=g(async(p=!0)=>{const{email:y,emailError:d}=e.value;if(i.value||s.value)return{status:"skipped"};if(!a)return{status:"failed",errors:[{field:[],code:"missing_content",message:"Transaction params are missing"}]};const f=[];if(d&&f.push({field:["email"],code:d,message:"email is blank or invalid"}),u.value.missingRequiredMobilePhoneNumber&&f.push({field:["phone"],code:P.InvalidPhone,message:Le}),f.length>0)return{status:"failed",errors:f};let _=p?n.signup.hcaptchaToken.value:void 0;if(!_)try{const R=await n.signup.captchaRef.value?.execute({async:!0});R&&(_=R.response)}catch(v){return v==="challenge-closed"?{status:"failed",errors:[]}:{status:"failed",errors:[{field:["hcaptcha"],code:String(v),message:"A captcha error was caught and handled"}]}}let S=null;try{const v=n.signup.phoneNumber.value||"";S=await fetch(o.shopPayCreateUnverifiedUser(),{method:"POST",body:JSON.stringify({email:y,phone:v,hcaptcha_token:_,origin:"c1_unverified_user_signup",checkout_token:t,transaction_params:a}),headers:{"Content-Type":"application/json",accept:"application/json"}})}catch{return{status:"failed",errors:[{field:[],code:"unknown_error",message:"An error was caught and handled during API request"}]}}const b=await S.json();return S.status!==200?Array.isArray(b?.errors)&&b?.errors.length===1&&b?.errors[0].code==="further_authorization_required"&&p?(n.signup.unstable_setHcaptchaToken(void 0),l(!1)):{status:"failed",errors:b?.errors||[{field:[],code:`response_with_http_error_${S.status}`,message:"Failed to create user"}]}:(r(b.parsed_phone),n.user.unstable_setEmail(y),n.user.unstable_updateFlow("authenticated_user"),{status:"success"})},[i,s,a,e,u,r,n,o,t]);return{createUnverifiedUser:l}}function Ge(){const{i18n:e,shopPay:t,checkout:{validation:{contactErrors:{emailInputError:o}}}}=c(),n=U(),{openModal:s}=ke(),r={[P.BlankEmail]:e.translate("field_errors.email_blank"),[P.InvalidEmail]:e.translate("field_errors.email_invalid"),[P.ShopAccountsInvalidEmail]:e.translate("field_errors.email_invalid")},a={[P.BlankPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[P.InvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[P.ShopAccountsInvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[P.ShopAccountsPhoneLimitReached]:e.translate("mobile_phone_number.phone_limit_reached")};return{handleCreateUnverifiedUserErrors:u=>{if(u.length===0)return;const l=u.map(d=>d.code),p=r[l.find(d=>d in r)],y=a[l.find(d=>d in a)];return p||y?(o.value=p,t.signup.unstable_setPhoneError(y)):s({type:J.Generic}),Promise.resolve().then(()=>n())}}}function G(){const{progressContinueWithResult:e}=We();return{progressContinue:g(async()=>await e()==="continue",[e])}}function We(){const{source:e,observability:t,shopPay:{progressInterceptor:o}}=c(),n=le(),{createUnverifiedUser:s}=De(),{handleCreateUnverifiedUserErrors:r}=Ge(),a=U(),i=g(async()=>{try{const u=await s(),l=await o.runInterceptors();n.validationErrors.value=Me({existing:n.validationErrors.value,scope:V,next:_e(l)});const p=Se(l);if(!p){const y=be(l);t.log("shop_pay_progress_interceptor_error_reported","Shop Pay progress interceptor reported an error in useShopPayProgressContinue",{interceptorErrors:y})}if(u?.status==="failed")return r(u.errors),"blocked";if(!p)return $e(a),"blocked"}catch(u){const l=u;return ue(l.message)||Ye(l)?t.log("shop_pay_progress_continue_unactionable_error","Shop Pay progress continue swallowed an unactionable error in useShopPayProgressContinue",{errorName:l.name,errorMessage:Ke(l.message),sourceType:e.type}):t.error(l,{errorClass:j.ShopPayProgressIntercept,severity:"error",metadata:{source:{type:e.type},checkout:{token:e.checkoutSessionIdentifier??"checkout_identifier_undefined"}}}),"errored"}return"continue"},[s,a,r,o,n,t,e]);return I(()=>({progressContinueWithResult:i}),[i])}const qe=200;function Ke(e){return e?.slice(0,qe)}function Ye(e){return fe.includes(e.name)}function $e(e){return Promise.resolve().then(()=>e())}function Je(){const{checkout:{identity:e},shopPay:t,observability:o}=c(),n=H(),{progressContinue:s}=G(),r=xe(),a=g(async()=>{t.session.unstable_setButtonProgressing(!0),o.log("installments_cta_clicked","[Installments] Continue to purchase button clicked");try{await s()&&r()}finally{t.session.unstable_setButtonProgressing(!1)}},[t.session,o,s,r]);return n||e.current.value!=="shopPay"||!t.session.isInstallmentsSelected.value?null:a}function Ve(){const{observability:e,source:t,router:o}=c(),{currentDetour:n,currentPage:s}=X().value,{nextPage:r,previousPage:a}=F();return I(()=>({ensureShopPayURL:()=>{s||o.navigate("/shoppay",{replace:!0})},logError:(i,{result:u}={})=>{e.error(new ce(i,{groupingHash:"ShopPayError::InvalidPageLogger"}),{severity:"error",metadata:{source:{type:t.type},checkout:{token:t.checkoutSessionIdentifier||t.sourceId},event:{currentDetour:JSON.stringify(n),currentPage:JSON.stringify(s),nextPage:JSON.stringify(r),previousPage:JSON.stringify(a),result:JSON.stringify(u)}}})}}),[n,s,e,r,a,o,t.checkoutSessionIdentifier,t.sourceId,t.type])}function je(){const{checkout:{identity:e},observability:t,shopPay:o}=c(),n=H(),{nextPage:s}=F(),{progress:r}=Z(),{progressContinue:a}=G(),i=Ve(),u=z(),l=Ie(),p=L({breadcrumbPrefix:E}),y=g(async()=>
1{if(p()){l();try{o.session.unstable_setButtonProgressing(!0),await a()?(t.leaveErrorBreadcrumb(`${E} - progress`),await r("shop-pay-progress-button-press",d=>{t.leaveErrorBreadcrumb(`${E} - progression`,{status:d.status,nextPageId:s.id}),s.id!=="thankYou"&&i.logError("Shop Pay button triggered progression when next page is not `thankYou`",{result:d})},{onProgressBlocked:()=>{t.leaveErrorBreadcrumb(`${E} - progress blocked`,{nextPageId:s.id}),i.ensureShopPayURL()}}),u.notify({checkout_in_progress:!0})):(t.leaveErrorBreadcrumb(`${E} - progress continue failed`,{nextPageId:s.id}),s.id!=="thankYou"&&(i.logError("Shop Pay button is pressed when next page is not `thankYou`"),i.ensureShopPayURL()))}finally{o.session.unstable_setButtonProgressing(!1)}}},[p,l,o.session,a,t,r,s,i,u]);return e.current.value!=="shopPay"||n?null:y}function Xe(){const{showApplePay:e}=D().value,o=B().applePaySessionHandler.value?.onClickHandler??null,n=L({breadcrumbPrefix:pe,isApplePay:!0}),s=g(()=>{o?.({validateButtonPress:n})},[o,n]);return e&&o?s:null}function wt(e){const{kind:t}=Ne(),o=Xe(),n=je(),s=Je();return t==="applePay"&&o?o:t==="installments"&&s?s:(t==="default"||t==="checkoutProtocol")&&n?n:e}const Ze="liLqL",ze="b71fw",Ot={Button:Ze,Sparkles:ze},Qe="OJbFq",et="wNUaA",Tt={Button:Qe,"Button-prefersDarkMode":"LhoYl",WalletLogoContainer:et},tt="XR3sZ",nt="_4fPUS",ot="_5FRe7",st="ZDqoP",rt="zANgR",at="_3A6oJ",it="K8y4t",lt="_7S3NK",ut="SdyJr",Nt={StickyFooter:tt,StickyFooterExperiment:nt,StickyFooterAtBottom:ot,StickyFooterBuffer:st,SDKStickyFooterBuffer:rt,EmbedStickyFooterBuffer:at,ButtonContainer:it,SDKButtonContainer:lt,EmbedButtonContainer:ut},ct="GsMGr",pt="eDhAI",dt="P0xJW",ht="COpTB",xt={Wrapper:ct,Container:pt,Section:dt,"Container-fixed":"iRlFp","Container-fixed-entering":"_24aJk","Container-fixed-exiting":"ktbnR","Container-fixed-enter":"PCKgT","Container-fixed-exited":"DvZWz",Shadow:ht,"Shadow-enter":"_0hDB9","Shadow-exiting":"P1NPi","Shadow-exited":"lQN1j"};export{It as D,Bt as H,Re as a,Ae as b,Tt as c,Nt as d,At as e,G as f,xe as g,Ne as h,D as i,We as j,Rt as k,xt as l,Me as r,Ot as s,wt as u};
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.