PageSourceSearch

https://lumna.co/assets/AdminPanel-D1Otr2J6.js

js lumna.co collected 2026-10-02 01:21:06 UTC 41,276 bytes, 1 lines download raw bytes

1import{j as e,b as F}from"./query-DDoy5vlF.js";import{r as h,k as Pe,d as Ne}from"./vendor-QzfJe3AZ.js";import{c as Oe,g as I,u as Ke,a as Re}from"./main-2h-e5THe.js";import{P as ve,N as Be,I as Ve}from"./ChessCoachesApp-Bah6rdPh.js";import{A as W,T as He}from"./Avatar-BA7XXw5h.js";import{R as re,B as ce,C as le,X as ie,Y as oe,T as de,a as xe}from"./charts-DOVPjeo-.js";import{a as V}from"./trash-2-EuOALCrF.js";import{a as H}from"./pencil-Z0Glh4Hh.js";import{L as me}from"./plus-BwKopYAs.js";import{C as be}from"./clock-B83KeYkD.js";import"./book-open-B7tl8GBo.js";import"./trophy-BNoWNxnz.js";import"./external-link-ch7O6ZBw.js";const Ge=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],We=Oe("cpu",Ge);function ae({data:a,color:u,height:s=200,yTicks:i,yDomain:m,tooltipUnit:_,tooltipLabel:j,formatUserValue:f,formatDayValue:N}){const[b,w]=h.useState(null),y=b?a.find(g=>g.date===b):null,D=g=>{const E=g,K=E?.date??E?.payload?.date;K&&w(G=>G===K?null:K)};return e.jsxs("div",{className:"[&_*:focus]:outline-none",children:[e.jsx(re,{width:"100%",height:s,children:e.jsxs(ce,{data:a,children:[e.jsx(le,{strokeDasharray:"3 3",stroke:"#334155"}),e.jsx(ie,{dataKey:"label",tick:{fill:"#e2e8f0",fontSize:11},angle:-45,textAnchor:"end",height:60,interval:0}),e.jsx(oe,{tick:{fill:"#e2e8f0",fontSize:13},allowDecimals:!1,...i?{ticks:i}:{},...m?{domain:m}:{}}),e.jsx(de,{cursor:!1,contentStyle:{backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:8},labelStyle:{color:"#e2e8f0"},formatter:g=>[`${g} ${_}`,j]}),e.jsx(xe,{dataKey:"value",fill:u,radius:[2,2,0,0],activeBar:!1,onClick:D,style:{cursor:"pointer"}})]})}),y&&e.jsxs("div",{className:"mt-3 rounded-lg border border-slate-700 bg-slate-800/50 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-slate-700/40 flex items-center justify-between",children:[e.jsxs("h4",{className:"text-xs font-medium text-slate-300",children:[y.label," — ",N(y.value)]}),e.jsx("button",{onClick:()=>w(null),className:"text-xs text-slate-500 hover:text-slate-300",children:"✕"})]}),y.by_user.length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-slate-500",children:"No activity"}):e.jsx("div",{className:"divide-y divide-slate-700/50",children:y.by_user.map(g=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[e.jsx(W,{name:g.name||"?",picture:g.picture,size:"sm"}),e.jsx("span",{className:"flex-1 text-sm text-slate-200 truncate",children:g.name||"—"}),e.jsx("span",{className:"text-sm font-mono text-slate-400",children:f(g.value)})]},g.user_id))})]})]})}const Ye={tsx:"text-sky-400",ts:"text-blue-400",js:"text-yellow-400",jsx:"text-cyan-400",py:"text-emerald-400",html:"text-orange-400",css:"text-pink-400"};function Xe(){const{data:a}=F({queryKey:["admin-codelines"],queryFn:async()=>(await I.get("/api/admin/codelines")).data});if(!a)return null;const u=Object.entries(a.by_lang).sort(([,s],[,i])=>i-s).map(([s,i])=>({lang:s,count:i,pct:a.lines?i/a.lines*100:0}));return e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsx("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50",children:e.jsx("h3",{className:"text-sm font-medium text-slate-300",children:"Codebase"})}),e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-baseline justify-center gap-2",children:[e.jsx("span",{className:"font-mono text-2xl font-bold text-slate-100",children:a.lines.toLocaleString()}),e.jsx("span",{className:"text-base text-slate-400",children:"lines of code"})]}),e.jsx("div",{className:"mt-2 flex flex-wrap justify-center gap-x-6 gap-y-1 text-base",children:u.map(({lang:s,pct:i})=>e.jsxs("span",{children:[e.jsx("span",{className:`font-semibold ${Ye[s]??"text-slate-300"}`,children:s})," ",e.jsxs("span",{className:"text-slate-400",children:[i.toFixed(1),"%"]})]},s))})]})]})}function Ze(a){return a==null?"—":Array.isArray(a)?a.join(", "):typeof a=="object"?JSON.stringify(a):String(a)}function Je(){const[a,u]=h.useState(!0),{data:s,isLoading:i,error:m}=F({queryKey:["admin-waitlist"],queryFn:async()=>(await I.get("/api/admin/waitlist")).data}),_=s?.total??0,j=s?.responses??[];return e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50 cursor-pointer hover:bg-slate-700/70 transition-colors",onClick:()=>u(f=>!f),children:[a?e.jsx(V,{className:"w-4 h-4 text-slate-400"}):e.jsx(H,{className:"w-4 h-4 text-slate-400"}),e.jsx("h3",{className:"text-sm font-medium text-slate-300",children:"Waitlist"}),e.jsxs("span",{className:"text-xs text-slate-400",children:["(",_,")"]})]}
1),!a&&e.jsxs("div",{className:"px-4 py-3",children:[i&&e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(me,{className:"w-5 h-5 text-purple-500 animate-spin"})}),m&&e.jsx("p",{className:"text-red-400 text-sm text-center py-4",children:"Failed to load waitlist. Make sure TYPEFORM_TOKEN is set on the backend."}),!i&&!m&&j.length===0&&e.jsx("p",{className:"text-slate-500 text-sm text-center py-4",children:"No responses yet"}),!i&&!m&&j.length>0&&e.jsx("div",{className:"space-y-3",children:j.map(f=>e.jsxs("div",{className:"rounded border border-slate-700 bg-slate-800/40",children:[e.jsx("div",{className:"px-3 py-1.5 bg-slate-700/30 text-xs text-slate-400",children:new Date(f.submitted_at).toLocaleString()}),e.jsx("div",{className:"divide-y divide-slate-700/50",children:f.answers.map((N,b)=>e.jsxs("div",{className:"px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-xs text-slate-500 mb-0.5",children:N.question}),e.jsx("div",{className:"text-slate-200 whitespace-pre-wrap break-words",children:Ze(N.value)})]},b))})]},f.response_id))})]})]})}function Qe(){const[a,u]=h.useState(!0),[s,i]=h.useState(null),{data:m,isLoading:_,error:j}=F({queryKey:["admin-feature-requests"],queryFn:async()=>(await I.get("/api/admin/feature-requests")).data}),f=m?.items??[],N=m?.interviewed_count??0,b=s?f.find(y=>y.tag===s):null,w=y=>{const D=y,g=D?.tag??D?.payload?.tag;g&&i(E=>E===g?null:g)};return e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50 cursor-pointer hover:bg-slate-700/70 transition-colors",onClick:()=>u(y=>!y),children:[a?e.jsx(V,{className:"w-4 h-4 text-slate-400"}):e.jsx(H,{className:"w-4 h-4 text-slate-400"}),e.jsx("h3",{className:"text-sm font-medium text-slate-300",children:"Features wanted (Notion CRM)"}),e.jsxs("span",{className:"text-xs text-slate-400",children:["(",N," interviewed)"]})]}),!a&&e.jsxs("div",{className:"px-4 py-3",children:[_&&e.jsx("div",{className:"flex items-center justify-center py-6",children:e.jsx(me,{className:"w-5 h-5 text-purple-500 animate-spin"})}),j&&e.jsx("p",{className:"text-red-400 text-sm text-center py-4",children:"Failed to load. Check NOTION_TOKEN / NOTION_DATABASE_ID and that the integration is connected to the database."}),!_&&!j&&f.length===0&&e.jsx("p",{className:"text-slate-500 text-sm text-center py-4",children:"No tags yet"}),!_&&!j&&f.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"[&_*:focus]:outline-none",children:e.jsx(re,{width:"100%",height:Math.max(f.length*32,160),children:e.jsxs(ce,{data:f,layout:"vertical",margin:{left:16,right:16,top:4,bottom:4},children:[e.jsx(le,{strokeDasharray:"3 3",stroke:"#334155",horizontal:!1}),e.jsx(ie,{type:"number",allowDecimals:!1,tick:{fill:"#e2e8f0",fontSize:11}}),e.jsx(oe,{type:"category",dataKey:"tag",tick:{fill:"#e2e8f0",fontSize:12},width:160}),e.jsx(de,{cursor:!1,contentStyle:{backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:8},labelStyle:{color:"#e2e8f0"},formatter:y=>[`${y}`,"Requests"]}),e.jsx(xe,{dataKey:"count",fill:"#a855f7",radius:[0,2,2,0],activeBar:!1,onClick:w,style:{cursor:"pointer"}})]})})}),b&&e.jsxs("div",{className:"mt-3 rounded-lg border border-slate-700 bg-slate-800/50 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-slate-700/40 flex items-center justify-between",children:[e.jsxs("h4",{className:"text-xs font-medium text-slate-300",children:[b.tag," — ",b.count]}),e.jsx("button",{onClick:()=>i(null),className:"text-xs text-slate-500 hover:text-slate-300",children:"✕"})]}),(b.people??[]).length===0?e.jsx("div",{className:"px-3 py-3 text-xs text-slate-500",children:"No names"}):e.jsx("ul",{className:"divide-y divide-slate-700/50",children:(b.people??[]).map((y,D)=>e.jsx("li",{className:"px-3 py-1.5 text-sm text-slate-200",children:y},D))})]})]})]})]})}function ne(a){if(a<60)return`${a}s`;const u=Math.floor(a/60);if(u<60)return`${u}m`;const s=Math.floor(u/60),i=u%60;return i>0?`${s}h ${i}m`:`${s}h`}function O(a){return a==="fr"?"fr-FR":a==="es"?"es-ES":"en-GB"}function we(a,u){return a?new Date(a).toLocaleDateString(O(u),{day:"numeric",month:"long",year:"numeric"}):"—"}function et(a,u){if(!a)return"—";const s=Date.now()-new Date(a).getTime(),i=Math.floor(s/6e4);if(u==="fr"){if(i<60)return`il y a ${i} minute${i!==1?"s":""}`;const j=Math.floor(i/60);if(j<24)return`il y a ${j} heure${j!==1?"s":""}`;const f=Math.floor(j/24);return`il y a ${f} jour${f!==1?"s":""}`}if(u==="es"){if(i<60)return`hace ${i} minuto${i!==1?"s":""}`;const j=Math.floor(i/60);if(j<24)return`hace ${j} hora${j!==1?"s":""}`;const f=Math.floor(j/24);return`hace ${f} día${f!==1?"s":""}`}if(i<60)return`${i} minute${i!==1?"s":""} ago`;const m=Math.floor(i/60);if(m<24)return`${m} hour${m!==1?"s":""} ago`;const _=Math.floor(m/24);return`${_} day${_!==1?"s":""} ago`}function U(a){return a?a>=1e6?`${(a/1e6).toFixed(1)}
1M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a):"0"}function q(a){return a===0?"$0":`$${a.toFixed(2)}`}function ke(a){return a.replace("gemini-","").replace("-preview","")}const Se={diagram:"Position Scanner"},Ce={diagram:["diagram"]},De="2026-03-23",Me=Be.flatMap(a=>a.items).filter(({path:a})=>["/chess/app/payments","/chess/app/students","/chess/app/diagram"].includes(a)).map(({path:a,labelKey:u})=>({id:a.replace(/^\/chess\/app\//,""),labelKey:u}));function pt(){const{user:a,isLoading:u}=Ke(),{t:s,language:i}=Re(),[m,_]=h.useState(new Set),[j,f]=h.useState(null),[N,b]=h.useState("total_seconds"),[w,y]=h.useState("desc"),[D,g]=h.useState(!1),[E,K]=h.useState(null),[G,$e]=h.useState(!1),[v,Te]=h.useState(null),[he,Le]=h.useState(!1),[pe,Y]=h.useState(null),[$,Ae]=h.useState("created_at"),[L,ue]=h.useState("desc"),z=t=>{$===t?ue(n=>n==="asc"?"desc":"asc"):(Ae(t),ue("desc"))},Fe=t=>{_(n=>{const r=new Set(n);return r.has(t)?r.delete(t):r.add(t),r})},{data:k,isLoading:Ie,error:Ue}=F({queryKey:["admin-coach-users"],queryFn:async()=>(await I.get("/api/admin/coach-users")).data,enabled:!!a?.is_admin});h.useEffect(()=>{k?.users&&!he&&(_(new Set(k.users.filter(t=>t.id!==a?.id).map(t=>t.id))),Le(!0))},[k?.users,he,a?.id]);const T=h.useMemo(()=>{if(k?.users){if(m.size===0)return"";if(m.size!==k.users.length)return[...m].join(",")}},[m,k?.users]),X=h.useMemo(()=>{if(v)return v},[v]),Z=T==="",{data:fe}=F({queryKey:["admin-coach-time-spent",T],queryFn:async()=>{if(Z)return[];const t={};return T&&(t.user_ids=T),(await I.get("/api/admin/coach-time-spent",{params:t})).data.daily_stats},enabled:!!a?.is_admin}),{data:je}=F({queryKey:["admin-coach-time-spent-feature",T,X],queryFn:async()=>{if(Z||!X)return[];const t={pages:X};return T&&(t.user_ids=T),(await I.get("/api/admin/coach-time-spent",{params:t})).data.daily_stats},enabled:!!a?.is_admin&&!!v}),{data:M}=F({queryKey:["admin-api-usage",T],queryFn:async()=>{if(Z)return{history:[],by_model:[],by_feature:[],by_phase:[],invocations:[],daily_invocations:[],daily_invocations_by_user:[],total_cost_usd:0,pricing:{}};const t={};return T&&(t.user_ids=T),(await I.get("/api/admin/api-usage",{params:t})).data},enabled:!!a?.is_admin}),R=t=>{N===t?y(n=>n==="asc"?"desc":"asc"):(b(t),y("desc"))},P=h.useMemo(()=>k?.users?[...k.users].sort((t,n)=>{let r=0;switch(N){case"name":r=(t.name||"").localeCompare(n.name||"");break;case"created_at":r=new Date(t.created_at).getTime()-new Date(n.created_at).getTime();break;case"last_active":r=(t.last_active?new Date(t.last_active).getTime():0)-(n.last_active?new Date(n.last_active).getTime():0);break;case"total_seconds":r=t.total_seconds-n.total_seconds;break;case"session_count":r=(t.session_count||0)-(n.session_count||0);break;case"cost_usd":r=(t.cost_usd||0)-(n.cost_usd||0);break}return w==="asc"?r:-r}):[],[k?.users,N,w]),ye=t=>{const n=new Date().toISOString().split("T")[0],r=new Date(De),c=new Date(n),o={};(t||[]).forEach(d=>{o[d.activity_date]=d});const l=[],x=new Date(r);for(;x<=c;){const d=x.toISOString().split("T")[0],C=o[d];l.push({date:d,label:x.toLocaleDateString(O(i),{day:"numeric",month:"long"}),value:Math.round((C?.total_seconds||0)/60),by_user:(C?.by_user||[]).map(A=>({user_id:A.user_id,name:A.name,picture:A.picture,value:A.seconds}))}),x.setDate(x.getDate()+1)}return l},J=h.useMemo(()=>ye(fe),[fe,i]),ge=h.useMemo(()=>ye(je),[je,i]),{data:Q}=F({queryKey:["admin-coach-students"],queryFn:async()=>(await I.get("/api/admin/coach-students")).data.coaches,enabled:!!a?.is_admin&&v==="students"}),ee=h.useMemo(()=>{if(Q)return m.size===0?[]:Q.filter(t=>m.has(t.coach_user_id))},[Q,m]),p=h.useMemo(()=>{if(!M)return;if(!v)return M;const t=new Set,n=Ce[v];if(n&&n.forEach(o=>t.add(o)),t.size===0)return{...M,by_feature:[],by_model:[],by_phase:[],invocations:[],daily_invocations:[],daily_invocations_by_user:[],total_cost_usd:0};const r=M.invocations.filter(o=>t.has(o.feature)),c=new Map;for(const o of r)for(const l of o.models){const x=c.get(l.model_id);x?(x.call_count+=1,x.paid_count+=l.billing_tier==="paid"?1:0,x.free_count+=l.billing_tier==="free"?1:0,x.total_input+=l.input_tokens,x.total_output+=l.output_tokens,x.total_thinking+=l.thinking_tokens||0,x.error_count+=l.error?1:0,x.cost_usd+=l.cost_usd,x.avg_elapsed=Math.round((x.avg_elapsed*(x.call_count-1)+l.elapsed_seconds)/x.call_count)):c.set(l.model_id,{model_id:l.model_id,call_count:1,paid_count:l.billing_tier==="paid"?1:0,free_count:l.billing_tier==="free"?1:0,total_input:l.input_tokens,total_output:l.output_tokens,total_thinking:l.thinking_tokens||0,error_count:l.error?1:0,avg_elapsed:l.elapsed_seconds,cost_usd:l.cost_usd})}return{...M,by_feature:M.by_feature.filter(o=>t.has(o.feature)),by_model:[...c.values()],by_phase:t.has("diagram")?M.by_phase:[],invocations:r,daily_invocations:M.daily_invocations.filter(o=>t.has(o.feature)),daily_invocations_by_user:M.daily_invocations_by_user.filter(o=>t.has(o.feature)),total_cost_usd:M.by_feature.filter(o=>t.has(o.feature)).reduce((o,l)=>o+l.cost_usd,0)}},[M,v]),_e=h.useMemo(()=>{const t=p?.daily_invocations;if(!t||t.length===0)return[];const n=new Date().toISOString().split("T")[0],r={};t.forEach(d=>{r[d.date]=(r[d.date]||0)+d.count});const c={};
1(p?.daily_invocations_by_user||[]).forEach(d=>{c[d.date]||(c[d.date]=new Map);const C=c[d.date].get(d.user_id);C?C.value+=d.count:c[d.date].set(d.user_id,{user_id:d.user_id,name:d.user_name||"—",picture:d.user_picture,value:d.count})});const o=[],l=new Date(De),x=new Date(n);for(;l<=x;){const d=l.toISOString().split("T")[0],C=r[d]||0,A=c[d]?[...c[d].values()].sort((se,Ee)=>Ee.value-se.value):[];o.push({date:d,label:l.toLocaleDateString(O(i),{day:"numeric",month:"long"}),value:C,by_user:A}),l.setDate(l.getDate()+1)}return o},[p?.daily_invocations,p?.daily_invocations_by_user,i]),te=h.useMemo(()=>p?.invocations?[...new Set(p.invocations.map(t=>t.user_id).filter(t=>t!==null))]:[],[p]),{data:B}=F({queryKey:["admin-all-user-uploads",te],queryFn:async()=>{const t=new Map;return await Promise.all(te.map(async n=>{const r=await I.get(`/api/admin/user-uploads/${n}`);t.set(n,r.data.uploads||[])})),t},enabled:te.length>0}),qe=h.useMemo(()=>{if(!p?.invocations||!B)return new Map;const t=new Map,n=new Map;for(const r of[...p.invocations].sort((c,o)=>new Date(c.created_at).getTime()-new Date(o.created_at).getTime())){const c=`${r.user_id}_${r.feature}`,o=n.get(c)||[];o.push(r),n.set(c,o)}for(const[,r]of n){const c=r[0].user_id!=null?B.get(r[0].user_id):void 0;if(!c)continue;const o=r[0].feature;r.forEach((l,x)=>{const d=x+1,C=new RegExp(`^${o}_.*_${d}(?:_\\d{4}-\\d{2}-\\d{2}_\\d{2}h\\d{2})?\\.[a-z]+$`,"i"),A=c.find(se=>C.test(se.filename));A&&t.set(l.request_id,A)})}return t},[p,B]);if(!u&&(!a||!a.is_admin))return e.jsx(Pe,{to:"/chess/app",replace:!0});const ze=h.useMemo(()=>{if(!p?.invocations)return[];const t=[...p.invocations],n=L==="asc"?1:-1;return t.sort((r,c)=>{switch($){case"created_at":return n*(new Date(r.created_at).getTime()-new Date(c.created_at).getTime());case"user_name":return n*(r.user_name||"").localeCompare(c.user_name||"");case"feature":return n*r.feature.localeCompare(c.feature);case"model_count":return n*(r.model_count-c.model_count);case"tokens":return n*((r.total_input||0)+(r.total_output||0)-((c.total_input||0)+(c.total_output||0)));case"elapsed_seconds":return n*(r.elapsed_seconds-c.elapsed_seconds);case"cost_usd":return n*(r.cost_usd-c.cost_usd);default:return 0}})},[p?.invocations,$,L]);if(u||Ie)return e.jsx(ve,{title:s("coaches.navAdmin"),children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(me,{className:"w-8 h-8 text-purple-500 animate-spin"})})});const S=({active:t,direction:n})=>t?n==="asc"?e.jsx(H,{className:"w-3 h-3 inline ml-1"}):e.jsx(V,{className:"w-3 h-3 inline ml-1"}):null;return e.jsxs(ve,{title:s("coaches.navAdmin"),children:[e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(Xe,{}),e.jsx(Je,{}),e.jsx(Qe,{}),Ue?e.jsx("p",{className:"text-red-400 text-center py-8",children:s("coaches.admin.failedLoad")}):e.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-700",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-700/50 text-slate-400 text-xs uppercase tracking-wider cursor-pointer hover:bg-slate-700/70 transition-colors",onClick:()=>g(t=>!t),children:[e.jsx("th",{className:"w-8 px-2 py-2",children:e.jsx("div",{className:"flex items-center justify-center gap-1",children:D?e.jsx(V,{className:"w-5 h-5 text-slate-400"}):e.jsx(H,{className:"w-5 h-5 text-slate-400"})})}),e.jsx("th",{className:"px-3 py-2 text-left text-sm normal-case tracking-normal text-slate-300",colSpan:D?6:1,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:P.length>0&&m.size===P.length,ref:t=>{t&&(t.indeterminate=m.size>0&&m.size<P.length)},onChange:()=>{m.size===P.length?_(new Set):_(new Set(P.map(t=>t.id)))},onClick:t=>t.stopPropagation(),className:"rounded border-slate-600 bg-slate-700 text-blue-600 focus:ring-blue-500 focus:ring-offset-0 cursor-pointer w-3.5 h-3.5"}),e.jsxs("span",{children:[k?.total??0," ",(k?.total??0)===1?s("coaches.admin.user1"):s("coaches.admin.users")]}),m.size>0&&e.jsxs("span",{className:"text-blue-400",children:["(",m.size," selected)"]})]})}),!D&&e.jsxs(e.Fragment,{children:[e.jsxs("th",{className:"px-3 py-2 text-center cursor-pointer hover:text-slate-200",onClick:t=>{t.stopPropagation(),R("created_at")},children:[s("coaches.admin.joined")," ",e.jsx(S,{active:N==="created_at",direction:w})]}),e.jsxs("th",{className:"px-3 py-2 text-center cursor-pointer hover:text-slate-200",onClick:t=>{t.stopPropagation(),R("last_active")},children:[s("coaches.admin.lastActive")," ",e.jsx(S,{active:N==="last_active",direction:w})]}),e.jsxs("th",{className:"px-3 py-2 text-center cursor-pointer hover:text-slate-200",onClick:t=>{t.stopPropagation(),R("session_count")},children:[s("coaches.admin.sessions")," ",e.jsx(S,{active:N==="session_count",direction:w})]}),e.jsxs("th",{className:"px-3 py-2 text-center cursor-pointer hover:text-slate-200",onClick:t=>{t.stopPropagation(),R("total_seconds")},children:[s("coaches.admin.time")," ",e.jsx(S,{active:N==="total_seconds",direction:w})]}),e.jsxs("th",{className:"px-3 py-2 text-right cursor-pointer hover:text-slate-200",onClick:t=>{t.stopPropagation(),R("cost_usd")},children:["Cost ",e.jsx(S,{active:N==="cost_usd",direction:w})]})]})]})}),!D&&e.jsx("tbody",{className:"divide-y divide-slate-700/50",children:P.map(t=>e.jsxs(Ne.Fragment,{children:[e.jsxs("tr",{className:`hover:bg-slate-700/30 transition-colors cursor-pointer ${m.has(t.id)?"bg-slate-700/20":""}`,onClick:()=>K(n=>n===t.id?null:t.id),children:[e.jsx("td",{className:"px-2 py-2 text-center",children:e.jsx("input",{type:"checkbox",checked:m.has(t.id),onChange:()=>Fe(t.id),onClick:n=>n.stopPropagation(),className:"rounded border-slate-600 bg-slate-700 text-blue-600 focus:ring-blue-500 focus:ring-offset-0 cursor-pointer w-3.5 h-3.5"})}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{name:t.name||t.email,picture:t.picture,size:"sm+"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-slate-200 truncate",children:t.name||t.email}),e.jsx("p",{className:"text-slate-500 text-xs truncate",children:t.email})]})]})}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center whitespace-nowrap",children:we(t.created_at,i)}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center whitespace-nowrap",children:et(t.last_active,i)}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:t.session_count||0}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center whitespace-nowrap",children:ne(t.total_seconds)}),e.jsx("td",{className:"px-3 py-2 text-green-400 text-right whitespace-nowrap font-medium",children:q(t.cost_usd||0)})]}),E===t.id&&e.jsx("tr",{className:"bg-slate-800/50",children:e.jsx("td",{colSpan:8,className:"px-6 py-3",children:e.jsxs("div",{className:"flex gap-6 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500",children:"Chess.com: "}),e.jsx("span",{className:"text-slate-300",children:t.coaches_chess_username||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500",children:"Lichess: "}),e.jsx("span",{className:"text-slate-300",children:t.lichess_username||"—"})]})]})})})]},t.id))})]})}),J.length>0&&e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50 cursor-pointer hover:bg-slate-700/70 transition-colors",onClick:()=>$e(t=>!t),children:[G?e.jsx(V,{className:"w-5 h-5 text-slate-400"}):e.jsx(H,{className:"w-5 h-5 text-slate-400"}),e.jsx(be,{className:"w-4 h-4 text-slate-400"}),e.jsx("h3",{className:"text-sm font-medium text-slate-300",children:s("coaches.admin.dailyTimeSpent")})]}),!G&&e.jsx("div",{className:"p-4",children:e.jsx(ae,{data:J,color:"#16a34a",yTicks:(()=>{const t=Math.max(0,...J.map(r=>r.value)),n=Math.max(60,Math.ceil(t/60)*60);return Array.from({length:n/30+1},(r,c)=>c*30)})(),yDomain:[0,t=>Math.max(60,Math.ceil(t/60)*60)],tooltipUnit:"min",tooltipLabel:s("coaches.admin.time"),formatUserValue:t=>ne(t),formatDayValue:t=>`${t} min`})})]}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("select",{value:v||"",onChange:t=>Te(t.target.value||null),className:"bg-slate-700 text-slate-200 text-base rounded-lg px-5 py-3 border border-slate-600 focus:outline-none focus:border-blue-500",children:[e.jsx("option",{value:"",disabled:!0,hidden:!0,children:s("coaches.admin.selectFeature")}),Me.map(t=>e.jsx("option",{value:t.id,children:s(t.labelKey)},t.id))]})}),v&&ge.length>0&&e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50",children:[e.jsx(be,{className:"w-4 h-4 text-slate-400"}),e.jsxs("h3",{className:"text-sm font-medium text-slate-300",children:[s(Me.find(t=>
1t.id===v)?.labelKey||"")," — ",s("coaches.admin.dailyTimeSpent")]})]}),e.jsx("div",{className:"p-4",children:e.jsx(ae,{data:ge,color:"#8b5cf6",height:180,tooltipUnit:"min",tooltipLabel:s("coaches.admin.time"),formatUserValue:t=>ne(t),formatDayValue:t=>`${t} min`})})]}),v==="students"&&ee&&e.jsxs("div",{className:"space-y-4",children:[(()=>{const t=ee.flatMap(d=>d.students.map(C=>C.created_at?new Date(C.created_at).toISOString().split("T")[0]:"")).filter(Boolean).sort();if(t.length===0)return null;const n=new Date(t[0]),r=new Date,c={};t.forEach(d=>{c[d]=(c[d]||0)+1});const o=[],l=new Date(n);let x=0;for(;l<=r;){const d=l.toISOString().split("T")[0];x+=c[d]||0,o.push({date:d,label:l.toLocaleDateString(O(i),{day:"numeric",month:"short"}),total:x}),l.setDate(l.getDate()+1)}return e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsx("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50",children:e.jsx("h3",{className:"text-sm font-medium text-slate-300",children:"Total students over time"})}),e.jsx("div",{className:"p-4",children:e.jsx(re,{width:"100%",height:180,children:e.jsxs(ce,{data:o,children:[e.jsx(le,{strokeDasharray:"3 3",stroke:"#334155"}),e.jsx(ie,{dataKey:"label",tick:{fill:"#e2e8f0",fontSize:11},angle:-45,textAnchor:"end",height:60,interval:0}),e.jsx(oe,{tick:{fill:"#e2e8f0",fontSize:13},allowDecimals:!1}),e.jsx(de,{cursor:!1,contentStyle:{backgroundColor:"#1e293b",border:"1px solid #334155",borderRadius:8},labelStyle:{color:"#e2e8f0"},formatter:d=>[`${d}`,"Students"]}),e.jsx(xe,{dataKey:"total",fill:"#8b5cf6",radius:[2,2,0,0],activeBar:!1,name:"Total students"})]})})})]})})(),ee.map(t=>e.jsxs("div",{className:"rounded-lg border border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-slate-700/50",children:[e.jsx(W,{name:t.coach_name||"?",picture:t.coach_picture,size:"sm"}),e.jsx("h4",{className:"text-sm font-medium text-slate-300",children:t.coach_name}),e.jsxs("span",{className:"text-xs text-slate-500",children:["(",t.students.length," students)"]})]}),e.jsx("div",{className:"divide-y divide-slate-700/50",children:t.students.map((n,r)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-sm",children:[e.jsx("span",{className:"text-slate-200",children:n.name}),e.jsx("span",{className:"text-xs text-slate-500",children:we(n.created_at,i)})]},r))})]},t.coach_user_id))]}),p&&v&&e.jsxs("div",{className:"bg-slate-700/30 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(We,{className:"w-4 h-4 text-purple-400"}),e.jsx("h3",{className:"text-sm font-medium text-slate-300",children:s("coaches.admin.geminiUsage")})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-green-400 font-medium",children:q(p.total_cost_usd)}),e.jsx("span",{className:"text-slate-500",children:s("coaches.admin.total")})]}),e.jsx("a",{href:"https://aistudio.google.com/spend",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-slate-500 hover:text-slate-300 transition-colors",children:s("coaches.admin.googleBilling")})]})]}),p.by_feature.length>0&&e.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-600/50",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-700/50 text-slate-400 text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 text-left",children:s("coaches.admin.feature")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.uses")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.tokens")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.avgTime")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.avgCost")}),e.jsx("th",{className:"px-3 py-2 text-right",children:s("coaches.admin.cost")})]})}),e.jsx("tbody",{className:"divide-y divide-slate-700/50",children:p.by_feature.map(t=>{const n=p.invocations.filter(o=>o.feature===t.feature),r=t.invocation_count||n.length||t.call_count,c=n.length>0?Math.round(n.reduce((o,l)=>o+l.elapsed_seconds,0)/n.length):0;return e.jsxs("tr",{className:"hover:bg-slate-700/30",children:[e.jsx("td",{className:"px-3 py-2 text-slate-200",children:Se[t.feature]||t.feature}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:r}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:U((t.total_input||0)+(t.total_output||0))}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:c>0?`${c}s`:"—"}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:r>0?q(t.cost_usd/r):"—"}),e.jsx("td",{className:"px-3 py-2 text-green-400 text-right font-medium",children:q(t.cost_usd)})]},t.feature)})})]})}),_e.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs text-slate-500 mb-2",children:s("coaches.admin.imagesProcessed")}),e.jsx(ae,{data:_e,color:"#8b5cf6",height:160,tooltipUnit:"",tooltipLabel:s("coaches.admin.images"),formatUserValue:t=>`${t}`,formatDayValue:t=>`${t} ${s("coaches.admin.images").toLowerCase()}`})]}),p.by_model.length>0&&e.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-600/50",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-700/50 text-slate-400 text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 text-left",children:s("coaches.admin.model")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.calls")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.paid")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.free")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.input")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.output")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.thinking")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.avgTime")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.errors")}),e.jsx("th",{className:"px-3 py-2 text-right",children:s("coaches.admin.cost")})]})}),e.jsx("tbody",{className:"divide-y divide-slate-700/50",children:p.by_model.map(t=>e.jsxs("tr",{className:"hover:bg-slate-700/30",children:[e.jsx("td",{className:"px-3 py-2 text-slate-200 font-mono text-xs",children:ke(t.model_id)}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:t.call_count}),e.jsx("td",{className:"px-3 py-2 text-center",children:t.paid_count>0?e.jsx("span",{className:"text-slate-300",children:t.paid_count}):e.jsx("span",{className:"text-slate-600",children:"0"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:t.free_count>0?e.jsx("span",{className:"text-emerald-400",children:t.free_count}):e.jsx("span",{className:"text-slate-600",children:"0"})}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:U(t.total_input)}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:U(t.total_output)}),e.jsx("td",{className:"px-3 py-2 text-center",children:t.total_thinking?e.jsx("span",{className:"text-amber-400",children:U(t.total_thinking)}):e.jsx("span",{className:"text-slate-600",children:"0"})}),e.jsxs("td",{className:"px-3 py-2 text-slate-400 text-center",children:[t.avg_elapsed,"s"]}),e.jsx("td",{className:"px-3 py-2 text-center",children:t.error_count>0?e.jsx("span",{className:"text-red-400",children:t.error_count}):e.jsx("span",{className:"text-slate-600",children:"0"})}),e.jsx("td",{className:"px-3 py-2 text-green-400 text-right font-medium",children:q(t.cost_usd)})]},t.model_id))})]})}),p.by_phase.length>0&&e.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-600/50",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-700/50 text-slate-400 text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 text-left",children:s("coaches.admin.phase")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.calls")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.avgTime")}),e.jsx("th",{className:"px-3 py-2 text-center",children:s("coaches.admin.errors")})]})}),e.jsx("tbody",{className:"divide-y divide-slate-700/50",children:p.by_phase.map(t=>e.jsxs("tr",{className:"hover:bg-slate-700/30",children:[e.jsx("td",{className:"px-3 py-2 text-slate-200 font-mono text-xs",children:t.phase}),e.jsx("td",{className:"px-3 py-2 text-slate-400 text-center",children:t.call_count}),e.jsxs("td",{className:"px-3 py-2 text-slate-400 text-center",children:[t.avg_elapsed,"s"]}),e.jsx("td",{className:"px-3 py-2 text-center",children:t.error_count>0?e.jsx("span",{className:"text-red-400",children:t.error_count}):e.jsx("span",{className:"text-slate-600",children:"0"})})]},t.phase))})]})}),p.invocations.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs text-slate-500 mb-2",children:[s("coaches.admin.history")," (",p.invocations.length," ",s("coaches.admin.invocations"),")"]}),e.jsx("div",{className:"max-h-64 overflow-y-auto rounded-lg border border-slate-600/50",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 z-10 select-none",children:e.jsxs("tr",{className:"bg-slate-700 text-slate-400 uppercase tracking-wider",children:[e.jsxs("th",{className:"px-2 py-1.5 text-left cursor-pointer hover:text-slate-200",onClick:()=>z("created_at"),children:[s("coaches.admin.time"),e.jsx(S,{active:$==="created_at",direction:L})]}),e.jsxs("th",{className:"px-2 py-1.5 text-left cursor-pointer hover:text-slate-200",onClick:()=>z("user_name"),children:[s("coaches.admin.user"),e.jsx(S,{active:$==="user_name",direction:L})]}),e.jsxs("th",{className:"px-2 py-1.5 text-left cursor-pointer hover:text-slate-200",onClick:()=>z("feature"),children:[s("coaches.admin.feature"),e.jsx(S,{active:$==="feature",direction:L})]}),e.jsxs("th",{className:"px-2 py-1.5 text-center cursor-pointer hover:text-slate-200",onClick:()=>z("model_count"),children:[s("coaches.admin.models"),e.jsx(S,{active:$==="model_count",direction:L})]}),e.jsxs("th",{className:"px-2 py-1.5 text-center cursor-pointer hover:text-slate-200",onClick:()=>z("tokens"),children:[s("coaches.admin.tokens"),e.jsx(S,{active:$==="tokens",direction:L})]}),e.jsxs("th",{className:"px-2 py-1.5 text-center cursor-pointer hover:text-slate-200",onClick:()=>z("elapsed_seconds"),children:[s("coaches.admin.time"),e.jsx(S,{active:$==="elapsed_seconds",direction:L})]}),e.jsxs("th",{className:"px-2 py-1.5 text-right cursor-pointer hover:text-slate-200",onClick:()=>z("cost_usd"),children:[s("coaches.admin.cost"),e.jsx(S,{active:$==="cost_usd",direction:L})]})]})}),e.jsx("tbody",{className:"divide-y divide-slate-700/30",children:ze.map(t=>{const n=j===t.request_id,r=qe?.get(t.request_id);return e.jsxs(Ne.Fragment,{children:[e.jsxs("tr",{className:`hover:bg-slate-700/20 cursor-pointer ${t.error_count>=t.model_count?"bg-red-900/10":""}`,onClick:()=>f(n?null:t.request_id),children:[e.jsxs("td",{className:"px-2 py-1 text-slate-500 
1whitespace-nowrap",children:[new Date(t.created_at).toLocaleDateString(O(i),{day:"numeric",month:"short"})," ",new Date(t.created_at).toLocaleTimeString(O(i),{hour:"2-digit",minute:"2-digit"})]}),e.jsx("td",{className:"px-2 py-1 text-slate-400",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(W,{name:t.user_name||"?",picture:t.user_picture,size:"xs"}),e.jsx("span",{className:"truncate max-w-[80px]",children:t.user_name?.split(" ")[0]||"—"})]})}),e.jsx("td",{className:"px-2 py-1 text-slate-300",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:Se[t.feature]||t.feature}),t.free_count>0&&e.jsxs("span",{className:"text-[10px] text-emerald-400 bg-emerald-400/10 px-1 rounded",children:[t.free_count," ",s("coaches.admin.free").toLowerCase()]}),r&&e.jsx("span",{className:"text-[10px] text-blue-400 hover:text-blue-300 cursor-zoom-in",onClick:c=>{c.stopPropagation(),Y(`/api/admin/user-uploads/${t.user_id}/${r.filename}`)},children:r.filename})]})}),e.jsx("td",{className:"px-2 py-1 text-slate-400 text-center",children:t.model_count}),e.jsx("td",{className:"px-2 py-1 text-slate-400 text-center",children:U((t.total_input||0)+(t.total_output||0))}),e.jsxs("td",{className:"px-2 py-1 text-slate-400 text-center",children:[t.elapsed_seconds,"s"]}),e.jsx("td",{className:"px-2 py-1 text-right",children:t.error_count>=t.model_count?e.jsxs("span",{className:"text-red-400 flex items-center justify-end gap-1",children:[e.jsx(He,{className:"w-3 h-3"}),q(t.cost_usd)]}):e.jsx("span",{className:"text-green-400",children:q(t.cost_usd)})})]}),n&&t.models&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-2 py-2 bg-slate-800/50",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-slate-500 text-[10px] uppercase",children:[e.jsx("th",{className:"px-2 py-1 text-left",children:s("coaches.admin.model")}),e.jsx("th",{className:"px-2 py-1 text-center",children:s("coaches.admin.tier")}),e.jsx("th",{className:"px-2 py-1 text-center",children:s("coaches.admin.retry")}),e.jsx("th",{className:"px-2 py-1 text-center",children:s("coaches.admin.input")}),e.jsx("th",{className:"px-2 py-1 text-center",children:s("coaches.admin.output")}),e.jsx("th",{className:"px-2 py-1 text-center",children:s("coaches.admin.thinking")}),e.jsx("th",{className:"px-2 py-1 text-center",children:s("coaches.admin.time")}),e.jsx("th",{className:"px-2 py-1 text-right",children:s("coaches.admin.cost")})]})}),e.jsx("tbody",{children:t.models.map((c,o)=>e.jsxs("tr",{className:c.error?"text-red-400/70":"",children:[e.jsx("td",{className:"px-2 py-0.5 font-mono",children:ke(c.model_id)}),e.jsx("td",{className:"px-2 py-0.5 text-center",children:c.retry_free_error?e.jsxs("span",{title:c.retry_free_error,children:[e.jsx("span",{className:"text-red-400/70 line-through",children:s("coaches.admin.free").toLowerCase()}),e.jsx("span",{className:"text-slate-600 mx-0.5",children:"→"}),e.jsx("span",{className:"text-slate-500",children:s("coaches.admin.paid").toLowerCase()})]}):c.billing_tier==="free"?e.jsx("span",{className:"text-emerald-400",children:s("coaches.admin.free").toLowerCase()}):e.jsx("span",{className:"text-slate-500",children:s("coaches.admin.paid").toLowerCase()})}),e.jsx("td",{className:"px-2 py-0.5 text-center",children:c.retry_free_error?e.jsxs("span",{className:"text-yellow-400",title:c.retry_free_error,children:[s("coaches.admin.free").toLowerCase()," ",c.retry_free_elapsed,"s"]}):e.jsx("span",{className:"text-slate-600",children:"—"})}),e.jsx("td",{className:"px-2 py-0.5 text-slate-400 text-center",children:U(c.input_tokens)}),e.jsx("td",{className:"px-2 py-0.5 text-slate-400 text-center",children:U(c.output_tokens)}),e.jsx("td",{className:"px-2 py-0.5 text-center",children:c.thinking_tokens?e.jsx("span",{className:"text-amber-400",children:U(c.thinking_tokens)}):e.jsx("span",{className:"text-slate-600",children:"0"})}),e.jsxs("td",{className:"px-2 py-0.5 text-slate-400 text-center",children:[c.elapsed_seconds,"s"]}),e.jsx("td",{className:"px-2 py-0.5 text-right",children:c.error?e.jsx("span",{className:"text-red-400",children:"err"}):e.jsx("span",{className:"text-green-400",children:q(c.cost_usd)})})]},o))})]})})})]},t.request_id)})})]})})]}),B&&[...B.entries()].map(([t,n])=>{const r=v?Ce[v]||[]:[],c=r.length>0?n.filter(l=>r.some(x=>l.filename.toLowerCase().startsWith(x))):n;if(c.length===0)return null;const o=k?.users.find(l=>l.id===t)?.name||`User ${t}`;return e.jsxs("div",{children:[e.jsxs("h4",{className:"text-base font-semibold text-white mb-2",children:[o," ",e.jsxs("span",{className:"text-white font-normal",children:["(",c.length,")"]})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:c.map(l=>{const x=`/api/admin/user-uploads/${t}/${l.filename}`;return e.jsxs("div",{className:"flex flex-col items-center gap-1 rounded border border-slate-600 hover:border-blue-500 overflow-hidden transition-colors p-1 group relative",children:[e.jsx("img",{src:x,alt:l.filename,className:"w-16 h-16 object-cover flex-shrink-0 rounded cursor-zoom-in",onClick:()=>Y(x)}),e.jsx("span",{className:"text-[10px] text-slate-400",children:l.filename}),e.jsx("a",{href:x,download:l.filename,className:"text-[9px] text-blue-400 hover:text-blue-300 transition-colors",children:"Download"})]},l.filename)})})]},t)}),p.by_model.length===0&&e.jsx("p",{className:"text-slate-500 text-sm text-center py-4",children:"No API calls recorded yet"})]})]}),pe&&e.jsx(Ve,{src:pe,alt:"Upload",onClose:()=>Y(null)})]})}export{pt as AdminPanel};

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.