1import{r as n,j as e,L as Ke}from"./vendor-B5DssOfd.js";import{D as Ve}from"./DashboardLayout-DYuT_LER.js";import{u as We}from"./i18n-uURfBduE.js";import{R as G,X as R,Y as J,T as H}from"./CartesianChart-Eon_FRs7.js";import{A as Ue,a as Ye}from"./AreaChart-D07M7oUq.js";import{C as ve}from"./getRadiusAndStrokeWidthFromDot-BJUOd2nR.js";import{B as Ne,a as ke,C as Xe}from"./BarChart-CPyDoWd9.js";import"./index-DkvNy9W1.js";const c="https://api.rstcc.net";function o(){const i=localStorage.getItem("token")??sessionStorage.getItem("token")??"";return i?{Authorization:`Token ${i}`}:{}}function h(i){return`â¬${i.toFixed(2)}`}function d(i){return i.toLocaleString("nl-NL")}function qe(i){const[B,x]=i.split("-").map(Number);return`${["jan","feb","mrt","apr","mei","jun","jul","aug","sep","okt","nov","dec"][(x||1)-1]} ${B}`}const we=10;function lt({base:i="/tms"}){const{i18n:B}=We(),x=B.language.startsWith("nl"),[a,g]=n.useState(null),[_e,K]=n.useState(!0),[V,v]=n.useState(null),[f,Se]=n.useState(30),[W,Ce]=n.useState(1),[j,Te]=n.useState("gebruik"),[U,N]=n.useState([]),[$e,Y]=n.useState(!1),[k,X]=n.useState(""),[q,Q]=n.useState(!1),[Z,O]=n.useState(""),[Pe,ee]=n.useState(""),[te,ae]=n.useState(!1),[Ae,Be]=n.useState(null),F=n.useRef(null),[w,se]=n.useState(""),[re,ne]=n.useState(!1),[le,_]=n.useState(""),[ie,E]=n.useState("");async function ce(){if(w.trim()){ne(!0),_(""),E("");try{const t=await fetch(`${c}/api/coupons/redeem/`,{method:"POST",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({code:w.trim()})}),s=await t.json();if(!t.ok){_(s.error||"Ongeldige code.");return}g(r=>r&&{...r,wallet_balance:parseFloat(s.wallet_balance)}),E(`+â¬${Number(s.amount_eur).toFixed(2)} bijgeschreven!`),se("")}catch(t){_(String(t))}finally{ne(!1)}}}const[Oe,D]=n.useState(!1),[Fe,S]=n.useState(!1),[b,oe]=n.useState(10),[de,xe]=n.useState("invoice"),[C,T]=n.useState(!1),[L,y]=n.useState("slider"),[me,Ee]=n.useState(null),[z,pe]=n.useState(""),[ue,$]=n.useState(""),[he,P]=n.useState(""),fe=n.useRef(null),[A,p]=n.useState(null),[be,De]=n.useState(null);n.useEffect(()=>{const t=new URLSearchParams(window.location.search);if(t.get("credits")!=="done")return;const s=t.get("order"),r=new URL(window.location.href);r.searchParams.delete("credits"),r.searchParams.delete("order"),window.history.replaceState({},"",r.toString()),s&&(p("processing"),fetch(`${c}/api/wallet/credit-orders/${s}/confirm/`,{method:"POST",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({})}).then(async l=>{const m=await l.json();if(m.balance_eur!==void 0){const ye=parseFloat(m.balance_eur);De(ye),g(I=>I&&{...I,wallet_balance:ye}),p("success")}else m.failed?p("failed"):p("pending")}).catch(()=>p("pending")))},[]),n.useEffect(()=>{K(!0),v(null),fetch(`${c}/api/my/gebruik/?days=${f}&full=1`,{headers:o()}).then(async t=>{if(!t.ok){v(`HTTP ${t.status}`);return}const s=await t.json();if(s.error){v(s.error);return}g(s)}).catch(t=>v(String(t))).finally(()=>K(!1))},[f]);const Le=(a==null?void 0:a.allow_payments)&&!(a!=null&&a.planner_free)&&(a==null?void 0:a.wallet_balance)<.5,M=(a==null?void 0:a.max_credit_purchase_eur)??50,u=!a||!a.daily||a.daily.length===0||a.token_sell_price<=0?null:a.daily.reduce((r,l)=>r+(l.tokens||0),0)/Math.max(a.daily.length,1)*30/1e3*a.token_sell_price,ge=()=>(Y(!0),fetch(`${c}/api/my/wallet-permissions/`,{headers:o()}).then(t=>t.json()).then(t=>{N(t.permissions??[]),ee(t.monthly_budget_eur??"")}).catch(()=>{}).finally(()=>Y(!1)));n.useEffect(()=>{j==="toegang"&&ge()},[j]);async function ze(t){if(t.preventDefault(),!!k.trim()){Q(!0),O("");try{const s=await fetch(`${c}/api/my/wallet-permissions/`,{method:"POST",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({role:"athlete",email:k.trim()})}),r=await s.json();if(!s.ok){O(r.error||"Fout bij toevoegen.");return}await ge(),X("")}catch(s){O(String(s))}finally{Q(!1)}}}async function Me(t,s){(await fetch(`${c}/api/my/wallet-permissions/${t}/`,{method:"PATCH",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({granted:s})})).ok&&N(l=>l.map(m=>m.id===t?{...m,granted:s}:m))}async function je(t,s){N(r=>r.map(l=>l.id===t?{...l,...s}:l)),await fetch(`${c}/api/my/wallet-permissions/${t}/`,{method:"PATCH",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify(s)}).catch(()=>{})}function Ie(t){ee(t),F.current&&clearTimeout(F.current),F.current=setTimeout(async()=>{ae(!0);try{await fetch(`${c}/api/my/wallet-permissions/`,{method:"PATCH",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({monthly_budget_eur:t.trim()===""?null:t})}),Be(Date.now())}finally{ae(!1)}},600)}async function Ge(t){(await fetch(`${c}/api/my/wallet-permissions/${t}/`,{method:"DELETE",headers:o()})).ok&&N(r=>r.filter(l=>l.id!==t))}function Re(){y("slider"),P(""),pe(""),$(""),oe(Math.min(10,M));const t=(a==null?void 0:a.payment_methods)??[];xe(t.length>0?t[0]:"invoice"),S(!0)}async function Je(){var t;T(!0),P("");try{const s=await fetch(`${c}/api/wallet/credit-orders/`,{method:"POST",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({amount_eur:b.toFixed(2),method:de,redirect_url:`${i}/gebruik`})}),r=await s.json();if(!s.ok){P(r.error||"Fout bij aanmaken order.");return}Ee(((t=r.order)==null?void 0:t.id)??null),r.checkout_url?window.location.href=r.checkout_url:r.offline?y("done"):r.validation_required?(y("otp"),setTimeout(()=>{var l;return(l=fe.current)==null?void 0:l.focus()},100)):(g(l=>l&&{...l,wallet_balance:parseFloat(r.balance_eur)}),y("done"))}catch(s){P(String(s))}finally{T(!1)}}async function He(){if(me){T(!0),$("");try{const t=await fetch(`${c}/api/wallet/credit-orders/${me}/confirm/`,{method:"POST",headers:{...o(),"Content-Type":"application/json"},body:JSON.stringify({code:z})}),s=await t.json();if(!t.ok){$(s.error||"Ongeldige code.");return}g(r=>
1r&&{...r,wallet_balance:parseFloat(s.balance_eur)}),y("done")}catch(t){$(String(t))}finally{T(!1)}}}return e.jsxs(Ve,{children:[e.jsxs("div",{className:"p-4 md:p-6 space-y-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Ke,{to:`${i}/dashboard`,className:"flex items-center gap-1.5 text-on-surface-variant/50 hover:text-on-surface transition-colors text-xs font-bold uppercase tracking-widest",children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:"arrow_back"}),"Dashboard"]}),e.jsx("div",{className:"h-4 w-px bg-outline-variant/20"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-black uppercase italic tracking-tight text-on-surface leading-none",children:"Mijn gebruik"}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/40 mt-0.5 font-bold uppercase tracking-widest",children:"AI-gebruik overzicht"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[[7,30,90].map(t=>e.jsxs("button",{onClick:()=>Se(t),className:`px-3 py-1.5 rounded-lg text-xs font-black uppercase tracking-widest transition-all ${f===t?"bg-primary text-on-primary":"bg-surface-container text-on-surface-variant/60 hover:bg-surface-container-high"}`,children:[t,"d"]},t)),a&&(a.token_sell_price>0||a.price_per_schema>0)&&e.jsx("button",{onClick:()=>D(!0),className:"w-8 h-8 flex items-center justify-center rounded-xl bg-surface-container hover:bg-primary/15 text-on-surface-variant/50 hover:text-primary transition-all",title:"Prijsoverzicht",children:e.jsx("span",{className:"material-symbols-outlined text-[17px]",children:"info"})})]})]}),A==="processing"&&e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-2xl px-5 py-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin shrink-0"}),e.jsx("p",{className:"text-sm font-bold text-on-surface-variant",children:x?"Betaling verifiëren en tegoed bijboekenâ¦":"Verifying payment and adding creditsâ¦"})]}),A==="success"&&e.jsxs("div",{className:"bg-green-500/10 border border-green-500/25 rounded-2xl px-5 py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-green-400 text-xl",children:"check_circle"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-green-300",children:x?"Tegoed bijgeboekt!":"Credits added!"}),be!==null&&e.jsxs("p",{className:"text-[11px] text-green-400/70 mt-0.5",children:[x?"Nieuw saldo:":"New balance:"," ",e.jsxs("strong",{children:["â¬",be.toFixed(2)]})]})]})]}),e.jsx("button",{onClick:()=>p(null),className:"text-green-400/50 hover:text-green-400",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),A==="pending"&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/25 rounded-2xl px-5 py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-amber-400 text-xl",children:"schedule"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-amber-300",children:x?"Betaling wordt verwerkt":"Payment processing"}),e.jsx("p",{className:"text-[11px] text-amber-400/70 mt-0.5",children:x?"Je tegoed wordt automatisch bijgeboekt zodra de betaalprovider bevestigt.":"Your credits will be added automatically once the payment provider confirms."})]})]}),e.jsx("button",{onClick:()=>p(null),className:"text-amber-400/50 hover:text-amber-400",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"close"})})]}),A==="failed"&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/25 rounded-2xl px-5 py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-red-400 text-xl",children:"cancel"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-red-300",children:x?"Betaling geannuleerd of mislukt":"Payment cancelled or failed"}),e.jsx("p",{className:"text-[11px] text-red-400/70 mt-0.5",children:x?"Je betaling is niet afgerond. Probeer het opnieuw.":"Your payment was not completed. Please try again."})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>{p(null),S(!0)},className:"px-3 py-1.5 rounded-lg bg-red-500/20 hover:bg-red-500/30 text-red-300 text-xs font-bold transition-colors",children:x?"Probeer opnieuw":"Try again"}),e.jsx("button",{onClick:()=>p(null),className:"text-red-400/50 hover:text-red-400",children:e.jsx("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.jsx("div",{className:"flex gap-1 bg-surface-container-high/40 rounded-xl p-1 w-fit",children:["gebruik","toegang"].map(t=>e.jsx("button",{onClick:()=>Te(t),className:`px-4 py-1.5 rounded-lg text-xs font-black uppercase tracking-widest transition-all ${j===t?"bg-primary text-on-primary shadow":"text-on-surface-variant/50 hover:text-on-surface"}`,children:t==="gebruik"?"Gebruik":"Toegang"},t))}),j==="gebruik"&&(_e?e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx("div",{className:"w-8 h-8 border-2 border-primary/30 border-t-primary rounded-full animate-spin"})}):V?e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-2xl px-5 py-4 text-sm text-red-400",children:["Fout bij laden: ",V]}):a?e.jsxs(e.Fragment,{children:[(a.monthly_credit_eur>0||a.monthly_ai_credit_tokens>0)&&e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-2xl px-5 py-3 flex flex-wrap items-center gap-4 text-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-primary/60 text-base",children:"savings"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 leading-none mb-0.5",children:"Maandbudget (automatisch bijschrijven)"}),e.jsxs("p",{className:"font-black text-on-surface",children:[d(a.monthly_ai_credit_tokens)," tokens",a.monthly_credit_eur>0&&e.jsxs("span",{className:"text-primary ml-2",children:["â ",h(a.monthly_credit_eur),"/mnd"]}
1)]})]}),a.ai_monthly_token_limit>0&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 leading-none mb-0.5",children:"Gratis limiet"}),e.jsxs("p",{className:"font-black text-on-surface",children:[d(a.ai_monthly_token_limit)," tokens/mnd"]})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3",children:[{label:`Calls (${f}d)`,val:d(a.ai_calls),icon:"bolt",sub:a.all_time?`All-time: ${d(a.all_time.ai_calls)}`:void 0},{label:`Tokens (${f}d)`,val:d(a.ai_tokens),icon:"token",sub:a.all_time?`All-time: ${d(a.all_time.ai_tokens)}`:void 0},{label:`Trainingen (${f}d)`,val:d(a.workouts),icon:"fitness_center",sub:a.all_time?`All-time: ${d(a.all_time.workouts)}`:void 0},{label:"Saldo",val:h(a.wallet_balance),icon:"account_balance_wallet",hl:a.wallet_balance>0,warn:a.wallet_balance<.5&&a.allow_payments&&!a.planner_free},{label:`App (${f}d)`,val:d(a.calls_app),icon:"smartphone"},{label:`Portal (${f}d)`,val:d(a.calls_portal),icon:"computer"}].map(t=>e.jsxs("div",{className:`rounded-2xl border p-4 ${t.warn?"bg-amber-500/5 border-amber-500/20":t.hl?"bg-primary/8 border-primary/20":"bg-surface-container border-outline-variant/10"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`material-symbols-outlined text-sm ${t.warn?"text-amber-400":t.hl?"text-primary":"text-on-surface-variant/40"}`,children:t.icon}),e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40 leading-tight",children:t.label})]}),e.jsx("p",{className:`text-xl font-black ${t.warn?"text-amber-400":t.hl?"text-primary":"text-on-surface"}`,children:t.val}),t.sub&&e.jsx("p",{className:"text-[10px] text-on-surface-variant/30 mt-1",children:t.sub})]},t.label))}),e.jsxs("div",{className:"bg-surface-container border border-outline-variant/10 rounded-2xl px-5 py-4 flex flex-wrap items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary/60",children:"redeem"}),e.jsxs("div",{className:"flex-1 min-w-[180px]",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 leading-none mb-0.5",children:"Kortingscode"}),e.jsx("p",{className:"text-xs text-on-surface-variant/60",children:"Wissel een code in voor gratis tegoed"})]}),e.jsx("input",{type:"text",value:w,onChange:t=>{se(t.target.value.toUpperCase()),_(""),E("")},onKeyDown:t=>{t.key==="Enter"&&ce()},placeholder:"CODE",className:"w-32 bg-surface-container-high border border-outline-variant/20 rounded-xl px-3 py-2 text-sm font-black tracking-widest focus:outline-none focus:border-primary/50"}),e.jsx("button",{onClick:ce,disabled:re||!w.trim(),className:"px-4 py-2 rounded-xl bg-primary/15 text-primary text-xs font-black uppercase tracking-widest hover:bg-primary hover:text-on-primary transition-colors disabled:opacity-40",children:re?"...":"Verzilver"}),le&&e.jsx("p",{className:"w-full text-xs text-red-400",children:le}),ie&&e.jsx("p",{className:"w-full text-xs text-green-400 font-bold",children:ie})]}),Le&&e.jsxs("div",{className:"bg-amber-500/8 border border-amber-500/20 rounded-2xl px-5 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-amber-400",children:"warning"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-black text-amber-300",children:["Laag saldo â ",h(a.wallet_balance)]}),e.jsx("p",{className:"text-xs text-on-surface-variant/50 mt-0.5",children:"Koop tegoed om door te gaan met AI-functies"})]})]}),e.jsxs("button",{onClick:Re,className:"flex items-center gap-2 px-4 py-2 rounded-xl bg-amber-500/20 text-amber-300 text-xs font-black uppercase tracking-widest hover:bg-amber-500/30 transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"add_card"}),"Tegoed kopen"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-5",children:[a.daily&&a.daily.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Dagelijks AI-gebruik (calls)"}),e.jsx(G,{width:"100%",height:160,children:e.jsxs(Ue,{data:a.daily,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"gMyCalls",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
1stopColor:"#6366f1",stopOpacity:.35}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]})}),e.jsx(ve,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(R,{dataKey:"date",tick:{fontSize:9,fill:"#ffffff30"},tickFormatter:t=>t==null?void 0:t.slice(5)}),e.jsx(J,{tick:{fontSize:9,fill:"#ffffff30"},allowDecimals:!1}),e.jsx(H,{contentStyle:{background:"#1e1e2e",border:"1px solid #ffffff15",borderRadius:8,fontSize:11}}),e.jsx(Ye,{type:"monotone",dataKey:"calls",name:"Calls",stroke:"#6366f1",fill:"url(#gMyCalls)",strokeWidth:2,dot:!1})]})})]}),a.daily.some(t=>(t.workouts??0)>0)&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Trainingen aangemaakt via AI (per dag)"}),e.jsx(G,{width:"100%",height:140,children:e.jsxs(Ne,{data:a.daily,children:[e.jsx(ve,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(R,{dataKey:"date",tick:{fontSize:9,fill:"#ffffff30"},tickFormatter:t=>t==null?void 0:t.slice(5)}),e.jsx(J,{tick:{fontSize:9,fill:"#ffffff30"},allowDecimals:!1}),e.jsx(H,{contentStyle:{background:"#1e1e2e",border:"1px solid #ffffff15",borderRadius:8,fontSize:11}}),e.jsx(ke,{dataKey:"workouts",name:"Trainingen",fill:"#34d399",radius:[3,3,0,0]})]})})]})]}),a.by_module&&a.by_module.length>0&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Gebruik per functie"}),e.jsx(G,{width:"100%",height:Math.max(120,a.by_module.length*36),children:e.jsxs(Ne,{data:a.by_module,layout:"vertical",children:[e.jsx(R,{type:"number",tick:{fontSize:9,fill:"#ffffff30"},allowDecimals:!1}),e.jsx(J,{type:"category",dataKey:"module",tick:{fontSize:10,fill:"#ffffff60"},width:130}),e.jsx(H,{contentStyle:{background:"#1e1e2e",border:"1px solid #ffffff15",borderRadius:8,fontSize:11}}),e.jsx(ke,{dataKey:"calls",name:"Calls",radius:[0,4,4,0],children:a.by_module.map((t,s)=>e.jsx(Xe,{fill:"#FF6B00"},s))})]})})]})]}),e.jsxs("div",{className:"space-y-5",children:[a.ai_calls>0&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"App vs Portal"}),e.jsx("div",{className:"space-y-3",children:[{label:"App",calls:a.calls_app,color:"#6366f1"},{label:"Portal",calls:a.calls_portal,color:"#a78bfa"}].map(t=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[e.jsx("span",{className:"font-bold text-on-surface",children:t.label}),e.jsxs("span",{className:"text-on-surface-variant/50",children:[d(t.calls)," (",a.ai_calls>0?Math.round(t.calls/a.ai_calls*100):0,"%)"]})]}),e.jsx("div",{className:"h-2 bg-surface-container-high rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${a.ai_calls>0?t.calls/a.ai_calls*100:0}%`,background:t.color}})})]},t.label))})]}),a.credit_history&&a.credit_history.length>0&&(()=>{const t=Math.ceil(a.credit_history.length/we),s=a.credit_history.slice(0,W*we);return e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Recente transacties"}),e.jsxs("span",{className:"text-[9px] text-on-surface-variant/30",children:[s.length," / ",a.credit_history.length]})]}),e.jsx("div",{className:"space-y-1.5",children:s.map((r,l)=>{var m;return e.jsxs("div",{className:"flex justify-between items-center text-xs py-1.5 border-b border-outline-variant/5",children:[e.jsxs("div",{children:[e.jsx("span",{className:`font-black ${r.kind==="topup"?"text-green-400":r.kind==="spend"?"text-red-400":"text-amber-400"}`,children:r.kind}),r.note&&e.jsx("span",{className:"text-on-surface-variant/40 ml-2 text-[10px]",children:r.note})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:`font-bold ${r.amount_eur>=0?"text-green-400":"text-red-400"}`,children:[r.amount_eur>=0?"+":"",h(r.amount_eur)]}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/30",children:(m=r.created_at)==null?void 0:m.slice(0,10)})]})]},l)})}),W<t&&e.jsxs("button",{onClick:()=>Ce(r=>r+1),className:"mt-3 w-full text-[10px] font-black uppercase tracking-widest text-primary/60 hover:text-primary py-2 border border-outline-variant/10 rounded-xl hover:border-primary/30 transition-all",children:["Toon meer (",a.credit_history.length-s.length," resterend)"]}
1)]})})()]})]})]}):null),j==="toegang"&&e.jsx("div",{className:"space-y-5 max-w-3xl",children:e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-1",children:"Coach toegang"}),e.jsx("p",{className:"text-xs text-on-surface-variant/50 mb-4",children:"Geef een coach toegang tot je AI-wallet. De coach kan dan AI-functies gebruiken vanuit jouw tegoed."}),e.jsxs("form",{onSubmit:ze,className:"flex gap-2 mb-5",children:[e.jsx("input",{type:"email",placeholder:"E-mailadres van coach",value:k,onChange:t=>X(t.target.value),className:"flex-1 bg-surface-container-high border border-outline-variant/20 rounded-xl px-3 py-2 text-sm text-on-surface placeholder:text-on-surface-variant/30 focus:outline-none focus:border-primary/50"}),e.jsx("button",{type:"submit",disabled:q||!k.trim(),className:"px-4 py-2 rounded-xl bg-primary text-on-primary text-xs font-black uppercase tracking-widest hover:bg-primary/90 disabled:opacity-40 transition-all whitespace-nowrap",children:q?"â¦":"Toevoegen"})]}),Z&&e.jsx("p",{className:"text-xs text-red-400 mb-3",children:Z}),e.jsxs("div",{className:"mb-5 pb-5 border-b border-outline-variant/10",children:[e.jsx("label",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-1.5 block",children:"Mijn maandbudget voor coaches (â¬)"}),e.jsx("p",{className:"text-[11px] text-on-surface-variant/40 mb-2",children:"Het percentage-aandeel per coach hieronder is een deel van dit bedrag. Leeg = geen budget ingesteld (dan telt alleen een eventuele losse max per coach hieronder)."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:0,step:"1",placeholder:"Geen budget",value:Pe,onChange:t=>Ie(t.target.value),className:"w-40 bg-surface-container-high border border-outline-variant/20 rounded-xl px-3 py-2 text-sm text-on-surface placeholder:text-on-surface-variant/30 focus:outline-none focus:border-primary/50"}),te&&e.jsx("span",{className:"text-[10px] text-on-surface-variant/40",children:"Opslaanâ¦"}),!te&&Ae&&e.jsx("span",{className:"text-[10px] text-green-400",children:"Opgeslagen â"})]})]}),$e?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("div",{className:"w-5 h-5 border-2 border-primary/30 border-t-primary rounded-full animate-spin"})}):U.length===0?e.jsx("p",{className:"text-xs text-on-surface-variant/30 text-center py-6",children:"Geen coaches gekoppeld"}):e.jsx("div",{className:"space-y-3",children:U.map(t=>e.jsxs("div",{className:"bg-surface-container-high/50 rounded-xl px-4 py-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-on-surface",children:t.coach_name}),e.jsx("p",{className:"text-[11px] text-on-surface-variant/40",children:t.coach_email})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>Me(t.id,!t.granted),className:`px-3 py-1 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${t.granted?"bg-green-500/15 text-green-400 hover:bg-red-500/15 hover:text-red-400":"bg-surface-container text-on-surface-variant/40 hover:bg-green-500/15 hover:text-green-400"}`,children:t.granted?"Actief":"Inactief"}),e.jsx("button",{onClick:()=>Ge(t.id),className:"text-on-surface-variant/30 hover:text-red-400 transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-base",children:"delete"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t border-outline-variant/10",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-baseline text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-1",children:[e.jsx("span",{children:"Aandeel van maandbudget"}),e.jsxs("span",{className:"text-primary text-xs",children:[t.usage_percent,"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,step:5,value:t.usage_percent,onChange:s=>je(t.id,{usage_percent:Number(s.target.value)}),className:"w-full accent-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-1 block",children:"Max per maand voor deze coach (â¬)"}),e.jsx("input",{type:"number",min:0,step:"1",placeholder:"Geen limiet",value:t.monthly_max_eur??"",onChange:s=>je(t.id,{monthly_max_eur:s.target.value===""?null:s.target.value}),className:"w-full bg-surface-container border border-outline-variant/20 rounded-lg px-2.5 py-1.5 text-xs text-on-surface placeholder:text-on-surface-variant/30 focus:outline-none focus:border-primary/50"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-1.5",children:"Verbruik per maand"}
1),!t.usage_by_month||t.usage_by_month.length===0?e.jsx("p",{className:"text-[11px] text-on-surface-variant/30",children:"Nog geen verbruik"}):e.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto pr-1",children:t.usage_by_month.map(s=>e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{className:"text-on-surface-variant/50 capitalize",children:qe(s.month)}),e.jsx("span",{className:"font-bold text-on-surface",children:h(parseFloat(s.spent_eur))})]},s.month))})]})]})]},t.id))})]})})]}),Fe&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-surface-container rounded-3xl border border-outline-variant/20 w-full max-w-sm shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-outline-variant/10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-black text-on-surface",children:"Tegoed kopen"}),e.jsx("p",{className:"text-xs text-on-surface-variant/50 mt-0.5",children:"AI-credits bijstorten op je wallet"})]}),e.jsx("button",{onClick:()=>S(!1),className:"text-on-surface-variant/40 hover:text-on-surface-variant",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),e.jsxs("div",{className:"px-6 py-6 space-y-5",children:[L==="slider"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-baseline mb-2",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Bedrag"}),e.jsx("span",{className:"text-2xl font-black text-amber-400",children:h(b)})]}),e.jsx("input",{type:"range",min:5,max:M,step:5,value:b,onChange:t=>oe(Number(t.target.value)),className:"w-full accent-amber-400"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-on-surface-variant/30 mt-1",children:[e.jsx("span",{children:"â¬5"}),e.jsxs("span",{children:["â¬",M]})]})]}),u!==null&&u>0&&e.jsxs("div",{className:"bg-surface-container-high rounded-2xl px-4 py-3 text-xs space-y-1",children:[e.jsx("p",{className:"font-black text-on-surface-variant/50 uppercase tracking-widest text-[10px]",children:"Inschatting op basis van gebruik"}),e.jsxs("p",{className:"text-on-surface",children:["Gemiddeld verbruik: ",e.jsxs("span",{className:"font-black text-primary",children:[h(u),"/maand"]})]}),u>0&&e.jsxs("p",{className:"text-on-surface-variant/50",children:["Dit tegoed is genoeg voor ca. ",e.jsxs("span",{className:"font-bold text-on-surface",children:[(b/u).toFixed(1)," maand",b/u>=2?"en":""]})]})]}),(a==null?void 0:a.allow_payments)&&(()=>{const t={pin:{label:"Pin",icon:"contactless"},stripe:{label:"Stripe",icon:"credit_card"},mollie:{label:"iDEAL / Mollie",icon:"account_balance_wallet"},factuur:{label:"Factuur",icon:"receipt_long"},overmaken:{label:"Overmaken",icon:"account_balance"},invoice:{label:"Factuur (e-mail)",icon:"receipt_long"}},s=a.payment_methods&&a.payment_methods.length>0?a.payment_methods:["invoice"];return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Betaalmethode"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:s.map(r=>{const l=t[r]??{label:r,icon:"payments"};return e.jsxs("button",{onClick:()=>xe(r),className:`flex items-center gap-2 px-3 py-2.5 rounded-xl border text-[11px] font-bold transition-all ${de===r?"bg-amber-500/15 border-amber-400/40 text-amber-400":"bg-white/5 border-white/10 text-on-surface-variant/60 hover:border-white/20"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:l.icon}),l.label]},r)})})]})})(),he&&e.jsx("p",{className:"text-xs text-red-400",children:he}),e.jsx("button",{onClick:Je,disabled:C,className:"w-full py-3 rounded-2xl bg-amber-500 text-black text-sm font-black uppercase tracking-widest hover:bg-amber-400 disabled:opacity-50 transition-all",children:C?"Bestelling aanmakenâ¦":`Bestel ${h(b)}`})]}),L==="otp"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-4xl text-amber-400",children:"mark_email_read"}),e.jsx("p",{className:"font-black text-on-surface",children:"Bevestig via e-mail"}),e.jsx("p",{className:"text-xs text-on-surface-variant/50",children:"Je ontvangt een 6-cijferige code op je e-mailadres. Vul die hieronder in."})]}),e.jsx("input",{ref:fe,type:"text",inputMode:"numeric",maxLength:6,placeholder:"000000",value:z,onChange:t=>pe(t.target.value.replace(/\D/g,"")),className:"w-full text-center text-2xl font-black tracking-widest bg-surface-container-high border border-outline-variant/20 rounded-2xl py-4 text-on-surface focus:outline-none focus:border-amber-400"}),ue&&e.jsx("p",{className:"text-xs text-red-400 text-center",children:ue}),e.jsx("button",{onClick:He,disabled:C||z.length<6,className:"w-full py-3 rounded-2xl bg-amber-500 text-black text-sm font-black uppercase tracking-widest hover:bg-amber-400 disabled:opacity-50 transition-all",children:C?"Bevestigenâ¦":"Bevestig code"})]}),L==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-2",children:[e.jsx("span",{className:"material-symbols-outlined text-5xl text-green-400",children:"check_circle"}),e.jsx("p",{className:"font-black text-on-surface text-lg",children:"Tegoed bijgeboekt!"}),e.jsxs("p",{className:"text-xs text-on-surface-variant/50",children:["Je wallet is opgeladen met ",h(b),"."]}),e.jsx("button",{onClick:()=>S(!1),className:"w-full py-3 rounded-2xl bg-surface-container-high text-on-surface text-sm font-black uppercase tracking-widest hover:bg-surface-container transition-all",children:"Sluiten"})]})]})]})}),Oe&&a&&e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",onClick:()=>D(!1),children:e.jsxs("div",{className:"bg-surface-container rounded-3xl border border-outline-variant/20 w-full max-w-sm shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-outline-variant/10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-black text-on-surface",children:"Prijsoverzicht"}),e.jsx("p",{className:"text-xs text-on-surface-variant/50 mt-0.5",children:"Hoe kosten worden berekend"})]}),e.jsx("button",{onClick:()=>D(!1),className:"text-on-surface-variant/40 hover:text-on-surface-variant",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4",children:[a.token_sell_price>0&&e.jsxs("div",{className:"bg-surface-container-high/60 rounded-2xl p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-sm",children:"token"}),e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-on-surface-variant",children:"Prijs per token"})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-black text-on-surface",children:["â¬",a.token_sell_price.toFixed(6)]}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/50 mt-0.5",children:"per
11.000 tokens (incl. BTW)"})]}),(a.btw_pct??0)>0&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-[10px] text-on-surface-variant/50",children:["incl. ",a.btw_pct,"% BTW"]}),e.jsxs("p",{className:"text-[11px] text-on-surface-variant/70 font-bold",children:["excl. â¬",(a.token_sell_price/(1+(a.btw_pct??0)/100)).toFixed(6)]})]})]}),a.charge_per_token&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-white/8",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[13px]",children:"check_circle"}),e.jsx("p",{className:"text-[10px] text-primary font-bold",children:"Tokens worden per workout afgeschreven"})]})]}),a.price_per_schema>0&&e.jsxs("div",{className:"bg-surface-container-high/60 rounded-2xl p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-sm",children:"fitness_center"}),e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-on-surface-variant",children:"Prijs per workout"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-black text-on-surface",children:["â¬",a.price_per_schema.toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/50 mt-0.5",children:"vast bedrag per workout"})]}),a.charge_per_schema&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pt-2 border-t border-white/8",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[13px]",children:"check_circle"}),e.jsx("p",{className:"text-[10px] text-primary font-bold",children:"Vaste prijs per gegenereerde workout"})]})]}),(a.charge_per_schema||a.charge_per_token)&&e.jsxs("div",{className:"bg-primary/5 border border-primary/15 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-sm",children:"payments"}),e.jsx("p",{className:"text-[11px] font-black uppercase tracking-widest text-on-surface-variant",children:"Afschrijving"})]}),a.charge_per_schema&&a.charge_per_token?e.jsxs("p",{className:"text-[11px] text-on-surface-variant/70",children:["Per workout: vaste prijs ",e.jsxs("strong",{className:"text-on-surface",children:["â¬",a.price_per_schema.toFixed(2)]})," + tokenkosten worden allebei afgeschreven."]}):a.charge_per_schema?e.jsxs("p",{className:"text-[11px] text-on-surface-variant/70",children:["Per workout wordt ",e.jsxs("strong",{className:"text-on-surface",children:["â¬",a.price_per_schema.toFixed(2)]})," van je tegoed afgeschreven."]}):e.jsxs("p",{className:"text-[11px] text-on-surface-variant/70",children:["Per workout worden de verbruikte tokens afgeschreven à ",e.jsxs("strong",{className:"text-on-surface",children:["â¬",a.token_sell_price.toFixed(6)]})," / 1k tokens."]})]}),a.planner_free&&e.jsxs("div",{className:"bg-green-500/10 border border-green-500/20 rounded-2xl p-4 flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-green-400 text-lg",children:"check_circle"}),e.jsx("p",{className:"text-[11px] text-green-300 font-bold",children:"Gratis â geen kosten per gebruik"})]}),u!==null&&u>0&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-white/8",children:[e.jsx("p",{className:"text-[11px] text-on-surface-variant/50 font-bold uppercase tracking-widest",children:"Geschat per maand"}),e.jsxs("p",{className:"text-base font-black text-amber-400",children:["â¬",u.toFixed(2)]})]}),!a.planner_free&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-white/8",children:[e.jsx("p",{className:"text-[11px] text-on-surface-variant/50 font-bold uppercase tracking-widest",children:"Huidig saldo"}),e.jsxs("p",{className:`text-base font-black ${a.wallet_balance<.5?"text-amber-400":"text-primary"}`,children:["â¬",a.wallet_balance.toFixed(2)]})]})]})]})})]})}export{lt 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.