1import{a as j,p as e}from"./chunk-EPOLDU6W-iGDn8P0T.js";import{at as M,an as S,ao as z,aZ as m,a_ as F,aI as C,aw as I,a$ as O,b0 as A}from"./userStore-CPET0UdN.js";import{T as i}from"./Text-CITZdxwZ.js";import{M as T,P as U}from"./PlusIcon-DddKRNUZ.js";import{B as n}from"./Button-DsbCUEhp.js";import{M as _}from"./Modal-DBTCvBmv.js";import{u as Y}from"./react-CE3T-M6l.js";import"./preload-helper-BXl3LOEh.js";import"./index-DiFMqVBZ.js";import"./index-CsxGVpB-.js";import"./component-PZEbI1O-.js";import"./index-C5s_o-M9.js";async function $(o){return M("user","/users/purchaseOrgCreditPacks",{method:"POST",body:JSON.stringify({purchaseAmountUSD:o})})}const R=25;function Z({close:o,payload:l}){const{organizationInfo:d}=Y(S),[a,p]=j.useState(1),[u,h]=j.useState(!1),b=z(d),c=d?.topUpAmountUSD||25,f=d?.costPerCredit||.05,x=c>0&&f>0?Math.round(c/f):500,g=x*a,s=c*a,v=l.variant==="out_of_credits"?"You're out of credits":"Running low on credits",w=l.variant==="out_of_credits"?"You're out of credits.":`You have ${m(l.creditsRemaining)} credits remaining.`,t=b&&x>0&&c>0;function k(r){r||o()}function P(){const r=d?.organizationID?.trim();r?F(r):C()}async function N(){if(!t||u)return;h(!0);const{data:r,error:y}=await $(Math.round(s*100)/100);if(h(!1),y){await I(y);return}r?.paymentIntentId&&(await O(),A("Payment submitted. Your credit balance should update in a minute."),C())}return e.jsxs(_,{title:v,maxWidth:684,open:!0,onOpenChange:k,children:[e.jsxs(i,{as:"p",variant:"studio/body/md",children:[w," ",t?e.jsxs(e.Fragment,{children:["Add ",m(g)," credits for $",s%1===0?s.toFixed(0):s.toFixed(2)," to keep working without interruption. Your organization will be automatically charged using the payment method on file."]}):e.jsx(e.Fragment,{children:"Credit purchases are not available for your current plan or billing setup."})]}),e.jsxs("div",{className:"bg-gray-15 dark:bg-gray-75 mt-6 flex items-center justify-between rounded-lg py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 pl-4",children:[e.jsx(n,{className:"dark:bg-gray-90 h-8 w-8 bg-white",variant:"secondary",icon:e.jsx(T,{}),size:"sm",onClick:()=>p(Math.max(1,a-1)),disabled:!t||a<=1}),e.jsx("div",{className:"flex min-w-48 items-center justify-center",children:e.jsx(i,{as:"span",variant:"studio/display/2xl",children:t?m(g):"â"})}),e.jsx(n,{className:"dark:bg-gray-90 h-8 w-8 bg-white",variant:"secondary",size:"sm",icon:e.jsx(U,{}),disabled:!t||a>=R,onClick:()=>p(a+1)}),e.jsx("div",{className:"pt-8",children:e.jsx(i,{as:"span",variant:"studio/body/bold/md",className:"font-display",children:"Credits"})})]})}),e.jsxs("div",{className:"flex items-center gap-2 pr-4",children:[e.jsx(i,{as:"span",variant:"studio/body/md",children:"Total:"}),e.jsx(i,{as:"span",variant:"studio/body/bold/md",children:t?`$${s%1===0?s.toFixed(0):s.toFixed(2)}`:"â"})]})]}),e.jsxs("div",{className:"mt-6 flex flex-row flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(n,{variant:"secondary",onClick:o,children:"Not now"}),e.jsx(n,{variant:"secondary",onClick:P,children:"Snooze for 2 hours"})]}),e.jsx(n,{className:"ml-auto",variant:"primary",onClick:N,disabled:!t||u,children:u?"Loadingâ¦":"Add Credits"})]})]})}export{Z as default}; 2//# sourceMappingURL=PurchaseCreditsModal-BtYvBnlO.js.map
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.