import{a as O,e as Y,f as I,l as G}from"./dist-vendor.a3kfnPsb.js";import{b as l,y as N,z as K,B as W,a as T,k as V,j as D,c as q,h as E,D as z,E as Q,G as J,H as j,J as X,V as Z,K as $}from"./shop-pay-FullScreenBackground.Bxb6RI8a.js";import{aw as u,ax as ee,ay as se,az as te,aA as ae,aB as ne,aC as re,aD as oe,aE as ie}from"./shop-pay-ButtonWithRegisterWebPixel.CUNg0UCj.js";const ce={id:"0c62c3aaedf84bd307e1134828e5fcc88a47d83c453c97544a6cc8711e6444af",type:"mutation",name:"SubscribeForShippingUpdates",source:""};class _ extends Error{constructor(){super(...arguments),this.name="SubscribeForShippingUpdateError"}}function he(){const e=Y(),{client:n,observability:r}=T(),t=n.unstable_getSerialization("sessionToken"),[a,s]=I(),[c,o]=I("idle"),p=u()?.orderIdentity?.id;async function S(d){if(o("loading"),s(void 0),!t||!p){o("failed"),s("SUBSCRIPTION_FAILED"),r.error(new _("Missing sessionToken or orderId"));return}const{data:i}=await e.mutate(ce,{variables:{sessionToken:t,orderId:p,email:d}});if(i){const{__typename:f}=i?.subscribeForShippingUpdates;switch(f){case"SubscribeForShippingUpdatesSuccess":o("subscribed");return;case"SubscribeForShippingUpdatesFailure":o("failed"),s(i?.subscribeForShippingUpdates.code);return;default:o("idle"),r.error(new _("Undefined subscribeForShippingUpdates type"))}}}return{submitSubscribeForShippingUpdate:S,status:c,error:a}}function me(){const e=l(),n=e.buyerIdentity,r=N(),t=K(),a=e.contactInfo,c=u()?.isRedacted??!1;return O(()=>!c&&t.value&&!a?.value?.email&&!n?.value?.purchasingCompany&&!r.value)}function ye(){const e=m(),r=u()?.isRedacted??!1,t=!!e?.shopAppEligible,a=!!e?.shopAppQrCodeKillswitch;return!r&&t&&!a}function Se(){const e=l().paymentLines,n=m();return O(()=>(e.value?e.value.lines.some(({method:t})=>t.type==="wallet"&&t.name==="SHOPIFY_INSTALLMENTS"):!1)&&!!n?.installmentsHighlightEligible)}function m(){const e=u();if(e)return{...e.shopAppLinksAndResources}}function Pe(){const e=u();if(e?.orderIdentity?.id)return Number(W(e.orderIdentity.id))}function be(){const{cart:e,embed:n,mobileCheckoutSdk:r,shopPay:t}=T(),a=l(),s=l().buyerIdentity.value?.purchasingCompany,c=a.buyerIdentity.value?.customerProfile,o=ee().value,y=V(),p=m(),d=D().paymentLines.value,{value:i}=a.paymentLines,{value:f}=a.paymentMethods,{currentDetour:P}=q().value,F=se(),b=!E(z),h=!E(Q),{shopPayAvailableForSellerOfRecord:R}=J(),{isTreatment:L}=te(),{isTreatment:U}=ae(),{isTreatment:M}=ne(),g=L||U||M,k=re(),w=!!oe(a.paymentMethods.value).length,{value:B}=a.managedByMarketsPro,A=ie({managedByMarketsPro:B}),H=e.proposal.negotiated.fields.mustSelectProvidedAddress.value,x=G().searchParams.get(j);return k||F?.shopPayOptInEnabled===!1||s||!R||c?.__typename==="CustomerProfile"&&o&&(!y||!w)||t.userIdentified||t.isActive||x||H||n||r.enabled||h&&p?.shopPayOrder||!f?.some(C=>C.type==="wallet"&&C.name==="SHOP_PAY")&&P?.type!=="thankYou"?!1:P?.type==="thankYou"?i?v({paymentLines:i.lines,isIdealEnabledForShopPay:A,isUsdcEnabled:b,isApplePayInShopPayAvailable:h,isCreateMoreAccountsExperimentTreatment:g}):!1:v({paymentLines:d,isIdealEnabledForShopPay:A,isUsdcEnabled:b,isApplePayInShopPayAvailable:h,isCreateMoreAccountsExperimentTreatment:g})}const v=({paymentLines:e,isIdealEnabledForShopPay:n,isUsdcEnabled:r,isApplePayInShopPayAvailable:t,isCreateMoreAccountsExperimentTreatment:a=!1})=>{if(a)return!X(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")||r&&s.paymentBrands?.includes("usdc")||n&&s.paymentBrands?.includes("ideal")):!!(s.type==="direct"||s.type===Z.CreditCard||n&&$(e)||t&&s.type==="wallet"&&s.name==="APPLE_PAY")};export{he as a,Pe as b,m as c,ye as d,Se as e,me as f,be as u};
