1import{I as M,m as q,x as d}from"./DM0lOU3H.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};u.SENTRY_RELEASE={id:"51b2b198a68ed14f5a166e7baac8c6e8a04672af"};var r=new u.Error().stack;r&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[r]="f0a7fae1-6feb-420f-9e32-80c0e3d3aa27",u._sentryDebugIdIdentifier="sentry-dbid-f0a7fae1-6feb-420f-9e32-80c0e3d3aa27")}catch{}})();var P="https://js.stripe.com/v3",N=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var O=function(){for(var r=document.querySelectorAll('script[src^="'.concat(P,'"]')),t=0;t<r.length;t++){var l=r[t];if(N.test(l.src))return l}return null},b=function(r){var t="",l=document.createElement("script");l.src="".concat(P).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(l),l},V=function(r,t){!r||!r._registerWrapper||r._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})},v=null,h=null,E=null,W=function(r){return function(){r(new Error("Failed to load Stripe.js"))}},$=function(r,t){return function(){window.Stripe?r(window.Stripe):t(new Error("Stripe.js not available"))}},B=function(r){return v!==null?v:(v=new Promise(function(t,l){if(typeof window>"u"||typeof document>"u"){t(null);return}if(window.Stripe){t(window.Stripe);return}try{var n=O();if(!(n&&r)){if(!n)n=b(r);else if(n&&E!==null&&h!==null){var o;n.removeEventListener("load",E),n.removeEventListener("error",h),(o=n.parentNode)===null||o===void 0||o.removeChild(n),n=b(r)}}E=$(t,l),h=W(l),n.addEventListener("load",E),n.addEventListener("error",h)}catch(f){l(f);return}}),v.catch(function(t){return v=null,Promise.reject(t)}))},G=function(r,t,l){if(r===null)return null;var n=r.apply(void 0,t);return V(n,l),n},y,w=!1,_=function(){return y||(y=B(null).catch(function(r){return y=null,Promise.reject(r)}),y)};Promise.resolve().then(function(){return _()}).catch(function(u){w||console.warn(u)});var X=function(){for(var r=arguments.length,t=new Array(r),l=0;l<r;l++)t[l]=arguments[l];w=!0;var n=Date.now();return _().then(function(o){return G(o,t,n)})};const g={theme:"stripe",variables:{colorPrimary:"#0570de",colorBackground:"#ffffff",colorText:"#1a1f36",colorTextSecondary:"#697386",colorDanger:"#df1b41",fontFamily:"system-ui, sans-serif",spacingUnit:"4px",borderRadius:"10px"}};function H(u){return u?{...g,variables:{...g.variables,colorPrimary:u}}:g}function J(){const{apiCaller:u}=M(),r=d(null),t=d(null),l=d(null),n=d(null),o=d(null),f=d(!1),m=d(!1),s=d(null),S=d(!1),C=q(()=>r.value!==null&&t.value!==null);async function z(e,a){try{f.value=!0,s.value=null;const i=a?{stripeAccount:a}:void 0;if(r.value=await X(e,i),!r.value)throw new Error("Failed to load Stripe")}catch(i){s.value=i instanceof Error?i.message:"Failed to initialize Stripe",console.error("Stripe initialization error:",i)}finally{f.value=!1}}async function A(e){if(!r.value)return s.value="Stripe not initialized. Call initializeStripe first.",null;try{f.value=!0,s.value=null;const a=await u.stripeConnect.createPaymentIntent.mutate({teamId:e.teamId,amount:e.amount,currency:e.currency||"usd",customerEmail:e.customerEmail,customerName:e.customerName,productId:e.productId,postId:e.postId,chatId:e.chatId,messageId:e.messageId,linkId:e.linkId,items:e.items,description:e.description,paymentType:e.paymentType,visitorId:e.visitorId,metadata:e.metadata,shippingRateId:e.shippingRateId,shippingCountry:e.shippingCountry,shippingAddress:e.shippingAddress,billingAddress:e.billingAddress,couponCode:e.couponCode,setupFutureUsage:e.setupFutureUsage});return l.value=a.clientSecret,n.value=a.paymentIntentId,o.value=a.stripeAccountId,t.value=r.value.elements({clientSecret:a.clientSecret,appearance:g}),a.clientSecret}catch(a){return s.value=a instanceof Error?a.message:"Failed to create payment",console.error("PaymentIntent creation error:",a),null}finally{f.value=!1}}async function L(e,a){if(!r.value||!t.value||!l.value)return{success:!1,error:"Payment not initialized. Please refresh and try again."};try{m.value=!0,s.value=null;const{error:i,paymentIntent:c}=await r.value.confirmPayment({elements:t.value,confirmParams:{return_url:e,...S.value&&a?{payment_method_data:{billing_details:{email:a}}}:{}}
1,redirect:"if_required"});return i?(s.value=i.message||"Payment failed",{success:!1,error:i.message}):c?.status==="succeeded"?{success:!0}:c?.status==="processing"?{success:!0}:{success:!1,error:`Payment status: ${c?.status}`}}catch(i){const c=i instanceof Error?i.message:"Payment failed";return s.value=c,{success:!1,error:c}}finally{m.value=!1}}async function T(e){if(!r.value){s.value="Stripe not initialized. Call initializeStripe first.";return}t.value=r.value.elements({mode:"payment",amount:e.amount,currency:(e.currency||"usd").toLowerCase(),appearance:H(e.accentColor),...e.setupFutureUsage?{setupFutureUsage:e.setupFutureUsage}:{},...e.paymentMethodTypes&&e.paymentMethodTypes.length>0?{paymentMethodTypes:e.paymentMethodTypes}:{}})}function D(e){t.value&&t.value.update({amount:e})}async function F(e){if(!r.value||!t.value)return{success:!1,error:"Payment not initialized."};m.value=!0,s.value=null;try{const{error:a}=await t.value.submit();if(a)return{success:!1,error:a.message||"Card details are invalid."};const i=await e.createIntent(),c=i.clientSecret;if(!c)return{success:!1,error:"Failed to create payment intent."};l.value=c,i.paymentIntentId&&(n.value=i.paymentIntentId);const{error:I,paymentIntent:p}=await r.value.confirmPayment({elements:t.value,clientSecret:c,confirmParams:{return_url:e.returnUrl,...S.value&&e.billingEmail?{payment_method_data:{billing_details:{email:e.billingEmail}}}:{}},redirect:"if_required"});return I?{success:!1,error:I.message||"Payment failed."}:(p?.id&&(n.value=p.id),p?.status==="succeeded"||p?.status==="processing"?{success:!0,paymentIntentId:p.id}:{success:!1,error:`Payment status: ${p?.status||"unknown"}`})}catch(a){return{success:!1,error:a instanceof Error?a.message:"Payment failed."}}finally{m.value=!1}}function j(e){return r.value?(l.value=e,t.value=r.value.elements({clientSecret:e,appearance:g}),!0):(s.value="Stripe not initialized. Call initializeStripe first.",!1)}function x(e,a){if(!t.value)return s.value="Elements not initialized. Create a payment intent first.",null;S.value=!0;const i=t.value.create("payment",{layout:{type:"tabs",defaultCollapsed:!1},wallets:{applePay:"auto",googlePay:"auto"},paymentMethodOrder:a?.paymentMethodOrder??["card","apple_pay","google_pay","link","us_bank_account","cashapp","klarna","afterpay_clearpay"],defaultValues:a?.customerEmail?{billingDetails:{email:a.customerEmail}}:void 0,fields:{billingDetails:{email:"never"}},business:a?.businessName?{name:a.businessName}:void 0,terms:{card:"auto",applePay:"auto",googlePay:"auto",cashapp:"auto",sepaDebit:"auto",usBankAccount:"auto"}});return i.mount(`#${e}`),i}function R(e){if(!t.value)return;const a=t.value.getElement("payment");a&&a.update({defaultValues:{billingDetails:{email:e}}})}async function U(e,a){if(!r.value)return{success:!1,error:"Stripe is not initialized."};try{const{error:i,paymentIntent:c}=await r.value.confirmPayment({clientSecret:e,confirmParams:{return_url:a},redirect:"if_required"});return i?{success:!1,error:i.message||"Payment failed."}:c?.status==="succeeded"||c?.status==="processing"?{success:!0}:{success:!1,error:`Payment status: ${c?.status||"unknown"}`}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Payment failed."}}}function k(){t.value=null,l.value=null,n.value=null,o.value=null,s.value=null,f.value=!1,m.value=!1,S.value=!1}return{stripe:r,elements:t,clientSecret:l,paymentIntentId:n,stripeAccountId:o,isLoading:f,isProcessing:m,error:s,isInitialized:C,initializeStripe:z,createPaymentIntent:A,createDeferredElements:T,updateDeferredAmount:D,submitDeferredPayment:F,initializeElementsFromClientSecret:j,confirmPayment:L,confirmClientSecret:U,mountPaymentElement:x,updatePaymentElementEmail:R,reset:k}}export{J 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.