1import{r as n,j as e}from"./react-vendor-DKbO0zba.js";import{C as v,b as E,u as F,c as k,d as A}from"./CheckoutFrame-CXkidUja.js";import{c as j,ds as N,dr as S,k as T,B as u}from"./index-BgbQzHQM.js";import{u as w}from"./ConfirmDialog-d8DKbYmV.js";import{g as P}from"./BillingPage-DgV5slSz.js";import"./recharts-CiGlJ7Ym.js";import"./AppTopBar-DvYCtcLp.js";import"./OrgSwitcher-Bhjq4cv1.js";import"./LanguageSwitcher-D95GkgE-.js";import"./firebase-BWzRhu08.js";import"./framer-motion-DCn40pwX.js";import"./sun-DdCRErpc.js";import"./AuthenticatedLayout-VR1oXQE6.js";import"./usePublicPlans-CvFOroBj.js";import"./invitations-CkPFcIRM.js";import"./MediaPlayer-BfyoPe__.js";import"./AudioPlayer-C7pUxHGt.js";import"./useSessionSocket-DFkZvUMn.js";import"./PipelineVisualizer-DhRMIKzi.js";import"./apiErrorToast-DEwg3W3m.js";import"./EmbedLinksDetachDialog-B4dBNgdY.js";import"./FloatingFeedbackButton-DzmQuX3W.js";import"./usePlanCheckoutFlow-0gx3blcd.js";import"./financeFormat-Bux3oD4M.js";import"./countries-D6Apy_Zw.js";import"./planCheckout-DaC3Oiub.js";import"./download-PqUzjzG9.js";import"./creditIntentDisplay-BlaICxE8.js";import"./billing-CzHyeKPF.js";import"./planTermSentence-C3Qdmwpr.js";import"./orgCredit-D7hagxZA.js";const b="#F4943D",C="#0A0A1A";function I(r){const t=r==="dark";return{theme:t?"night":"stripe",variables:{colorPrimary:b,colorBackground:t?C:"#FFFFFF",colorText:t?"#F3F4F6":"#111827",colorTextSecondary:t?"#9CA3AF":"#6B7280",colorDanger:t?"#F87171":"#DC2626",fontFamily:"Inter, system-ui, -apple-system, sans-serif",borderRadius:"10px",spacingUnit:"4px"},rules:{".Input":{border:`1px solid ${t?"rgba(255,255,255,0.12)":"#E5E7EB"}`,boxShadow:"none"},".Input:focus":{border:`1px solid ${b}`,boxShadow:"0 0 0 3px rgba(244, 148, 61, 0.25)"},".Tab":{border:`1px solid ${t?"rgba(255,255,255,0.12)":"#E5E7EB"}`,boxShadow:"none"},".Tab--selected":{border:`1px solid ${b}`,boxShadow:"0 0 0 3px rgba(244, 148, 61, 0.20)"},".Label":{fontWeight:"500"}}}}const L=2e3,R=15;function _({onConfirmed:r,onCancel:t}){const{t:i}=j("admin"),m=F(),d=k(),[a,s]=n.useState(null),[o,l]=n.useState(!1),c=async g=>{if(g.preventDefault(),!m||!d)return;l(!0),s(null);const p=await m.confirmSetup({elements:d,confirmParams:{return_url:window.location.href},redirect:"if_required"});if(l(!1),p.error){s(p.error.message??i("billing.add.failed"));return}r()};return e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsx(A,{}),e.jsx("p",{className:"rounded-md bg-gray-50 p-3 text-xs leading-relaxed text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:i("billing.add.mandate")}),a?e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",role:"alert",children:a}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(u,{type:"button",variant:"secondary",size:"sm",onClick:t,disabled:o,"data-help":"common.dialog.cancel",children:i("billing.add.cancel")}),e.jsx(u,{type:"submit",variant:"primary",size:"sm",isLoading:o,disabled:!m||!d||o,"data-help":"billing.method.save",children:i("billing.add.submit")})]})]})}function ue({isOpen:r,onClose:t,clientSecret:i,publishableKey:m,onSaved:d}){const{t:a}=j("admin"),[s,o]=n.useState(i?"entering":"confirming"),l=n.useRef(!1),c=N(),g=n.useMemo(()=>I(c),[c]),p=w({isOpen:r,onClose:t,closeOnEscape:s!=="confirming"});n.useEffect(()=>(r&&(l.current=!1,o(i?"entering":"confirming")),()=>{l.current=!0}),[r]);const x=n.useCallback(async()=>{o("confirming");for(let h=0;h<R;h+=1){if(await new Promise(y=>setTimeout(y,L)),l.current)return;try{if((await P()).payment_method!==null){d(),l.current||o("saved");return}}catch{}}l.current||o("timeout")},[d]),f=n.useRef(!1);return n.useEffect(()=>{r&&!i&&!f.current&&(f.current=!0,x()),r||(f.current=!1)},[r,i,x]),r?e.jsxs(v,{dialogRef:p,titleId:"add-payment-method-title",title:a("billing.add.title"),onClose:t,closeLabel:a("billing.add.close"),closeDisabled:s==="confirming",width:"lg",children:[s==="entering"&&i?e.jsx(E,{stripe:S(m),options:{clientSecret:i,appearance:g},children:e.jsx(_,{onConfirmed:x,onCancel:t})}):null,s==="confirming"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-10 text-center",children:[e.jsx(T,{size:"lg"}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:a("billing.add.confirming")})]}
1):null,s==="saved"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-10 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-green-700 dark:text-green-400",children:a("billing.add.saved")}),e.jsx(u,{variant:"primary",size:"sm",onClick:t,"data-help":"billing.method.done",children:a("billing.add.done")})]}):null,s==="timeout"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-10 text-center",children:[e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:a("billing.add.stillConfirming")}),e.jsx(u,{variant:"secondary",size:"sm",onClick:t,"data-help":"billing.method.closeWhileConfirming",children:a("billing.add.close")})]}):null]}):null}export{ue as default};
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.