1import{by as k,J as x,m as K,aL as _,x as i,aR as z}from"./CY6l2md7.js";import{u as L}from"./ChmxlblL.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"b07c79a46f452f94e9fec9f643715e4e019743d6"};var l=new a.Error().stack;l&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[l]="57145258-fc4c-4bd4-b72e-b8b239b8508e",a._sentryDebugIdIdentifier="sentry-dbid-57145258-fc4c-4bd4-b72e-b8b239b8508e")}catch{}})();function F(a){return a.isTestMode&&a.testKey||a.liveKey}function U(a){return{dueMinor:Math.max(a.subtotalMinor-Math.max(a.discountMinor,0),0)+Math.max(a.shippingMinor,0)}}function q(a){const{dueMinor:l}=U(a);return l<=0||a.discountMinor>0&&l<k(a.currency)}function B(a){const{apiCaller:l}=x(),p=z(),n=L(),d=i(!1),m=i(!1),r=i(null),o=i(!1),b=i(!1),v=i(null),h=i(!1),I=i("USD"),y=i(["card"]),E=`${a?.elementIdPrefix??"checkout-stripe"}-${Math.random().toString(36).slice(2,8)}`,u=i(!1),S={testModeNoKey:"Test mode is on but no test payment key is configured.",configError:"Payment configuration error.",loadFailed:"Failed to load payment form.",loadFailedRefresh:"Failed to load payment form. Please refresh."};function P(e){return{...S,...e}}function T(){return{liveKey:p.public.stripeConnectPublishableKey||"",testKey:p.public.stripeConnectPublishableKeyTest||""}}async function w(e){const t=await l.stripeConnect.getPublicStripeStatus.query({teamId:e});return b.value=t.cryptoEnabled,v.value=t.cryptoRecipientAddress,h.value=t.paypalEnabled,t.defaultCurrency&&(I.value=t.defaultCurrency),y.value=t.subscriptionPaymentMethodTypes??["card"],o.value=t.testMode===!0,d.value=!!(t.stripeEnabled&&t.stripeAccountId),t}async function M(e){for(let t=0;t<25;t++){if(await _(),document.getElementById(E)){n.mountPaymentElement(E,{customerEmail:e.customerEmail,businessName:e.businessName}),m.value=!0;return}await new Promise(c=>setTimeout(c,60))}r.value=e.loadFailedRefresh??S.loadFailedRefresh}async function R(e){if(u.value||e.amount<=0)return;u.value=!0,r.value=null;const t=P(e.messages);try{const s=await w(e.teamId);if(!d.value||!s.stripeAccountId)return;const{liveKey:c,testKey:f}=T();if(o.value&&!f){r.value=t.testModeNoKey;return}const C=F({isTestMode:o.value,liveKey:c,testKey:f});if(!C){r.value=t.configError;return}await n.initializeStripe(C,s.stripeAccountId),await n.createDeferredElements({amount:e.amount,currency:e.currency.toLowerCase(),accentColor:e.accentColor,setupFutureUsage:"off_session",...e.forMembership?{paymentMethodTypes:y.value.length>0?y.value:["card"]}:{}}),await M({customerEmail:e.customerEmail,businessName:e.businessName,loadFailedRefresh:t.loadFailedRefresh})}catch(s){console.error("Stripe setup failed:",s),r.value=s instanceof Error?s.message:t.loadFailed,u.value=!1}}async function g(e){u.value=!0,r.value=null;const t=P(e.messages);try{o.value=e.publishableKeyIsTest;const{liveKey:s,testKey:c}=T();if(e.publishableKeyIsTest&&!c){r.value=t.testModeNoKey;return}const f=F({isTestMode:e.publishableKeyIsTest,liveKey:s,testKey:c});if(!f){r.value=t.configError;return}if(await n.initializeStripe(f,e.stripeAccountId),!n.initializeElementsFromClientSecret(e.clientSecret)){r.value=t.loadFailed;return}d.value=!0,await M({customerEmail:e.customerEmail,businessName:e.businessName,loadFailedRefresh:t.loadFailedRefresh})}catch(s){console.error("Stripe client-secret setup failed:",s),r.value=s instanceof Error?s.message:t.loadFailed,u.value=!1}}function A(){u.value=!1}function D(){u.value=!1,d.value=!1,m.value=!1,r.value=null,o.value=!1,b.value=!1,v.value=null,h.value=!1,n.reset()}function N(e){m.value&&e>0&&n.updateDeferredAmount(Math.max(e,100))}return{stripeCheckout:n,stripeElementId:E,stripeAvailable:d,stripeReady:m,stripeMountError:r,isTestMode:o,cryptoEnabled:b,cryptoRecipientAddress:v,paypalEnabled:h,storeCurrency:I,subscriptionPaymentMethodTypes:y,hasAttemptedSetup:K(()=>u.value),hasElements:K(()=>!!n.elements.value),paymentIntentId:K(()=>n.paymentIntentId.value),loadStatus:w,setupDeferred:R,setupFromClientSecret:g,mountWhenReady:M,allowRetry:A,reset:D,updateDeferredAmount:N,updatePaymentElementEmail:n.updatePaymentElementEmail,submitDeferredPayment:n.submitDeferredPayment,confirmPayment:n.confirmPayment,confirmClientSecret:n.confirmClientSecret}}export{q as i,B 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.