1import{u as e,S as t,t as n,s as a,T as s,z as r}from"./2c1ab0fe.GMbxnz74.js";import{P as o,o as i,e2 as l,a5 as u,B as c,e3 as d,b_ as p,e4 as h,e5 as m,e6 as y,e7 as f,e8 as g,e as v,R as P,i as _,bv as b}from"./164ad2e3.BmqNdq2P.js";import{S as k,cN as S,T as I,W as E,dy as C,cM as w,dz as A,bO as B,X as R,dA as x,a9 as N,_ as M,aw as L,dB as j,ax as D,bf as U,dC as F,dD as T}from"./4c290a1e.2OXqqQwu.js";import{S as O}from"./39921a74.CFM70_Q1.js";import{u as W,c as q,d as G,e as J}from"./e3e348f2.DoE2sBpq.js";import{s as $}from"./ccdf3592.CPmKJLin.js";import{a as H}from"./app.iZwEIta_.js";import{a as Y,i as K,b as z}from"./e477f96c.C25EBhFr.js";import{v as X,a as V}from"./0c0ad074.BYdsTJAo.js";import{u as Z}from"./53bbdad9.Z4N3tZKQ.js";import{u as Q,a as ee}from"./ec391382.D2dArcp8.js";function te({line:n}){const{i18n:a,source:s}=k(),r="paymentCollection"===s.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"}),d=0===u.amount?"uppercase":void 0;return e(o,{children:[l,r?null:e(t,{children:[" · ",e(i,{type:"strong",letterCase:d,children:c})]})]},l)}const ne="shop-pay-hsa-details",ae=`${ne}-description`;function se(){const{checkout:e,shop:t,shopPay:a}=k(),s=I().paymentMethods,{paymentLines:r}=E();return n(()=>{const n=C(s.value);if(!t.hasFlagEnabled(w)||!function({identity:e}){return"shopPay"===e.current.value}({identity:e.identity})||"ELIGIBLE"!==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=r.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 re(){const{checkout:e,shopPay:t}=k(),a=se();return n(()=>a.value&&S(e.proposal.negotiated.fields.paymentMethods.value)&&t.session.hsaRequested.value)}function oe(){const{i18n:s,shopPay:r,checkout:i}=k(),d=n(()=>C(i.proposal.negotiated.fields.paymentMethods.value)),p=n(()=>"ELIGIBLE"!==d.value),h="MIXED_CART"===d.value,m=n(()=>!p.value&&r.session.hsaRequested.value),y=h?s.translate("payment.shop_pay_hsa.mixed_cart_description"):s.translate("payment.shop_pay_hsa.description"),f=a(e=>{p.value||r.session.unstable_setHsaRequested(e)},[p,r.session]);return e(c,{background:"base",colorLayer:"control",border:"base",borderRadius:"base",children:[e("span",{id:ae,hidden:!0,children:y}),e(l,{id:ne,open:h||m.value,summary:e(c,{padding:"base",children:e(O,{label:s.translate("payment.shop_pay_hsa.label"),checked:m.value,disabled:p.value,onChange:f,icon:"none","aria-controls":`${ne}-content`,"aria-describedby":ae})}),content:e(t,{children:[e(u,{}),e(c,{padding:"base",children:e(o,{type:"small",color:"subdued",children:y})})]})})]})}function ie(e){return s(()=>e.some(e=>{if("customField"===e.kind)return A(e).required.peek();const t=A(e);return t.behaviors.peek().blockProgress&&t.capabilities.blockProgress}),[e])}function le(){const e=k(),{shop:t}=e,a=W(),s=B(),r=t.hasFlagEnabled(R);return n(()=>x(e.checkout,{showPayWithApplePayButton:a.value,paymentFullyCoveredByRedeemablesAndGiftCards:s.value,isApplePayInShopPayKillswitched:r}))}function ue(){const e=k(),{checkout:t,shopPay:a}=e,s="shopPay"===t.identity.current.value,r=q().value,o=function(){const{checkout:{identity:e}}=k(),{paymentLines:t}=E(),{inMemoryGooglePayParts:{paymentSheetOpenPromise:a}}=N(),s=function(){const{persistedGooglePaySignal:e}=N(),{checkout:t}=k();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&&!!M(t.value,"GOOGLE_PAY")&&(void 0!==a?.value||s.value))}().value,i=G().value,l=!s&&r&&!i,u=!s&&o,{showApplePay:c,isApplePayInShopPay:p}=le().value,h=J(),m=function(){const e=d(),t=e?.config;return"NATIVE"===t?.payActionType}();return{kind:$(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:p,shouldDeferWalletToReview:i}}function ce(e){return Promise.resolve().then(()=>e())}function de({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 pe=(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))(pe||{});function he(){const{progressContinueWithResult:e}=me();return{progressContinue:a(async()=>"continue"===await e(),[e])}}function me(){const{source:e,observability:t,shopPay:{progressInterceptor:o}}=k(),i=L(),{createUnverifiedUser:l}=function(){const e=function(){const{email:e}=E(),{shopPay:t}=k();return n(()=>{const n=e.value.trim(),a=t.userVerification.value,s=X(n,pe.BlankEmail),r=V(n,pe.InvalidEmail),o="invalid"===a.status&&a.email===n?pe.InvalidEmail:void 0;return{email:n,emailError:s||r||o}})}(),{source:{checkoutSessionIdentifier:t},url:s,shopPay:o}=k(),i=o.user.phoneNumber,l=o.user.unstable_setPhoneNumber,{transactionParams:u}=o.config,c=o.user.isAuthenticatedUser,d=(()=>{const{shopPay:e}=k(),t=e.signup.phoneNumber,a=e.signup.phoneCountryCode,s=Z(),o=r(s.isPhoneNumberUtilLoaded),i=r(s.validatePhoneNumber),l=e.user.isAuthenticatedUser;return n(()=>({missingRequiredMobilePhoneNumber:Boolean(!l.value&&(!t.value||o.value&&!i.value(t.value,a.value,!0)))}))})(),p=a(async(n=!0)=>{const{email:a,emailError:r}=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(r&&h.push({field:["email"],code:r,message:"email is blank or invalid"}),d.value.missingRequiredMobilePhoneNumber&&h.push({field:["phone"],code:pe.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(s.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),p(!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,d,l,o,s,t]);return{createUnverifiedUser:p}}(),{handleCreateUnverifiedUserErrors:u}=function(){const{i18n:e,shopPay:t,checkout:{validation:{contactErrors:{emailInputError:n}}}}=k(),a=p(),{openModal:s}=h(),r={[pe.BlankEmail]:e.translate("field_errors.email_blank"),[pe.InvalidEmail]:e.translate("field_errors.email_invalid"),[pe.ShopAccountsInvalidEmail]:e.translate("field_errors.email_invalid")},o={[pe.BlankPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[pe.InvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[pe.ShopAccountsInvalidPhone]:e.translate("mobile_phone_number.mobile_phone_invalid"),[pe.ShopAccountsPhoneLimitReached]:e.translate("mobile_phone_number.phone_limit_reached")};return{handleCreateUnverifiedUserErrors:e=>{if(0===e.length)return;const i=e.map(e=>e.code),l=r[i.find(e=>e in r)],u=o[i.find(e=>e in o)];return l||u?(n.value=l,t.signup.unstable_setPhoneError(u)):s({type:m.Generic}),Promise.resolve().then(()=>a())}}}(),c=p(),d=a(async()=>{try{const e=await l(),n=await o.runInterceptors();i.setValidationErrors(de({existing:i.validationErrors.value,scope:y,next:Y(n)}));const a=K(n);if(!a){const e=z(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 ce(c),"blocked"}catch(a){const s=a;return j(s.message)||function(e){return H.includes(e.name)}(s)?t.log("shop_pay_progress_continue_unactionable_error","Shop Pay progress continue swallowed an unactionable error in useShopPayProgressContinue",{errorName:s.name,errorMessage:(n=s.message,n?.slice(0,ye)),sourceType:e.type}):t.error(s,{errorClass:f.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 s(()=>({progressContinueWithResult:d}),[d])}const ye=200;function fe(){const{source:e,checkout:t,shop:n,shopPay:s,observability:r,userEvents:o}=k(),i=s.installments,l=s.user.installments;return a(()=>{l.isRejected.value&&!l.isRetryable.value||(i.unstable_setModalOpen(!0,"checkout_button"),r.log("installments_modal_opened","[Installments] Modal opened"),o.monorailEvent({schemaId:"shopify_pay_payment_page_ui_interaction/1.2",payload:{...D(e,t,n),action:"continue_with_installments"}}))},[i,l,r,o,e,t,n])}function ge(e){const{kind:t}=ue(),n=function(){const{showApplePay:e}=le().value,t=N().applePaySessionHandler.value,n=t?.onClickHandler??null,s=ee({breadcrumbPrefix:T,isApplePay:!0}),r=a(()=>{n?.({validateButtonPress:s})},[n,s]);return e&&n?r:null}(),r=function(){const{checkout:{identity:e},observability:t,shopPay:n}=k(),r=g(),{nextPage:o}=P(),{progress:i}=_(),{progressContinue:l}=he(),u=function(){const{observability:e,source:t,router:n}=k(),{currentDetour:a,currentPage:r}=v().value,{nextPage:o,previousPage:i}=P();return s(()=>({ensureShopPayURL:()=>{r||n.navigate("/shoppay",{replace:!0})},logError:(n,{result:s}={})=>
1{e.error(new U(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(r),nextPage:JSON.stringify(o),previousPage:JSON.stringify(i),result:JSON.stringify(s)}}})}}),[a,r,e,o,i,n,t.checkoutSessionIdentifier,t.sourceId,t.type])}(),c=b(),d=Q(),p=ee({breadcrumbPrefix:F}),h=a(async()=>{if(p()){d();try{n.session.unstable_setButtonProgressing(!0),await l()?(t.leaveErrorBreadcrumb(`${F} - progress`),await i("shop-pay-progress-button-press",e=>{t.leaveErrorBreadcrumb(`${F} - 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(`${F} - progress blocked`,{nextPageId:o.id}),u.ensureShopPayURL()}}),c.notify({checkout_in_progress:!0})):(t.leaveErrorBreadcrumb(`${F} - 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)}}},[p,d,n.session,l,t,i,o,u,c]);return"shopPay"!==e.current.value||r?null:h}(),o=function(){const{checkout:{identity:e},shopPay:t,observability:n}=k(),s=g(),{progressContinue:r}=he(),o=fe(),i=a(async()=>{t.session.unstable_setButtonProgressing(!0),n.log("installments_cta_clicked","[Installments] Continue to purchase button clicked");try{await r()&&o()}finally{t.session.unstable_setButtonProgressing(!1)}},[t.session,n,r,o]);return s||"shopPay"!==e.current.value||!t.session.isInstallmentsSelected.value?null:i}();return"applePay"===t&&n?n:"installments"===t&&o?o:"default"!==t&&"checkoutProtocol"!==t||!r?e:r}const ve={Button:"liLqL",Sparkles:"b71fw"},Pe={Button:"OJbFq","Button-prefersDarkMode":"LhoYl",WalletLogoContainer:"wNUaA"},_e={StickyFooter:"XR3sZ",StickyFooterExperiment:"_4fPUS",StickyFooterAtBottom:"_5FRe7",StickyFooterBuffer:"ZDqoP",SDKStickyFooterBuffer:"zANgR",EmbedStickyFooterBuffer:"_3A6oJ",ButtonContainer:"K8y4t",SDKButtonContainer:"_7S3NK",EmbedButtonContainer:"SdyJr"},be={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{te as D,oe as H,se as a,Pe as b,_e as c,re as d,he as e,fe as f,ce as g,ue as h,le as i,me as j,ie as k,be as l,de as r,ve as s,ge 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.