1import{u as e,S as t,k as n,q as a,T as r,s}from"./2c1ab0fe.Bywc2Brn.js";import{f as o,j as i,e9 as l,aj as u,b as c,ea as p,cb as d,eb as h,ec as m,k as y,x as f,s as g,bL as v}from"./164ad2e3.CZ86Jn5i.js";import{c as _,cA as P,de as b,cz as k,m as E,bu as S,Q as I,df as C,a5 as R,N as B,as as w,aY as A,dg as L,dh as x}from"./9dba8418.ogFVeXB5.js";import{S as N}from"./39921a74.BtGvlOAG.js";import{a as U,u as M,b as j,e as D}from"./e3e348f2.Krefqpnj.js";import{s as T}from"./ccdf3592.DDsFqWmj.js";import{d as F}from"./f67abd2c.LtwWKIr5.js";import{U as O}from"./app.DWJ9FfA1.js";import{g as G,i as W,a as q}from"./2bac2c53.BWpgDRdR.js";import{S as J}from"./71b60e0a.DfPLdYsH.js";import{b as Y,U as $}from"./24773686.BN3rGjti.js";import{v as H,b as K}from"./1f5e7811.BSn0CeW0.js";import{u as Q}from"./22345fd4.gEtcWjYq.js";import{u as z,a as V}from"./ec391382.DNiaG7XB.js";function X({line:n}){const{i18n:a,source:r}=_(),s="paymentCollection"===r.type,{title:l,lineAmount:u}=n,c=0===u.amount?a.translate("shipping.free_rate_label"):a.formatCurrency(u.amount,{currency:u.currencyCode,form:"short"}),p=0===u.amount?"uppercase":void 0;return e(o,{children:[l,s?null:e(t,{children:[" · ",e(i,{type:"strong",letterCase:p,children:c})]})]},l)}const Z="shop-pay-hsa-details",ee=`${Z}-description`;function te(){const{checkout:e,shop:t,shopPay:a}=_(),r=e.negotiator.current.fields.paymentMethods,{paymentLines:s}=e.negotiator.parts;return n(()=>{const n=b(r.value);if(!t.hasFlagEnabled(k)||!function({identity:e}){return"shopPay"===e.current.value}({identity:e.identity})||"ELIGIBLE"!==n&&"ELIGIBLE_LMN_REQUIRED"!==n&&"ELIGIBLE_LMN_NOT_REQUIRED"!==n&&"MIXED_CART"!==n||a.session.isInstallmentsSelected.value)return!1;const o=a.session.selectedPaymentMethod.value;if(o)return"CREDIT_CARD"===o.paymentMethod;const i=s.value[0]?.method,l="wallet"===i?.type&&"SHOP_PAY"===i.name?i.walletContent:void 0,u=null!=l&&"paymentMethod"in l&&"CREDIT_CARD"===l.paymentMethod;return"direct"===i?.type||u})}function ne(){const{checkout:e,shopPay:t}=_(),a=te();return n(()=>a.value&&P(e.proposal.negotiated.fields.paymentMethods.value)&&t.session.hsaRequested.value)}function ae(){const{i18n:r,shopPay:s,checkout:i}=_(),p=n(()=>b(i.proposal.negotiated.fields.paymentMethods.value)),d=n(()=>"ELIGIBLE"!==p.value&&"ELIGIBLE_LMN_REQUIRED"!==p.value&&"ELIGIBLE_LMN_NOT_REQUIRED"!==p.value),h="MIXED_CART"===p.value,m=n(()=>!d.value&&s.session.hsaRequested.value),y=h?r.translate("payment.shop_pay_hsa.mixed_cart_description"):r.translate("payment.shop_pay_hsa.description"),f=a(e=>{d.value||s.session.unstable_setHsaRequested(e)},[d,s.session]);return e(c,{background:"base",colorLayer:"control",border:"base",borderRadius:"base",children:[e("span",{id:ee,hidden:!0,children:y}),e(l,{id:Z,open:h||m.value,summary:e(c,{padding:"base",children:e(N,{label:r.translate("payment.shop_pay_hsa.label"),checked:m.value,disabled:d.value,onChange:f,icon:"none","aria-controls":`${Z}-content`,"aria-describedby":ee})}),content:e(t,{children:[e(u,{}),e(c,{padding:"base",children:e(o,{type:"small",color:"subdued",children:y})})]})})]})}function re(e){return r(()=>e.some(e=>{if("customField"===e.kind)return E(e).required.peek();const t=E(e);return t.behaviors.peek().blockProgress&&t.capabilities.blockProgress}),[e])}function se(){const e=_(),{shop:t}=e,a=U(),r=S(),s=t.hasFlagEnabled(I);return n(()=>C(e.checkout,{showPayWithApplePayButton:a.value,paymentFullyCoveredByRedeemablesAndGiftCards:r.value,isApplePayInShopPayKillswitched:s}))}function oe(){const e=_(),{checkout:t,shopPay:a}=e,r="shopPay"===t.identity.current.value,s=M().value,o=function(){const{checkout:{identity:e,negotiator:t}}=_(),{paymentLines:a}=t.parts,{inMemoryGooglePayParts:{paymentSheetOpenPromise:r}}=R(),s=function(){const{persistedGooglePaySignal:e}=R(),{checkout:t}=_();return n(()=>{const n=e.value?.receiptIdForPaymentFailure,a=t.latestReceipt.value;return Boolean("failed"===a?.status&&"payment"===a?.failure?.type&&n&&a?.id===n)})}();return n(()=>"googlePay"===e.current.value&&!!B(a.value,"GOOGLE_PAY")&&(void 0!==r?.value||s.value))}().value,i=j().value,l=!r&&s&&!i,u=!r&&o,{showApplePay:c,isApplePayInShopPay:d}=se().value,h=D(),m=function(){const e=p(),t=e?.config;return"NATIVE"===t?.payActionType}();return{kind:T(t,{showPayWithPayPal:l,showApplePay:c&&!i,showPayWithGooglePay:u,isEmbeddedCheckout:h,shouldRenderCheckoutProtocolButton:m,isInstallmentsSupported:e.checkout.installments.isSupported.value,isInstallmentsSelected:a.session.isInstallmentsSelected.value}),showPayWithPayPal:l,isApplePayInShopPay:d,shouldDeferWalletToReview:i}}function ie(e){return Promise.resolve().then(()=>e())}function le({existing:e,scope:t,next:n}){return[...e.filter(e=>!function(e,t){return!!e&&(e===t||e.startsWith(`${t}.`))}(e.target,t)),...n]}var ue=(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))(ue||{});function ce(){const{progressContinueWithResult:e}=pe();return{progressContinue:a(async()=>"continue"===await e(),[e])}}function pe(){const{source:e,observability:t,shopPay:{progressInterceptor:o},checkout:{negotiator:i}}=_(),{createUnverifiedUser:l}=function(){const e=function(){const{shopPay:e,checkout:{negotiator:t}}=_(),{email:a}=t.parts;return n(()=>{const t=a.value.trim(),n=e.userVerification.value,r=H(t,ue.BlankEmail),s=K(t,ue.InvalidEmail),o="invalid"===n.status&&n.email===t?ue.InvalidEmail:void 0;return{email:t,emailError:r||s||o}})}(),{source:{checkoutSessionIdentifier:t},url:r,shopPay:o}=_(),i=o.user.phoneNumber,l=o.user.unstable_setPhoneNumber,{transactionParams:u}=o.config,c=o.user.isAuthenticatedUser,p=(()=>{const{shopPay:e}=_(),t=e.signup.phoneNumber,a=e.signup.phoneCountryCode,r=Q(),o=s(r.isPhoneNumberUtilLoaded),i=s(r.validatePhoneNumber),l=e.user.isAuthenticatedUser;return n(()=>({missingRequiredMobilePhoneNumber:Boolean(!l.value&&(!t.value||o.value&&!i.value(t.value,a.value,!0)))}))})(),d=a(async(n=!0)=>{const{email:a,emailError:s}=e.value;if(c.value||i.value)return{status:"skipped"};if(!u)return{status:"failed",errors:[{field:[],code:"missing_content",message:"Transaction params are missing"}]};const h=[];if(s&&h.push({field:["email"],code:s,message:"email is blank or invalid"}),p.value.missingRequiredMobilePhoneNumber&&h.push({field:["phone"],code:ue.InvalidPhone,message:"Mobile phone number is missing or invalid"}),h.length>0)return{status:"failed",errors:h};let m=n?o.signup.hcaptchaToken.value:void 0;if(!m)try{const e=o.signup.captchaRef.value,t=await(e?.execute({async:!0}));t&&(m=t.response)}catch(g){return"challenge-closed"===g?{status:"failed",errors:[]}:{status:"failed",errors:[{field:["hcaptcha"],code:String(g),message:"A captcha error was caught and handled"}]}}let y=null;try{const e=o.signup.phoneNumber.value||"";y=await fetch(r.shopPayCreateUnverifiedUser(),{method:"POST",body:JSON.stringify({email:a,phone:e,hcaptcha_token:m,origin:"c1_unverified_user_signup",checkout_token:t,transaction_params:u}),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 f=await y.json();return 200!==y.status?Array.isArray(f?.errors)&&1===f?.errors.length&&"further_authorization_required"===f?.errors[0].code&&n?(o.signup.unstable_setHcaptchaToken(void 0),d(!1)):{status:"failed",errors:f?.errors||[{field:[],code:`response_with_http_error_${y.status}`,message:"Failed to create user"}]}:(l(f.parsed_phone),o.user.unstable_setEmail(a),o.user.unstable_updateFlow("authenticated_user"),{status:"success"})},[c,i,u,e,p,l,o,r,t]);return{createUnverifiedUser:d}}(),{handleCreateUnverifiedUserErrors:u}=function(){const{i18n:e,shopPay:t,checkout:{validation:{contactErrors:{emailInputError:n}}}}=_(),s=d(),{openModal:o}=Y(),i=r(()=>({[ue.BlankEmail]:e.translate("field_errors.email_blank"),[ue.InvalidEmail]:e.translate("field_errors.email_invalid"),[ue.ShopAccountsInvalidEmail]:e.translate("field_errors.email_invalid")}),[e]),l=r(()=>({[ue.BlankPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[ue.InvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[ue.ShopAccountsInvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[ue.ShopAccountsPhoneLimitReached]:e.translate("mobile_phone_number.phone_limit_reached")}),[e]);return{handleCreateUnverifiedUserErrors:a(e=>{if(0===e.length)return;const a=e.map(e=>e.code),r=i[a.find(e=>e in i)],u=l[a.find(e=>e in l)];return r||u?(n.value=r,t.signup.unstable_setPhoneError(u)):o({type:$.Generic}),Promise.resolve().then(()=>s())},[i,n,s,o,l,t.signup])}}(),c=d(),p=a(async()=>{try{const e=await l(),n=await o.runInterceptors();i.setValidationErrors(le({existing:i.validationErrors.value,scope:h,next:G(n)}));const a=W(n);if(!a){const e=q(n);t.log("shop_pay_progress_interceptor_error_reported","Shop Pay progress interceptor reported an error in useShopPayProgressContinue",{interceptorErrors:e})}if("failed"===e?.status)return u(e.errors),"blocked";if(!a)return ie(c),"blocked"}catch(a){const r=a;return F(r.message)||function(e){return O.includes(e.name)}(r)?t.log("shop_pay_progress_continue_unactionable_error","Shop Pay progress continue swallowed an unactionable error in useShopPayProgressContinue",{errorName:r.name,errorMessage:(n=r.message,n?.slice(0,de)),sourceType:e.type}):t.error(r,{errorClass:J.ShopPayProgressIntercept,severity:"error",metadata:{source:{type:e.type},checkout:{token:e.checkoutSessionIdentifier??"checkout_identifier_undefined"}}}),"errored"}var n;return"continue"},[l,c,u,o,i,t,e]);return r(()=>({progressContinueWithResult:p}),[p])}const de=200;function he(){const{source:e,checkout:t,shop:n,shopPay:r,observability:s,userEvents:o}=_(),i=r.installments,l=r.user.installments;return a(()=>{l.isRejected.value&&!l.isRetryable.value||(i.unstable_setModalOpen(!0,"checkout_button"),s.log("installments_modal_opened","[Installments] Modal opened"),o.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...w(e,t,n),action:"continue_with_installments"}}))},[i,l,s,o,e,t,n])}function me(e){const{kind:t}=oe(),n=function(){const{showApplePay:e}=se().value,t=R().applePaySessionHandler.value,n=t?.onClickHandler??null,r=V({breadcrumbPrefix:x,isApplePay:!0}),s=a(()=>{n?.({validateButtonPress:r})},[n,r]);return e&&n?s:null}(),s=function(){const{checkout:{identity:e},observability:t,shopPay:n}=_(),s=m(),{nextPage:o}=f(),{progress:i}=g(),{progressContinue:l}=ce(),u=function(){const{observability:e,source:t,router:n}=_(),{currentDetour:a,currentPage:s}=y().value,{nextPage:o,previousPage:i}=f();return r(()=>({ensureShopPayURL:()=>{s||n.navigate("/shoppay",{replace:!0})},logError:(n,{result:r}={})=>{e.error(new A(n,{groupingHash:"ShopPayError::InvalidPageLogger"}),{severity:"error",metadata:{source:{type:t.type},checkout:{token:t.checkoutSessionIdentifier||t.sourceId},event:{currentDetour:JSON.stringify(a),currentPage:JSON.stringify(s),nextPage:JSON.stringify(o),previousPage:JSON.stringify(i),result:JSON.stringify(r)}}})}}),[a,s,e,o,i,n,t.checkoutSessionIdentifier,t.sourceId,t.type])}(),c=v(),p=z(),d=V({breadcrumbPrefix:L}),h=a(async()=>
1{if(d()){p();try{n.session.unstable_setButtonProgressing(!0),await l()?(t.leaveErrorBreadcrumb(`${L} - progress`),await i("shop-pay-progress-button-press",e=>{t.leaveErrorBreadcrumb(`${L} - progression`,{status:e.status,nextPageId:o.id}),"thankYou"!==o.id&&u.logError("Shop Pay button triggered progression when next page is not `thankYou`",{result:e})},{onProgressBlocked:()=>{t.leaveErrorBreadcrumb(`${L} - progress blocked`,{nextPageId:o.id}),u.ensureShopPayURL()}}),c.notify({checkout_in_progress:!0})):(t.leaveErrorBreadcrumb(`${L} - progress continue failed`,{nextPageId:o.id}),"thankYou"!==o.id&&(u.logError("Shop Pay button is pressed when next page is not `thankYou`"),u.ensureShopPayURL()))}finally{n.session.unstable_setButtonProgressing(!1)}}},[d,p,n.session,l,t,i,o,u,c]);return"shopPay"!==e.current.value||s?null:h}(),o=function(){const{checkout:{identity:e},shopPay:t,observability:n}=_(),r=m(),{progressContinue:s}=ce(),o=he(),i=a(async()=>{t.session.unstable_setButtonProgressing(!0),n.log("installments_cta_clicked","[Installments] Continue to purchase button clicked");try{await s()&&o()}finally{t.session.unstable_setButtonProgressing(!1)}},[t.session,n,s,o]);return r||"shopPay"!==e.current.value||!t.session.isInstallmentsSelected.value?null:i}();return"applePay"===t&&n?n:"installments"===t&&o?o:"default"!==t&&"checkoutProtocol"!==t||!s?e:s}const ye={Button:"liLqL",Sparkles:"b71fw"},fe={Button:"OJbFq","Button-prefersDarkMode":"LhoYl",WalletLogoContainer:"wNUaA"},ge={StickyFooter:"XR3sZ",StickyFooterExperiment:"_4fPUS",StickyFooterAtBottom:"_5FRe7",StickyFooterBuffer:"ZDqoP",SDKStickyFooterBuffer:"zANgR",EmbedStickyFooterBuffer:"_3A6oJ",ButtonContainer:"K8y4t",SDKButtonContainer:"_7S3NK",EmbedButtonContainer:"SdyJr"},ve={Wrapper:"GsMGr",Container:"eDhAI",Section:"P0xJW","Container-fixed":"iRlFp","Container-fixed-entering":"_24aJk","Container-fixed-exiting":"ktbnR","Container-fixed-enter":"PCKgT","Container-fixed-exited":"DvZWz",Shadow:"COpTB","Shadow-enter":"_0hDB9","Shadow-exiting":"P1NPi","Shadow-exited":"lQN1j"};export{X as D,ae as H,te as a,fe as b,ge as c,ne as d,ce as e,he as f,ie as g,oe as h,se as i,pe as j,re as k,ve as l,le as r,ye as s,me 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.