1import{a as g,n as f,r as o,j as e,b as u,B as x,g as m,C as p,s as j}from"./index-DroIlAnG.js";import{C as b}from"./circle-check-big-yBUVm5iY.js";const N=["1000","5000","10000"],k=[100,250,500,1e3],v=()=>{const[c]=g(),{user:a}=f(),t=c.get("pack")||"1000",i=parseInt(c.get("threshold")||"250",10),s=k.includes(i)?i:250,[l,n]=o.useState("loading"),[h,d]=o.useState("");return o.useEffect(()=>{if(!a)return;if(!N.includes(t)){n("error"),d("Invalid token pack selected.");return}(async()=>{try{const{error:r}=await j.functions.invoke("update-refill-settings",{body:{auto_refill_threshold:s,auto_refill_token_pack:t}});if(r)throw r;n("success")}catch(r){n("error"),d(r.message||"Failed to enable auto-refill")}})()},[a,t,s]),a?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"max-w-md w-full bg-card rounded-xl shadow-lg border p-8 text-center space-y-6",children:[l==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),e.jsx("h1",{className:"text-xl font-semibold text-foreground",children:"Enabling Auto-Refill..."}),e.jsxs("p",{className:"text-muted-foreground",children:["Setting up ",Number(t).toLocaleString()," token auto-refill at ",s," threshold"]})]}),l==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"h-16 w-16 mx-auto text-green-500"}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Auto-Refill Enabled! â
"}),e.jsxs("div",{className:"bg-muted rounded-lg p-4 text-left space-y-2",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Refill amount:"})," ",Number(t).toLocaleString()," tokens"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Threshold:"})," ",s," tokens"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["When your balance drops below ",s,", we'll automatically charge your card for ",Number(t).toLocaleString()," tokens."]})]}),e.jsx(x,{asChild:!0,className:"w-full",children:e.jsx(m,{to:"/billing",children:"Go to Billing â"})})]}),l==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"h-16 w-16 mx-auto text-destructive"}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground",children:h}),e.jsx(x,{asChild:!0,variant:"outline",className:"w-full",children:e.jsx(m,{to:"/billing",children:"Go to Billing"})})]})]})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(u,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"text-muted-foreground",children:"Redirecting to login..."})]})})};export{v 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.