1import{J as M,r as n,bv as q,k as B,b0 as D,j as e,Y as m,B as u,bd as I,s as l,ae as p,bw as L,aW as V}from"./index-DL0d_lAK.js";import{C as r}from"./card-DnGeKDac.js";import{I as x}from"./input-BZVgYfh9.js";import{C as _}from"./CreditLedger-1d_zf-ex.js";import{P as z}from"./PageHeader-C6rx3uss.js";import{a as U,V as Y}from"./volume-x-CO0IAnaF.js";function R(){const{user:a}=M(),[i,N]=n.useState(q()),{data:c}=B({queryKey:["profile",a==null?void 0:a.id],enabled:!!a,queryFn:async()=>V(await l.from("profiles").select("full_name,email").eq("id",a.id).maybeSingle())}),{balance:y,granted:w,spent:S,entries:C}=D(),[f,h]=n.useState(""),[d,j]=n.useState(""),[g,v]=n.useState(""),[b,o]=n.useState("");n.useEffect(()=>{c&&(h(c.full_name??""),j((a==null?void 0:a.email)??""))},[c,a==null?void 0:a.email]);async function E(s){s.preventDefault();const{error:t}=await l.from("profiles").update({full_name:f}).eq("id",a.id);o(t?p(t,{action:"Account.saveName"}):"Name saved.")}async function A(s){if(s.preventDefault(),d===a.email)return o("That is already your email.");const{error:t}=await l.auth.updateUser({email:d});o(t?p(t,{action:"Account.changeEmail"}):"Check your new inbox to confirm the email change.")}async function P(s){s.preventDefault();const{error:t}=await l.auth.updateUser({password:g});o(t?p(t,{action:"Account.changePassword"}):"Password updated."),t||v("")}function k(){const s=!i;L(s),N(s)}return e.jsxs("div",{className:"max-w-4xl",children:[e.jsx(z,{title:"Account"}),b&&e.jsx("p",{className:"text-sm text-slate-600 mb-4",children:b}),e.jsxs("div",{className:"max-w-lg space-y-4",children:[e.jsx(r,{className:"p-4 sm:p-6",children:e.jsxs("form",{onSubmit:E,className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"Display name"}),e.jsx(x,{value:f,onChange:s=>h(s.target.value)})]}),e.jsx(u,{variant:"brand",children:"Save name"})]})}),e.jsx(r,{className:"p-4 sm:p-6",children:e.jsxs("form",{onSubmit:A,className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"Email"}),e.jsx(x,{type:"email",value:d,onChange:s=>j(s.target.value)})]}),e.jsx(u,{variant:"outline",children:"Change email"})]})}),e.jsx(r,{className:"p-4 sm:p-6",children:e.jsxs("form",{onSubmit:P,className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(m,{children:"New password"}),e.jsx(x,{type:"password",value:g,onChange:s=>v(s.target.value),minLength:6,required:!0})]}),e.jsx(u,{variant:"outline",children:"Change password"})]})}),e.jsxs(r,{className:"p-4 sm:p-6",children:[e.jsx("h2",{className:"font-medium mb-1",children:"Billing"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You're on the free plan. Paid plans are coming soon."})]})]}),e.jsxs(r,{className:"p-4 sm:p-6 mt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium",children:"Credits"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Every AI action draws credits from your balance. Need more? Ask us for a top-up."})]}),e.jsxs("button",{onClick:k,title:i?"Enable cost sound":"Mute cost sound",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground shrink-0 p-2 -m-2 rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand/40",children:[i?e.jsx(U,{size:16}):e.jsx(Y,{size:16})," ",i?"Sound off":"Sound on"]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[["Balance",y],["Granted",w],["Spent",S]].map(([s,t])=>e.jsxs("div",{className:"rounded-xl border border-border px-4 py-3",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.12em] font-bold text-muted-foreground",children:s}),e.jsx("div",{className:"text-xl font-semibold tabular-nums",children:I(t)})]},s))}),e.jsx(_,{entries:C})]})]})}export{R 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.