import{a as R,e as V,f as T,K as q,u as n,k as b}from"./dist-vendor.DBR6g02j.js";import{b as m,km as D,kn as Q,L as j,a as l,k as J,j as Z,c as X,h as E,dY as $,cW as ee,ec as se,j2 as te,aD as re,V as ne,cz as ae}from"./shop-pay-FullScreenBackground.CUfzz8_n.js";import{ec as d,cS as oe,hw as ie,gm as ce,gf as le,gg as pe,iq as de,lk as ue,fZ as me,d_ as F,T as k,L as w,I as M}from"./shop-pay-ButtonWithRegisterWebPixel.Bb6ujYnt.js";const he={id:"0c62c3aaedf84bd307e1134828e5fcc88a47d83c453c97544a6cc8711e6444af",type:"mutation",name:"SubscribeForShippingUpdates",source:""};class O extends Error{constructor(){super(...arguments),this.name="SubscribeForShippingUpdateError"}}function Ce(){const e=V(),{client:a,observability:t}=l(),r=a.unstable_getSerialization("sessionToken"),[o,s]=T(),[p,i]=T("idle"),u=d()?.orderIdentity?.id;async function P(h){if(i("loading"),s(void 0),!r||!u){i("failed"),s("SUBSCRIPTION_FAILED"),t.error(new O("Missing sessionToken or orderId"));return}const{data:c}=await e.mutate(he,{variables:{sessionToken:r,orderId:u,email:h}});if(c){const{__typename:f}=c?.subscribeForShippingUpdates;switch(f){case"SubscribeForShippingUpdatesSuccess":i("subscribed");return;case"SubscribeForShippingUpdatesFailure":i("failed"),s(c?.subscribeForShippingUpdates.code);return;default:i("idle"),t.error(new O("Undefined subscribeForShippingUpdates type"))}}}return{submitSubscribeForShippingUpdate:P,status:p,error:o}}function Ie(){const e=m(),a=e.buyerIdentity,t=D(),r=Q(),o=e.contactInfo,p=d()?.isRedacted??!1;return R(()=>!p&&r.value&&!o?.value?.email&&!a?.value?.purchasingCompany&&!t.value)}function ve(){const e=_(),t=d()?.isRedacted??!1,r=!!e?.shopAppEligible,o=!!e?.shopAppQrCodeKillswitch;return!t&&r&&!o}function Te(){const e=m().paymentLines,a=_();return R(()=>(e.value?e.value.lines.some(({method:r})=>r.type==="wallet"&&r.name==="SHOPIFY_INSTALLMENTS"):!1)&&!!a?.installmentsHighlightEligible)}function _(){const e=d();if(e)return{...e.shopAppLinksAndResources}}function Ee(){const e=d();if(e?.orderIdentity?.id)return Number(j(e.orderIdentity.id))}function Oe(){const{cart:e,embed:a,mobileCheckoutSdk:t,shopPay:r}=l(),o=m(),s=m().buyerIdentity.value?.purchasingCompany,p=o.buyerIdentity.value?.customerProfile,i=oe().value,S=J(),u=_(),h=Z().paymentLines.value,{value:c}=o.paymentLines,{value:f}=o.paymentMethods,{currentDetour:g}=X().value,U=ie(),A=!E($),y=!E(ee),{shopPayAvailableForSellerOfRecord:x}=se(),{isTreatment:H}=ce(),{isTreatment:B}=le(),{isTreatment:Y}=pe(),C=H||B||Y,G=de(),N=!!ue(o.paymentMethods.value).length,{value:K}=o.managedByMarketsPro,I=me({managedByMarketsPro:K}),W=e.proposal.negotiated.fields.mustSelectProvidedAddress.value,z=q().searchParams.get(te);return G||U?.shopPayOptInEnabled===!1||s||!x||p?.__typename==="CustomerProfile"&&i&&(!S||!N)||r.userIdentified||r.isActive||z||W||a||t.enabled||y&&u?.shopPayOrder||!f?.some(v=>v.type==="wallet"&&v.name==="SHOP_PAY")&&g?.type!=="thankYou"?!1:g?.type==="thankYou"?c?L({paymentLines:c.lines,isIdealEnabledForShopPay:I,isUsdcEnabled:A,isApplePayInShopPayAvailable:y,isCreateMoreAccountsExperimentTreatment:C}):!1:L({paymentLines:h,isIdealEnabledForShopPay:I,isUsdcEnabled:A,isApplePayInShopPayAvailable:y,isCreateMoreAccountsExperimentTreatment:C})}const L=({paymentLines:e,isIdealEnabledForShopPay:a,isUsdcEnabled:t,isApplePayInShopPayAvailable:r,isCreateMoreAccountsExperimentTreatment:o=!1})=>{if(o)return!re(e,"SHOPIFY_INSTALLMENTS");if(!e?.length||!e[0].method)return!1;const{method:s}=e[0];return s.type==="customOnsite"?!!(s.paymentBrands?.includes("bogus_app_coin")||t&&s.paymentBrands?.includes("usdc")||a&&s.paymentBrands?.includes("ideal")):!!(s.type==="direct"||s.type===ne.CreditCard||a&&ae(e)||r&&s.type==="wallet"&&s.name==="APPLE_PAY")};function fe(){const{i18n:e}=l();return n(k,{size:"small",color:"subdued",children:n(F,{children:e.translate("shop_pay_remember_me.terms_and_privacy_html",{privacy_href:n(be,{}),terms_href:n(ye,{})})})})}function ye(){const{i18n:e}=l();return n(b,{children:n(w,{target:"_blank",href:"https://shop.app/terms-of-service",tone:"monochrome",accessibilityLabel:e.translate("shop_pay_remember_me.new_window_disclaimer"),children:[e.translate("shop_pay_remember_me.terms_of_service"),n(M,{type:"external",size:"small",display:"inline"})]})})}function be(){const{i18n:e}=l();return n(b,{children:n(w,{target:"_blank",href:"https://www.shopify.com/legal/privacy/app-users",tone:"monochrome",accessibilityLabel:e.translate("shop_pay_remember_me.new_window_disclaimer"),children:[e.translate("shop_pay_remember_me.privacy_policy"),n(M,{type:"external",size:"small",display:"inline"})]})})}function Le({field:e="phone",link:a}){const{i18n:t}=l();return n(b,{children:[n(k,{color:"subdued",children:n(F,{children:[e==="phone"?t.translate("shop_pay_remember_me.description_html"):t.translate("shop_pay_remember_me.email_description_html")," ",a]})}),n(fe,{})]})}export{Le as R,Ce as a,Ee as b,_ as c,ve as d,Te as e,Ie as f,Oe as u};
