1import{u as h,S as N,f as m,q as g,T as I,l as w}from"./2c1ab0fe.DYQSH7bT.js";import{P as x,n as q,e2 as K,a0 as J,B as k,e3 as Y,bW as U,e4 as $,e5 as V,e6 as X,e7 as L,e as j,K as H,h as Q,br as Z}from"./164ad2e3.BcELPLd1.js";import{O as c,cB as z,P as ee,Q as A,dr as F,cA as te,dn as O,ds as ne,bJ as oe,S as se,dt as re,a6 as B,X as ae,aq as ie,du as le,ar as ue,b9 as ce,dv as v,dw as pe}from"./4c290a1e.CvCmFIo_.js";import{S as de}from"./39921a74.BJI6Ssr2.js";import{u as he,c as ye,d as Pe,e as me}from"./e3e348f2.FEGbJPeA.js";import{E as T}from"./5587f402.CeT4RdJn.js";import{s as ge}from"./ccdf3592.DEIwKw5E.js";import{a as fe}from"./app.Bvc4uxd4.js";import{g as _e,a as Se,b as ve}from"./8599b02a.CeEg7uRS.js";import{v as be,a as Ee,u as ke}from"./0c0ad074.C6n2uAo_.js";import{u as Ce}from"./53bbdad9.C7Msysac.js";import{u as Ie,a as D}from"./ec391382.BFIAqvUW.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(x,{children:[s,n?null:h(N,{children:[" · ",h(q,{type:"strong",letterCase:i,children:a})]})]},s)}const C="shop-pay-hsa-details",M=`${C}-description`;function Ae(){const{checkout:e,shop:t,shopPay:o}=c(),n=ee().paymentMethods,{paymentLines:s}=A();return m(()=>{const r=F(n.value);if(!(t.hasFlagEnabled(te)&&Be({identity:e.identity})&&(r==="ELIGIBLE"||r==="MIXED_CART"))||o.session.isInstallmentsSelected.value)return!1;const i=o.session.selectedPaymentMethod.value;if(i)return i.paymentMethod==="CREDIT_CARD";const u=s.value[0]?.method,l=u?.type==="wallet"&&u.name==="SHOP_PAY"?u.walletContent:void 0,p=l!=null&&"paymentMethod"in l&&l.paymentMethod==="CREDIT_CARD";return u?.type==="direct"||p})}function Be({identity:e}){return e.current.value==="shopPay"}function At(){const{checkout:e,shopPay:t}=c(),o=Ae();return m(()=>o.value&&z(e.proposal.negotiated.fields.paymentMethods.value)&&t.session.hsaRequested.value)}function Bt(){const{i18n:e,shopPay:t,checkout:o}=c(),n=m(()=>F(o.proposal.negotiated.fields.paymentMethods.value)),s=m(()=>n.value!=="ELIGIBLE"),r=n.value==="MIXED_CART",a=m(()=>!s.value&&t.session.hsaRequested.value),i=r?e.translate("payment.shop_pay_hsa.mixed_cart_description"):e.translate("payment.shop_pay_hsa.description"),u=g(l=>{s.value||t.session.unstable_setHsaRequested(l)},[s,t.session]);return h(k,{background:"base",colorLayer:"control",border:"base",borderRadius:"base",children:[h("span",{id:M,hidden:!0,children:i}),h(K,{id:C,open:r||a.value,summary:h(k,{padding:"base",children:h(de,{label:e.translate("payment.shop_pay_hsa.label"),checked:a.value,disabled:s.value,onChange:u,icon:"none","aria-controls":`${C}-content`,"aria-describedby":M})}),content:h(N,{children:[h(J,{}),h(k,{padding:"base",children:h(x,{type:"small",color:"subdued",children:i})})]})})]})}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 G(){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 Me(){const e=c(),{checkout:t,shopPay:o}=e,n=t.identity.current.value==="shopPay",s=ye().value,r=Te().value,a=Pe().value,i=!n&&s&&!a,u=!n&&r,{showApplePay:l,isApplePayInShopPay:p}=G().value,P=me(),d=we(),f=Re();return{kind:ge(t,{showPayWithPayPal:i,showApplePay:l&&!a,showPayWithGooglePay:u,isEmbeddedCheckout:P,shouldRenderCheckoutProtocolButton:d,isInstallmentsSupported:e.checkout.installments.isSupported.value,isInstallmentsSelected:o.session.isInstallmentsSelected.value,isInstallmentsUkHoldoutTreatment:f}),showPayWithPayPal:i,isApplePayInShopPay:p,shouldDeferWalletToReview:a}}function Ne({existing:e,scope:t,next:o}){return[...e.filter(n=>!xe(n.target,t)),...o]}function xe(e,t){return e?e===t||e.startsWith(`${t}.`):!1}var y=(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))(y||{});function Ue(){const{email:e}=A(),{shopPay:t}=c();return m(()=>{const o=e.value.trim(),n=t.userVerification.value,s=be(o,y.BlankEmail),r=Ee(o,y.InvalidEmail),a=n.status==="invalid"&&n.email===o?y.InvalidEmail:void 0;return{email:o,emailError:s||r||a}})}const Le=()=>{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)))}))},He="Mobile phone number is missing or invalid";function Fe(){const e=Ue(),{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=Le(),l=g(async(p=!0)=>{const{email:P,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:y.InvalidPhone,message:He}),f.length>0)return{status:"failed",errors:f};let b=p?n.signup.hcaptchaToken.value:void 0;if(!b)try{const R=await n.signup.captchaRef.value?.execute({async:!0});R&&(b=R.response)}catch(S){return S==="challenge-closed"?{status:"failed",errors:[]}:{status:"failed",errors:[{field:["hcaptcha"],code:String(S),message:"A captcha error was caught and handled"}]}}let E=null;try{const S=n.signup.phoneNumber.value||"";E=await fetch(o.shopPayCreateUnverifiedUser(),{method:"POST",body:JSON.stringify({email:P,phone:S,hcaptcha_token:b,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 _=await E.json();return E.status!==200?Array.isArray(_?.errors)&&_?.errors.length===1&&_?.errors[0].code==="further_authorization_required"&&p?(n.signup.unstable_setHcaptchaToken(void 0),l(!1)):{status:"failed",errors:_?.errors||[{field:[],code:`response_with_http_error_${E.status}`,message:"Failed to create user"}]}:(r(_.parsed_phone),n.user.unstable_setEmail(P),n.user.unstable_updateFlow("authenticated_user"),{status:"success"})},[i,s,a,e,u,r,n,o,t]);return{createUnverifiedUser:l}}function De(){const{i18n:e,shopPay:t,checkout:{validation:{contactErrors:{emailInputError:o}}}}=c(),n=U(),{openModal:s}=ke(),r={[y.BlankEmail]:e.translate("field_errors.email_blank"),[y.InvalidEmail]:e.translate("field_errors.email_invalid"),[y.ShopAccountsInvalidEmail]:e.translate("field_errors.email_invalid")},a={[y.BlankPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[y.InvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[y.ShopAccountsInvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[y.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)],P=a[l.find(d=>d in a)];return p||P?(o.value=p,t.signup.unstable_setPhoneError(P)):s({type:$.Generic}),Promise.resolve().then(()=>n())}}}function W(){const{progressContinueWithResult:e}=Ge();return{progressContinue:g(async()=>await e()==="continue",[e])}}function Ge(){const{source:e,observability:t,shopPay:{progressInterceptor:o}}=c(),n=ie(),{createUnverifiedUser:s}=Fe(),{handleCreateUnverifiedUserErrors:r}=De(),a=U(),i=g(async()=>{try{const u=await s(),l=await o.runInterceptors();n.validationErrors.value=Ne({existing:n.validationErrors.value,scope:V,next:_e(l)});const p=Se(l);if(!p){const P=ve(l);t.log("shop_pay_progress_interceptor_error_reported","Shop Pay progress interceptor reported an error in useShopPayProgressContinue",{interceptorErrors:P})}if(u?.status==="failed")return r(u.errors),"blocked";if(!p)return Je(a),"blocked"}catch(u){const l=u;return le(l.message)||Ke(l)?t.log("shop_pay_progress_continue_unactionable_error","Shop Pay progress continue swallowed an unactionable error in useShopPayProgressContinue",{errorName:l.name,errorMessage:qe(l.message),sourceType:e.type}):t.error(l,{errorClass:X.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 We=200;function qe(e){return e?.slice(0,We)}function Ke(e){return fe.includes(e.name)}function Je(e){return Promise.resolve().then(()=>e())}function Ye(){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:{...ue(e,t,o),action:"continue_with_installments"}}))},[a,i,s,r,e,t,o])}function $e(){const{checkout:{identity:e},shopPay:t,observability:o}=c(),n=L(),{progressContinue:s}=W(),r=Ye(),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}=j().value,{nextPage:r,previousPage:a}=H();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 Xe(){const{checkout:{identity:e},observability:t,shopPay:o}=c(),n=L(),{nextPage:s}=H(),{progress:r}=Q(),{progressContinue:a}=W(),i=Ve(),u=Z(),l=Ie(),p=D({breadcrumbPrefix:v}),P=g(async()=>
1{if(p()){l();try{o.session.unstable_setButtonProgressing(!0),await a()?(t.leaveErrorBreadcrumb(`${v} - progress`),await r("shop-pay-progress-button-press",d=>{t.leaveErrorBreadcrumb(`${v} - 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(`${v} - progress blocked`,{nextPageId:s.id}),i.ensureShopPayURL()}}),u.notify({checkout_in_progress:!0})):(t.leaveErrorBreadcrumb(`${v} - 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:P}function je(){const{showApplePay:e}=G().value,o=B().applePaySessionHandler.value?.onClickHandler??null,n=D({breadcrumbPrefix:pe,isApplePay:!0}),s=g(()=>{o?.({validateButtonPress:n})},[o,n]);return e&&o?s:null}function wt(e){const{kind:t}=Me(),o=je(),n=Xe(),s=$e();return t==="applePay"&&o?o:t==="installments"&&s?s:(t==="default"||t==="checkoutProtocol")&&n?n:e}const Qe="liLqL",Ze="b71fw",Ot={Button:Qe,Sparkles:Ze},ze="OJbFq",et="wNUaA",Tt={Button:ze,"Button-prefersDarkMode":"LhoYl",WalletLogoContainer:et},tt="XR3sZ",nt="_4fPUS",ot="_5FRe7",st="ZDqoP",rt="zANgR",at="_3A6oJ",it="K8y4t",lt="_7S3NK",ut="SdyJr",Mt={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",Nt={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,Mt as d,At as e,W as f,Ye as g,Me as h,G as i,Ge as j,Rt as k,Nt as l,Ne 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.