import{aC as i,b as s}from"./Theme-utilities.CseKBzVQ.js";import{cE as o,cF as d,gl as u}from"./shared-is-shop-pay-active.DnBz7ku_.js";function T(e){const{__typename:n,...t}=e;return t}function F(e){const n=e?.attributions.find(t=>t.__typename==="DraftOrderAttributions");if(n)return{draftOrder:{userId:n.userIdentifier,locationId:n.locationIdentifier,sourceName:n.sourceName}}}function U(e){if(e?.attributions&&e?.attributions.length!==0){const n=[];return e?.attributions.forEach(t=>{let r;t.recipient.__typename==="Location"?r={location:{id:t.recipient.id}}:t.recipient.__typename==="StaffMember"?r={staffMember:{id:t.recipient.id}}:t.recipient.__typename==="PointOfSaleDevice"&&(r={pointOfSaleDevice:{id:t.recipient.id}}),r&&n.push({recipient:r,targetMerchandiseLines:c(t.targetMerchandiseLines)})}),{attributions:n}}}function c(e){return e.__typename==="FilledMerchandiseLineTargetCollection"?{lines:e.linesV2.reduce((n,t)=>t.__typename!=="MerchandiseLine"&&t.__typename!=="MerchandiseBundleLineComponent"?n:[...n,{stableId:t.stableId}],[])}:e.__typename==="AnyMerchandiseLineTargetCollection"?{any:e.any}:{}}function O({deliveryExpectations:e}){switch(e?.__typename){case void 0:case"PendingTerms":return;case"UnavailableTerms":return{status:"unavailable",deliveryExpectationLines:null};case"FilledDeliveryExpectationTerms":return{status:"filled",deliveryExpectationLines:e.deliveryExpectations}}}function S(e){switch(e.__typename){case"FilledMembershipTerms":return{status:"filled",memberships:e.memberships.map(n=>({apply:n.apply,handle:n.handle}))};case"PendingTerms":return{status:"pending"};case"UnavailableTerms":return{status:"unavailable"}}}function A(e){if(e)switch(e.__typename){case"PendingTerms":return{status:"pending",taskId:e.taskId??void 0,pollDelay:e.pollDelay??void 0};case"FilledShopCashBalance":return{status:"filled",availableBalance:i(e.availableBalance),eligible:e.eligible,nonEligibleReason:e.nonEligibleReason,redeemableBalance:e.redeemableBalance?i(e.redeemableBalance):void 0};case"UnavailableTerms":return{status:"unavailable"};default:return}}function M(e){if(e)switch(e.__typename){case"PendingTerms":return{status:"pending",taskId:e.taskId??void 0,pollDelay:e.pollDelay??void 0};case"FilledShopPromotion":return{status:"filled",promotions:e.promotions.map(n=>({promotionId:n.promotionId,availableBalance:i(n.availableBalance)}))??[]};case"UnavailableTerms":return{status:"unavailable"};default:return}}function V(e){if(e)switch(e.__typename){case"PendingTerms":return{status:"pending",taskId:e.taskId??void 0,pollDelay:e.pollDelay??void 0};case"FilledShopDiscountOffer":return{status:"filled",discountOffer:{adType:e.discountOffer?.adType??null,campaignHandle:e.discountOffer?.campaignHandle??null,offerAmount:e.discountOffer?.offerAmount?i(e.discountOffer.offerAmount):i({amount:"0",currencyCode:"USD",__typename:"Money"}),minimumOrderValue:e.discountOffer?.minimumOrderValue?i(e.discountOffer?.minimumOrderValue):null,minimumOrderValueRemainder:e.discountOffer?.minimumOrderValueRemainder?i(e.discountOffer?.minimumOrderValueRemainder):null,minimumOrderValueSatisfied:e.discountOffer?.minimumOrderValueSatisfied??!1}};case"UnavailableTerms":return{status:"unavailable"};default:return}}const f=()=>window.self!==window.top,m=/\.(shop\.dev|shop\.test|tunnel\.shopifycloud\.tech)$/,p=/-prod\.tunnel\.shopifycloud\.tech$/;function y(){if(typeof window>"u")return!1;const e=window.location.host;return m.test(e)&&!p.test(e)}const b=()=>/debug=yes/.test(window.location.href)||/debug=true/.test(window.location.href)||/debug=1/.test(window.location.href)?!0:/debug=no/.test(window.location.href)||/debug=false/.test(window.location.href)||/debug=0/.test(window.location.href)?!1:!!y(),_=e=>{const n=e??(typeof window>"u"?void 0:window.location.href);if(!n)return;let t;try{t=typeof n=="string"?new URL(n).pathname:n.pathname}catch{return}const r=t.match(/checkout\/([^/]+)\/([a-z]{2,3})/)?.[1];if(!r)return;const a=parseInt(r,10);if(!isNaN(a))return a},v=[62390304886,69293637654,85847245104,75664294112,86752461117];function g(e){return e&&e.isStripeExpress?"shop_pay_external_wallet":"shop_pay_external"}function x(e,n){const t=g(e),r=I();return{flow_version:f()?"iframe":"popup",...r&&{shopId:r},debugMode:b(),os:d(),browser:o().name,entrypoint:t,...n&&{client_source:n}}}function I(){const e=_();if(e)return e&&v.includes(e)?String(e):"other"}function P(e){const{purchasingCompany:n,billingCountries:t,countryDetails:r,...a}=e;if(!n)return!1;if(!r)return!0;const l=s(n.location.billingAddress);return u(l,"billing",{...a,countryDetails:r,fallbackCountry:r,availableCountries:t,isMobilePhoneFieldVisible:!1}).size===0}export{f as a,O as b,T as c,F as d,A as e,M as f,V as g,g as h,P as i,_ as j,x as k,S as m,U as s};
