PageSourceSearch

https://ytprompt.ai/assets/AdminFlowVeoTokens-CkTMLAtF.js

js ytprompt.ai collected 2026-10-05 14:49:01 UTC 223,535 bytes, 94 lines download raw bytes

1import{j as e}from"./vendor-markdown-Bj2spg3f.js";import{r as i}from"./vendor-react-B-0p-RVf.js";import{b as f}from"./index-45gJDKBt.js";import{I as ti,aa as L,aU as Bs,m as at,ag as B,af as ae,aW as Sn,aB as qr,q as We,ap as rt,a_ as Is,v as wn,O as y,c as Fe,Z as _n,b2 as qt,a8 as es,ae as Ne,ak as ts,an as si,bn as Lr,W as Er,t as ss,bl as ni,bm as oi,n as Pe,E as jt,S as Dr,a0 as nt,aj as Te,aX as ot,b6 as zn,C as ns,a as os,bc as Rn,b4 as Cn,bo as $r,bp as Fr,au as ii,y as Nr}from"./vendor-icons-D-5f6XKt.js";import{a as Pr}from"./Pagination-YjWvfJrB.js";import"./vendor-misc-D0V4jby4.js";import"./vendor-i18n-D8j9R6P3.js";const it="#8B5CF6";function Mr({token:w,onClose:xe}){const[K,M]=i.useState(""),[A,ue]=i.useState(null),[V,Ie]=i.useState(""),[g,Z]=i.useState(!1),[I,ge]=i.useState(null),[he,S]=i.useState("input"),[As,lt]=i.useState([]),Me=i.useRef(null),He=i.useRef(null),dt=w?.email||`token-${w?.id}`,is=C=>{const z=C.target.files?.[0];if(!z)return;const O=new FileReader;O.onload=W=>{ue(W.target.result),Ie(W.target.result.split(",")[1])},O.readAsDataURL(z)},kt=async()=>{if(!K.trim())return;Z(!0),ge(null),lt([]),S("logs");const C={prompt:K.trim()};V&&(C.image_base64=V);try{const z=localStorage.getItem("token"),O=await fetch(`/api/admin/flow-veo-tokens/${w.id}/test`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${z}`},body:JSON.stringify(C)});if(!O.ok){const le=await O.text();let be=`HTTP ${O.status}`;try{be=JSON.parse(le).detail||be}catch{}ge({success:!1,error:be,logs:[`[0s] ${be}`],duration:0}),Z(!1);return}const W=O.body.getReader(),Be=new TextDecoder;let F="";const Lt=[];let q=null;for(;;){const{done:le,value:be}=await W.read();if(le)break;F+=Be.decode(be,{stream:!0});const ct=F.split(`
2`);F=ct.pop()||"";for(const vt of ct){if(!vt.startsWith("data: "))continue;const St=vt.slice(6).trim();if(St)try{const Ae=JSON.parse(St);Ae.type==="log"?(lt(Ue=>[...Ue,Ae.message]),setTimeout(()=>He.current?.scrollIntoView({behavior:"smooth"}),50)):Ae.type==="output_chunk"?Lt.push(Ae.chunk):Ae.type==="result"&&(q=Ae,Ae.output_chunked&&(q.output=Lt.join("")),delete q.type,delete q.output_chunked,ge(q),q.success&&S("output"))}catch{}}}q||ge({success:!1,error:"Stream ended without result",logs:[],duration:0})}catch(z){ge({success:!1,error:z.message||"Request failed",logs:[`[0s] ${z.message}`],duration:0})}finally{Z(!1)}},Oe=()=>{if(!I?.output)return;const C=atob(I.output),z=new Uint8Array(C.length);for(let F=0;F<C.length;F++)z[F]=C.charCodeAt(F);const O=new Blob([z],{type:"video/mp4"}),W=URL.createObjectURL(O),Be=document.createElement("a");Be.href=W,Be.download=`flow_veo_test_${w.id}.mp4`,Be.click(),URL.revokeObjectURL(W)},qs=C=>navigator.clipboard.writeText(C).catch(()=>{}),G={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:16},modal:{background:"var(--card-bg, #fff)",borderRadius:18,width:"100%",maxWidth:800,maxHeight:"95vh",display:"flex",flexDirection:"column",border:"1px solid var(--border, #e5e7eb)",boxShadow:"0 20px 60px rgba(0,0,0,0.4)",overflow:"hidden"},header:{padding:"20px 24px",borderBottom:"1px solid var(--border, #e5e7eb)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},body:{flex:1,overflow:"auto",padding:0},tab:C=>({padding:"10px 18px",border:"none",borderBottom:C?`2px solid ${it}`:"2px solid transparent",cursor:"pointer",fontSize:13,fontWeight:600,background:"none",color:C?"var(--text, #111)":"var(--text-muted, #6b7280)",display:"flex",alignItems:"center",gap:6,transition:"all 0.15s"}),input:{width:"100%",padding:"10px 14px",borderRadius:8,border:"1px solid var(--border, #e5e7eb)",background:"var(--bg, #f9fafb)",color:"var(--text, #111)",fontSize:13,outline:"none",boxSizing:"border-box",fontFamily:"inherit",resize:"vertical"}},$=I?.logs||As;return e.jsxs("div",{style:G.overlay,onClick:C=>C.target===C.currentTarget&&!g&&xe(),children:[e.jsxs("div",{style:G.modal,children:[e.jsxs("div",{style:G.header,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${it}22`,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(ti,{size:18,color:it})}),e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:800,color:"var(--text, #111)"},children:"Playground: Google Flow VEO"}),e.jsxs("span",{style:{fontSize:12,color:"var(--text-muted, #6b7280)"},children:[dt," · flow_veo · video"]})]})]}),e.jsx("button",{onClick:()=>!g&&xe(),style:{background:"none",border:"none",cursor:g?"not-allowed":"pointer",color:"var(--text-muted, #6b7280)",padding:4},children:e.jsx(L,{size:20})})]}),e.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--border, #e5e7eb)",flexShrink:0,background:"var(--bg, #f9fafb)"},children:[e.jsxs("button",{style:G.tab(he==="input"),onClick:()=>S("input"),children:[e.jsx(Bs,{size:14})," Input"]}),e.jsxs("button",{style:G.tab(he==="logs"),onClick:()=>S("logs"),children:[e.jsx(at,{size:14})," Logs",$.length>0&&e.jsx("span",{style:{fontSize:10,background:`${it}22`,color:it,borderRadius:20,padding:"1px 6px",fontWeight:700},children:$.length})]}),e.jsxs("button",{style:G.tab(he==="output"),onClick:()=>S("output"),children:[e.jsx(ti,{size:14})," Output",I?.success&&e.jsx(B,{size:12,color:"#10B981"}),I&&!I.success&&e.jsx(ae,{size:12,color:"#EF4444"})]})]}),e.jsxs("div",{style:G.body,children:[he==="input"&&e.jsxs("div",{style:{padding:24},children:[e.jsx("div",{style:{padding:"10px 14px",borderRadius:8,background:`${it}08`,border:`1px solid ${it}22`,marginBottom:20,fontSize:13,color:"var(--text-muted, #6b7280)"},children:"Enter a text prompt to generate a video. Optionally upload a reference image for image-to-vi
2deo."}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsxs("label",{style:{fontSize:12,fontWeight:600,color:"var(--text, #111)",marginBottom:6,display:"block"},children:["Text Prompt ",e.jsx("span",{style:{color:"#EF4444"},children:"*"})]}),e.jsx("textarea",{style:{...G.input,minHeight:100},value:K,onChange:C=>M(C.target.value),placeholder:"A calm ocean with gentle waves and a beautiful sunset, cinematic camera movement",disabled:g}),!K&&e.jsx("button",{onClick:()=>M("A calm ocean with gentle waves and a beautiful sunset, cinematic camera movement"),style:{marginTop:6,padding:"4px 10px",borderRadius:6,border:"1px solid var(--border, #e5e7eb)",background:"none",cursor:"pointer",fontSize:11,color:"var(--text-muted, #6b7280)"},children:"Use example prompt"})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{fontSize:12,fontWeight:600,color:"var(--text, #111)",marginBottom:6,display:"block"},children:"Reference Image (optional)"}),e.jsx("input",{type:"file",accept:"image/*",ref:Me,onChange:is,style:{display:"none"}}),A?e.jsxs("div",{style:{position:"relative",display:"inline-block"},children:[e.jsx("img",{src:A,alt:"Preview",style:{maxWidth:300,maxHeight:200,borderRadius:10,border:"1px solid var(--border, #e5e7eb)"}}),e.jsx("button",{onClick:()=>{ue(null),Ie(""),Me.current&&(Me.current.value="")},style:{position:"absolute",top:6,right:6,width:24,height:24,borderRadius:"50%",background:"rgba(0,0,0,0.7)",border:"none",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:e.jsx(L,{size:14})})]}):e.jsxs("button",{onClick:()=>Me.current?.click(),disabled:g,style:{padding:"28px 40px",borderRadius:10,border:"2px dashed var(--border, #e5e7eb)",background:"var(--bg, #f9fafb)",cursor:"pointer",color:"var(--text-muted, #6b7280)",display:"flex",flexDirection:"column",alignItems:"center",gap:8,width:"100%"},children:[e.jsx(Bs,{size:24}),e.jsx("span",{style:{fontSize:13,fontWeight:600},children:"Click to upload image"}),e.jsx("span",{style:{fontSize:11},children:"PNG, JPG up to 10MB"})]})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",paddingTop:8},children:e.jsx("button",{onClick:kt,disabled:g||!K.trim(),style:{padding:"10px 22px",borderRadius:8,border:"none",background:it,color:"#fff",cursor:g||!K.trim()?"not-allowed":"pointer",fontWeight:700,fontSize:14,display:"flex",alignItems:"center",gap:8,opacity:g||!K.trim()?.7:1},children:g?e.jsxs(e.Fragment,{children:[e.jsx(Sn,{size:16,style:{animation:"spin 1s linear infinite"}})," Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx(qr,{size:16})," Run Test"]})})})]}),he==="logs"&&e.jsxs("div",{children:[e.jsxs("div",{style:{background:"#0d1117",color:"#c9d1d9",fontFamily:'"JetBrains Mono", "Fira Code", monospace',fontSize:12,lineHeight:1.7,minHeight:300,padding:"16px 20px",overflowX:"auto"},children:[$.length===0&&!g&&e.jsx("div",{style:{color:"#484f58",fontStyle:"italic",padding:"40px 0",textAlign:"center"},children:"No logs yet. Run a test to see execution logs here."}),g&&$.length===0&&e.jsxs("div",{style:{color:"#f0883e",display:"flex",alignItems:"center",gap:8},children:[e.jsx(Sn,{size:14,style:{animation:"spin 1s linear infinite"}})," Running test..."]}),$.map((C,z)=>{const O=/error|fail|traceback/i.test(C),W=/success/i.test(C);return e.jsxs("div",{style:{color:O?"#f85149":W?"#3fb950":"#c9d1d9",borderLeft:`2px solid ${O?"#f8514944":W?"#3fb95044":"#30363d"}`,paddingLeft:10,marginBottom:2},children:[e.jsx("span",{style:{color:"#484f58",marginRight:8,userSelect:"none"},children:String(z+1).padStart(2,"0")}),C]},z)}),g&&$.length>0&&e.jsxs("div",{style:{color:"#f0883e",display:"flex",alignItems:"center",gap:8,marginTop:4},children:[e.jsx(Sn,{size:14,style:{animation:"spin 1s linear infinite"}})," Processing..."]}),e.jsx("div",{ref:He})]}),I&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid #21262d",background:"#161b22",display:"flex",alignItems:"center",gap:16,flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[I.success?e.jsx(B,{size:14,color:"#3fb950"}):e.jsx(ae,{size:14,color:"#f85149"}),e.jsx("span",{style:{fontSize:12,fontWeight:700,color:I.success?"#3fb950":"#f85149"},children:I.success?"PASSED":"FAILED"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"#8b949e",fontSize:12},children:[e.jsx(We,{size:12})," ",I.duration,"s"]}),$.length>0&&e.jsxs("button",{onClick:()=>qs($.join(`
3`)),style:{marginLeft:"auto",padding:"4px 10px",borderRadius:6,border:"1px solid #30363d",background:"none",cursor:"pointer",color:"#8b949e",fontSize:11,display:"flex",alignItems:"center",gap:4},children:[e.jsx(rt,{size:11})," Copy Logs"]})]})]}),he==="output"&&e.jsxs("div",{style:{padding:24},children:[!I&&e.jsxs("div",{style:{textAlign:"center",padding:"60px 0",color:"var(--text-muted, #6b7280)"},children:[e.jsx(at,{size:40,style:{opacity:.2,marginBottom:12}}),e.jsx("p",{style:{margin:0,fontSize:14},children:"No output yet. Run a test first."})]}),I&&!I.success&&e.jsxs("div",{style:{padding:"16px 20px",borderRadius:10,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(ae,{size:16,color:"#EF4444"}),e.jsx("span",{style:{fontWeight:700,color:"#EF4444",fontSize:14},children:"Test Failed"}),e.jsxs("span",{style:{marginLeft:"auto",fontSize:12,color:"var(--text-muted, #6b7280)"},children:[I.duration,"s"]})]}),e.jsx("p",{style:{margin:0,fontSize:13,color:"#EF4444",wordBreak:"break-word"},children:I.error})]}),I?.success&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(B,{size:16,color:"#10B981"}),e.jsx("span",{style:{fontWeight:700,color:"#10B981",fontSize:14},children:"Video Generated"}),e.jsxs("span",{style:{fontSize:12,color:"var(--text-muted, #6b7280)"},children:[I.duration,"s"]})]}),e.jsxs("button",{onClick:Oe,style:{padding:"5px 12px",borderRadius:6,border:"1px solid var(--border, #e5e7eb)",background:"none",cursor:"pointer",color:"var(--text-muted, #6b7280)",fontSize:12,display:"flex",alignItems:"center",gap:4},children:[e.jsx(Is,{size:12})," Download"]})]}),e.jsx("div",{style:{textAlign:"center",padding:16,background:"var(--bg, #f9fafb)",borderRadius:10,border:"1px solid var(--border, #e5e7eb)"},children:e.jsx("video",{controls:!0,style:{maxWidth:"100%",maxHeight:400,borderRadius:8},src:`data:video/mp4;base64,${I.output}`})})]})]})]})]}),e.jsx("style",{children:"@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"})]})}function Hr(w){if(!w)return"—";const xe=w.includes("Z")||w.includes("+")?w:w+"Z",K=new Date(xe),M=Math.floor((Date.now()-K.getTime())/1e3);return M<60?`${M}s ago`:M<3600?`${Math.floor(M/60)}m ago`:M<86400?`${Math.floor(M/3600)}h ago`:M<2592e3?`${Math.floor(M/86400)}d ago`:M<31536e3?`${Math.floor(M/2592e3)}mo ago`:`${Math.floor(M/31536e3)}y ago`}function Or(w){if(!w)return"";const xe=w.includes("Z")||w.includes("+")?w:w+"Z";
3return new Date(xe).toLocaleString()}function Ur(w){if(!w)return{label:"—",color:"#6b7280",expired:!1,countdown:!1};const xe=w.includes("Z")||w.includes("+")?w:w+"Z",A=new Date(xe)-new Date;if(A<=0)return{label:"Expired",color:"#ef4444",expired:!0,countdown:!1};const ue=Math.floor(A/1e3),V=Math.floor(ue/60),Ie=Math.floor(ue/3600),g=Math.floor(ue/86400);if(V<60){const Z=String(V).padStart(2,"0"),I=String(ue%60).padStart(2,"0");return{label:`${Z}:${I}`,color:V<10?"#ef4444":"#f59e0b",expired:!1,countdown:!0}}return Ie<24?{label:`${Ie}h ${V%60}m left`,color:"#22c55e",expired:!1,countdown:!1}:{label:`${g}d ${Ie%24}h left`,color:"#22c55e",expired:!1,countdown:!1}}function oa(){const[w,xe]=i.useState(10),[K,M]=i.useState([]),[A,ue]=i.useState({total:0,active:0,inactive:0,total_generated:0,all_time_generated:0,today_generated:0,today_failed:0,all_time_failed:0,inactive_counts:{},all_tags:[]}),[V,Ie]=i.useState(0),[g,Z]=i.useState({pending:0,active:0,failed:0,worker_count:0,remote_worker_count:0,configured_concurrency:60}),[I,ge]=i.useState(!0),[he,S]=i.useState(null),[As,lt]=i.useState(!1),[Me,He]=i.useState({tokens:""}),[dt,is]=i.useState(!1),[kt,Oe]=i.useState(null),[qs,G]=i.useState(!1),[$,C]=i.useState(null),[z,O]=i.useState(!1),[W,Be]=i.useState({chunk:0,totalChunks:0,added:0,updated:0,skipped:0,errors:[]}),[F,Lt]=i.useState(!1),[q,le]=i.useState({open:!1,fetched:0,total:0,status:"",error:null,cancel:!1,doneFile:null}),be=i.useRef(!1),[ct,vt]=i.useState(!1),[St,Ae]=i.useState("all"),[Ue,Tn]=i.useState(!1),Ls=i.useRef(null),Wn=i.useRef(null),[In,ri]=i.useState(""),[Et,Bn]=i.useState(""),[Vr,Qr]=i.useState(!1),[An,qn]=i.useState(null),[wt,qe]=i.useState(new Set),[H,Ln]=i.useState(!1),[Jr,ai]=i.useState(0),[En,Es]=i.useState(null),[Ve,li]=i.useState(()=>{try{return localStorage.getItem("fveo_auto_refresh")!=="false"}catch{return!0}}),Dn=i.useRef(!0),[$n,Fn]=i.useState(null),[v,rs]=i.useState(null),[Nn,as]=i.useState(!1),[di,Pn]=i.useState({}),[Ds,Mn]=i.useState(!1),[Dt,_t]=i.useState(null),[ee,Qe]=i.useState({}),[$s,Hn]=i.useState(!1),[zt,Fs]=i.useState(""),[Y,Ns]=i.useState(""),[ci,$t]=i.useState(!1),[j,ne]=i.useState({daily_quota:10,quota_reset_hours:30,model_name:"veo-3.1-generate-preview",disable_prompt_rewrite:!1,quota_error_threshold:5,auto_smart_unmark_enabled:!1,auto_smart_unmark_active_threshold:800,cooldown_sec:180,warmup_sec:120,audio_check_enabled:!1,video_worker_concurrency:60}),[Ps,On]=i.useState(!1),[Je,Un]=i.useState({daily_quota:10,quota_reset_hours:30,model_name:"veo-3.1-generate-preview",disable_prompt_rewrite:!1,quota_error_threshold:5,auto_smart_unmark_enabled:!1,auto_smart_unmark_active_threshold:800,cooldown_sec:180,warmup_sec:120,audio_check_enabled:!1,video_worker_concurrency:60}),[oe,ye]=i.useState(null),[Vn,Rt]=i.useState(null),[pi,Ms]=i.useState(""),[Qn,Jn]=i.useState(null),[Kn,Gn]=i.useState(null),[Yn,Zn]=i.useState(null),[ls,ds]=i.useState(!1),Hs=i.useRef(null),[Kr,Gr]=i.useState(!1),[cs,fi]=i.useState({configured:!1,masked_key:""}),[Os,Xn]=i.useState(""),[Us,eo]=i.useState(!1),[N,xi]=i.useState(null),[pt,to]=i.useState({configured:!1,masked_key:"",full_key:""}),[ps,so]=i.useState(!1),[fs,no]=i.useState(!1),[ui,oo]=i.useState(!1),[te,io]=i.useState({configured:!1,hub_url:"",worker_id:"",masked_key:"",max_hub_requests:500,hub_request_limit_enabled:!0,active_hub_requests:0,waiting_hub_requests:0}),[_,ft]=i.useState({hub_url:"",hub_api_key:"",worker_id:"",max_hub_requests:500,hub_request_limit_enabled:!0}),[Ft,xt]=i.useState(!1),[ro,ao]=i.useState(!1),[de,ie]=i.useState(null),[lo,co]=i.useState(!1),[po,fo]=i.useState(!1),[Nt,gi]=i.useState([]),[Vs,xo]=i.useState(!1),[Ct,xs]=i.useState({}),[us,uo]=i.useState(null),[Pt,gs]=i.useState(!1),[hs,go]=i.useState(!1),[bs,ys]=i.useState(!1),[ms,js]=i.useState(!1),[E,Mt]=i.useState(null),[T,hi]=i.useState("tokens"),[ho,bo]=i.useState([]),[Qs,yo]=i.useState(!1),[Ht,bi]=i.useState(1),[ks,mo]=i.useState(0),[Js,yi]=i.useState(1),[jo,ko]=i.useState({success:0,failed:0}),[Le,mi]=i.useState(""),[Ke,ji]=i.useState(""),[Ks,ki]=i.useState(null),[vs,vi]=i.useState("webhook"),[Gs,vo]=i.useState(!1),[Tt,Si]=i.useState("queue"),[re,So]=i.useState({queue:[],count:0,next_cycle_at:0,last_cycle_at:0}
3),[Ot,Ys]=i.useState(!1),[wo,_o]=i.useState([]),[Zs,zo]=i.useState(!1),[Ut,wi]=i.useState(1),[_i,Ro]=i.useState(0),[Xs,zi]=i.useState(1),[en,Co]=i.useState({success:0,failed:0,session_destroy:0}),[Ee,Ri]=i.useState(""),[Ge,Ci]=i.useState(""),[Ti,Wi]=i.useState(null),[tn,To]=i.useState([]),[sn,Wo]=i.useState(!1),[Vt,Ii]=i.useState(1),[Bi,Io]=i.useState(0),[nn,Ai]=i.useState(1),[Ss,Bo]=i.useState({errors:0,warnings:0,successes:0,infos:0}),[me,qi]=i.useState(""),[je,Ao]=i.useState(""),[ke,Li]=i.useState(""),[U,Qt]=i.useState(null),[Ei,qo]=i.useState(!1),[se,on]=i.useState(null),[Ye,Lo]=i.useState("today"),[rn,ws]=i.useState([]),[Di,Eo]=i.useState(!1),[Jt,an]=i.useState(1),[$i,_s]=i.useState(0),[ln,dn]=i.useState(1),[zs,Do]=i.useState({total:0,errors:0,warnings:0,successes:0}),[ut,cn]=i.useState(""),[Wt,pn]=i.useState("");i.useEffect(()=>{const t=setInterval(()=>ai(n=>n+1),1e3);return()=>clearInterval(t)},[]),i.useEffect(()=>{if(!ct)return;const t=n=>{Ls.current&&!Ls.current.contains(n.target)&&vt(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[ct]);const[ve,fn]=i.useState(""),[ce,It]=i.useState("all"),[gt,Ze]=i.useState(1),[De,Fi]=i.useState(!1),[ht,$o]=i.useState(!1),[Ni,Pi]=i.useState(new Set),[Fo,xn]=i.useState(null),[bt,Mi]=i.useState(()=>{try{return localStorage.getItem("fveo_auto_terminate")!=="false"}catch{return!0}}),[Se,Hi]=i.useState(()=>{try{return Math.max(1,Math.min(10,parseInt(localStorage.getItem("fveo_auto_terminate_mins")||"10",10)))}catch{return 10}}),[Oi,No]=i.useState(!1);i.useEffect(()=>{if(T!=="tokens")return;const t=async()=>{try{const r=(await f.get("/api/admin/flow-veo-tokens/queue-stats")).data||{pending:0,active:0};if(Z(r),bt){const l=Se*60,d=Date.now()/1e3;(r.active_jobs||[]).some(s=>s.started_at&&d-s.started_at>=l)&&f.post("/api/admin/flow-veo-tokens/terminate-stuck-jobs",{threshold_minutes:Se}).catch(()=>{})}}catch{}};t();const a=setInterval(t,ht?3e3:1e4);return()=>clearInterval(a)},[T,ht,bt,Se]),i.useEffect(()=>{const t=E?.operation_id;if(!t||["completed","failed"].includes(E?.status))return;let n=!1,a;const o=async()=>{try{const r=await f.get(`/api/admin/flow-veo-tokens/operations/${t}`);if(n)return;const l=r.data||{};if(Mt(l),["completed","failed"].includes(l.status)){f.get("/api/admin/flow-veo-tokens/queue-stats").then(d=>Z(d.data||{pending:0,active:0})).catch(()=>{}),ys(!1),js(!1),S({type:l.status==="completed"?"success":"error",msg:l.status==="completed"?l.message:l.error||"The bulk operation failed"}),setTimeout(()=>S(null),5e3);return}}catch(r){if(!n&&r?.response?.status===404){Mt(l=>l&&{...l,status:"failed",phase:"Failed",error:"The operation expired or is no longer available."}),ys(!1),js(!1);return}}n||(a=setTimeout(o,800))};return o(),()=>{n=!0,clearTimeout(a)}},[E?.operation_id,E?.status]),i.useEffect(()=>{if(T!=="refresh_logs")return;const t=()=>{f.get("/api/admin/flow-veo-tokens/refresh-queue").then(a=>So(a.data||{queue:[],count:0,next_cycle_at:0,last_cycle_at:0})).catch(()=>{})};t();const n=setInterval(t,5e3);return()=>clearInterval(n)},[T]),i.useEffect(()=>{Dn.current=Ve;try{localStorage.setItem("fveo_auto_refresh",Ve?"true":"false")}catch{}},[Ve]);const un=i.useRef({page:gt,search:ve,statusFilter:ce,tagFilter:Y,sortByVideos:De});i.useEffect(()=>{un.current={page:gt,search:ve,statusFilter:ce,tagFilter:Y,sortByVideos:De}},[gt,ve,ce,Y,De]),i.useEffect(()=>{if(T!=="tokens")return;const n=setInterval(async()=>{if(document.visibilityState==="hidden"||!Rs.current||!Dn.current)return;const{page:a,search:o,statusFilter:r,tagFilter:l,sortByVideos:d}=un.current;await Promise.all([Cs(),Gt(a,o,r,l,d,!1)]),Es(new Date)},3e4);return()=>clearInterval(n)},[T]);const Po=t=>{if(t==="queue"){$o(!0);return}Fi(t==="videos"),t==="total"?It("all"):t==="active"?It("active"):t==="inactive"?It("inactive_expired"):t==="videos"&&It("all"),Ze(1)},p=(t,n="success")=>{S({msg:t,type:n}),setTimeout(()=>S(null),3500)},Kt=i.useRef(null),Rs=i.useRef(!1),Gt=async(t,n,a,o,r,l=!0)=>{l&&ge(!0);try{const d=new URLSearchParams({page:t,limit:w,search:n||"",status:a||"all",tag:o||"",sort_by:r?"videos":"created_at"}),u=await f.get(`/api/admin/flow-veo-tokens?${d}`);M(u.data.tokens||[]),Ie(u.data.total||0)}catch{p("Failed to load tokens","error")}finally{l&&ge(!1)}},Cs=async()=>{try{const t=await f.get("/api/admin/flow-veo-tokens/stats");ue(t.data||{})}catch{}},Q=async()=>{await Promise.all([Gt(gt,ve,ce,Y,De,!1),Cs()])},Mo=async()=>{ge(!0);try{const[t,n,a,o]=await Promise.all([f.get(`/api/admin/flow-veo-tokens?page=1&limit=${w}&status=all&sort_by=created_at`),f.get("/api/admin/flow-veo-tokens/stats").catch(()=>null),f.get("/api/admin/flow-veo-tokens/settings"),f.get("/api/admin/flow-veo-tokens/queue-stats").catch(()=>null)]);M(t.data.tokens||[]),Ie(t.data.total||0),n&&ue(n.data||{}),o&&Z(o.data||{pending:0,active:0});const r=a.data||{};Un(r),ne({daily_quota:r.daily_quota??10,quota_reset_hours:r.quota_reset_hours??30,model_name:r.model_name??"veo-3.1-generate-preview",disable_prompt_rewrite:r.disable_prompt_rewrite??!1,quota_error_threshold:r.quota_error_threshold??5,auto_smart_unmark_enabled:r.auto_smart_unmark_enabled??!1,auto_smart_unmark_active_threshold:r.auto_smart_unmark_active_threshold??800,cooldown_sec:r.cooldown_sec??180,warmup_sec:r.warmup_sec??120,audio_check_enabled:r.audio_check_enabled??!1,video_worker_concurrency:r.video_worker_concurrency??60})}catch{p("Failed to load tokens","error")}finally{ge(!1),Rs.current=!0,Es(new Date)}},Ui=async()=>{ri(`${window.location.origin}/api/public/flow-veo/tokens/webhook`);try{const t=await f.get("/api/webhook/flow-accounts/get-secret");Bn(t.data.secret||"")}catch(t){console.error(t)}},Vi=async()=>{On(!0);try{await f.post("/api/admin/flow-veo-tokens/settings",{daily_quota:Number(j.daily_quota),quota_reset_hours:Number(j.quota_reset_hours),model_name:j.model_name,disable_prompt_rewrite:!!j.disable_prompt_rewrite,quota_error_threshold:Number(j.quota_error_threshold),auto_
3smart_unmark_enabled:!!j.auto_smart_unmark_enabled,auto_smart_unmark_active_threshold:Number(j.auto_smart_unmark_active_threshold),cooldown_sec:Number(j.cooldown_sec),warmup_sec:Number(j.warmup_sec),audio_check_enabled:!!j.audio_check_enabled,video_worker_concurrency:Number(j.video_worker_concurrency)}),Un({...Je,daily_quota:Number(j.daily_quota),quota_reset_hours:Number(j.quota_reset_hours),model_name:j.model_name,disable_prompt_rewrite:!!j.disable_prompt_rewrite,quota_error_threshold:Number(j.quota_error_threshold),auto_smart_unmark_enabled:!!j.auto_smart_unmark_enabled,auto_smart_unmark_active_threshold:Number(j.auto_smart_unmark_active_threshold),cooldown_sec:Number(j.cooldown_sec),warmup_sec:Number(j.warmup_sec),audio_check_enabled:!!j.audio_check_enabled,video_worker_concurrency:Number(j.video_worker_concurrency)}),$t(!1),p("Settings saved","success")}catch(t){p(t?.response?.data?.detail||"Failed to save settings","error")}finally{On(!1)}},Qi=async()=>{ye("recheck");try{const t=await f.post("/api/admin/flow-veo-tokens/recheck-all");Ms(`Recheck All — ${t.data.checked} token(s)`),Rt(t.data.results||[]),await Q(),p(`Rechecked ${t.data.checked} tokens`,"success")}catch(t){p(t?.response?.data?.detail||"Recheck failed","error")}finally{ye(null)}},Ji=async()=>{ye("refresh");try{const t=await f.post("/api/admin/flow-veo-tokens/refresh-all");Ms(`Refresh All — ${t.data.refreshed} refreshed, ${t.data.failed} failed`),Rt(t.data.results||[]),await Q(),p(`Refreshed ${t.data.refreshed} token(s)`,"success")}catch(t){p(t?.response?.data?.detail||"Refresh failed","error")}finally{ye(null)}},Ki=async()=>{if(ds(!1),!!window.confirm(`Overall Reset Unmark — ALL quota-full tokens?
4
5This will:
6• Clear quota_filled_at on every token
7• Set videos_generated = 0
8• Reset all error counts
9• Re-activate all non-session tokens
10
11Proceed?`)){ye("reset_quotas");try{const t=await f.post("/api/admin/flow-veo-tokens/reset-all-quotas");await Q(),p(`Quota reset for ${t.data.affected} token(s) — all marked active`,"success")}catch(t){p(t?.response?.data?.detail||"Reset failed","error")}finally{ye(null)}}},Gi=async()=>{if(ds(!1),!!window.confirm(`Smart Unmark — error-caused quota-full only?
12
13This will reset ONLY accounts where:
14• Status is "Quota Full"
15• Videos (Today) have NOT hit the daily limit
16• Errors have hit the limit
17
18Actions for matched accounts:
19• Clear quota_filled_at
20• Reset error count to 0
21• Re-activate token
22• KEEP videos_generated unchanged
23
24Proceed?`)){ye("smart_unmark");try{const t=await f.post("/api/admin/flow-veo-tokens/unmark-quota-smart");await Q(),p(`Smart unmark complete — ${t.data.affected} error-caused quota(s) cleared`,"success")}catch(t){p(t?.response?.data?.detail||"Smart unmark failed","error")}finally{ye(null)}}},Yi=async()=>{const t=we.session_destroy;if(window.confirm(`Delete ALL ${t} "Session Destroyed" token account(s)?
25
26This will permanently remove them and cannot be undone.
27
28Proceed?`)){ye("delete_session_destroyed");try{const n=await f.delete("/api/admin/flow-veo-tokens/bulk-session-destroyed");await Q(),p(`Deleted ${n.data.deleted} session-destroyed token(s)`,"success")}catch(n){p(n?.response?.data?.detail||"Delete failed","error")}finally{ye(null)}}},Zi=async t=>{Jn(t);try{await f.post(`/api/admin/flow-veo-tokens/${t}/refresh`),p("Token refreshed","success"),await Q()}catch(n){p(n?.response?.data?.detail||"Refresh failed","error")}finally{Jn(null)}},Xi=async t=>{Gn(t);try{await f.post(`/api/admin/flow-veo-tokens/${t}/reset-quota`),p("Daily quota reset to 0","success"),await Q()}catch(n){p(n?.response?.data?.detail||"Reset failed","error")}finally{Gn(null)}},er=async t=>{Zn(t);try{await f.post(`/api/admin/flow-veo-tokens/${t}/unmark-quota`),p("Quota-full flag cleared — token re-activated","success"),await Q()}catch(n){p(n?.response?.data?.detail||"Unmark failed","error")}finally{Zn(null)}},tr=async()=>{if(F)return;be.current=!1,Lt(!0),le({open:!0,fetched:0,total:0,status:"Preparing export…",error:null,cancel:!1,doneFile:null});const t=1e3,n=[];let a=0,o=0;try{for(;;){if(be.current){le(m=>({...m,status:"Cancelled",cancel:!0})),p("Export cancelled","error");return}const x=(await f.get("/api/admin/flow-veo-tokens/export-chunk",{params:{offset:a,limit:t}})).data||{};o=Number(x.total||0);const h=Array.isArray(x.tokens)?x.tokens:[];if(n.push(...h),a+=h.length,le(m=>({...m,fetched:n.length,total:o,status:o>0?`Fetched ${n.length.toLocaleString()} / ${o.toLocaleString()} accounts…`:`Fetched ${n.length.toLocaleString()} accounts…`})),h.length===0||n.length>=o)break}le(c=>({...c,status:"Building JSON file…"}));const r=JSON.stringify({version:1,exported_at:new Date().toISOString(),total:n.length,tokens:n}),l=new Blob([r],{type:"application/json"}),d=URL.createObjectURL(l),u=`flow_veo_tokens_${new Date().toISOString().slice(0,10)}.json`,s=document.createElement("a");s.href=d,s.download=u,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(d),5e3),le(c=>({...c,status:`Done — ${n.length.toLocaleString()} accounts exported`,doneFile:u})),p(`Exported ${n.length.toLocaleString()} accounts`,"success")}catch(r){const l=r?.response?.data?.detail||r?.message||"Export failed";le(d=>({...d,status:"Failed",error:l})),p(`Export failed: ${l}`,"error")}finally{Lt(!1)}},sr=()=>{be.current=!0},gn=()=>{F||le({open:!1,fetched:0,total:0,status:"",error:null,cancel:!1,doneFile:null})},nr=async()=>{if(!Ue){Tn(!0),vt(!1);try{const n=(await f.get("/api/admin/flow-veo-tokens/export-emails",{params:{status:St}})).data,a=JSON.stringify(n,null,2),o=new Blob([a],{type:"application/json"}),r=URL.createObjectURL(o),l=`flow_veo_emails_${St}_${new Date().toISOString().slice(0,10)}.json`,d=document.createElement("a");d.href=r,d.download=l,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>
28URL.revokeObjectURL(r),5e3),p(`Exported ${n.count.toLocaleString()} emails`,"success")}catch(t){p(t?.response?.data?.detail||"Email export failed","error")}finally{Tn(!1)}}},Ho=200,or=async t=>{const n=t.target.files?.[0];if(!n)return;t.target.value="",C(null),O(!0),G(!0);let a=[];try{const l=await n.text(),d=JSON.parse(l);if(a=Array.isArray(d)?d:d.tokens||[],!a.length){p("No tokens found in file","error"),O(!1),G(!1);return}}catch{p("Invalid JSON file","error"),O(!1),G(!1);return}const o=[];for(let l=0;l<a.length;l+=Ho)o.push(a.slice(l,l+Ho));const r={chunk:0,totalChunks:o.length,added:0,updated:0,skipped:0,errors:[]};Be({...r});for(let l=0;l<o.length;l++){r.chunk=l+1,Be({...r});try{const d=await f.post("/api/admin/flow-veo-tokens/import",{tokens:o[l]});r.added+=d.data.added??0,r.updated+=d.data.updated??0,r.skipped+=d.data.skipped??0,d.data.errors?.length&&r.errors.push(...d.data.errors)}catch(d){const u=d?.response?.data?.detail||`Chunk ${l+1} failed`;r.errors.push(u)}Be({...r})}O(!1),C({added:r.added,updated:r.updated,skipped:r.skipped,errors:r.errors}),p(`Done: ${r.added} added, ${r.updated} updated`,"success"),await Q()},Oo=async()=>{try{const t=await f.get("/api/admin/flow-veo-tokens/api-key");fi(t.data||{configured:!1,masked_key:""})}catch(t){console.error(t)}},ir=async()=>{eo(!0),Xn("");try{const t=await f.post("/api/admin/flow-veo-tokens/api-key/generate");Xn(t.data.api_key||""),await Oo(),p("New API key generated","success")}catch(t){p(t?.response?.data?.detail||"Failed to generate key","error")}finally{eo(!1)}},Xe=async(t=1,n=Ke,a=Le)=>{yo(!0);try{const o=new URLSearchParams({page:t,limit:20});n&&o.set("status",n),a&&o.set("search",a);const r=await f.get(`/api/admin/webhook-logs?${o}`);bo(r.data.logs||[]),mo(r.data.total||0),yi(r.data.total_pages||1),ko(r.data.stats||{success:0,failed:0}),bi(t)}catch(o){console.error(o)}finally{yo(!1)}},et=async(t=1,n=Ge,a=Ee)=>{zo(!0);try{const o=new URLSearchParams({page:t,page_size:20});n&&o.set("status",n),a&&o.set("search",a);const r=await f.get(`/api/admin/flow-veo-tokens/refresh-logs?${o}`);_o(r.data.logs||[]),Ro(r.data.total||0),zi(r.data.total_pages||1),Co(r.data.stats||{success:0,failed:0,session_destroy:0}),wi(t)}catch(o){console.error(o)}finally{zo(!1)}},rr=async()=>{Ys(!0);try{await f.post("/api/admin/flow-veo-tokens/refresh-queue/trigger-now"),p("Refresh cycle started — refreshing all queued accounts now","success");let t=0;const n=20,a=3e3,o=()=>{t++,f.get("/api/admin/flow-veo-tokens/refresh-queue").then(r=>So(r.data||{queue:[],count:0,next_cycle_at:0,last_cycle_at:0})).catch(()=>{}),t<n?setTimeout(o,a):Ys(!1)};setTimeout(o,1500)}catch(t){p(t?.response?.data?.detail||"Failed to trigger refresh","error"),Ys(!1)}},ar=async()=>{if(window.confirm("Clear all refresh worker logs?"))try{await f.delete("/api/admin/flow-veo-tokens/refresh-logs"),_o([]),Ro(0),Co({success:0,failed:0,session_destroy:0}),p("Refresh logs cleared","success")}catch{p("Failed to clear logs","error")}},$e=async(t=1,n=je,a=ke,o=me)=>{Wo(!0);try{const r=new URLSearchParams({page:t,page_size:50});n&&r.set("severity",n),a&&r.set("event_type",a),o&&r.set("search",o);const l=await f.get(`/api/admin/flow-veo-tokens/token-logs?${r}`);To(l.data.logs||[]),Io(l.data.total||0),Ai(l.data.total_pages||1),Bo(l.data.stats||{errors:0,warnings:0,successes:0,infos:0}),Ii(t)}catch(r){console.error(r)}finally{Wo(!1)}},lr=async()=>{if(window.confirm("Clear ALL token logs from all accounts?"))try{await f.delete("/api/admin/flow-veo-tokens/token-logs"),To([]),Io(0),Bo({errors:0,warnings:0,successes:0,infos:0}),p("All token logs cleared","success")}catch{p("Failed to clear logs","error")}},[Uo,Vo]=i.useState(!1),dr=async()=>{if(window.confirm(`Clear all ${ks} webhook log(s)?
29
30This permanently removes every entry from the webhook logs table. This cannot be undone.`)){Vo(!0);try{await f.delete("/api/admin/webhook-logs"),bo([]),mo(0),ko({success:0,failed:0}),p("All webhook logs cleared","success")}catch(t){p(t?.response?.data?.detail||"Failed to clear logs","error")}finally{Vo(!1)}}},yt=async(t,n=1,a=Wt,o=ut,r=Ye)=>{if(t){Eo(!0);try{const l=new URLSearchParams({page:n,page_size:50});a&&l.set("severity",a),o&&l.set("search",o),r==="today"&&l.set("today_only","true");const d=await f.get(`/api/admin/flow-veo-tokens/${t.id}/logs?${l}`);ws(d.data.logs||[]),_s(d.data.total||0),dn(d.data.total_pages||1),Do(d.data.stats||{total:0,errors:0,warnings:0,successes:0}),an(n)}catch(l){console.error(l)}finally{Eo(!1)}}},cr=t=>{on(t),Lo("today"),an(1),pn(""),cn(""),ws([]),_s(0),dn(1),yt(t,1,"","","today")},pr=t=>{Lo(t),an(1),pn(""),cn(""),ws([]),_s(0),dn(1),yt(se,1,"","",t)},fr=async()=>
30{if(se&&window.confirm(`Clear all logs for ${se.email||`token #${se.id}`}?`))try{await f.delete(`/api/admin/flow-veo-tokens/${se.id}/logs`),ws([]),_s(0),Do({total:0,errors:0,warnings:0,successes:0}),p("Token logs cleared","success")}catch{p("Failed to clear logs","error")}},xr=async()=>{vo(!0);try{const t=await f.post("/api/webhook/flow-accounts/generate-secret"),n=t.data.webhook_secret||t.data.secret||"";Bn(n),p("Webhook secret regenerated","success")}catch(t){p(t?.response?.data?.detail||"Failed to generate secret","error")}finally{vo(!1)}};i.useEffect(()=>{Mo(),Ui(),Oo()},[]),i.useEffect(()=>{if(!ls)return;const t=n=>{Hs.current&&!Hs.current.contains(n.target)&&ds(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[ls]),i.useEffect(()=>{if(Rs.current)return Kt.current&&clearTimeout(Kt.current),Kt.current=setTimeout(()=>{Ze(1),qe(new Set),Gt(1,ve,ce,Y,De),Cs()},ve?350:0),()=>{Kt.current&&clearTimeout(Kt.current)}},[ve,ce,Y,De]),i.useEffect(()=>{Rs.current&&(qe(new Set),Gt(gt,ve,ce,Y,De))},[gt,w]),i.useEffect(()=>{T==="webhook"&&Xe(1,"",""),T==="refresh_logs"&&et(1,"",""),T==="token_logs"&&$e(1,"","",""),T==="multi_server"&&Ws()},[T]);const Ts=async()=>{xo(!0);try{const t=await f.get("/api/admin/flow-veo-tokens/worker-stats");gi(t.data.workers||[])}catch{}finally{xo(!1)}};i.useEffect(()=>{if(T!=="multi_server"||N!=="worker")return;const t=async()=>{try{const a=await f.get("/api/admin/flow-veo-tokens/worker-config");io(o=>({...o,...a.data}))}catch{}};t();const n=setInterval(t,3e3);return()=>clearInterval(n)},[T,N]);const ur=async t=>{if(confirm(`Disconnect worker "${t}" from the hub?
31
32This marks it as disconnected and removes it from the Connected Workers list. It will reappear if it sends another heartbeat.`)){xs(n=>({...n,[t]:"disconnect"}));try{await f.post(`/api/admin/flow-veo-tokens/workers/${encodeURIComponent(t)}/disconnect`),p(`Worker "${t}" disconnected`),Ts()}catch(n){p(n.response?.data?.detail||"Disconnect failed","error")}finally{xs(n=>{const a={...n};return delete a[t],a})}}},gr=async t=>{if(confirm(`Permanently delete all history for worker "${t}"?
33
34This removes every job record for this worker and it will no longer appear in the list. This cannot be undone.`)){xs(n=>({...n,[t]:"delete"}));try{await f.delete(`/api/admin/flow-veo-tokens/workers/${encodeURIComponent(t)}`),p(`Worker "${t}" deleted`),Ts()}catch(n){p(n.response?.data?.detail||"Delete failed","error")}finally{xs(n=>{const a={...n};return delete a[t],a})}}},Ws=async()=>{oo(!0);try{const[t,n,a]=await Promise.all([f.get("/api/admin/flow-veo-tokens/server-mode"),f.get("/api/admin/flow-veo-tokens/hub-key-info"),f.get("/api/admin/flow-veo-tokens/worker-config")]),o=t.data.mode;xi(o),to(n.data),io(a.data),a.data.configured&&ft(r=>({...r,hub_url:a.data.hub_url||"",worker_id:a.data.worker_id||"",max_hub_requests:a.data.max_hub_requests??500,hub_request_limit_enabled:a.data.hub_request_limit_enabled??!0})),o==="hub"&&Ts()}catch{p("Failed to load multi-server info","error")}finally{oo(!1)}},Qo=async()=>{if(window.confirm("This will generate a new Hub API key. All worker VPS servers will need to be updated with the new key. Continue?")){no(!0);try{const t=await f.post("/api/admin/flow-veo-tokens/generate-hub-key");to({configured:!0,masked_key:t.data.key.slice(0,10)+"..."+t.data.key.slice(-4),full_key:t.data.key}),so(!0),p("Hub API key generated successfully!")}catch{p("Failed to generate hub key","error")}finally{no(!1)}}},hr=async()=>{if(!_.hub_url||!_.hub_api_key)return p("Enter Hub URL and API Key first","error");ao(!0),ie(null);try{const t=await f.post("/api/admin/flow-veo-tokens/test-hub-connection",{hub_url:_.hub_url,hub_api_key:_.hub_api_key});ie(t.data)}catch(t){ie({success:!1,message:t?.response?.data?.detail||"Test failed"})}finally{ao(!1)}},br=async()=>{if(!_.hub_url||!_.hub_api_key)return p("Hub URL and API Key are required","error");co(!0);try{await f.post("/api/admin/flow-veo-tokens/worker-config",{hub_url:_.hub_url,hub_api_key:_.hub_api_key,worker_id:_.worker_id,max_hub_requests:Number(_.max_hub_requests),hub_request_limit_enabled:!!_.hub_request_limit_enabled}),p("Connected to Hub successfully!"),xt(!1),ie(null),await Ws()}catch(t){p(t?.response?.data?.detail||"Failed to save configuration","error")}finally{co(!1)}},yr=async()=>
34{if(window.confirm("Disconnect from Hub? This server will switch back to Hub mode and use its own local tokens.")){fo(!0);try{await f.delete("/api/admin/flow-veo-tokens/worker-config"),p("Disconnected from Hub. Now running in Hub mode."),ft({hub_url:"",hub_api_key:"",worker_id:"",max_hub_requests:500,hub_request_limit_enabled:!0}),xt(!1),ie(null),await Ws()}catch{p("Failed to disconnect","error")}finally{fo(!1)}}},mr=async()=>{if(!Me.tokens.trim())return p("Enter at least one token","error");is(!0),Oe(null);try{const t=Me.tokens.trim();let n;try{const o=JSON.parse(t);o&&typeof o=="object"&&!Array.isArray(o)?n=[o]:Array.isArray(o)?n=o:n=[t]}catch{n=t.split(`
35`).map(o=>o.trim()).filter(Boolean)}const a=await f.post("/api/admin/flow-veo-tokens",{tokens:n});p(`Added ${a.data.added}, updated ${a.data.updated} token(s)`),Oe(a.data.results||[]),He({tokens:""}),Q()}catch(t){p(t.response?.data?.detail||"Failed to add tokens","error")}finally{is(!1)}},jr=async t=>{const n=t.status==="active"?"inactive":"active";try{await f.patch(`/api/admin/flow-veo-tokens/${t.id}`,{status:n}),p(`Token ${n}`),Q()}catch{p("Failed to update token","error")}},kr=async t=>{if(confirm("Delete this token?"))try{await f.delete(`/api/admin/flow-veo-tokens/${t}`),p("Token deleted"),qe(n=>{const a=new Set(n);return a.delete(t),a}),Q()}catch{p("Failed to delete token","error")}},vr=async t=>{qn(t);try{const n=await f.post(`/api/admin/flow-veo-tokens/${t}/recheck`),{email:a,expires_in:o,status:r}=n.data;p(`${a||"Token"} — ${r==="active"?`${Math.round(o/60)}m remaining`:"Expired"}`),Q()}catch(n){p(n.response?.data?.detail||"Recheck failed","error")}finally{qn(null)}},Bt=t=>navigator.clipboard.writeText(t).then(()=>p("Copied!")),Sr=async t=>{as(!0),rs(null),Pn({}),Mn(!1);try{const n=await f.get(`/api/admin/flow-veo-tokens/${t.id}`);rs(n.data)}catch{p("Failed to load token details","error")}finally{as(!1)}},wr=t=>{Sr(t)},_r=async t=>{_t(null);try{const n=await f.get(`/api/admin/flow-veo-tokens/${t.id}`);_t(n.data),Fs(""),Qe({status:n.data.status||"active",refresh_token:n.data.refresh_token||"",refresh_access_token:n.data.refresh_access_token||"",cookies:n.data.cookies||"",tags:Array.isArray(n.data.tags)?[...n.data.tags]:[]})}catch{p("Failed to load token details","error")}},zr=async()=>{if(Dt){Hn(!0);try{const t=[...ee.tags||[]];zt.trim()&&t.push(zt.trim()),await f.patch(`/api/admin/flow-veo-tokens/${Dt.id}`,{status:ee.status,refresh_token:ee.refresh_token||null,refresh_access_token:ee.refresh_access_token||null,cookies:ee.cookies||null,tags:t}),p("Token updated"),_t(null),Q()}catch(t){p(t.response?.data?.detail||"Failed to save","error")}finally{Hn(!1)}}},mt=async t=>{const n=[...wt];if(n.length&&!(t==="delete"&&!confirm(`Delete ${n.length} token(s)?`))){Ln(!0);try{if(t==="recheck"||t==="refresh"||t==="reset-quota"||t==="unmark-quota"){const o=(await Promise.allSettled(n.map(u=>t==="recheck"?f.post(`/api/admin/flow-veo-tokens/${u}/recheck`).then(s=>({id:u,...s.data})):t==="refresh"?f.post(`/api/admin/flow-veo-tokens/${u}/refresh`).then(s=>({id:u,...s.data})):t==="unmark-quota"?f.post(`/api/admin/flow-veo-tokens/${u}/unmark-quota`).then(s=>({id:u,...s.data})):f.post(`/api/admin/flow-veo-tokens/${u}/reset-quota`).then(s=>({id:u,...s.data}))))).map((u,s)=>u.status==="fulfilled"?{id:n[s],...u.value}:{id:n[s],success:!1,error:u.reason?.response?.data?.detail||u.reason?.message||"Failed"}),r=o.filter(u=>u.success!==!1).length,l=o.length-r,d={recheck:"Recheck",refresh:"Refresh","reset-quota":"Reset Quota","unmark-quota":"Unmark Quota Full"};Ms(`${d[t]} (${n.length} selected) — ${r} OK${l?`, ${l} failed`:""}`),Rt(o.map(u=>({...u,status:u.status||(t==="reset-quota"?`videos_generated = ${u.videos_generated??0}`:t==="unmark-quota"?`active, videos_generated kept at ${u.videos_generated??0}`:void 0)}))),r>0?p(`${d[t]}: ${r}/${n.length} succeeded`,"success"):p(`${d[t]} failed for all tokens`,"error"),qe(new Set),Q()}else await Promise.all(n.map(a=>t==="delete"?f.delete(`/api/admin/flow-veo-tokens/${a}`):f.patch(`/api/admin/flow-veo-tokens/${a}`,{status:t}))),p(`${t==="delete"?"Deleted":t==="active"?"Activated":"Deactivated"} ${n.length} token(s)`),qe(new Set),Q()}catch{p("Bulk action failed","error")}finally{Ln(!1)}}},Jo=async t=>{const n=t==="clear_data";if(confirm(n?`⚠ PERMANENTLY CLEAR ALL VIDEO JOB DATA?
36
37This will cancel active generations, delete every job record from the video queue tables in chunks, and clear queued/processing/worker data from Redis. You will see live progress. This cannot be undone.`:`⚠ TERMINATE ALL RUNNING VIDEO JOBS?
38
39This will stop every queued/active generation, release tokens, and cancel remote worker jobs in chunks. You will see live progress.`)){n?js(!0):ys(!0);try{const o=n?await f.delete("/api/admin/flow-veo-tokens/queue-data"):await f.post("/api/admin/flow-veo-tokens/terminate-all-jobs");Mt(o.data)}catch(o){n?js(!1):ys(!1),S({type:"error",msg:o?.response?.data?.detail||"Could not start the bulk operation"}),setTimeout(()=>S(null),5e3)}}},Ko=Je.daily_quota??10,Go=t=>{if(t.status==="session_destroy")return{key:"session_destroy",label:"Session Destroyed",color:"#7c3aed",bg:"#ede9fe",icon:"alert"};if(t.status==="invalid")return{key:"invalid",label:"Invalid",color:"#f97316",bg
39:"#ffedd5",icon:"alert"};if(t.status==="inactive")return{key:"inactive",label:"Inactive",color:"#ef4444",bg:"#fee2e2",icon:"alert"};if(t.status!=="active")return{key:"inactive",label:"Inactive",color:"#ef4444",bg:"#fee2e2",icon:"alert"};if(t.expires_at){const n=t.expires_at.includes("Z")||t.expires_at.includes("+")?t.expires_at:t.expires_at+"Z";if(new Date(n)<=new Date)return{key:"expired",label:"Expired",color:"#ef4444",bg:"#fee2e2",icon:"alert"}}return t.quota_filled_at||(t.videos_generated??0)>=Ko?{key:"quota_full",label:"Daily Quota Full",color:"#d97706",bg:"#fef3c7",icon:"alert"}:{key:"active",label:"Active",color:"#22c55e",bg:"#dcfce7",icon:"check"}},Rr=t=>t==="active"?"#22c55e":t==="invalid"?"#f97316":t==="session_destroy"?"#7c3aed":"#ef4444",Cr=t=>t==="active"?"#dcfce7":t==="invalid"?"#ffedd5":t==="session_destroy"?"#ede9fe":"#fee2e2",Tr=K,Yo=K,Zo=A.all_tags||[],we=i.useMemo(()=>({inactive:0,expired:0,quota_full:0,invalid:0,session_destroy:0,...A.inactive_counts||{}}),[A]),hn=i.useMemo(()=>({active:A.active??0,inactive:A.inactive??0,free:A.free??0}),[A]),pe=Math.max(1,Math.ceil(V/w)),D=Math.min(gt,pe),Yt=Yo.map(t=>t.id),bn=Yt.length>0&&Yt.every(t=>wt.has(t)),Wr=wt.size>0,Ir=()=>{qe(bn?t=>{const n=new Set(t);return Yt.forEach(a=>n.delete(a)),n}:t=>{const n=new Set(t);return Yt.forEach(a=>n.add(a)),n})},Br=t=>{qe(n=>{const a=new Set(n);return a.has(t)?a.delete(t):a.add(t),a})};return e.jsxs("div",{className:"admin-page",children:[he&&e.jsx("div",{style:{position:"fixed",top:20,right:20,zIndex:9999,padding:"12px 20px",borderRadius:8,background:he.type==="error"?"#ef4444":"#22c55e",color:"#fff",fontWeight:500,boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:he.msg}),E&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"bulk-job-operation-title",style:{position:"fixed",inset:0,zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center",padding:20,background:"rgba(15, 23, 42, 0.55)"},children:e.jsxs("div",{style:{width:"min(480px, 100%)",background:"#fff",borderRadius:14,padding:24,boxShadow:"0 20px 60px rgba(15,23,42,0.25)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[e.jsxs("div",{children:[e.jsx("h2",{id:"bulk-job-operation-title",style:{margin:0,fontSize:18,color:"#111827"},children:E.operation_type==="clear_data"?"Clearing video job data":"Terminating video jobs"}),e.jsx("div",{style:{marginTop:5,fontSize:12,color:"#6b7280"},children:E.status==="completed"?"The operation completed successfully.":E.status==="failed"?"The operation could not finish.":"The server is processing records in small chunks."})]}),["completed","failed"].includes(E.status)&&e.jsx("button",{onClick:()=>Mt(null),"aria-label":"Close progress dialog",style:{border:"none",background:"none",color:"#6b7280",cursor:"pointer",padding:2},children:e.jsx(L,{size:20})})]}),e.jsx("div",{style:{marginTop:22,height:12,background:"#e5e7eb",borderRadius:8,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${Math.max(0,Math.min(100,E.percent||0))}%`,background:E.status==="failed"?"#ef4444":E.status==="completed"?"#22c55e":"#2563eb",borderRadius:8,transition:"width 0.35s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:8,fontSize:13,fontWeight:700,color:"#374151"},children:[e.jsx("span",{children:E.phase||"Preparing"}),e.jsxs("span",{children:[Math.round(E.percent||0),"%"]})]}),e.jsx("div",{style:{marginTop:12,fontSize:13,color:"#4b5563",minHeight:20},children:E.error||E.message||"Preparing…"}),E.total>0&&e.jsxs("div",{style:{marginTop:8,fontSize:12,color:"#6b7280"},children:["Processed ",Number(E.processed||0).toLocaleString()," of ",Number(E.total).toLocaleString()," records"]}),["completed","failed"].includes(E.status)&&e.jsx("button",{onClick:()=>Mt(null),style:{marginTop:20,width:"100%",padding:"10px 14px",border:"none",borderRadius:8,background:"#111827",color:"#fff",fontWeight:700,cursor:"pointer"},children:"Close"})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:20},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:22,fontWeight:700,margin:0},children:"Flow VEO Tokens"}),e.jsx("p",{style:{color:"#6b7280",margin:"4px 0 0",fontSize:14},children:"Manage OAuth bearer tokens for Google Flow VEO video generation"})]}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[T==="tokens"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>$t(!0),className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},title:"Token Settings",children:[e.jsx(wn,{size:16})," Settings"]}),e.jsxs("button",{onClick:Qi,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},disabled:oe==="recheck",title:"Recheck all tokens",children:[oe==="recheck"?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(Fe,{size:16})," Recheck All"]}),e.jsxs("button",{onClick:Ji,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},disabled:oe==="refresh",title:"Refresh all tokens with refresh_token",children:[oe==="refresh"?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(_n,{size:16})," Refresh Tokens"]}),e.jsxs("div",{ref:Hs,style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>ds(t=>
39!t),className:"btn btn-secondary",disabled:oe==="reset_quotas"||oe==="smart_unmark",title:"Unmark quota-full tokens",style:{display:"flex",alignItems:"center",gap:6,color:"#d97706",borderColor:"#fcd34d"},children:[oe==="reset_quotas"||oe==="smart_unmark"?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(qt,{size:16}),"Unmark Quota Full",e.jsx(es,{size:14,style:{marginLeft:2,transition:"transform 0.15s",transform:ls?"rotate(180deg)":"none"}})]}),ls&&e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",right:0,zIndex:200,background:"var(--card-bg)",border:"1px solid var(--border)",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",minWidth:260,padding:6},children:[e.jsxs("button",{onClick:Ki,disabled:oe==="reset_quotas",style:{width:"100%",display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:7,border:"none",cursor:"pointer",background:"transparent",textAlign:"left"},onMouseEnter:t=>t.currentTarget.style.background="var(--bg)",onMouseLeave:t=>t.currentTarget.style.background="transparent",children:[e.jsx(qt,{size:16,style:{color:"#d97706",marginTop:1,flexShrink:0}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:"Overall Reset Unmark"}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,lineHeight:1.4},children:"Reset ALL quota-full accounts — clears videos today, errors & re-activates"})]})]}),e.jsx("div",{style:{height:1,background:"var(--border)",margin:"4px 6px"}}),e.jsxs("button",{onClick:Gi,disabled:oe==="smart_unmark",style:{width:"100%",display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:7,border:"none",cursor:"pointer",background:"transparent",textAlign:"left"},onMouseEnter:t=>t.currentTarget.style.background="var(--bg)",onMouseLeave:t=>t.currentTarget.style.background="transparent",children:[e.jsx(B,{size:16,style:{color:"#10b981",marginTop:1,flexShrink:0}}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)"},children:["Smart Unmark ",e.jsx("span",{style:{fontSize:10,background:"rgba(16,185,129,0.12)",color:"#10b981",borderRadius:4,padding:"1px 6px",fontWeight:700,marginLeft:4},children:"Recommended"})]}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,lineHeight:1.4},children:"Only accounts with Quota Full + errors at limit + videos below limit — resets errors only, keeps video count"})]})]})]})]}),e.jsx("button",{onClick:Yi,className:"btn btn-secondary",disabled:oe==="delete_session_destroyed"||we.session_destroy===0,title:`Delete all ${we.session_destroy} Session Destroyed token accounts permanently`,style:{display:"flex",alignItems:"center",gap:6,color:"#7c3aed",borderColor:"#c4b5fd"},children:oe==="delete_session_destroyed"?e.jsxs(e.Fragment,{children:[e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}})," Deleting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{size:16})," Delete Session Destroyed ",we.session_destroy>0&&e.jsx("span",{style:{background:"#ede9fe",color:"#7c3aed",borderRadius:5,padding:"0px 6px",fontSize:12,fontWeight:700},children:we.session_destroy})]})}),e.jsxs("button",{onClick:Mo,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(y,{size:16})," Refresh"]}),e.jsxs("button",{onClick:tr,className:"btn btn-secondary",disabled:F,title:"Export all tokens as JSON",style:{display:"flex",alignItems:"center",gap:6},children:[F?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(Is,{size:16})," Export"]}),e.jsxs("div",{style:{position:"relative"},ref:Ls,children:[e.jsxs("button",{onClick:()=>vt(t=>!t),className:"btn btn-secondary",disabled:Ue,title:"Export emails as JSON",style:{display:"flex",alignItems:"center",gap:6},children:[Ue?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(ts,{size:16}),"Export Emails",e.jsx(es,{size:13,style:{marginLeft:1,transform:ct?"rotate(180deg)":"none",transition:"transform 0.15s"}})]}),ct&&e.jsxs("div",{style:{position:"absolute",top:"100%",right:0,marginTop:4,background:"#1f2937",border:"1px solid #374151",borderRadius:8,padding:"12px 16px",minWidth:215,zIndex:50,boxShadow:"0 4px 24px rgba(0,0,0,0.45)"},children:[e.jsx("div",{style:{fontSize:11,color:"#9ca3af",fontWeight:700,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Filter by Status"}),[{value:"all",label:"All Accounts"},{value:"active",label:"Active"},{value:"inactive",label:"Inactive"},{value:"session_destroy",label:"Session Destroyed"},{value:"quota_filled",label:"Quota Filled"}].map(t=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",padding:"5px 0",color:"#d1d5db",fontSize:14},children:[e.jsx("input",{type:"radio",name:"emailExportStatus",checked:St===t.value,onChange:()=>Ae(t.value),style:{accentColor:"#3b82f6"}}),t.label]},t.value)),e.jsxs("button",{onClick:nr,disabled:Ue,style:{marginTop:12,width:"100%",padding:"7px 0",background:"#3b82f6",color:"#fff",border:"none",borderRadius:6,fontWeight:600,cursor:Ue?"not-allowed":"pointer",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center",gap:6,opacity:Ue?.7:1},children:[e.jsx(Is,{size:14})," Download JSON"]})]})]}),e.jsxs("button",{onClick:()=>Wn.current?.click(),className:"btn btn-secondary",disabled:z,title:"Import tokens from JSON file",style:{display:"flex",alignItems:"center",gap:6},children:[z?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(Bs,{size:16})," Import"]}),e.jsx("input",{ref:Wn,type:"file",accept:".json,application/json",style:{display:"none"},onChange:or}),e.jsxs("button",{onClick:()=>{lt(t=>!t),Oe(null)},className:"btn btn-primary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(si,{size:16})," Add Tokens"]})]}),T==="webhook"&&e.jsx(e.Fragment,{children:e.jsxs("button",{onClick:()=>Xe(1,Ke,Le),className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(y,{size:16})," Refresh Logs"]})}),T==="refresh_logs"&&e.jsx(e.Fragment,{children:Tt==="logs"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:ar,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,color:"#ef4444"},children:[e.jsx(Ne,{size:16})," Clear Logs"]}),e.jsxs("button",{onClick:()=>et(1,Ge,Ee),disabled:Zs,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(y,{size:16,style:{animation:Zs?"spin 1s linear infinite":"none"}})," Refresh"]})]})}),T==="token_logs"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:lr,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,color:"#ef4444"},children:[e.jsx(Ne,{size:16})," Clear All Logs"]}),e.jsxs("button",{onClick:()=>$e(1,je,ke,me),disabled:sn,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6}
39,children:[e.jsx(y,{size:16,style:{animation:sn?"spin 1s linear infinite":"none"}})," Refresh"]})]})]})]}),e.jsx("div",{style:{display:"flex",gap:0,marginBottom:24,borderBottom:"2px solid #e5e7eb"},children:[{key:"tokens",label:"Tokens",icon:e.jsx(Lr,{size:15})},{key:"webhook",label:"Webhook",icon:e.jsx(Er,{size:15})},{key:"refresh_logs",label:"Refresh Worker Logs",icon:e.jsx(y,{size:15})},{key:"token_logs",label:"Token Logs",icon:e.jsx(at,{size:15})},{key:"multi_server",label:"Multi-Server",icon:e.jsx(ss,{size:15})}].map(t=>e.jsxs("button",{onClick:()=>hi(t.key),style:{display:"flex",alignItems:"center",gap:6,padding:"10px 20px",border:"none",background:"none",cursor:"pointer",fontSize:14,fontWeight:600,color:T===t.key?"#6366f1":"#6b7280",borderBottom:T===t.key?"2px solid #6366f1":"2px solid transparent",marginBottom:-2,transition:"all 0.15s"},children:[t.icon," ",t.label]},t.key))}),T==="tokens"&&e.jsxs(e.Fragment,{children:[(()=>{const t=En?Math.floor((Date.now()-En.getTime())/1e3):null,n=t===null?"—":t<5?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ${t%60}s ago`;return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:10,marginBottom:10},children:[e.jsxs("span",{style:{fontSize:12,color:"#9ca3af",display:"flex",alignItems:"center",gap:5},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Last refreshed: ",e.jsx("strong",{style:{color:"#6b7280"},children:n})]}),e.jsxs("button",{onClick:async()=>{const{page:a,search:o,statusFilter:r,tagFilter:l,sortByVideos:d}=un.current;await Promise.all([Cs(),Gt(a,o,r,l,d,!1)]),Es(new Date)},title:"Refresh now",style:{display:"flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"4px 10px",borderRadius:7,border:"1.5px solid #e5e7eb",background:"#fff",color:"#374151",cursor:"pointer"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("polyline",{points:"1 20 1 14 7 14"}),e.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),"Refresh"]}),e.jsx("button",{onClick:()=>li(a=>!a),title:Ve?"Pause auto-refresh":"Resume auto-refresh (every 30s)",style:{display:"flex",alignItems:"center",gap:5,fontSize:12,fontWeight:600,padding:"4px 10px",borderRadius:7,cursor:"pointer",border:`1.5px solid ${Ve?"#22c55e":"#d1d5db"}`,background:Ve?"#f0fdf4":"#f9fafb",color:Ve?"#16a34a":"#6b7280",transition:"all 0.15s"},children:Ve?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("rect",{x:"6",y:"4",width:"4",height:"16"}),e.jsx("rect",{x:"14",y:"4",width:"4",height:"16"})]})," Auto"]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})," Auto"]})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:16,marginBottom:24},children:[[{key:"total",label:"Total Tokens",value:A.total||V,color:"#6366f1",activeFilter:ce==="all"&&!De},{key:"active",label:"Active",value:hn.active,color:"#22c55e",sub:!0,activeFilter:ce==="active"},{key:"inactive",label:"Inactive / Expired / Quota Full",value:hn.inactive,color:"#ef4444",activeFilter:ce==="inactive_expired",showBreakdown:!0},{key:"videos",label:"All-Time Videos",value:A.all_time_generated??0,color:"#f59e0b",activeFilter:De}].map(t=>e.jsxs("div",{onClick:()=>Po(t.key),title:t.key==="videos"?"Sort by most videos generated":`Filter: ${t.label}`,style:{background:t.activeFilter?"rgba(99,102,241,0.04)":"#fff",borderRadius:12,padding:"16px 20px",border:`1.5px solid ${t.activeFilter?t.color:"#e5e7eb"}`,boxShadow:t.activeFilter?`0 0 0 2px ${t.color}22`:"0 1px 3px rgba(0,0,0,0.05)",cursor:"pointer",transition:"all 0.15s",userSelect:"none"},children:[t.key==="videos"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[e.jsx("span",{style:{fontSize:28,fontWeight:700,color:"#f59e0b"},children:A.all_time_generated??0}),e.jsx("span",{style:{fontSize:13,color:"#9ca3af",fontWeight:500},children:"|"}),e.jsx("span",{style:{fontSize:22,fontWeight:700,color:"#fbbf24"},children:A.today_generated??0})]}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:4},children:"Total | Today's Videos"}),(A.all_time_failed??0)>0&&e.jsxs("div",{style:{display:"flex",gap:6,marginTop:8,flexWrap:"wrap"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:8,background:"#fee2e2",color:"#dc2626"},children:["✕ ",A.today_failed??0," failed today"]}),(A.all_time_failed??0)!==(A.today_failed??0)&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:8,background:"#fef2f2",color:"#ef4444"},children:[A.all_time_failed??0," total failed"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:28,fontWeight:700,color:t.color},children:t.value??0}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:4},children:t.label}),t.sub&&e.jsx("div",{style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,padding:"2px 8px",borderRadius:8,background:"#f3f4f6",color:"#6b7280"},children:[hn.free??0," free"]})}),t.showBreakdown&&e.jsx("div",{style:{display:"flex",gap:6,marginTop:8,flexWrap:"wrap"},children:[{label:"Inactive",count:we.inactive,color:"#ef4444",bg:"#fee2e2"},{label:"Expired",count:we.expired,color:"#ef4444",bg:"#fee2e2"},{label:"Quota Full",count:we.quota_full,color:"#d97706",bg:"#fef3c7"}
39,{label:"Invalid",count:we.invalid,color:"#f97316",bg:"#ffedd5"},{label:"Session",count:we.session_destroy,color:"#7c3aed",bg:"#ede9fe"}].filter(n=>n.count>0).map(n=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:8,background:n.bg,color:n.color},children:[n.count," ",n.label]},n.label))})]}),t.activeFilter&&e.jsx("div",{style:{fontSize:10,color:t.color,fontWeight:700,marginTop:6,textTransform:"uppercase",letterSpacing:"0.04em"},children:t.key==="videos"?"↓ Sorted":"▼ Filtered"})]},t.label)),e.jsxs("div",{onClick:()=>Po("queue"),title:"View real-time queue details",style:{background:ht?"rgba(14,165,233,0.04)":"#fff",borderRadius:12,padding:"16px 20px",border:`1.5px solid ${ht?"#0ea5e9":"#e5e7eb"}`,boxShadow:ht?"0 0 0 2px #0ea5e922":"0 1px 3px rgba(0,0,0,0.05)",position:"relative",overflow:"hidden",cursor:"pointer",transition:"all 0.15s",userSelect:"none"},children:[(g.pending>0||g.active>0)&&e.jsx("span",{style:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:"50%",background:"#22c55e",boxShadow:"0 0 0 2px #dcfce7",animation:"pulse 1.5s infinite"}}),e.jsx("div",{style:{fontSize:28,fontWeight:700,color:"#0ea5e9"},children:g.pending??0}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:4},children:"Waiting in Queue"}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:8,background:g.active>0?"#dcfce7":"#f3f4f6",color:g.active>0?"#166534":"#6b7280"},children:[g.active??0," generating"]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:8,background:"#eff6ff",color:"#1d4ed8"},children:[g.redis_active_jobs??0,"/",g.redis_capacity??0," Redis slots · ",g.remote_worker_active??0," active on ",g.remote_worker_count??0," remote"]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:8,background:g.failed>0?"#fef2f2":"#f3f4f6",color:g.failed>0?"#b91c1c":"#6b7280"},children:[g.failed??0," failed"]})]}),ht&&e.jsx("div",{style:{fontSize:10,color:"#0ea5e9",fontWeight:700,marginTop:6,textTransform:"uppercase",letterSpacing:"0.04em"},children:"▼ Viewing"})]})]}),ht&&(()=>{const t=s=>s>=60?`${Math.floor(s/60)}m ${s%60}s`:`${s}s`,n=Object.fromEntries(K.map(s=>[String(s.id),s])),a=s=>Pi(c=>{const x=new Set(c);return x.has(s)?x.delete(s):x.add(s),x}),o=({source:s,workerId:c})=>{const x=s&&s.startsWith("worker:"),h=c||(x?s.replace("worker:",""):"");return x?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:6,background:"#ede9fe",color:"#6d28d9",border:"1px solid #ddd6fe"},children:[e.jsx(ss,{size:9})," WORKER",h?`: ${h}`:""]}):e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:6,background:"#dbeafe",color:"#1d4ed8",border:"1px solid #bfdbfe"},children:[e.jsx(Pe,{size:9})," PARENT HUB"]})},r=({plan:s})=>{if(!s)return null;const c=s.toLowerCase(),x=c.includes("pro")?"#7c3aed":c.includes("business")||c.includes("enterprise")?"#0369a1":"#374151",h=c.includes("pro")?"#ede9fe":c.includes("business")||c.includes("enterprise")?"#dbeafe":"#f3f4f6";return e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:5,background:h,color:x,border:`1px solid ${h}`},children:s})},l=({hasImage:s,aspectRatio:c})=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:5,background:s?"#fef3c7":"#f0fdf4",color:s?"#92400e":"#166534",border:`1px solid ${s?"#fde68a":"#bbf7d0"}`},children:[s?"🖼 Img→Vid":"✏️ Text→Vid",c&&c!=="16:9"&&e.jsxs("span",{style:{opacity:.7},children:[" · ",c]})]}),d=({jobId:s,prompt:c,promptPreview:x,accentColor:h})=>{const m=Ni.has(s),k=c&&c.length>120,R=m?c:x||c||"";
39return R?e.jsxs("div",{style:{marginTop:6,fontSize:11,color:"#374151",lineHeight:1.5},children:[e.jsx("span",{style:{fontWeight:600,color:h,marginRight:4},children:"Prompt:"}),e.jsxs("span",{style:{wordBreak:"break-word"},children:[R,!m&&k?"…":""]}),k&&e.jsx("button",{onClick:()=>a(s),style:{marginLeft:6,fontSize:10,color:h,background:"none",border:"none",cursor:"pointer",fontWeight:700,padding:0},children:m?"show less ▲":"show more ▼"})]}):null},u=s=>xn(s);return e.jsxs("div",{style:{background:"#fff",border:"1.5px solid #0ea5e9",borderRadius:12,padding:20,marginBottom:24,boxShadow:"0 2px 8px rgba(14,165,233,0.1)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Fe,{size:16,color:"#0ea5e9"}),e.jsx("span",{style:{fontWeight:700,fontSize:14},children:"Live Queue"}),(g.pending>0||g.active>0)&&e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"#22c55e",display:"inline-block",boxShadow:"0 0 0 2px #dcfce7",animation:"pulse 1.5s infinite"}}),e.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:"auto-refreshes every 3s"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsxs("div",{style:{display:"flex",gap:12,fontSize:12},children:[e.jsxs("span",{style:{color:"#166534",fontWeight:700},children:["⚡ ",(g.active_jobs||[]).length," generating"]}),e.jsxs("span",{style:{color:"#0369a1",fontWeight:700},children:["⏳ ",(g.pending_jobs||[]).length," waiting"]}),e.jsxs("span",{style:{color:"#9d174d",fontWeight:700},children:["❄️ ",Object.keys(g.cooldowns||{}).length," cooldown"]})]}),(g.active_jobs||[]).some(s=>s.started_at&&Date.now()/1e3-s.started_at>=Se*60)&&e.jsxs("button",{disabled:hs,onClick:async()=>{const s=(g.active_jobs||[]).filter(c=>c.started_at&&Date.now()/1e3-c.started_at>=Se*60).length;if(confirm(`Terminate all ${s} stuck job(s) running for ${Se}+ minutes?
40
41Their tokens will be released immediately so new jobs can use them.`)){go(!0);try{const c=await f.post("/api/admin/flow-veo-tokens/terminate-stuck-jobs",{threshold_minutes:Se});S({type:"success",msg:c.data.message||`Terminated ${c.data.released} stuck job(s)`}),setTimeout(()=>S(null),5e3),f.get("/api/admin/flow-veo-tokens/queue-stats").then(x=>Z(x.data||{pending:0,active:0})).catch(()=>{})}catch(c){S({type:"error",msg:c?.response?.data?.detail||"Bulk terminate failed"}),setTimeout(()=>S(null),4e3)}finally{go(!1)}}},style:{fontSize:11,fontWeight:700,padding:"4px 10px",borderRadius:6,cursor:hs?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,border:"1.5px solid #fca5a5",background:"#fef2f2",color:"#dc2626"},children:[hs?e.jsx(y,{size:12,style:{animation:"spin 1s linear infinite"}}):e.jsx(ae,{size:12}),hs?"Terminating…":"Terminate All Stuck"]}),((g.active_jobs||[]).length>0||(g.pending_jobs||[]).length>0)&&e.jsxs("button",{disabled:bs,onClick:()=>Jo("terminate_all"),style:{fontSize:11,fontWeight:700,padding:"4px 10px",borderRadius:6,cursor:bs?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,border:"1.5px solid #991b1b",background:"#7f1d1d",color:"#fef2f2"},children:[bs?e.jsx(y,{size:12,style:{animation:"spin 1s linear infinite"}}):e.jsx(ae,{size:12}),bs?"Terminating…":"Terminate All"]}),e.jsxs("button",{disabled:ms,onClick:()=>Jo("clear_data"),title:"Permanently delete all video queue records and clear Redis",style:{fontSize:11,fontWeight:700,padding:"4px 10px",borderRadius:6,cursor:ms?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,border:"1.5px solid #7f1d1d",background:"#fff1f2",color:"#9f1239"},children:[ms?e.jsx(y,{size:12,style:{animation:"spin 1s linear infinite"}}):e.jsx(Ne,{size:12}),ms?"Clearing…":"Clear Job Data"]}),e.jsxs("button",{disabled:Pt,onClick:async()=>{const s=g.workers_paused,c=s?"/api/admin/flow-veo-tokens/resume-workers":"/api/admin/flow-veo-tokens/pause-workers";if(confirm(s?"Resume workers? Jobs will start dispatching again.":"Stop workers? New jobs will queue but not start until resumed. In-progress jobs continue.")){gs(!0);try{const h=await f.post(c);S({type:s?"success":"warning",msg:h.data.message||(s?"Workers resumed":"Workers paused")}),setTimeout(()=>S(null),5e3),f.get("/api/admin/flow-veo-tokens/queue-stats").then(m=>Z(m.data||{pending:0,active:0})).catch(()=>{})}catch(h){S({type:"error",msg:h?.response?.data?.detail||"Failed to toggle workers"}),setTimeout(()=>S(null),4e3)}finally{gs(!1)}}},style:{fontSize:11,fontWeight:700,padding:"4px 10px",borderRadius:6,cursor:Pt?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,border:"1.5px solid",...g.workers_paused?{background:"#f0fdf4",color:"#16a34a",borderColor:"#86efac"}:{background:"#fff7ed",color:"#c2410c",borderColor:"#fdba74"}},children:[Pt?e.jsx(y,{size:12,style:{animation:"spin 1s linear infinite"}}):g.workers_paused?e.jsx(Fe,{size:12}):e.jsx(ae,{size:12}),g.workers_paused?"Resume Workers":"Stop Workers"]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>No(s=>
41!s),title:"Auto-terminate settings",style:{fontSize:11,fontWeight:700,padding:"4px 10px",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",gap:4,border:"1.5px solid",...bt?{background:"#f0fdf4",color:"#16a34a",borderColor:"#86efac"}:{background:"#f9fafb",color:"#6b7280",borderColor:"#d1d5db"}},children:[e.jsx(wn,{size:12}),"Auto-Kill ",bt?`${Se}m`:"Off"]}),Oi&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>No(!1),style:{position:"fixed",inset:0,zIndex:49}}),e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",right:0,zIndex:50,background:"#fff",border:"1.5px solid #e5e7eb",borderRadius:10,boxShadow:"0 8px 24px rgba(0,0,0,0.13)",padding:16,minWidth:252},children:[e.jsx("div",{style:{fontWeight:700,fontSize:13,marginBottom:12,color:"#111827"},children:"Auto-Terminate Settings"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("span",{style:{fontSize:12,color:"#374151"},children:"Enable auto-terminate"}),e.jsx("button",{onClick:()=>{const s=!bt;Mi(s);try{localStorage.setItem("fveo_auto_terminate",String(s))}catch{}},style:{background:"none",border:"none",cursor:"pointer",padding:0,lineHeight:0},children:bt?e.jsx(ni,{size:26,color:"#16a34a"}):e.jsx(oi,{size:26,color:"#9ca3af"})})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{fontSize:12,color:"#374151",display:"block",marginBottom:6},children:"Timeout (minutes)"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"number",min:1,max:10,value:Se,onChange:s=>{const c=Math.max(1,Math.min(10,parseInt(s.target.value)||10));Hi(c);try{localStorage.setItem("fveo_auto_terminate_mins",String(c))}catch{}},style:{width:72,padding:"5px 8px",borderRadius:6,border:"1.5px solid #d1d5db",fontSize:14,fontWeight:700,textAlign:"center",outline:"none"}}),e.jsx("span",{style:{fontSize:12,color:"#6b7280"},children:"min (1–10)"})]})]}),e.jsx("div",{style:{fontSize:11,color:"#6b7280",borderTop:"1px solid #f3f4f6",paddingTop:10,lineHeight:"1.5"},children:bt?`The server watchdog always terminates jobs at 10 minutes; this panel can also sweep jobs after ${Se} minutes.`:"The server-side 10-minute watchdog remains active even when this browser sweep is disabled."})]})]})]}),e.jsx("button",{onClick:()=>$o(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:2},children:e.jsx(L,{size:16})})]})]}),g.workers_paused&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",marginBottom:12,background:"#fff7ed",border:"1.5px solid #fdba74",borderRadius:8},children:[e.jsx(ae,{size:14,color:"#c2410c"}),e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#c2410c"},children:"Workers are paused — new jobs are queuing but not being dispatched."}),e.jsxs("button",{disabled:Pt,onClick:async()=>{if(confirm("Resume workers? Jobs will start dispatching again.")){gs(!0);try{const s=await f.post("/api/admin/flow-veo-tokens/resume-workers");S({type:"success",msg:s.data.message||"Workers resumed"}),setTimeout(()=>S(null),5e3),f.get("/api/admin/flow-veo-tokens/queue-stats").then(c=>Z(c.data||{pending:0,active:0})).catch(()=>{})}catch(s){S({type:"error",msg:s?.response?.data?.detail||"Failed to resume workers"}),setTimeout(()=>S(null),4e3)}finally{gs(!1)}}},style:{marginLeft:"auto",fontSize:11,fontWeight:700,padding:"3px 10px",borderRadius:6,border:"1px solid #86efac",background:"#f0fdf4",color:"#16a34a",cursor:Pt?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4},children:[e.jsx(Fe,{size:11})," Resume Workers"]})]}),(()=>{const s=g.active_jobs||[],c=g.pending_jobs||[],x={};for(const m of s){const k=m.source||"hub";x[k]=x[k]||{active:0,pending:0},x[k].active+=1}for(const m of c){const k=m.source||"hub";x[k]||(x[k]={active:0,pending:0}),x[k].pending+=1}const h=Object.entries(x);return h.length===0?null:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginBottom:18,padding:"10px 14px",background:"#f8fafc",borderRadius:10,border:"1px solid #e2e8f0"},children:h.map(([m,k])=>{const R=m.startsWith("worker:"),J=R?m.replace("worker:",""):"",P=R?`WORKER${J?`: ${J}`:""}`:"PARENT HUB",_e=R?"#ede9fe":"#dbeafe",tt=R?"#c4b5fd":"#93c5fd",ze=R?"#5b21b6":"#1e40af",Zt=k.active>0?"#22c55e":"#d1d5db";return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:8,background:_e,border:`1.5px solid ${tt}`},children:[R?e.jsx(ss,{size:11,color:ze}):e.jsx(Pe,{size:11,color:ze}),e.jsx("span",{style:{fontSize:11,fontWeight:700,color:ze},children:P}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:11,fontWeight:800,padding:"1px 7px",borderRadius:6,background:k.active>0?"#dcfce7":"#f3f4f6",color:k.active>0?"#15803d":"#9ca3af",border:`1px solid ${k.active>0?"#86efac":"#e5e7eb"}`},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:Zt,display:"inline-block",...k.active>0?{animation:"pulse 1.5s infinite"}:{}}}),k.active," active"]}),k.pending>0&&e.jsxs("span",{style:{fontSize:11,fontWeight:700,padding:"1px 7px",borderRadius:6,background:"#dbeafe",color:"#1d4ed8",border:"1px solid #93c5fd"},children:[k.pending," waiting"]})]},m)})})})(),e.jsxs("div",{style:{marginBottom:20},children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,color:"#166534",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"#22c55e",display:"inline-block",animation:"pulse 1.5s infinite"}}),"Generating (",(g.active_jobs||[]).length,")",(g.active_jobs||[]).some(s=>s.started_at&&Date.now()/1e3-s.started_at>=600)&&e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:5,background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},children:"⚠ STUCK"})]}),(g.active_jobs||[]).some(s=>s.started_at&&Date.now()/1e3-s.started_at>=600)&&e.jsxs("button",{onClick:async()=>
41{if(confirm(`Force-release all stuck tokens from the active queue?
42
43This will free them so new jobs can use them. Any running HTTP requests will complete in the background but won't block other jobs.`))try{const s=await f.post("/api/admin/flow-veo-tokens/force-release-stuck");S({type:"success",msg:s.data.message||`Released ${s.data.released} token(s)`}),setTimeout(()=>S(null),4e3),f.get("/api/admin/flow-veo-tokens/queue-stats").then(c=>Z(c.data||{pending:0,active:0})).catch(()=>{})}catch(s){S({type:"error",msg:s?.response?.data?.detail||"Force release failed"}),setTimeout(()=>S(null),4e3)}},style:{fontSize:11,fontWeight:700,padding:"3px 10px",borderRadius:6,border:"1px solid #fca5a5",background:"#fef2f2",color:"#dc2626",cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[e.jsx(ae,{size:12})," Force Release Stuck"]})]}),(g.active_jobs||[]).length===0?e.jsx("div",{style:{fontSize:13,color:"#9ca3af",fontStyle:"italic",padding:"10px 0"},children:"No active generations right now"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:(g.active_jobs||[]).map((s,c)=>{const x=s.started_at?Math.round(Date.now()/1e3-s.started_at):null,h=x!==null?t(x):"",m=s.source&&s.source.startsWith("worker:"),k=x!==null&&x>=600;return e.jsxs("div",{style:{borderRadius:10,background:k?"#fff5f5":"#f0fdf4",border:`1.5px solid ${k?"#fca5a5":"#bbf7d0"}`,padding:"12px 14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0,flex:1},children:[e.jsx(y,{size:13,color:k?"#dc2626":"#16a34a",style:{animation:"spin 1.5s linear infinite",flexShrink:0}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsxs("span",{style:{fontSize:12,fontWeight:700,color:k?"#991b1b":"#166534",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s.email||(s.label?s.label:`Token #${s.token_id}`),s.label&&s.email&&e.jsxs("span",{style:{fontSize:10,color:"#4b5563",fontWeight:400,marginLeft:5},children:["(",s.label,")"]})]}),e.jsxs("span",{style:{fontSize:10,color:"#6b7280"},children:["Token #",s.token_id]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[k&&e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:5,background:"#fef2f2",color:"#dc2626",border:"1px solid #fecaca"},children:"STUCK"}),h&&e.jsx("span",{style:{fontSize:13,fontWeight:800,color:k?"#dc2626":"#15803d",fontFamily:"monospace",background:k?"#fef2f2":"#dcfce7",padding:"2px 8px",borderRadius:6},children:h})]})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginBottom:6},children:[e.jsx(o,{source:s.source,workerId:s.worker_id}),s.tool_name&&e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:6,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:s.tool_name}),e.jsx(l,{hasImage:s.has_image,aspectRatio:s.aspect_ratio}),s.aspect_ratio==="16:9"&&e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:5,background:"#f3f4f6",color:"#374151"},children:"16:9"}),s.video_style&&e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:5,background:"#fdf4ff",color:"#7e22ce",border:"1px solid #e9d5ff"},children:s.video_style})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:10,color:"#6b7280",fontWeight:600},children:"User:"}),s.user_email?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:11,color:"#1d4ed8",fontWeight:600},children:s.user_email}),e.jsx(r,{plan:s.user_plan})]}):s.user_id?e.jsxs("span",{style:{fontSize:11,color:"#374151"},children:["ID #",s.user_id]}):e.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontStyle:"italic"},children:m?"from worker server":"—"})]}),e.jsx(d,{jobId:s.job_id||`a${c}`,prompt:s.prompt,promptPreview:s.prompt_preview,accentColor:"#15803d"}),e.jsxs("div",{style:{marginTop:8,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}
43,children:[e.jsxs("div",{style:{fontSize:10,color:"#9ca3af"},children:["job #",s.job_id]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("button",{type:"button",onClick:()=>u(s),title:"View complete generation details","aria-label":`View details for generation ${s.job_id||s.token_id}`,style:{fontSize:11,fontWeight:700,padding:"3px 8px",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",gap:4,border:"1px solid #86efac",background:"#f0fdf4",color:"#166534"},children:[e.jsx(jt,{size:12})," Details"]}),(k||x!==null)&&e.jsxs("button",{disabled:us===s.token_id,onClick:async()=>{const R=s.email||s.label||`Token #${s.token_id}`,J=k?`Force-terminate stuck job for ${R}?
44
45This will release the token so it can be reused. The in-flight HTTP request may still complete in the background.`:`Terminate active job for ${R}?`;if(confirm(J)){uo(s.token_id);try{const P=await f.post("/api/admin/flow-veo-tokens/terminate-job",{token_id:s.token_id});S({type:"success",msg:P.data.message||`Token #${s.token_id} terminated`}),setTimeout(()=>S(null),4e3),f.get("/api/admin/flow-veo-tokens/queue-stats").then(_e=>Z(_e.data||{pending:0,active:0})).catch(()=>{})}catch(P){S({type:"error",msg:P?.response?.data?.detail||"Termination failed"}),setTimeout(()=>S(null),4e3)}finally{uo(null)}}},style:{fontSize:11,fontWeight:700,padding:"3px 10px",borderRadius:6,cursor:us===s.token_id?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,border:"1px solid",...k?{background:"#fef2f2",color:"#dc2626",borderColor:"#fca5a5"}:{background:"#fff7ed",color:"#c2410c",borderColor:"#fdba74"}},children:[us===s.token_id?e.jsx(y,{size:11,style:{animation:"spin 1s linear infinite"}}):e.jsx(ae,{size:11}),us===s.token_id?"Terminating…":"Terminate"]})]})]})]},s.job_id||c)})})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,color:"#0369a1",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:10,display:"flex",alignItems:"center",gap:6},children:[e.jsx(We,{size:11,color:"#0ea5e9"}),"Waiting in Queue (",(g.pending_jobs||[]).length,")"]}),(g.pending_jobs||[]).length===0?e.jsx("div",{style:{fontSize:13,color:"#9ca3af",fontStyle:"italic",padding:"10px 0"},children:"Queue is empty"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:(g.pending_jobs||[]).map((s,c)=>{const x=s.enqueued_at?Math.round(Date.now()/1e3-s.enqueued_at):null,h=x!==null?t(x):"";return e.jsxs("div",{style:{borderRadius:10,background:"#f0f9ff",border:"1.5px solid #bae6fd",padding:"12px 14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{fontSize:18,fontWeight:800,color:"#0ea5e9",lineHeight:1},children:["#",c+1]}),e.jsx("span",{style:{fontSize:11,color:"#0369a1",fontWeight:600},children:"in queue"})]}),h&&e.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"#0369a1",fontFamily:"monospace",background:"#dbeafe",padding:"2px 8px",borderRadius:6},children:["waiting ",h]})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginBottom:6},children:[e.jsx(o,{source:s.source,workerId:s.worker_id}),s.tool_name&&e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:6,background:"#fef3c7",color:"#92400e",border:"1px solid #fde68a"},children:s.tool_name}),e.jsx(l,{hasImage:s.has_image,aspectRatio:s.aspect_ratio}),s.aspect_ratio==="16:9"&&e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:5,background:"#f3f4f6",color:"#374151"},children:"16:9"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{fontSize:10,color:"#6b7280",fontWeight:600},children:"User:"}),s.user_email?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:11,color:"#1d4ed8",fontWeight:600},children:s.user_email}),e.jsx(r,{plan:s.user_plan})]}):s.user_id?e.jsxs("span",{style:{fontSize:11,color:"#374151"},children:["ID #",s.user_id]}):e.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontStyle:"italic"},children:"—"})]}),e.jsx(d,{jobId:s.job_id||`p${c}`,prompt:s.prompt,promptPreview:s.prompt_preview,accentColor:"#0369a1"}
45),e.jsxs("div",{style:{marginTop:6,fontSize:10,color:"#9ca3af"},children:["job #",s.job_id]})]},s.job_id||c)})})]}),(()=>{const s=g.cooldowns||{},c=Object.entries(s).filter(([,x])=>x>0);return e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,color:"#9d174d",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:10,display:"flex",alignItems:"center",gap:6},children:[e.jsx(We,{size:11,color:"#ec4899"}),"Cooldown Queue (",c.length,")"]}),c.length===0?e.jsx("div",{style:{fontSize:13,color:"#9ca3af",fontStyle:"italic",padding:"10px 0"},children:"No accounts in cooldown"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:c.map(([x,h])=>{const m=n[x],k=Math.floor(h/60),R=h%60,J=k>0?`${k}m ${R}s`:`${R}s`,P=Math.round((1-h/(g.cooldown_sec||180))*100);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",borderRadius:8,background:"#fdf2f8",border:"1px solid #fbcfe8"},children:[e.jsx(We,{size:13,color:"#ec4899",style:{flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#9d174d",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m?.email||m?.label||`Token #${x}`}),m?.label&&m?.email&&e.jsxs("span",{style:{fontSize:10,color:"#6b7280"},children:["(",m.label,")"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:10,color:"#be185d"},children:"Post-generation cooldown"}),e.jsxs("span",{style:{fontSize:10,color:"#9ca3af"},children:["Token #",x]})]}),P>=0&&e.jsx("div",{style:{marginTop:5,height:3,background:"#fce7f3",borderRadius:2,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${Math.min(P,100)}%`,background:"#ec4899",borderRadius:2,transition:"width 1s linear"}})})]}),e.jsx("span",{style:{fontSize:13,fontWeight:800,color:"#9d174d",flexShrink:0,fontFamily:"monospace",background:"#fce7f3",padding:"3px 9px",borderRadius:6},children:J})]},x)})})]})})()]})})()]}),Fo&&(()=>{const t=Fo,n=t.started_at?new Date(t.started_at*1e3):null,a=t.enqueued_at?new Date(t.enqueued_at*1e3):null,o=t.started_at?Math.max(0,Math.round(Date.now()/1e3-t.started_at)):null,r=o!==null&&o>=600,l=t.metadata||t.request_metadata||{},d=[["Job ID",t.job_id],["Status",r?"Generating · over 10-minute limit":t.status||"processing"],["Source",t.source||t.source_server||"hub"],["Worker / server",t.worker_id||(t.source&&t.source.startsWith("worker:")?t.source.slice(7):"Parent Hub")],["Token ID",t.token_id],["Token email",t.email||t.token_email],["Token label",t.label||t.token_label],["User ID",t.user_id],["User email",t.user_email],["User name",t.user_name],["Plan",t.user_plan],["Started",n?n.toLocaleString():null],["Enqueued",a?a.toLocaleString():null],["Elapsed",o!==null?`${Math.floor(o/60)}m ${o%60}s`:null]],u=[["Request origin",t.request_origin||t.source_server||t.source],["Origin",l.origin||t.origin],["Host",l.host||t.host],["IP address",t.remote_ip||t.ip_address||t.ip],["Referrer",t.referrer||t.referer],["User agent",t.user_agent],["Request URL",l.request_url||t.request_url]],s=[["Mode",t.has_image?"Image to video":"Text to video"],["Aspect ratio",t.aspect_ratio],["Model",t.model_name||t.model||"—"],["Tool",t.tool_name],["Video style",t.video_style],["Custom style description",t.custom_style_description],["Image supplied",t.has_image?"Yes":"No"]],c=x=>x.map(([h,m])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"170px minmax(0, 1fr)",gap:12,padding:"8px 0",borderBottom:"1px solid #f1f5f9",fontSize:12},children:[e.jsx("span",{style:{color:"#64748b",fontWeight:700},children:h}),e.jsx("span",{style:{color:"#0f172a",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:m==null||m===""?"—":String(m)})]},h));return e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"active-generation-details-title",onClick:()=>xn(null),style:{position:"fixed",inset:0,zIndex:1300,background:"rgba(15,23,42,0.58)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},children:e.jsxs("div",{onClick:x=>x.stopPropagation(),style:{width:"min(1120px, 96vw)",maxHeight:"92vh",overflowY:"auto",background:"#fff",borderRadius:14,boxShadow:"0 24px 70px rgba(15,23,42,0.32)",border:"1px solid #cbd5e1"},children:[e.jsxs("div",{style:{position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"16px 22px",background:"#fff",borderBottom:"1px solid #e2e8f0"},children:[e.jsxs("div",{style:{minWidth:0}
45,children:[e.jsxs("div",{id:"active-generation-details-title",style:{display:"flex",alignItems:"center",gap:8,fontWeight:800,fontSize:16,color:"#0f172a"},children:[e.jsx(jt,{size:18,color:r?"#dc2626":"#16a34a"}),"Active generation details",e.jsx("span",{style:{fontSize:11,fontWeight:700,padding:"3px 8px",borderRadius:999,background:r?"#fee2e2":"#dcfce7",color:r?"#b91c1c":"#166534"},children:r?"STUCK":"GENERATING"})]}),e.jsxs("div",{style:{marginTop:4,color:"#64748b",fontSize:11,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.job_id||"Unknown job"," · live queue record"]})]}),e.jsx("button",{type:"button",onClick:()=>xn(null),"aria-label":"Close generation details",style:{background:"none",border:"none",cursor:"pointer",color:"#64748b",padding:5,display:"flex"},children:e.jsx(L,{size:21})})]}),e.jsxs("div",{style:{padding:"20px 22px 24px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:18},children:[e.jsxs("section",{style:{border:"1px solid #e2e8f0",borderRadius:10,padding:"12px 14px",background:"#f8fafc"},children:[e.jsx("h3",{style:{margin:"0 0 4px",fontSize:12,color:"#334155",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Identity & lifecycle"}),c(d)]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:18},children:[e.jsxs("section",{style:{border:"1px solid #dbeafe",borderRadius:10,padding:"12px 14px",background:"#eff6ff"},children:[e.jsx("h3",{style:{margin:"0 0 4px",fontSize:12,color:"#1d4ed8",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Request & traffic"}),c(u)]}),e.jsxs("section",{style:{border:"1px solid #e9d5ff",borderRadius:10,padding:"12px 14px",background:"#faf5ff"},children:[e.jsx("h3",{style:{margin:"0 0 4px",fontSize:12,color:"#7e22ce",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Generation options"}),c(s)]})]})]}),e.jsxs("section",{style:{marginTop:18,border:"1px solid #bbf7d0",borderRadius:10,padding:"14px 16px",background:"#f0fdf4"},children:[e.jsx("h3",{style:{margin:"0 0 8px",fontSize:12,color:"#166534",textTransform:"uppercase",letterSpacing:"0.05em"},children:"User-requested prompt"}),e.jsx("div",{style:{fontSize:13,color:"#14532d",lineHeight:1.65,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.prompt||t.prompt_preview||"No prompt was included in this queue record."})]}),e.jsxs("section",{style:{marginTop:18,border:"1px solid #e2e8f0",borderRadius:10,padding:"14px 16px",background:"#fff"},children:[e.jsx("h3",{style:{margin:"0 0 8px",fontSize:12,color:"#475569",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Available request metadata"}),Object.keys(l).length>0?e.jsx("pre",{style:{margin:0,maxHeight:220,overflow:"auto",padding:12,borderRadius:8,background:"#0f172a",color:"#e2e8f0",fontSize:11,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(l,null,2)}):e.jsx("div",{style:{fontSize:12,color:"#94a3b8"},children:"No additional metadata was recorded for this generation."})]})]})]})})})(),T==="webhook"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:20,marginBottom:24},children:[e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:20,boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsxs("h3",{style:{fontWeight:600,marginBottom:14,display:"flex",alignItems:"center",gap:8,margin:"0 0 14px"},children:[e.jsx(Dr,{size:17,color:"#6366f1"})," Webhook Config"]}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",marginBottom:5,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Endpoint URL"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("code",{style:{background:"#1e293b",color:"#e2e8f0",padding:"6px 10px",borderRadius:6,fontSize:12,flex:1,wordBreak:"break-all"},children:In}),e.jsx("button",{onClick:()=>Bt(In),className:"btn btn-secondary",style:{padding:"6px 10px",flexShrink:0},children:e.jsx(rt,{size:13})})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",marginBottom:5,textTransform:"uppercase",letterSpacing:"0.04em"},children:"X-Webhook-Secret Header"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("code",{style:{background:"#1e293b",color:Et?"#86efac":"#94a3b8",padding:"6px 10px",borderRadius:6,fontSize:12,flex:1,wordBreak:"break-all"}
45,children:Et||"(not configured)"}),Et&&e.jsx("button",{onClick:()=>Bt(Et),className:"btn btn-secondary",style:{padding:"6px 10px",flexShrink:0},children:e.jsx(rt,{size:13})})]})]}),e.jsxs("button",{onClick:xr,disabled:Gs,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,fontSize:13},children:[Gs?e.jsx(y,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(qt,{size:14}),Gs?"Generating...":Et?"Regenerate Secret":"Generate Secret"]})]}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:20,boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsxs("h3",{style:{fontWeight:600,marginBottom:14,display:"flex",alignItems:"center",gap:8,margin:"0 0 14px"},children:[e.jsx(nt,{size:17,color:"#6366f1"})," Emails API Key"]}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"0 0 14px"},children:["Use this key to query token emails via ",e.jsx("code",{style:{background:"#f3f4f6",padding:"1px 4px",borderRadius:3},children:"X-API-Key"})," header. Raw tokens are never exposed."]}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",marginBottom:5,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Current API Key"}),e.jsx("code",{style:{display:"block",background:"#1e293b",color:cs.configured?"#e2e8f0":"#94a3b8",padding:"6px 10px",borderRadius:6,fontSize:12,wordBreak:"break-all"},children:cs.configured?cs.masked_key:"(not configured — generate below)"})]}),Os&&e.jsxs("div",{style:{marginBottom:14,background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:8,padding:"10px 12px"},children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#16a34a",marginBottom:6},children:"New key — copy now, won't show again:"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("code",{style:{background:"#1e293b",color:"#86efac",padding:"6px 10px",borderRadius:6,fontSize:12,flex:1,wordBreak:"break-all"},children:Os}),e.jsx("button",{onClick:()=>Bt(Os),className:"btn btn-secondary",style:{padding:"6px 10px",flexShrink:0},children:e.jsx(rt,{size:13})})]})]}),e.jsxs("button",{onClick:ir,disabled:Us,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,fontSize:13},children:[Us?e.jsx(y,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(nt,{size:14}),Us?"Generating...":cs.configured?"Regenerate API Key":"Generate API Key"]})]})]}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,marginBottom:24,boxShadow:"0 1px 3px rgba(0,0,0,0.05)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",borderBottom:"1px solid #e5e7eb"},children:[{key:"webhook",label:"Webhook Payload Examples",icon:e.jsx(at,{size:14})},{key:"emails",label:"Emails Info Types",icon:e.jsx(nt,{size:14})}].map(t=>e.jsxs("button",{onClick:()=>vi(t.key),style:{display:"flex",alignItems:"center",gap:6,padding:"12px 20px",fontSize:13,fontWeight:600,cursor:"pointer",border:"none",background:"none",borderBottom:vs===t.key?"2px solid #6366f1":"2px solid transparent",color:vs===t.key?"#6366f1":"#6b7280",marginBottom:-1,transition:"color 0.15s"},children:[t.icon,t.label]},t.key))}),e.jsxs("div",{style:{padding:20},children:[vs==="webhook"&&e.jsx("pre",{style:{margin:0,fontSize:12,color:"#374151",overflow:"auto",background:"#f8fafc",padding:16,borderRadius:8,border:"1px solid #e2e8f0",lineHeight:1.6},children:`// Add raw token strings (email & expiry auto-fetched from Google)
46{ "action": "add", "tokens": ["ya29.xxx", "ya29.yyy"] }
47
48// Add full JSON response (saves refresh token, cookies, token_info)
49{ "action": "add", "token_data": { "access_token": "ya29.xxx", "OAuthRefreshToken": "1//...", "refresh_api": { "access_token": "ya29.yyy", "expires_in": 3599 }, "cookies": [...], "token_info": { "email": "[email protected]", "exp": "1775552580", "expires_in": "2259" } } }
50
51// Mix of raw strings and JSON objects in one batch
52{ "action": "add", "tokens": ["ya29.xxx", { "access_token": "ya29.yyy", "OAuthRefreshToken": "..." }] }
53
54// List active tokens
55{ "action": "list" }
56
57// Deactivate a token
58{ "action": "deactivate", "token_id": 3 }`}),vs==="emails"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("p",{style:{margin:0,fontSize:13,color:"#6b7280"},children:["Query token emails via ",e.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:4,fontSize:12},children:"GET /api/public/flow-veo-tokens/emails"}),". Authenticate with the ",e.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:4,fontSize:12},children:"X-API-Key"})," header. Raw tokens are never exposed."]}),[{type:"all",label:"All Tokens",desc:"Returns emails for every token in the database regardless of status.",response:`{
59  "type": "all",
60  "count": 12,
61  "emails": [
62    "[email protected]",
63    "[email protected]",
64    ...
65  ]
66}`},{type:"active",label:"Active Tokens Only",desc:"Returns emails for tokens that are currently active and within quota.",response:`{
67  "type": "active",
68  "count": 8,
69  "emails": [
70    "[email protected]",
71    "[email protected]",
72    ...
73  ]
74}`},{type:"expired",label:"Expired / Inactive Tokens",desc:"Returns emails for tokens that are expired or inactive.",response:`{
75  "type": "expired",
76  "count": 4,
77  "emails": [
78    "[email protected]",
79    "[email protected]",
80    ...
81  ]
82}`},{type:"session_destroy",label:"Session Destroyed Tokens",desc:"Returns emails for tokens whose OAuth session was destroyed — refresh failed with a non-200 response or missing access_token.",response:`{
83  "type": "session_destroy",
84  "count": 2,
85  "emails": [
86    "[email protected]",
87    "[email protected]",
88    ...
89  ]
90}`}].map(t=>e.jsxs("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,overflow:"hidden"},children:[e.jsxs("div",{style:{background:"#f8fafc",padding:"8px 14px",borderBottom:"1px solid #e5e7eb",display:"flex",alignItems:"center",gap:8},children:[e.jsxs("code",{style:{fontSize:12,color:"#6366f1",fontWeight:600},children:["?type=",t.type]}),e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"#374151"},children:["— ",t.label]})]}),e.jsxs("div",{style:{padding:"10px 14px",display:"flex",gap:16,flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:1,minWidth:200},children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#9ca3af",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Request"}),e.jsx("pre",{style:{margin:0,fontSize:11,background:"#1e293b",color:"#e2e8f0",padding:"10px 12px",borderRadius:6,overflow:"auto"},children:`GET /api/public/flow-veo-tokens/emails?type=${t.type}
91X-API-Key: fveo_8f2***...***94b0`}),e.jsx("p",{style:{margin:"8px 0 0",fontSize:12,color:"#6b7280"},children:t.desc})]}),e.jsxs("div",{style:{flex:1,minWidth:200},children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"#9ca3af",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Response"}),e.jsx("pre",{style:{margin:0,fontSize:11,background:"#f0fdf4",color:"#166534",padding:"10px 12px",borderRadius:6,border:"1px solid #bbf7d0",overflow:"auto"},children:t.response})]})]})]},t.type))]})]})]}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:20,boxSh
91adow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[e.jsxs("h3",{style:{fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:8},children:[e.jsx(at,{size:17,color:"#6366f1"})," Webhook Logs",e.jsxs("span",{style:{fontSize:12,fontWeight:500,color:"#6b7280"},children:["(",ks," total)"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,fontSize:13},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,color:"#16a34a",fontWeight:600},children:[e.jsx(B,{size:14})," ",jo.success," success"]}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,color:"#dc2626",fontWeight:600},children:[e.jsx(Te,{size:14})," ",jo.failed," failed"]}),e.jsxs("button",{onClick:()=>Xe(1,Ke,Le),disabled:Qs,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:5,fontSize:13,padding:"5px 12px"},children:[e.jsx(y,{size:13,style:{animation:Qs?"spin 1s linear infinite":"none"}})," Refresh"]}),e.jsxs("button",{onClick:dr,disabled:Uo||ks===0,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:5,fontSize:13,padding:"5px 12px",color:"#ef4444",borderColor:"#fca5a5",opacity:ks===0?.45:1},children:[Uo?e.jsx(y,{size:13,style:{animation:"spin 1s linear infinite"}}):e.jsx(Ne,{size:13}),"Clear All Logs"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,alignItems:"center"},children:[e.jsxs("div",{style:{position:"relative",flex:1},children:[e.jsx(ot,{size:14,style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",color:"#9ca3af",pointerEvents:"none"}}),e.jsx("input",{type:"text",value:Le,onChange:t=>mi(t.target.value),onKeyDown:t=>t.key==="Enter"&&Xe(1,Ke,Le),placeholder:"Search by email, IP, payload...",style:{width:"100%",padding:"7px 12px 7px 32px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box"}})]}),e.jsxs("select",{value:Ke,onChange:t=>{ji(t.target.value),Xe(1,t.target.value,Le)},style:{padding:"7px 10px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"#fff"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"failed",children:"Failed"})]}),e.jsxs("button",{onClick:()=>Xe(1,Ke,Le),className:"btn btn-secondary",style:{padding:"7px 12px",fontSize:13,display:"flex",alignItems:"center",gap:5},children:[e.jsx(ot,{size:13})," Search"]})]}),Qs?e.jsxs("div",{style:{textAlign:"center",padding:40,color:"#6b7280"},children:[e.jsx(y,{size:20,style:{animation:"spin 1s linear infinite",marginBottom:8}}),e.jsx("div",{children:"Loading logs..."})]}):ho.length===0?e.jsxs("div",{style:{textAlign:"center",padding:40,color:"#9ca3af",border:"1px dashed #e5e7eb",borderRadius:8},children:[e.jsx(at,{size:28,style:{marginBottom:8,opacity:.4}}),e.jsx("div",{style:{fontSize:14},children:"No webhook logs found"})]}):e.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc",borderBottom:"1px solid #e5e7eb"},children:[e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:"#374151",width:70},children:"Status"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Email / Account"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:"#374151",width:80},children:"Action"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:"#374151",width:100},children:"IP"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:"#374151",width:130},children:"Time"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:600,color:"#374151",width:60}})]})}),e.jsx("tbody",{children:ho.map((t,n)=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{borderBottom:"1px solid #f1f5f9",background:n%2===0?"#fff":"#fafafa"},children:[e.jsx("td",{style:{padding:"8px 12px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:t.status==="success"?"#dcfce7":"#fee2e2",color:t.status==="success"?"#16a34a":"#dc2626"},children:[t.status==="success"?e.jsx(B,{size:11}):e.jsx(Te,{size:11}),t.status]})}),e.jsx("td",{style:{padding:"8px 12px",color:"#374151",maxWidth:180},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0},title:t.email||t.account_name||"",children:[e.jsx(ts,{size:12,color:"#9ca3af",style:{flexShrink:0}}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.email||t.account_name||e.jsx("span",{style:{color:"#9ca3af"},children:"—"})})]})}),e.jsx("td",{style:{padding:"8px 12px"},children:t.action?e.jsx("span",{style:{padding:"2px 7px",borderRadius:6,background:"#ede9fe",color:"#7c3aed",fontSize:11,fontWeight:600},children:t.action}):"—"}),e.jsx("td",{style:{padding:"8px 12px",color:"#6b7280",fontFamily:"monospace",fontSize:12},children:t.ip_address||"—"}),e.jsx("td",{style:{padding:"8px 12px",color:"#9ca3af",fontSize:12},children:t.created_at?new Date(t.created_at+(t.created_at.includes("Z")?"":"Z")).toLocaleStr
91ing():"—"}),e.jsx("td",{style:{padding:"8px 12px",textAlign:"center"},children:(t.payload_summary||t.error_message||t.response_summary)&&e.jsx("button",{onClick:()=>ki(Ks===t.id?null:t.id),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:2,display:"flex",alignItems:"center"},children:Ks===t.id?e.jsx(zn,{size:15}):e.jsx(es,{size:15})})})]},t.id),Ks===t.id&&e.jsx("tr",{style:{background:"#f8fafc",borderBottom:"1px solid #e5e7eb"},children:e.jsxs("td",{colSpan:6,style:{padding:"10px 16px"},children:[t.payload_summary&&e.jsxs("div",{style:{marginBottom:6},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#6b7280",textTransform:"uppercase"},children:"Payload"}),e.jsx("pre",{style:{margin:"4px 0 0",fontSize:11,color:"#374151",background:"#fff",border:"1px solid #e5e7eb",padding:"8px 10px",borderRadius:6,overflow:"auto",maxHeight:120,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.payload_summary})]}),t.error_message&&e.jsxs("div",{style:{marginBottom:6},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#dc2626",textTransform:"uppercase"},children:"Error"}),e.jsx("pre",{style:{margin:"4px 0 0",fontSize:11,color:"#dc2626",background:"#fff5f5",border:"1px solid #fecaca",padding:"8px 10px",borderRadius:6,overflow:"auto",maxHeight:80,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.error_message})]}),t.response_summary&&e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#6b7280",textTransform:"uppercase"},children:"Response"}),e.jsx("pre",{style:{margin:"4px 0 0",fontSize:11,color:"#374151",background:"#fff",border:"1px solid #e5e7eb",padding:"8px 10px",borderRadius:6,overflow:"auto",maxHeight:80,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.response_summary})]})]})},`${t.id}-detail`)]}))})]})}),Js>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:8,marginTop:16},children:[e.jsx("button",{onClick:()=>Xe(Ht-1,Ke,Le),disabled:Ht<=1,className:"btn btn-secondary",style:{padding:"6px 12px"},children:e.jsx(ns,{size:14})}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Page ",Ht," of ",Js]}),e.jsx("button",{onClick:()=>Xe(Ht+1,Ke,Le),disabled:Ht>=Js,className:"btn btn-secondary",style:{padding:"6px 12px"},children:e.jsx(os,{size:14})})]})]})]}),T==="refresh_logs"&&(()=>{const t=Date.now()/1e3,n=re.next_cycle_at>t?Math.round(re.next_cycle_at-t):0,a=Math.floor(n/60),o=n%60,r=(re.queue||[]).filter(s=>s.status==="pending").length,l=(re.queue||[]).filter(s=>s.status==="success").length,d=(re.queue||[]).filter(s=>s.status==="failed").length,u=(re.queue||[]).filter(s=>s.status==="session_destroy").length;return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",gap:0,marginBottom:20,borderBottom:"2px solid #e5e7eb"},children:[{key:"queue",label:"Queue Accounts",count:re.count},{key:"logs",label:"Logs"}].map(s=>e.jsxs("button",{onClick:()=>{Si(s.key),s.key==="logs"&&et(1,Ge,Ee)},style:{padding:"9px 18px",fontSize:13,fontWeight:Tt===s.key?700:500,color:Tt===s.key?"#6366f1":"#6b7280",background:"none",border:"none",borderBottom:Tt===s.key?"2px solid #6366f1":"2px solid transparent",marginBottom:-2,cursor:"pointer",display:"flex",alignItems:"center",gap:6,transition:"color 0.15s"},children:[s.label,s.count!==void 0&&e.jsx("span",{style:{background:s.count>0?"#6366f1":"#e5e7eb",color:s.count>0?"#fff":"#9ca3af",borderRadius:10,padding:"1px 7px",fontSize:11,fontWeight:700},children:s.count})]},s.key))}),Tt==="queue"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:20,flexWrap:"wrap",alignItems:"center"},children:[e.jsxs("div",{style:{background:"#f0f9ff",border:"1px solid #bae6fd",borderRadius:10,padding:"10px 18px",display:"flex",alignItems:"center",gap:8},children:[e.jsx(We,{size:15,style:{color:"#0ea5e9"}}),e.jsxs("span",{style:{fontSize:13,color:"#0369a1",fontWeight:500},children:["Next refresh cycle in: ",e.jsx("strong",{style:{fontVariantNumeric:"tabular-nums"},children:n>0?`${a}m ${String(o).padStart(2,"0")}s`:"Running soon…"})]})]}),re.last_cycle_at>0&&e.jsxs("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:10,padding:"10px 18px",display:"flex",alignItems:"center",gap:8},children:[e.jsx(Fe,{size:15,style:{color:"#6b7280"}}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Last cycle: ",e.jsx("strong",{children:new Date(re.last_cycle_at*1e3).toLocaleTimeString()})]})]}),e.jsxs("button",{onClick:rr,disabled:Ot,title:"Immediately run a full refresh cycle for all queued accounts",style:{background:"#6366f1",color:"#fff",border:"none",borderRadius:10,padding:"10px 18px",fontSize:13,fontWeight:600,cursor:Ot?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:7,opacity:Ot?.7:1,transition:"opacity 0.15s"},children:[e.jsx(y,{size:14,style:{animation:Ot?"spin 1s linear infinite":"none"}}),Ot?"Starting…":"Refresh Now"]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:14,marginBottom:20},children:[{label:"Total Queued",value:re.count,color:"#6366f1"},{label:"Pending",value:r,color:"#f59e0b"},{label:"Refreshed",value:l,color:"#22c55e"},{label:"Failed / SD",value:d+u,color:"#ef4444"}].map(s=>e.jsxs("div",{style:{background:"#fff",borderRadius:12,padding:"14px 18px",border:"1px solid #e5e7eb",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("div",{style:{fontSize:26,fontWeight:700,color:s.color},children:s.value??0}),e.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:3},children:s.label})]},s.label))}),e.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:(re.queue||[]).length===0?e.jsxs("div",{style:{textAlign:"center",padding:"52px 0",color:"#9ca3af",fontSize:14},children:[e.jsx(y,{size:22,style:{display:"block",margin:"0 auto 10px",opacity:.4}}),"No accounts currently queued — worker runs every 15 minutes.",n>0&&e.jsxs("div",{style:{marginTop:6,fontSize:12},children:["Next cycle in ",a,"m ",String(o).padStart(2,"0"),"s"]})]}):e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc",borderBottom:"1px solid #e5e7eb"},children:[e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"#"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Email"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Expired"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Queued"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Status"})]})}),e.jsx("tbody",{children:(re.queue||[]).map((s,c)=>{const x=s.expires_at?new Date(s.expires_at):null,h=x?Math.round((Date.now()-x.getTime())/1e3):null,m=h!==null?h>=3600?`${Math.floor(h/3600)}h ${Math.floor(h%3600/60)}m ago`:h>=60?`${Math.floor(h/60)}m ${h%60}s ago`:`${h}s ago`:"Unknown",k=s.queued_at?Math.round(t-s.queued_at):null,R=k!==null?k<60?`${k}s ago`:`${Math.floor(k/60)}m ago`:"—",J=s.status==="success"?{bg:"#dcfce7",color:"#16a34a"}:s.status==="failed"?{bg:"#fee2e2",color:"#dc2626"}:s.status==="session_destroy"?{bg:"#ede9fe",color:"#7c3aed"}:{bg:"#fef9c3",color:"#92400e"},P=s.status==="session_destroy"?"Session Destroyed":s.status.charAt(0).toUpperCase()+s.status.slice(1);return e.jsxs("tr",{style:{borderBottom:"1px solid #f3f4f6",background:c%2===0?"#fff":"#fafafa"},children:[e.jsx("td",{style:{padding:"10px 14px",color:"#9ca3af",fontSize:12},children:c+1}),e.jsx("td",{style:{padding:"10px 14px",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},title:s.email,children:s.email||"—"}),e.jsx("td",{style:{padding:"10px 14px",color:x&&x<new Date?"#ef4444":"#374151",whiteSpace:"nowrap",fontSize:12},children:m}),e.jsx("td",{style:{padding:"10px 14px",color:"#6b7280",whiteSpace:"nowrap",fontSize:12},children:R}),e.jsx("td",{style:{padding:"10px 14px"},children:e.jsx("span",{style:{padding:"3px 10px",borderRadius:10,fontSize:11,fontWeight:700,background:J.bg,color:J.color},children:P})})]},s.id)})})]})})]}),Tt==="logs"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:16,marginBottom:24},children:[{label:"Total Attempts",value:_i,color:"#6366f1"},{label:"Successful",value:en.success,color:"#22c55e"},{label:"Failed",value:en.failed,color:"#ef4444"},{label:"Session Destroyed",value:en.session_destroy,color:"#7c3aed"}].map(s=>e.jsxs("div",{style:{background:"#fff",borderRadius:12,padding:"16px 20px",border:"1px solid #e5e7eb",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("div",{style:{fontSize:28,fontWeight:700,color:s.color},children:s.value??0}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:4},children:s.label})]},s.label))}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,padding:20,boxSh
91adow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,alignItems:"center"},children:[e.jsxs("div",{style:{position:"relative",flex:1},children:[e.jsx(ot,{size:14,style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",color:"#9ca3af",pointerEvents:"none"}}),e.jsx("input",{type:"text",value:Ee,onChange:s=>Ri(s.target.value),onKeyDown:s=>s.key==="Enter"&&et(1,Ge,Ee),placeholder:"Search by email or error message...",style:{width:"100%",padding:"8px 12px 8px 34px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box"}})]}),e.jsxs("select",{value:Ge,onChange:s=>{Ci(s.target.value),et(1,s.target.value,Ee)},style:{padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,background:"#fff",minWidth:160},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"session_destroy",children:"Session Destroyed"})]}),e.jsxs("button",{onClick:()=>et(1,Ge,Ee),className:"btn btn-secondary",style:{padding:"8px 14px",fontSize:13,display:"flex",alignItems:"center",gap:5},children:[e.jsx(ot,{size:13})," Search"]})]}),Zs?e.jsxs("div",{style:{textAlign:"center",padding:"40px 0",color:"#9ca3af",fontSize:14},children:[e.jsx(y,{size:18,style:{animation:"spin 1s linear infinite",marginRight:8}})," Loading logs..."]}):wo.length===0?e.jsx("div",{style:{textAlign:"center",padding:"48px 0",color:"#9ca3af",fontSize:14},children:"No refresh logs yet — the background worker runs every 15 minutes."}):e.jsx("div",{style:{border:"1px solid #e5e7eb",borderRadius:8,overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f8fafc",borderBottom:"1px solid #e5e7eb"},children:[e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280",whiteSpace:"nowrap"},children:"Time"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Email"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Status"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"Expires In"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"},children:"New Expiry"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:600,color:"#6b7280"}})]})}),e.jsx("tbody",{children:wo.map((s,c)=>{const x=Ti===s.id,h=s.status==="success"?{color:"#16a34a",bg:"#dcfce7"}:s.status==="session_destroy"?{color:"#7c3aed",bg:"#ede9fe"}:{color:"#dc2626",bg:"#fee2e2"};return e.jsxs(i.Fragment,{children:[e.jsxs("tr",{style:{borderBottom:"1px solid #f3f4f6",background:c%2===0?"#fff":"#fafafa"},children:[e.jsx("td",{style:{padding:"10px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:s.created_at?new Date(s.created_at).toLocaleString():"—"}),e.jsx("td",{style:{padding:"10px 14px",maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:s.email,children:s.email||"—"}),e.jsx("td",{style:{padding:"10px 14px"},children:e.jsx("span",{style:{padding:"3px 10px",borderRadius:10,fontSize:12,fontWeight:600,background:h.bg,color:h.color},children:s.status==="session_destroy"?"Session Destroyed":s.status.charAt(0).toUpperCase()+s.status.slice(1)})}),e.jsx("td",{style:{padding:"10px 14px",color:"#374151"},children:s.expires_in?`${Math.round(s.expires_in/60)}m`:"—"}),e.jsx("td",{style:{padding:"10px 14px",color:"#374151",whiteSpace:"nowrap"},children:s.new_expires_at?new Date(s.new_expires_at).toLocaleString():"—"}),e.jsx("td",{style:{padding:"10px 14px"},children:s.error_message&&e.jsxs("button",{onClick:()=>Wi(x?null:s.id),style:{background:"none",border:"none",cursor:"pointer",color:"#6366f1",fontSize:12,display:"flex",alignItems:"center",gap:3},children:[x?e.jsx(zn,{size:13}):e.jsx(es,{size:13})," Error"]})})]}),x&&e.jsx("tr",{style:{borderBottom:"1px solid #f3f4f6"},children:e.jsx("td",{colSpan:6,style:{padding:"10px 14px 14px",background:"#fef2f2"},children:e.jsx("pre",{style:{margin:0,fontSize:12,color:"#991b1b",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:s.error_message})})})]},s.id)})})]})}),Xs>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:8,marginTop:16},children:[e.jsx("button",{onClick:()=>et(Ut-1,Ge,Ee),disabled:Ut<=1,className:"btn btn-secondary",style:{padding:"6px 12px"},children:e.jsx(ns,{size:14})}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Page ",Ut," / ",Xs]}),e.jsx("button",{onClick:()=>et(Ut+1,Ge,Ee),disabled:Ut>=Xs,className:"btn btn-secondary",style:{padding:"6px 12px"},children:e.jsx(os,{size:14})})]})]})]})]})})(),T==="tokens"&&e.jsxs(e.Fragment,{children:[As&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},onClick:()=>{dt||(lt(!1),He({tokens:""}),Oe(null))},children:e.jsxs("div",{style:{background:"#fff",borderRadius:14,padding:28,width:600,maxWidth:"100%",maxHeight:"90vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.22)"},onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[e.jsxs("h3",{style:{fontWeight:700,margin:0,fontSize:17,display:"flex",alignItems:"center",gap:8},children:[e.jsx(nt,{size:18})," Add Bearer Tokens"]}),e.jsx("button",{onClick:()=>{lt(!1),He({tokens:""}),Oe(null)},style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,display:"flex"},children:e.jsx(L,{size:18})})]}),e.jsxs("p",{style:{fontSize:13,color:"#6b7280",marginBottom:18,marginTop:4},children:["Paste raw ",e.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:4},children:"ya29.xxx"})," token strings (one per line) ",e.jsx("strong",{children:"or"})," paste the full JSON response object to also save the refresh token and cookies."]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{fontSize:13,fontWeight:600,display:"block",marginBottom:6},children:"Token data (raw tokens or JSON response)"}),e.jsx("textarea",{value:Me.tokens,onChange:t=>He(n=>({...n,tokens:t.target.value})),placeholder:`ya29.a0Aa7MYiqYp1kO...
92
93OR paste the full JSON:
94{ "access_token": "ya29...", "OAuthRefreshToken": "1//...", "refresh_api": {...}, "cookies": [...], "token_info": {...} }`,rows:8,autoFocus:!0,style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,fontFamily:"monospace",boxSizing:"border-box",resize:"vertical"}})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:mr,disabled:dt,className:"btn btn-primary",style:{display:"flex",alignItems:"center",gap:6},children:[dt?e.jsx(y,{size:16,style:{animation:"spin 1s linear infinite"}}):e.jsx(si,{size:16})," ",dt?"Validating & Saving...":"Add Tokens"]}),e.jsx("button",{onClick:()=>{lt(!1),He({tokens:""}),Oe(null)},className:"btn btn-secondary",disabled:dt,children:"Cancel"})]}),kt&&kt.length>0&&e.jsxs("div",{style:{marginTop:20,background:"#f8fafc",borderRadius:8,border:"1px solid #e2e8f0",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid #e2e8f0",fontWeight:600,fontSize:13},children:"Token Validation Results"}),kt.map((t,n)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 14px",borderBottom:n<kt.length-1?"1px solid #f1f5f9":"none",flexWrap:"wrap"},children:[t.status==="active"?e.jsx(B,{size:16,color:"#22c55e"}):e.jsx(Te,{size:16,color:"#ef4444"}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13},children:[e.jsx(ts,{size:13,color:"#6b7280"})," ",t.email||"—"]}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13},children:[e.jsx(We,{size:13,color:"#6b7280"})," ",t.expires_in>0?`${Math.round(t.expires_in/60)}m remaining`:"Expired"]}),t.has_refresh_token&&e.jsx("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:8,background:"#dbeafe",color:"#1d4ed8",fontWeight:600},children:"Refresh Token ✓"}),t.has_cookies&&e.jsx("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:8,background:"#fef3c7",color:"#92400e",fontWeight:600},children:"Cookies ✓"}),e.jsx("span",{style:{marginLeft:"auto",padding:"2px 8px",borderRadius:10,fontSize:12,fontWeight:500,background:Cr(t.status),color:Rr(t.status)},children:t.status})]},n))]})]})}),q.open&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},onClick:gn,children:e.jsxs("div",{style:{background:"#fff",borderRadius:14,padding:28,width:480,maxWidth:"100%",boxShadow:"0 24px 64px rgba(0,0,0,0.22)"},onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("h3",{style:{fontWeight:700,margin:0,fontSize:17,display:"flex",alignItems:"center",gap:8},children:[e.jsx(Is,{size:18})," Exporting Tokens"]}),e.jsx("button",{onClick:gn,disabled:F,style:{background:"none",border:"none",cursor:F?"not-allowed":"pointer",color:"#6b7280",padding:4,display:"flex",opacity:F?.4:1},title:F?"Export in progress":"Close",children:e.jsx(L,{size:18})})]}),e.jsx("p",{style:{margin:"0 0 12px",fontSize:13,color:"#6b7280"},children:q.error?"Export failed. You can try again.":q.doneFile?"Your JSON file has been downloaded.":"Fetching accounts in chunks of 1,000 and assembling a single JSON file. Please keep this dialog open."}),e.jsx("div",{style:{background:"#f3f4f6",borderRadius:8,height:14,overflow:"hidden",marginBottom:8},children:e.jsx("div",{style:{height:"100%",background:q.error?"#ef4444":q.doneFile?"#22c55e":"#6366f1",width:q.total>0?`${Math.min(100,Math.round(q.fetched/q.total*100))}%`:F?"8%":"0%",transition:"width 0.25s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,color:"#374151",marginBottom:16},children:[e.jsx("span",{children:q.status}),q.total>0&&e.jsxs("span",{style:{fontWeight:600},children:[Math.min(100,Math.round(q.fetched/q.total*100)),"%"]})]}),q.error&&e.jsx("div",{style:{background:"#fee2e2",color:"#991b1b",padding:"10px 12px",borderRadius:8,fontSize:12,marginBottom:12,wordBreak:"break-word"},children:q.error}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:F?e.jsxs("button",{onClick:sr,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(L,{size:14})," Cancel"]}):e.jsx("button",{onClick:gn,className:"btn btn-primary",children:"Close"})})]})}),qs&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},onClick:()=>{z||G(!1)},children:e.jsxs("div",{style:{background:"#fff",borderRadius:16,padding:30,width:540,maxWidth:"100%",maxHeight:"85vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.25)"},onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:22},children:[e.jsxs("h3",{style:{fontWeight:700,margin:0,fontSize:17,display:"flex",alignItems:"center",gap:8},children:[e.jsx(Bs,{size:18,color:"#6366f1"}),z?"Importing Tokens…":"Import Complete"]}),!z&&e.jsx("button",{onClick:()=>G(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,display:"flex"},children:e.jsx(L,{size:18})})]}),z&&W.totalChunks>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,color:"#6b7280",marginBottom:6},children:[e.jsxs("span",{children:["Chunk ",W.chunk," of ",W.totalChunks]}),e.jsxs("span",{children:[Math.round(W.chunk/W.totalChunks*100),"%"]})]}),e.jsx("div",{style:{height:10,borderRadius:99,background:"#e5e7eb",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:99,background:"linear-gradient(90deg,#6366f1,#8b5cf6)",width:`${Math.round(W.chunk/W.totalChunks*100)}%`,transition:"width 0.3s ease"}})})]}),e.jsxs("div",{style:{fontSize:12,color:"#9ca3af",marginBottom:20,textAlign:"center"},children:["Processing ",W.totalChunks*200>200?`${W.totalChunks} batches of up to 200 accounts each`:"accounts","…"]})]}),(z||$)&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10,marginBottom:20},children:[e.jsxs("div",{style:{background:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:10,padding:"14px 10px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:26,fontWeight:800,color:"#16a34a"},children:z?W.added:$?.added??0}),e.jsx("div",{style:{fontSize:11,color:"#6b7280",marginTop:3,fontWeight:600},children:"Added"})]}),e.jsxs("div",{style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:10,padding:"14px 10px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:26,fontWeight:800,color:"#2563eb"},children:z?W.updated:$?.updated??0}),e.jsx("div",{style:{fontSize:11,color:"#6b7280",marginTop:3,fontWeight:600},children:"Updated"})]}),e.jsxs("div",{style:{background:"#fafafa",border:"1px solid #e5e7eb",borderRadius:10,padding:"14px 10px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:26,fontWeight:800,color:"#6b7280"},children:z?W.skipped:$?.skipped??0}),e.jsx("div",{style:{fontSize:11,color:"#6b7280",marginTop:3,fontWeight:600},children:"Skipped"})]})]}),z&&W.totalChunks===0&&e.jsxs("div",{style:{textAlign:"center",padding:"20px 0",color:"#6b7280"},children:[e.jsx(y,{size:24,style:{animation:"spin 1s linear infinite",marginBottom:10}}),e.jsx("div",{style:{fontSize:13},children:"Parsing file…"})]}),!z&&$?.errors?.length>0&&e.jsxs("div",{style:{background:"#fff7f7",border:"1px solid #fecaca",borderRadius:8,padding:"10px 14px",marginBottom:16},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:12,color:"#dc2626",marginBottom:6},children:[$.errors.length," error(s) during import"]}
94),e.jsxs("div",{style:{maxHeight:100,overflowY:"auto"},children:[$.errors.slice(0,20).map((t,n)=>e.jsxs("div",{style:{fontSize:11,color:"#b91c1c",marginBottom:2},children:["• ",t]},n)),$.errors.length>20&&e.jsxs("div",{style:{fontSize:11,color:"#9ca3af"},children:["…and ",$.errors.length-20," more"]})]})]}),!z&&$&&e.jsx("button",{onClick:()=>G(!1),className:"btn btn-primary",style:{width:"100%",marginTop:4},children:"Done"})]})}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:12,alignItems:"center"},children:[e.jsxs("div",{style:{position:"relative",flex:1},children:[e.jsx(ot,{size:15,style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",color:"#9ca3af",pointerEvents:"none"}}),e.jsx("input",{type:"text",value:ve,onChange:t=>fn(t.target.value),placeholder:"Search by email or token...",style:{width:"100%",padding:"8px 12px 8px 32px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box",background:"#fff"}}),ve&&e.jsx("button",{onClick:()=>fn(""),style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"#9ca3af",padding:2,display:"flex"},children:e.jsx(L,{size:14})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Rn,{size:15,color:"#6b7280"}),e.jsxs("select",{value:ce,onChange:t=>It(t.target.value),style:{padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,background:"#fff",cursor:"pointer",minWidth:140},children:[e.jsx("option",{value:"all",children:"All Statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"quota_full",children:"Daily Quota Full"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"inactive",children:"Inactive"}),e.jsx("option",{value:"invalid",children:"Invalid"}),e.jsx("option",{value:"session_destroy",children:"Session Destroyed"})]})]}),Zo.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsxs("select",{value:Y,onChange:t=>Ns(t.target.value),style:{padding:"8px 12px",border:`1px solid ${Y?"#6366f1":"#d1d5db"}`,borderRadius:8,fontSize:14,background:"#fff",cursor:"pointer",minWidth:120,color:Y?"#6366f1":"inherit",fontWeight:Y?600:400},children:[e.jsx("option",{value:"",children:"All Tags"}),Zo.map(t=>e.jsx("option",{value:t,children:t},t))]}),Y&&e.jsx("button",{onClick:()=>Ns(""),title:"Clear tag filter",style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af",padding:2,display:"flex"},children:e.jsx(L,{size:14})})]}),e.jsxs("div",{style:{fontSize:13,color:"#6b7280",whiteSpace:"nowrap"},children:[V," token",V!==1?"s":""]})]}),Wr&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"#1e293b",color:"#fff",borderRadius:10,padding:"10px 16px",marginBottom:12,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",flexWrap:"wrap"},children:[e.jsxs("span",{style:{fontSize:14,fontWeight:600,whiteSpace:"nowrap",marginRight:4},children:[wt.size," selected"]}),e.jsx("div",{style:{flex:1}}),e.jsxs("button",{onClick:()=>mt("active"),disabled:H,style:{background:"#22c55e",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[e.jsx(B,{size:13})," Activate"]}),e.jsxs("button",{onClick:()=>mt("inactive"),disabled:H,style:{background:"#f59e0b",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[e.jsx(Te,{size:13})," Deactivate"]}),e.jsxs("button",{onClick:()=>mt("delete"),disabled:H,style:{background:"#ef4444",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[e.jsx(Ne,{size:13})," Delete"]}),e.jsx("div",{style:{width:1,height:24,background:"#334155",margin:"0 4px"}}),e.jsxs("button",{onClick:()=>mt("recheck"),disabled:H,title:"Re-verify expiry & status via Google tokeninfo for each selected token",style:{background:"#3b82f6",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[H?e.jsx(y,{size:13,style:{animation:"spin 1s linear infinite"}}):e.jsx(Fe,{size:13})," Recheck Expiry & Status"]}),e.jsxs("button",{onClick:()=>mt("refresh"),disabled:H,title:"Generate a new access token using the stored OAuthRefreshToken for each selected account",style:{background:"#8b5cf6",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[H?e.jsx(y,{size:13,style:{animation:"spin 1s linear infinite"}}):e.jsx(_n,{size:13})," Refresh Access Token"]}),e.jsxs("button",{onClick:()=>mt("reset-quota"),disabled:H,title:"Reset videos_generated to 0 for each selected token",style:{background:"#0d9488",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[H?e.jsx(y,{size:13,style:{animation:"spin 1s linear infinite"}}):e.jsx(qt,{size:13})," Reset Daily Quota"]}),e.jsxs("button",{onClick:()=>mt("unmark-quota"),disabled:H,title:"Clear quota-full flag and re-activate — keeps videos_generated count unchanged",style:{background:"#f59e0b",color:"#fff",border:"none",borderRadius:6,padding:"6px 12px",fontSize:13,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:5,opacity:H?.6:1},children:[H?e.jsx(y,{size:13,style:{animation:"spin 1s linear infinite"}}):e.jsx(B,{size:13})," Unmark Quota Full"]}),e.jsx("button",{onClick:()=>qe(new Set),style:{background:"none",border:"none",color:"#94a3b8",curs
94or:"pointer",padding:4,display:"flex",alignItems:"center",marginLeft:4},children:e.jsx(L,{size:16})})]}),I?e.jsx("div",{style:{textAlign:"center",padding:48,color:"#6b7280"},children:"Loading tokens..."}):K.length===0?e.jsxs("div",{style:{textAlign:"center",padding:48,background:"#fff",borderRadius:12,border:"1px solid #e5e7eb",color:"#6b7280"},children:[e.jsx(nt,{size:40,style:{margin:"0 auto 12px",opacity:.3}}),e.jsx("div",{style:{fontWeight:500,marginBottom:4},children:"No Flow VEO tokens yet"}),e.jsx("div",{style:{fontSize:13},children:'Click "Add Tokens" to add your OAuth bearer tokens'})]}):Tr.length===0?e.jsxs("div",{style:{textAlign:"center",padding:48,background:"#fff",borderRadius:12,border:"1px solid #e5e7eb",color:"#6b7280"},children:[e.jsx(ot,{size:36,style:{margin:"0 auto 12px",opacity:.3}}),e.jsx("div",{style:{fontWeight:500,marginBottom:4},children:"No results found"}),e.jsx("div",{style:{fontSize:13},children:"Try adjusting your search or filter"}),e.jsx("button",{onClick:()=>{fn(""),It("all")},style:{marginTop:12,background:"none",border:"1px solid #d1d5db",borderRadius:6,padding:"6px 14px",cursor:"pointer",fontSize:13},children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:12,overflowX:"auto",overflowY:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:e.jsxs("table",{style:{width:"100%",minWidth:1050,borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid #e5e7eb",background:"#f9fafb"},children:[e.jsx("th",{style:{padding:"12px 14px",width:40},children:e.jsx("input",{type:"checkbox",checked:bn,ref:t=>{t&&(t.indeterminate=Yt.some(n=>wt.has(n))&&!bn)},onChange:Ir,style:{width:16,height:16,cursor:"pointer",accentColor:"#6366f1"}})}),["#","Email","Token","Auth Data","Status","Expires","Videos (Today)","Quota Errors","Total Videos","Added","Actions"].map(t=>e.jsx("th",{style:{padding:"12px 14px",textAlign:"left",fontSize:12,fontWeight:600,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",whiteSpace:"nowrap"},children:t},t))]})}),e.jsx("tbody",{children:Yo.map((t,n)=>{const a=Ur(t.expires_at),o=wt.has(t.id),r=(D-1)*w+n+1;return e.jsxs("tr",{style:{borderBottom:"1px solid #f3f4f6",background:o?"#f0f9ff":"transparent",transition:"background 0.1s"},children:[e.jsx("td",{style:{padding:"12px 14px"},children:e.jsx("input",{type:"checkbox",checked:o,onChange:()=>Br(t.id),style:{width:16,height:16,cursor:"pointer",accentColor:"#6366f1"}})}),e.jsx("td",{style:{padding:"12px 14px",color:"#9ca3af",fontSize:13},children:r}),e.jsx("td",{style:{padding:"12px 14px",maxWidth:180},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.email?e.jsxs("span",{title:t.email,style:{display:"flex",alignItems:"center",gap:5,fontSize:13,minWidth:0},children:[e.jsx(ts,{size:13,color:"#6b7280",style:{flexShrink:0}}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.email})]}):e.jsx("span",{style:{color:"#9ca3af",fontSize:13},children:"—"}),t.is_busy?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:8,background:"#fef9c3",color:"#854d0e",width:"fit-content",letterSpacing:"0.02em"},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"#ca8a04",display:"inline-block",animation:"pulse-opacity 1s ease-in-out infinite"}}),"IN QUEUE"]}):e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:8,background:"#f3f4f6",color:"#9ca3af",width:"fit-content"},children:"FREE"}),(()=>{const l=g.cooldowns?.[String(t.id)];if(!l)return null;const d=Math.floor(l/60),u=l%60,s=d>0?`${d}m ${u}s`:`${u}s`;return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:8,background:"#fdf2f8",color:"#9d174d",width:"fit-content",letterSpacing:"0.02em",border:"1px solid #fbcfe8"},children:[e.jsx(We,{size:9})," COOLDOWN QUEUE ",s]})})(),Array.isArray(t.tags)&&t.tags.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:3,marginTop:2}
94,children:t.tags.map(l=>e.jsx("span",{onClick:()=>Ns(Y===l?"":l),title:`Filter by "${l}"`,style:{display:"inline-block",padding:"1px 7px",borderRadius:10,fontSize:10,fontWeight:600,cursor:"pointer",background:Y===l?"#6366f1":"#ede9fe",color:Y===l?"#fff":"#5b21b6"},children:l},l))})]})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("code",{style:{background:"#f3f4f6",padding:"3px 8px",borderRadius:4,fontSize:12,color:"#374151"},children:t.token_preview}),e.jsx("button",{onClick:()=>Bt(t.token),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:2},title:"Copy full token",children:e.jsx(rt,{size:13})})]})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("span",{title:"Refresh Token (OAuthRefreshToken)",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"2px 7px",borderRadius:8,fontWeight:600,background:t.has_refresh_token?"#dbeafe":"#f3f4f6",color:t.has_refresh_token?"#1d4ed8":"#9ca3af",whiteSpace:"nowrap"},children:[e.jsx(y,{size:10})," RT ",t.has_refresh_token?"✓":"—"]}),e.jsxs("span",{title:"Stored cookies",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"2px 7px",borderRadius:8,fontWeight:600,background:t.has_cookies?"#fef3c7":"#f3f4f6",color:t.has_cookies?"#92400e":"#9ca3af",whiteSpace:"nowrap"},children:["🍪 ",t.has_cookies?"✓":"—"]})]})}),e.jsx("td",{style:{padding:"12px 14px"},children:(()=>{const l=Go(t);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:500,background:l.bg,color:l.color,whiteSpace:"nowrap"},children:[l.icon==="check"?e.jsx(B,{size:12}):e.jsx(Te,{size:12})," ",l.label]})})()}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:a.countdown?14:13,fontWeight:a.countdown?700:500,color:a.color,fontFamily:a.countdown?"monospace":"inherit",letterSpacing:a.countdown?"0.05em":"normal"},children:[e.jsx(We,{size:13,style:{flexShrink:0}}),a.label,a.countdown&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:a.color,display:"inline-block",animation:"pulse-opacity 1s ease-in-out infinite",marginLeft:2}})]})}),e.jsx("td",{style:{padding:"12px 14px"},children:(()=>{const l=t.videos_generated??0,d=Je.daily_quota||10,u=Math.min(l/d*100,100),s=u>=100?"#ef4444":u>=70?"#f59e0b":"#22c55e";let c=null;const x=t.last_video_at||t.first_video_at;if(x){const h=Je.quota_reset_hours||30,R=new Date(new Date(x).getTime()+h*60*60*1e3)-new Date;if(R>0){const J=Math.floor(R/36e5),P=Math.floor(R%36e5/6e4);c=`Resets in ${J}h ${P}m`}else c="Resets soon"}return e.jsxs("div",{style:{minWidth:90},children:[e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:u>=100?"#ef4444":"#374151",marginBottom:4},children:[l," ",e.jsxs("span",{style:{fontWeight:400,color:"#9ca3af"},children:["/ ",d]})]}),e.jsx("div",{style:{height:5,background:"#f3f4f6",borderRadius:4,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${u}%`,background:s,borderRadius:4,transition:"width 0.3s"}})}),c&&e.jsx("div",{style:{fontSize:10,color:u>=100?"#ef4444":"#6b7280",marginTop:3,fontWeight:500},children:c})]})})()}),e.jsx("td",{style:{padding:"12px 14px"},children:(()=>{const l=t.quota_error_count??0,d=Je.quota_error_threshold||5,u=l>=d,s=l>0,c=u?"#ef4444":s?"#f59e0b":"#d1d5db",x=u?"#ef4444":s?"#b45309":"#9ca3af";let h=null;if(t.last_error_at&&!u){const m=t.last_error_at,k=new Date(m.includes?.("Z")||m.includes?.("+")?m:m+"Z"),R=Je.cooldown_sec||180,P=k.getTime()+R*1e3-Date.now();if(P>0){const _e=Math.ceil(P/1e3),tt=Math.floor(_e/60),ze=_e%60;h=tt>0?`${tt}m ${ze}s`:`${ze}s`}}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:3},title:"FREE_QUOTA_EXHAUSTED error count only",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0}}),e.jsxs("span",{style:{fontSize:13,fontWeight:700,color:x,fontFamily:"monospace"},children:[l,e.jsxs("span",{style:{fontWeight:400,color:"#9ca3af"},children:["/",d]})]})]}),u?e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#ef4444",letterSpacing:"0.04em",textTransform:"uppercase"},children:"LIMIT HIT"}):e.jsx("span",{style:{fontSize:9,color:"#9ca3af",letterSpacing:"0.02em",textTransform:"uppercase"},children:"FREE QUOTA"}),h&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:6,background:"#fff7ed",color:"#c2410c",border:"1px solid #fed7aa",letterSpacing:"0.03em",fontFamily:"monospace"},children:[e.jsx(We,{size:9})," ERR CD ",h]})]})})()}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",ga
94p:2},children:[e.jsx("span",{style:{fontSize:15,fontWeight:700,color:"#6366f1"},children:t.total_videos_generated??0}),e.jsx("span",{style:{fontSize:11,color:"#9ca3af"},children:"all-time"})]})}),e.jsx("td",{style:{padding:"12px 14px",whiteSpace:"nowrap"},children:e.jsx("span",{title:Or(t.created_at),style:{fontSize:12,color:"#6b7280",cursor:"default"},children:Hr(t.created_at)})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:[e.jsx("button",{onClick:()=>wr(t),title:"View details",style:{background:"none",border:"1px solid #e9d5ff",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#7c3aed",display:"flex",alignItems:"center"},children:e.jsx(jt,{size:15})}),e.jsx("button",{onClick:()=>cr(t),title:"View token logs",style:{background:"none",border:"1px solid #fde68a",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#b45309",display:"flex",alignItems:"center"},children:e.jsx(at,{size:15})}),e.jsx("button",{onClick:()=>_r(t),title:"Edit token",style:{background:"none",border:"1px solid #bbf7d0",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#16a34a",display:"flex",alignItems:"center"},children:e.jsx(Cn,{size:15})}),e.jsx("button",{onClick:()=>vr(t.id),disabled:An===t.id,title:"Recheck expiry & status",style:{background:"none",border:"1px solid #bfdbfe",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#3b82f6",display:"flex",alignItems:"center"},children:e.jsx(qt,{size:15,style:{animation:An===t.id?"spin 1s linear infinite":"none"}})}),t.has_refresh_token&&e.jsx("button",{onClick:()=>Zi(t.id),disabled:Qn===t.id,title:"Refresh access token",style:{background:"none",border:"1px solid #fde68a",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#d97706",display:"flex",alignItems:"center"},children:e.jsx(_n,{size:15,style:{animation:Qn===t.id?"spin 1s linear infinite":"none"}})}),e.jsx("button",{onClick:()=>Xi(t.id),disabled:Kn===t.id,title:"Reset daily quota (set videos today = 0)",style:{background:"none",border:"1px solid #99f6e4",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#0d9488",display:"flex",alignItems:"center"},children:e.jsx($r,{size:15,style:{animation:Kn===t.id?"spin 1s linear infinite":"none"}})}),(t.quota_filled_at||(t.videos_generated??0)>=Ko)&&e.jsx("button",{onClick:()=>er(t.id),disabled:Yn===t.id,title:"Unmark Quota Full — clears quota flag, re-activates token, keeps video count",style:{background:"none",border:"1px solid #fde68a",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#d97706",display:"flex",alignItems:"center"},children:e.jsx(B,{size:15,style:{animation:Yn===t.id?"spin 1s linear infinite":"none"}})}),e.jsx("button",{onClick:()=>jr(t),title:t.status==="active"?"Deactivate":"Activate",style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#6b7280",display:"flex",alignItems:"center"},children:t.status==="active"?e.jsx(ni,{size:16,color:"#22c55e"}):e.jsx(oi,{size:16})}),e.jsx("button",{onClick:()=>Fn(t),title:"Playground: test video generation",style:{background:"none",border:"1px solid #c7d2fe",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#4f46e5",display:"flex",alignItems:"center"},children:e.jsx(Fr,{size:15})}),e.jsx("button",{onClick:()=>kr(t.id),title:"Delete",style:{background:"none",border:"1px solid #fecaca",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#ef4444",display:"flex",alignItems:"center"},children:e.jsx(Ne,{size:15})})]})})]},t.id)})})]})}),V>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:16,flexWrap:"wrap",gap:8},children:[e.jsx(Pr,{value:w,onChange:t=>{xe(t),Ze(1)},total:V}),e.jsxs("div",{style:{fontSize:13,color:"#6b7280"},children:["Showing ",(D-1)*w+1,"–",Math.min(D*w,V)," of ",V]}),e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx("button",{onClick:()=>Ze(1),disabled:D===1,style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"5px 10px",cursor:D===1?"not-allowed":"pointer",color:D===1?"#d1d5db":"#374151",fontSize:13},children:"«"}),e.jsx("button",{onClick:()=>Ze(t=>Math.max(1,t-1)),disabled:D===1,style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"5px 8px",cursor:D===1?"not-allowed":"pointer",color:D===1?"#d1d5db":"#374151",display:"flex",alignItems:"center"},children:e.jsx(ns,{size:15})}),Array.from({length:pe},(t,n)=>n+1).filter(t=>t===1||t===pe||Math.abs(t-D)<=1).reduce((t,n,a,o)=>(a>0&&n-o[a-1]>1&&t.push("..."),t.push(n),t),[]).map((t,n)=>t==="..."?e.jsx("span",{style:{padding:"5px 6px",color:"#9ca3af",fontSize:13},children:"…"},`e${n}`):e.jsx("button",{onClick:()=>Ze(t),style:{background:t===D?"#6366f1":"none",color:t===D?"#fff":"#374151",border:`1px solid ${t===D?"#6366f1":"#e5e7eb"}`,borderRadius:6,padding:"5px 10px",cursor:"pointer",fontSize:13,fontWeight:t===D?600:400,minWidth:34},children:t},t)),e.jsx("button",{onClick:()=>Ze(t=>Math.min(pe,t+1)),disabled:D===pe,style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"5px 8px",cursor:D===pe?"not-allowed":"pointer",color:D===pe?"#d1d5db":"#374151",display:"flex",alignItems:"center"},children:e.jsx(os,{size:15})}),e.jsx("button",{onClick:()=>Ze(pe),disabled:D===pe,style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"5px 10px",cursor:D===pe?"not-allowed":"pointer",color:D===pe?"#d1d5db":"#374151",fontSize:13},children:"»"})]})]})]})]}),(Nn||v)&&e.jsx("div",{onClick:()=>{rs(null),as(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:20},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"#fff",borderRadius:14,width:"100%",maxWidth:680,maxHeight:"90vh",display:"flex",flexDirection:"column",boxShadow:"0 24px 60px rgba(0,0,0,0.25)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"18px 24px",borderBottom:"1px solid #e5e7eb",flexShrink:0},children:[e.jsxs("h2",{style:{margin:0,fontSize:17,fontWeight:700,display:"flex",alignItems:"center",gap:8},children:[e.jsx(jt,{size:18,color:"#7c3aed"})," Token Details"]}
94),e.jsx("button",{onClick:()=>{rs(null),as(!1)},style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,display:"flex"},children:e.jsx(L,{size:20})})]}),e.jsx("div",{style:{overflowY:"auto",padding:"20px 24px",flex:1},children:Nn&&!v?e.jsx("div",{style:{textAlign:"center",padding:40,color:"#6b7280"},children:e.jsx(y,{size:24,style:{animation:"spin 1s linear infinite"}})}):v&&(()=>{const t=di,n=o=>Pn(r=>({...r,[o]:!r[o]})),a=({label:o,value:r,field:l})=>r?e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("code",{style:{flex:1,background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:6,padding:"6px 10px",fontSize:12,fontFamily:"monospace",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",color:"#1e293b"},children:t[l]?r:r.slice(0,24)+"••••••••••••••"}),e.jsx("button",{onClick:()=>n(l),style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"5px 7px",cursor:"pointer",color:"#6b7280",flexShrink:0,display:"flex"},title:t[l]?"Hide":"Show",children:t[l]?e.jsx(ii,{size:14}):e.jsx(jt,{size:14})}),e.jsx("button",{onClick:()=>Bt(r),style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"5px 7px",cursor:"pointer",color:"#6b7280",flexShrink:0,display:"flex"},title:"Copy",children:e.jsx(rt,{size:14})})]})]}):e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:o}),e.jsx("span",{style:{fontSize:13,color:"#9ca3af"},children:"—"})]});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:20,background:"#f8fafc",borderRadius:10,padding:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:"Email"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:14},children:[e.jsx(ts,{size:14,color:"#6b7280"})," ",v.email||"—"]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:"Status"}),(()=>{const o=Go(v);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:12,fontSize:12,fontWeight:500,background:o.bg,color:o.color},children:[o.icon==="check"?e.jsx(B,{size:12}):e.jsx(Te,{size:12})," ",o.label]})})()]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:"Expires"}),e.jsx("div",{style:{fontSize:13},children:v.expires_at?new Date(v.expires_at+(v.expires_at.includes("Z")?"":"Z")).toLocaleString():"—"})]})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsxs("div",{style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:12,display:"flex",alignItems:"center",gap:6},children:[e.jsx(nt,{size:15})," Auth Tokens"]}),e.jsx(a,{label:"Access Token",value:v.token,field:"token"}),e.jsx(a,{label:"Refresh Token (OAuthRefreshToken)",value:v.refresh_token,field:"refresh_token"}),e.jsx(a,{label:"Refresh Access Token",value:v.refresh_access_token,field:"refresh_access_token"})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#1e293b",display:"flex",alignItems:"center",gap:6},children:"🍪 Cookies"}),v.cookies&&e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsxs("button",{onClick:()=>Mn(o=>!o),style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"4px 10px",cursor:"pointer",fontSize:12,color:"#374151",display:"flex",alignItems:"center",gap:4}
94,children:[Ds?e.jsx(zn,{size:13}):e.jsx(es,{size:13})," ",Ds?"Collapse":"Expand"]}),e.jsx("button",{onClick:()=>Bt(v.cookies),style:{background:"none",border:"1px solid #e5e7eb",borderRadius:6,padding:"4px 8px",cursor:"pointer",color:"#6b7280",display:"flex",alignItems:"center"},children:e.jsx(rt,{size:13})})]})]}),v.cookies?Ds?e.jsx("pre",{style:{background:"#1e293b",color:"#e2e8f0",padding:"12px 14px",borderRadius:8,fontSize:12,overflowX:"auto",maxHeight:280,margin:0},children:v.cookies}):e.jsx("div",{style:{background:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:8,padding:"10px 14px",fontSize:13,color:"#6b7280"},children:(()=>{try{const o=JSON.parse(v.cookies);return`${Array.isArray(o)?o.length:"?"} cookie(s) stored — click Expand to view`}catch{return"Stored — click Expand to view"}})()}):e.jsx("span",{style:{fontSize:13,color:"#9ca3af"},children:"—"})]}),Array.isArray(v.tags)&&v.tags.length>0&&e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"#1e293b",marginBottom:10,display:"flex",alignItems:"center",gap:6},children:"🏷️ Tags"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:v.tags.map(o=>e.jsx("span",{style:{display:"inline-block",padding:"3px 10px",borderRadius:10,background:"#ede9fe",color:"#5b21b6",fontSize:13,fontWeight:600},children:o},o))})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12,background:"#f8fafc",borderRadius:10,padding:16},children:[{label:"Videos Today",value:`${v.videos_generated??0} / ${Je.daily_quota||10}`},{label:"All-Time Videos",value:v.total_videos_generated??0},{label:"Last Used",value:v.last_used_at?new Date(v.last_used_at+(v.last_used_at.includes?.("Z")?"":"Z")).toLocaleString():"—"},{label:"Last Video At",value:v.last_video_at?new Date(v.last_video_at+(v.last_video_at.includes?.("Z")?"":"Z")).toLocaleString():"—"},{label:"Quota Resets At",value:(()=>{const o=v.last_video_at||v.first_video_at;return o?new Date(new Date(o+(o.includes?.("Z")?"":"Z")).getTime()+30*36e5).toLocaleString():"—"})()},{label:"Quota Filled At",value:v.quota_filled_at?new Date(v.quota_filled_at+(v.quota_filled_at.includes?.("Z")?"":"Z")).toLocaleString():"—"},{label:"Last Error At",value:(()=>{if(!v.last_error_at)return"—";const o=v.last_error_at,r=new Date(o.includes?.("Z")||o.includes?.("+")?o:o+"Z"),l=Je.cooldown_sec||180,u=r.getTime()+l*1e3-Date.now();return u>0?`${r.toLocaleString()} — ERR CD ${Math.ceil(u/1e3)}s left`:r.toLocaleString()})()}].map(o=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#6b7280",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:o.label}),e.jsx("div",{style:{fontSize:14,fontWeight:600},children:o.value})]},o.label))})]})})()})]})}),Dt&&e.jsx("div",{onClick:()=>_t(null),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:20},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"#fff",borderRadius:14,width:"100%",maxWidth:600,maxHeight:"90vh",display:"flex",flexDirection:"column",boxShadow:"0 24px 60px rgba(0,0,0,0.25)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"18px 24px",borderBottom:"1px solid #e5e7eb",flexShrink:0},children:[e.jsxs("h2",{style:{margin:0,fontSize:17,fontWeight:700,display:"flex",alignItems:"center",gap:8},children:[e.jsx(Cn,{size:18,color:"#16a34a"})," Edit Token"]}),e.jsx("button",{onClick:()=>_t(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,display:"flex"},children:e.jsx(L,{size:20})})]}),e.jsxs("div",{style:{overflowY:"auto",padding:"20px 24px",flex:1},children:[e.jsx("div",{style:{marginBottom:14},children:e.jsxs("div",{style:{fontSize:12,color:"#6b7280",marginBottom:3},children:["Account: ",e.jsx("strong",{children:Dt.email||Dt.token_preview})]})}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{fontSize:13,fontWeight:500,display:"block",marginBottom:5},children:"Status"}),e.jsxs("select",{value:ee.status,onChange:t=>Qe(n=>({...n,status:t.target.value})),style:{width:"100%",padding:"8px 10px",border:"1px solid #d1d5db",borderRadius:7,fontSize:13,background:"#fff",boxSizing:"border-box"},children:[e.jsx("option",{value:"active",children:"active"}),e.jsx("option",{value:"inactive",children:"inactive"}),e.jsx("option",{value:"invalid",children:"invalid"})]})]}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("label",{style:{fontSize:13,fontWeight:500,display:"block",marginBottom:5},children:["Refresh Token ",e.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(OAuthRefreshToken)"})]}),e.jsx("textarea",{value:ee.refresh_token,onChange:t=>Qe(n=>({...n,refresh_token:t.target.value})),placeholder:"1//05HvPsNnUh707...",rows:2,style:{width:"100%",padding:"8px 10px",border:"1px solid #d1d5db",borderRadius:7,fontSize:12,fontFamily:"monospace",boxSizing:"border-box",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("label",{style:{fontSize:13,fontWeight:500,display:"block",marginBottom:5},children:["Refresh Access Token ",e.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(refresh_api.access_token)"})]}),e.jsx("textarea",{value:ee.refresh_access_token,onChange:t=>Qe(n=>({...n,refresh_access_token:t.target.value})),placeholder:"ya29.a0Aa7MYio...",rows:2,style:{width:"100%",padding:"8px 10px",border:"1px solid #d1d5db",borderRadius:7,fontSize:12,fontFamily:"monospace",boxSizing:"border-box",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("label",{style:{fontSize:13,fontWeight:500,display:"block",marginBottom:5},children:["Cookies ",e.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(JSON array)"})]}),e.jsx("textarea",{value:ee.cookies,onChange:t=>Qe(n=>({...n,cookies:t.target.value})),placeholder:'[{"name":"OAuthRefreshToken","value":"..."}]',rows:5,style:{width:"100%",padding:"8px 10px",border:"1px solid #d1d5db",borderRadius:7,fontSize:12,fontFamily:"monospace",boxSizing:"border-box",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:8},children:[e.jsxs("label",{style:{fontSize:13,fontWeight:500,display:"block",marginBottom:6},children:["Tags ",e.jsx("span",{style:{fontSize:11,color:"#9ca3af",fontWeight:400},children:"(press Enter or comma to add)"})]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"6px 8px",border:"1px solid #d1d5db",borderRadius:7,background:"#fff",minHeight:38,alignItems:"center",cursor:"text"},onClick:()=>document.getElementById("tag-input-edit")?.focus(),children:[(ee.tags||[]).map(t=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:10,background:"#ede9fe",color:"#5b21b6",fontSize:12,fontWeight:600},children:[t,e.jsx("button",{onClick:()=>Qe(n=>({...n,tags:n.tags.filter(a=>a!==t)})),style:{background:"none",border:"none",cursor:"pointer",color:"#7c3aed",padding:0,display:"flex",lineHeight:1},children:e.jsx(L,{size:11})})]}
94,t)),e.jsx("input",{id:"tag-input-edit",value:zt,onChange:t=>Fs(t.target.value),onKeyDown:t=>{if((t.key==="Enter"||t.key===",")&&zt.trim()){t.preventDefault();const n=zt.trim().replace(/,/g,"");n&&!(ee.tags||[]).includes(n)&&Qe(a=>({...a,tags:[...a.tags||[],n]})),Fs("")}else t.key==="Backspace"&&!zt&&(ee.tags||[]).length>0&&Qe(n=>({...n,tags:n.tags.slice(0,-1)}))},placeholder:(ee.tags||[]).length?"":"e.g. production, batch-1…",style:{border:"none",outline:"none",fontSize:13,flex:1,minWidth:80,padding:"2px 2px"}})]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,padding:"16px 24px",borderTop:"1px solid #e5e7eb",flexShrink:0},children:[e.jsxs("button",{onClick:zr,disabled:$s,className:"btn btn-primary",style:{display:"flex",alignItems:"center",gap:6},children:[$s?e.jsx(y,{size:15,className:"spin"}):e.jsx(B,{size:15})," ",$s?"Saving...":"Save Changes"]}),e.jsx("button",{onClick:()=>_t(null),className:"btn btn-secondary",children:"Cancel"})]})]})}),ci&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},onClick:()=>$t(!1),children:e.jsxs("div",{style:{background:"#fff",borderRadius:14,width:"100%",maxWidth:700,maxHeight:"90vh",display:"flex",flexDirection:"column",boxShadow:"0 24px 64px rgba(0,0,0,0.25)"},onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"20px 28px 16px",borderBottom:"1px solid #e5e7eb",flexShrink:0},children:[e.jsxs("h3",{style:{margin:0,fontSize:17,fontWeight:700,display:"flex",alignItems:"center",gap:8},children:[e.jsx(wn,{size:18})," Flow VEO Settings"]}),e.jsx("button",{onClick:()=>$t(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,borderRadius:6,display:"flex",alignItems:"center"},children:e.jsx(L,{size:18})})]}),e.jsxs("div",{style:{overflowY:"auto",flex:1,padding:"20px 28px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 24px"},children:[e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"Daily Quota per Token"}),e.jsx("input",{type:"number",min:1,max:1e3,value:j.daily_quota,onChange:t=>ne(n=>({...n,daily_quota:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsx("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:"Max videos per token per day before quota-full. (1–1000)"})]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"Quota Reset (hours)"}),e.jsx("input",{type:"number",min:1,max:168,value:j.quota_reset_hours,onChange:t=>ne(n=>({...n,quota_reset_hours:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:["Hours after ",e.jsx("strong",{children:"last_video_at"})," before quota resets. Default: 30h. (1–168)"]})]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"Quota Error Threshold"}),e.jsx("input",{type:"number",min:1,max:100,value:j.quota_error_threshold,onChange:t=>ne(n=>({...n,quota_error_threshold:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:[e.jsx("code",{children:"FREE_QUOTA_EXHAUSTED"})," hits in a row before marking quota-full. Default: ",e.jsx("strong",{children:"5"}),". (1–100)"]})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginBottom:18,padding:"14px 16px",borderRadius:10,border:`1.5px solid ${j.auto_smart_unmark_enabled?"#7c3aed":"#e5e7eb"}`,background:j.auto_smart_unmark_enabled?"#faf5ff":"#f9fafb",transition:"all 0.2s"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer"},children:[e.jsx("div",{onClick:()=>ne(t=>({...t,auto_smart_unmark_enabled:!t.auto_smart_unmark_enabled})),style:{width:40,height:22,borderRadius:11,position:"relative",curs
94or:"pointer",flexShrink:0,background:j.auto_smart_unmark_enabled?"#7c3aed":"#d1d5db",transition:"background 0.2s"},children:e.jsx("div",{style:{position:"absolute",top:3,left:j.auto_smart_unmark_enabled?20:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:j.auto_smart_unmark_enabled?"#7c3aed":"#374151"},children:"Automatic Smart Unmark"})]}),e.jsx("p",{style:{fontSize:12,color:j.auto_smart_unmark_enabled?"#6b7280":"#9ca3af",margin:"8px 0 0 50px",lineHeight:1.5},children:"Automatically recovers error-caused quota-full accounts when available active accounts fall below the configured threshold. Video counts are preserved."}),j.auto_smart_unmark_enabled&&e.jsxs("div",{style:{margin:"12px 0 0 50px",maxWidth:360},children:[e.jsx("label",{style:{display:"block",fontSize:12,fontWeight:600,color:"#374151",marginBottom:6},children:"Minimum Active Accounts"}),e.jsx("input",{type:"number",min:1,max:1e6,value:j.auto_smart_unmark_active_threshold,onChange:t=>ne(n=>({...n,auto_smart_unmark_active_threshold:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:["The refresher checks this every 15 minutes. Default: ",e.jsx("strong",{children:"800"}),"."]})]})]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"Post-Generation Cooldown (sec)"}),e.jsx("input",{type:"number",min:0,max:3600,value:j.cooldown_sec,onChange:t=>ne(n=>({...n,cooldown_sec:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:["Wait after successful generation before reuse. Default: ",e.jsx("strong",{children:"180s"}),". (0–3600)"]})]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"New Account Warmup (sec)"}),e.jsx("input",{type:"number",min:0,max:3600,value:j.warmup_sec,onChange:t=>ne(n=>({...n,warmup_sec:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:["Delay before a new account can be dispatched. Default: ",e.jsx("strong",{children:"120s"}),". (0–3600)"]})]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"Video Worker Concurrency"}),e.jsx("input",{type:"number",min:1,max:200,value:j.video_worker_concurrency,onChange:t=>ne(n=>({...n,video_worker_concurrency:t.target.value})),style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:14,boxSizing:"border-box"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:["Redis worker slots for video jobs. Start with ",e.jsx("strong",{children:"60"}),"; changes apply without code changes. (1–200)"]})]}),e.jsxs("div",{style:{marginBottom:18},children:[e.jsx("label",{style:{display:"block",fontSize:13,fontWeight:600,color:"#374151",marginBottom:6},children:"Model Name"}),e.jsx("input",{type:"text",value:j.model_name,onChange:t=>ne(n=>({...n,model_name:t.target.value})),placeholder:"veo-3.1-generate-preview",style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",fontFamily:"monospace"}}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"5px 0 0",lineHeight:1.4},children:["VEO model identifier for generation requests. Default: ",e.jsx("code",{children:"veo-3.1-generate-preview"})]})]})]}),e.jsxs("div",{style:{marginBottom:14,padding:"14px 16px",borderRadius:10,border:"1px solid #e5e7eb",background:"#f9fafb"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer"},children:[e.jsx("div",{onClick:()=>ne(t=>({...t,disable_prompt_rewrite:!t.disable_prompt_rewrite})),style:{width:40,height:22,borderRadius:11,position:"relative",curs
94or:"pointer",flexShrink:0,background:j.disable_prompt_rewrite?"var(--primary, #7c3aed)":"#d1d5db",transition:"background 0.2s"},children:e.jsx("div",{style:{position:"absolute",top:3,left:j.disable_prompt_rewrite?20:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#374151"},children:"Disable Prompt Rewrite"})]}),e.jsxs("p",{style:{fontSize:12,color:"#6b7280",margin:"6px 0 0 50px",lineHeight:1.5},children:["Sends ",e.jsx("code",{children:"disablePromptRewrite: true"})," — prompt is used verbatim without AI rewriting."]})]}),e.jsxs("div",{style:{marginBottom:8,padding:"14px 16px",borderRadius:10,border:`1.5px solid ${j.audio_check_enabled?"#7c3aed":"#e5e7eb"}`,background:j.audio_check_enabled?"#faf5ff":"#f9fafb",transition:"all 0.2s"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer"},children:[e.jsx("div",{onClick:()=>ne(t=>({...t,audio_check_enabled:!t.audio_check_enabled})),style:{width:40,height:22,borderRadius:11,position:"relative",cursor:"pointer",flexShrink:0,background:j.audio_check_enabled?"#7c3aed":"#d1d5db",transition:"background 0.2s"},children:e.jsx("div",{style:{position:"absolute",top:3,left:j.audio_check_enabled?20:3,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:j.audio_check_enabled?"#7c3aed":"#374151"},children:"Auto-Regenerate on Silent Video"})]}),e.jsx("p",{style:{fontSize:12,color:j.audio_check_enabled?"#6b7280":"#9ca3af",margin:"8px 0 0 50px",lineHeight:1.5},children:j.audio_check_enabled?e.jsxs(e.Fragment,{children:["Inspects every generated video with ",e.jsx("code",{children:"ffprobe"})," for audio. If silent, discards and regenerates — up to ",e.jsx("strong",{children:"3 attempts"}),". Failed videos do ",e.jsx("strong",{children:"not"})," consume daily quota."]}):e.jsxs(e.Fragment,{children:["Audio check is ",e.jsx("strong",{children:"disabled"})," — videos are delivered as-is without audio verification."]})})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",padding:"16px 28px",borderTop:"1px solid #e5e7eb",flexShrink:0,background:"#fff",borderRadius:"0 0 14px 14px"},children:[e.jsxs("button",{onClick:Vi,disabled:Ps,className:"btn btn-primary",style:{display:"flex",alignItems:"center",gap:6},children:[Ps?e.jsx(y,{size:15,style:{animation:"spin 1s linear infinite"}}):e.jsx(B,{size:15})," ",Ps?"Saving...":"Save Settings"]}),e.jsx("button",{onClick:()=>$t(!1),className:"btn btn-secondary",children:"Cancel"})]})]})}),Vn&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>Rt(null),children:e.jsxs("div",{style:{background:"#fff",borderRadius:12,padding:28,width:520,maxWidth:"95vw",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 20px 60px rgba(0,0,0,0.2)"},onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:700},children:pi}),e.jsx("button",{onClick:()=>Rt(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4},children:e.jsx(L,{size:18})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Vn.map((t,n)=>e.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,border:"1px solid #e5e7eb",background:t.success===!1?"#fef2f2":"#f0fdf4",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"#374151"},children:["ID #",t.id]}),t.email&&e.jsx("span",{style:{fontSize:12,color:"#6b7280",marginLeft:8},children:t.email}),t.error&&e.jsx("div",{style:{fontSize:12,color:"#ef4444",marginTop:2},children:t.error})]}),e.jsx("span",{style:{fontSize:12,fontWeight:600,color:t.success===!1?"#ef4444":"#16a34a"},children:t.success===!1?"Failed":t.status||"OK"})]},t.id??n))}),e.jsx("div",{style:{marginTop:16,textAlign:"right"},children:e.jsx("button",{onClick:()=>Rt(null),className:"btn btn-secondary",children:"Close"})})]})}),$n&&e.jsx(Mr,{token:$n,onClose:()=>Fn(null)}),T==="multi_server"&&e.jsx("div",{children:ui?e.jsxs("div",{style:{textAlign:"center",padding:60,color:"#6b7280"},children:[e.jsx(y,{size:24,style:{animation:"spin 1s linear infinite",marginBottom:12}}),e.jsx("div",{children:"Loading server configuration..."})]}):e.jsxs("div",{style:{maxWidth:820},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24,padding:"16px 22px",borderRadius:12,background:N==="hub"?"linear-gradient(135deg,#ede9fe,#f0fdf4)":"linear-gradient(135deg,#dbeafe,#fef9c3)",border:`1.5px solid ${N==="hub"?"#c4b5fd":"#93c5fd"}`},children:[e.jsx("div",{style:{padding:12,borderRadius:10,background:N==="hub"?"#7c3aed":"#2563eb",flexShrink:0},children:N==="hub"?e.jsx(ss,{size:22,color:"#fff"}):e.jsx(Pe,{size:22,color:"#fff"})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:700,color:"var(--text)"},children:["This server is in"," ",e.jsx("span",{style:{color:N==="hub"?"#7c3aed":"#2563eb"},children:N==="hub"?"Hub Mode":"Worker Mode"})]}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:3},children:N==="hub"?"This server stores and manages all tokens. Other VPS servers can connect here to borrow tokens.":`Connected to Hub at ${te.hub_url||""}${te.worker_id?` · Worker ID: ${te.worker_id}`:""}`})]}),e.jsxs("button",{onClick:Ws,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx(y,{size:13})," Refresh"]})]}),N==="hub"&&e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Pe,{size:16,color:"#7c3aed"}),e.jsx("span",{style:{fontSize:15,fontWeight:700,color:"var(--text)"},children:"Connected Workers"}),Nt.length>0&&e.jsx("span",{style:{background:"#ede9fe",color:"#7c3aed",borderRadius:20,padding:"2px 10px",fontSize:12,fontWeight:700},children:Nt.length})]}),e.jsxs("button",{onClick:Ts,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:5,fontSize:12},disabled:Vs,children:[e.jsx(y,{size:12,style:Vs?{animation:"spin 1s linear infinite"}:{}}),"Refresh"]})]}),Vs?e.jsxs("div",{style:{textAlign:"center",padding:"32px 0",color:"#9ca3af",fontSize:13},children:[e.jsx(y,{size:18,style:{animation:"spin 1s linear infinite",marginBottom:8}}),e.jsx("div",{children:"Loading worker stats..."})]}):Nt.length===0?e.jsxs("div",{style:{padding:"32px 24px",borderRadius:12,background:"var(--card-bg)",border:"1.5px dashed var(--border)",textAlign:"center"},children:[e.jsx(Pe,{size:28,color:"#d1d5db",style:{marginBottom:10}}),e.jsx("div",{style:{fontSize:14,fontWeight:600,color:"#6b7280",marginBottom:4},children:"No worker servers yet"}),e.jsx("div",{style:{fontSize:12,color:"#9ca3af"},children:"Worker VPS servers that connect to this Hub will appear here once they start processing jobs."})]}):e.jsxs("div",{style:{borderRadius:12,border:"1.5px solid var(--border)",overflow:"hidden",background:"var(--card-bg)"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"var(--bg)"},children:["Worker ID","Last Seen","Live Now","Today","Yesterday","All Time","Status","Actions"].map(t=>e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontWeight:700,fontSize:11,color:"#6b7280",textTransform:"uppercase",letterSpacing:.5,borderBottom:"1px solid var(--border)",whiteSpace:"nowrap"},children:t},t))})}),e.jsx("tbody",{children:Nt.map((t,n)=>{const a=t.last_seen?Date.now()-new Date(t.last_seen).getTime():null,o=a!==null&&a<1800*1e3,r=a===null?"—":a<6e4?"just now":a<36e5?`${Math.floor(a/6e4)}m ago`:a<864e5?`${Math.floor(a/36e5)}h ago`:`${Math.floor(a/864e5)}d ago`,l=({d})=>e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:"#22c55e",fontWeight:700},children:[e.jsx(B,{size:11})," ",d.success]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:"#ef4444",fontWeight:700},children:[e.jsx(ae,{size:11})," ",d.failed]}),d.in_progress>0&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,color:"#f59e0b",fontWeight:700},children:[e.jsx(y,{size:11,style:{animation:"spin 1s linear infinite"}})," ",d.in_progress]})]});return e.jsxs("tr",{style:{borderBottom:n<Nt.length-1?"1px solid var(--border)":"none"},children:[e.jsx("td",{style:{padding:"12px 14px",fontFamily:"monospace",fontWeight:700,color:"#7c3aed",fontSize:13},children:t.worker_id}),e.jsx("td",{style:{padding:"12px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:r}),e.jsx("td",{style:{padding:"12px 14px",color:t.active_jobs>0?"#b45309":"#9ca3af",fontWeight:800,whiteSpace:"nowrap"},children:t.active_jobs??0}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsx(l,{d:t.today})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsx(l,{d:t.yesterday})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsx(l,{d:t.total})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"3px 10px",borderRadius:20,fontSize:11,fontWeight:700,background:o?"#dcfce7":"#f3f4f6",color:o?"#15803d":"#6b7280"},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o?"#22c55e":"#9ca3af",display:"inline-block"}}),o?"Online":"Idle"]})}),e.jsx("td",{style:{padding:"12px 14px"},children:e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsxs("button",{onClick:()=>ur(t.worker_id),disabled:!!Ct[t.worker_id],title:"Disconnect this worker from the hub",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:6,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid #d1d5db",background:"#f9fafb",color:"#374151",opacity:Ct[t.worker_id]?.5:1},children:[Ct[t.worker_id]==="disconnect"?e.jsx(y,{size:11,style:{animation:"spin 1s linear infinite"}}):e.jsx(ae,{size:11}),"Disconnect"]}),e.jsxs("button",{onClick:()=>gr(t.worker_id),disabled:!!Ct[t.worker_id],title:"Permanently delete all history for this worker",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:6,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid #fca5a5",background:"#fff5f5",color:"#ef4444",opacity:Ct[t.worker_id]?.5:1},children:[Ct[t.worker_id]==="delete"?e.jsx(y,{size:11,style:{animation:"spin 1s linear infinite"}}):e.jsx(Ne,{size:11}),"Delete"]})]})})]},t.worker_id)})})]}),e.jsxs("div",{style:{padding:"10px 14px",borderTop:"1px solid var(--border)",display:"flex",gap:16,fontSize:11,color:"#9ca3af"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(B,{size:11,color:"#22c55e"})," Success"]}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(ae,{size:11,color:"#ef4444"})," Failed"]}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx(y,{size:11,color:"#f59e0b"})," In Progress"]}),e.jsx("span",{style:{marginLeft:"auto"},children:"Online = active within last 30 min"})]})]})]}),N==="worker"&&e.jsxs("div",{style:{marginBottom:24,padding:"20px 24px",borderRadius:12,background:"var(--card-bg)",border:"1.5px solid #86efac"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[e.jsx(B,{size:18,color:"#22c55e"}),e.jsx("h3",{style:{margin:0,fontSize:15,fontWeight:700,color:"#15803d"},children:"Connected to Hub"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginBottom:16},children:[{label:"Hub URL",value:te.hub_url},{label:"API Key",value:te.masked_key},{label:"Worker ID",value:te.worker_id||"—"},{label:"Mode",value:"Worker (tokens from Hub)"},{label:"Max Hub requests",value:te.hub_request_limit_enabled===!1?"Unlimited":`${te.max_hub_requests??500} simultaneous`},{label:"Slot backend",value:te.slot_backend==="redis"?"Redis shared slots":"Local fallback"}].map((t,n)=>e.jsxs("div",{style:{padding:"10px 14px",borderRadius:8,background:"var(--bg)",border:"1px solid var(--border)"},children:[e.jsx("div",{style:{fontSize:11,color:"#9ca3af",fontWeight:600,textTransform:"uppercase",letterSpacing:.5,marginBottom:4},children:t.label}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text)",wordBreak:"break-all",fontFamily:t.label==="Hub URL"||t.label==="API Key"?"monospace":"inherit"},children:t.value})]},n))}),(()=>{const t=te.hub_request_limit_enabled!==!1,n=Number(te.active_hub_requests??
940),a=Number(te.waiting_hub_requests??0),o=Number(te.max_hub_requests??500),r=t&&n>=o;return e.jsxs("div",{style:{marginBottom:16,padding:"14px 16px",borderRadius:10,background:r?"#fff5f5":"#f8fafc",border:`1.5px solid ${r?"#fca5a5":"#e2e8f0"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:10,flexWrap:"wrap"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.jsx(Fe,{size:15,color:r?"#dc2626":"#2563eb"}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:r?"#991b1b":"#1e3a8a"},children:"Hub request slots (Redis shared)"})]}),e.jsx("span",{style:{fontSize:12,color:"#6b7280"},children:"Live · refreshes every 3s"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8},children:[e.jsxs("div",{style:{padding:"9px 10px",borderRadius:8,background:r?"#fee2e2":"#dbeafe"},children:[e.jsx("div",{style:{fontSize:22,lineHeight:1,fontWeight:800,color:r?"#dc2626":"#1d4ed8"},children:n}),e.jsx("div",{style:{fontSize:10,marginTop:5,color:"#6b7280",fontWeight:600},children:"Active / running"})]}),e.jsxs("div",{style:{padding:"9px 10px",borderRadius:8,background:a>0?"#fef3c7":"#f3f4f6"},children:[e.jsx("div",{style:{fontSize:22,lineHeight:1,fontWeight:800,color:a>0?"#b45309":"#6b7280"},children:a}),e.jsx("div",{style:{fontSize:10,marginTop:5,color:"#6b7280",fontWeight:600},children:"Waiting, not sent"})]}),e.jsxs("div",{style:{padding:"9px 10px",borderRadius:8,background:t?"#f3f4f6":"#f0fdf4"},children:[e.jsx("div",{style:{fontSize:22,lineHeight:1,fontWeight:800,color:t?"#374151":"#15803d"},children:t?o:"∞"}),e.jsx("div",{style:{fontSize:10,marginTop:5,color:"#6b7280",fontWeight:600},children:"Maximum simultaneous"})]})]}),r&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:10,padding:"8px 10px",borderRadius:7,background:"#fee2e2",color:"#b91c1c",fontSize:12,fontWeight:700},children:[e.jsx(Te,{size:14}),"Hub request limit reached. New job requests are queued locally and are not sent until a running request completes."]}),!r&&a>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:10,padding:"8px 10px",borderRadius:7,background:"#fffbeb",color:"#92400e",fontSize:12,fontWeight:600},children:[e.jsx(We,{size:14}),a," job request",a===1?"":"s"," waiting for the next Redis slot; they will be sent only after a running request completes."]})]})})(),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("button",{onClick:()=>{xt(!0),ie(null)},className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(Cn,{size:14})," Edit Connection"]}),e.jsxs("button",{onClick:yr,disabled:po,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,color:"#ef4444",borderColor:"#fca5a5"},children:[po?e.jsx(y,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(L,{size:14}),"Disconnect from Hub"]})]})]}),N==="hub"&&e.jsxs("div",{style:{marginBottom:24,padding:"20px 24px",borderRadius:12,background:"var(--card-bg)",border:"1px solid var(--border)"},children:[e.jsxs("h3",{style:{fontSize:15,fontWeight:700,margin:"0 0 6px",display:"flex",alignItems:"center",gap:8},children:[e.jsx(nt,{size:16,color:"#7c3aed"})," Hub Internal API Key"]}),e.jsxs("p",{style:{fontSize:13,color:"#6b7280",margin:"0 0 16px",lineHeight:1.5},children:["Generate this key once and paste it into the ",e.jsx("strong",{children:"API Key"})," field when connecting any worker VPS to this Hub."]}),pt.configured?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:14},children:[e.jsx("div",{style:{flex:1,padding:"10px 14px",borderRadius:8,background:"#f3f4f6",fontFamily:"monospace",fontSize:13,wordBreak:"break-all"},children:ps&&pt.full_key?pt.full_key:pt.masked_key}),pt.full_key&&e.jsxs("button",{onClick:()=>so(t=>!t),className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap"},children:[ps?e.jsx(ii,{size:14}):e.jsx(jt,{size:14})," ",ps?"Hide":"Reveal"]}),ps&&pt.full_key&&e.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(pt.full_key),p("Key copied!")},className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap"},children:[e.jsx(rt,{size:14})," Copy"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(B,{size:14,color:"#22c55e"}),e.jsx("span",{style:{fontSize:13,color:"#22c55e",fontWeight:600},children:"Key is active"}),e.jsxs("button",{onClick:Qo,disabled:fs,className:"btn btn-secondary",style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6,color:"#ef4444",borderColor:"#fca5a5",fontSize:12},children:[fs?e.jsx(y,{size:13,style:{animation:"spin 1s linear infinite"}}):e.jsx(qt,{size:13})," Rotate Key"]})]})]}):e.jsxs("div",{style:{textAlign:"center",padding:"20px 0"},children:[e.jsx(Te,{size:28,color:"#f59e0b",style:{marginBottom:8}}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginBottom:14},children:"No Hub API key generated yet."}),e.jsxs("button",{onClick:Qo,disabled:fs,className:"btn btn-primary",style:{display:"inline-flex",alignItems:"center",gap:8},children:[fs?e.jsx(y,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(nt,{size:14}),"Generate Hub API Key"]})]})]}),(N==="hub"||Ft)&&e.jsxs("div",{style:{marginBottom:24,padding:"20px 24px",borderRadius:12,background:"var(--card-bg)",border:"1px solid var(--border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:15,fontWeight:700,display:"flex",alignItems:"center",gap:8},children:[e.jsx(Pe,{size:16,color:"#2563eb"}),N==="worker"?"Edit Hub Connection":"Connect This Server to a Hub"]}),N==="hub"&&!Ft&&e.jsxs("button",{onClick:()=>{xt(!0),ie(null)},className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6,fontSize:13},children:[e.jsx(Pe,{size:13})," Connect to a Hub"]}),Ft&&N!=="worker"&&e.jsx("button",{onClick:()=>{xt(!1),ie(null)},style:{background:"none",border:"none",cursor:"pointer",color:"#9ca3af"},children:e.jsx(L,{size:18})})]}),(Ft||N==="worker")&&e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:13,color:"#6b7280",margin:"0 0 16px",lineHeight:1.5},children:["Enter the Hub server details below. After testing the connection, click ",e.jsx("strong",{children:"Save & Connect"})," to switch this server to Worker mode."]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14,marginBottom:16},children:[e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:["Hub URL ",e.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),e.jsx("input",{value:_.hub_url,onChange:t=>{ft(n=>({...n,hub_url:t.target.value})),ie(null)},placeholder:"https://your-hub-server.com",style:{width:"100%",padding:"9px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",fontFamily:"monospace"}}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:4},children:"The full public URL of the Hub server (no trailing slash)"})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:["Hub API Key ",e.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),e.jsx("input",{type:"password",value:_.hub_api_key,onChange:t=>{ft(n=>({...n,hub_api_key:t.target.value})),ie(null)},placeholder:"fvhub_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",style:{width:"100%",padding:"9px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",fontFamily:"monospace"}}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:4},children:"Copy this from Admin → Multi-Server on the Hub server"})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:["Worker ID ",e.jsx("span",{style:{color:"#9ca3af",fontWeight:400},children:"(optional)"})]}),e.jsx("input",{value:_.worker_id,onChange:t=>ft(n=>({...n,worker_id:t.target.value})),placeholder:"vps-2",style:{width:"100%",padding:"9px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box"}}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:4},children:"A label to identify this VPS in Hub logs (e.g. vps-2, us-east-1)"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:13,fontWeight:600,color:"var(--text)",display:"block",marginBottom:6},children:"Max simultaneous Hub requests"}),e.jsx("input",{type:"number",min:1,max:500,value:_.max_hub_requests,disabled:!_.hub_request_limit_enabled,onChange:t=>ft(n=>({...n,max_hub_requests:t.target.value})),style:{width:"100%",padding:"9px 12px",border:"1px solid #d1d5db",borderRadius:8,fontSize:13,boxSizing:"border-box",background:_.hub_request_limit_enabled?"#fff":"#f3f4f6",color:_.hub_request_limit_enabled?"#111827":"#9ca3af"}}),e.jsxs("div",{style:{fontSize:11,color:"#9ca3af",marginTop:4},children:["Additional requests wait silently and continue showing as generating. Default: ",e.jsx("strong",{children:"500"}),". Maximum: ",e.jsx("strong",{children:"500"}),"."]}),e.jsxs("button",{type:"button","aria-pressed":_.hub_request_limit_enabled,onClick:()=>ft(t=>({...t,hub_request_limit_enabled:!t.hub_request_limit_enabled})),style:{marginTop:10,display:"inline-flex",alignItems:"center",gap:8,padding:"7px 10px",borderRadius:7,border:`1px solid ${_.hub_request_limit_enabled?"#86efac":"#d1d5db"}`,background:_.hub_request_limit_enabled?"#f0fdf4":"#f9fafb",color:_.hub_request_limit_enabled?"#15803d":"#6b7280",cursor:"pointer",fontSize:12,fontWeight:700},children:[e.jsx("span",{style:{width:28,height:16,borderRadius:999,background:_.hub_request_limit_enabled?"#22c55e":"#9ca3af",padding:2,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:_.hub_request_limit_enabled?"flex-end":"flex-start"},children:e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),_.hub_request_limit_enabled?"Request limit enabled":"Disable request limit (unlimited)"]}),e.jsx("div",{style:{fontSize:11,color:_.hub_request_limit_enabled?"#6b7280":"#b45309",marginTop:5},children:_.hub_request_limit_enabled?"This worker will send at most the configured number of simultaneous requests to the Hub.":"Unlimited mode: this worker can send requests to the Hub without the 500-request cap."})]})]}),de&&e.jsxs("div",{style:{padding:"12px 16px",borderRadius:8,marginBottom:14,background:de.success?"#f0fdf4":"#fef2f2",border:`1px solid ${de.success?"#86efac":"#fca5a5"}
94`,display:"flex",alignItems:"flex-start",gap:10},children:[de.success?e.jsx(B,{size:16,color:"#22c55e",style:{flexShrink:0,marginTop:1}}):e.jsx(Te,{size:16,color:"#ef4444",style:{flexShrink:0,marginTop:1}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:de.success?"#15803d":"#b91c1c"},children:de.message}),de.hub_status&&e.jsxs("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:["Hub: ",de.hub_status.active_tokens," active token",de.hub_status.active_tokens!==1?"s":""," · Queue: ",de.hub_status.queue_pending," pending / ",de.hub_status.queue_active," active"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[e.jsxs("button",{onClick:hr,disabled:ro||!_.hub_url||!_.hub_api_key,className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[ro?e.jsx(y,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(Fe,{size:14}),"Test Connection"]}),e.jsxs("button",{onClick:br,disabled:lo||!_.hub_url||!_.hub_api_key,className:"btn btn-primary",style:{display:"flex",alignItems:"center",gap:6},children:[lo?e.jsx(y,{size:14,style:{animation:"spin 1s linear infinite"}}):e.jsx(B,{size:14}),"Save & Connect"]}),N==="worker"&&e.jsxs("button",{onClick:()=>{xt(!1),ie(null)},className:"btn btn-secondary",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(L,{size:14})," Cancel"]})]})]}),!Ft&&N==="hub"&&e.jsxs("div",{style:{textAlign:"center",padding:"12px 0 4px"},children:[e.jsx("p",{style:{fontSize:13,color:"#6b7280",margin:"0 0 12px"},children:"Want this server to use tokens from another Hub? Click below to configure a remote connection."}),e.jsxs("button",{onClick:()=>{xt(!0),ie(null)},className:"btn btn-secondary",style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(Pe,{size:14})," Connect to a Hub Server"]})]})]}),e.jsxs("div",{style:{padding:"20px 24px",borderRadius:12,background:"var(--card-bg)",border:"1px solid var(--border)"},children:[e.jsxs("h3",{style:{fontSize:14,fontWeight:700,margin:"0 0 14px",display:"flex",alignItems:"center",gap:8,color:"#6b7280",textTransform:"uppercase",letterSpacing:.5},children:[e.jsx(Fe,{size:14})," How It Works"]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[{icon:e.jsx(ss,{size:18,color:"#7c3aed"}),title:"Hub Server",desc:"Stores all tokens. Manages quota, cooldown, refresh. Shares tokens via secure API."},{icon:e.jsx(Nr,{size:18,color:"#f59e0b"}),title:"API Key Auth",desc:"Workers authenticate with the Hub key. Only authorised servers can borrow tokens."},{icon:e.jsx(Pe,{size:18,color:"#2563eb"}),title:"Worker VPS",desc:"Configured here in the UI. Borrows a token, generates video locally, returns the token."}].map((t,n)=>e.jsxs("div",{style:{padding:"12px 14px",borderRadius:10,background:"var(--bg)",border:"1px solid var(--border)"},children:[e.jsx("div",{style:{marginBottom:6},children:t.icon}),e.jsx("div",{style:{fontSize:13,fontWeight:700,marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:12,color:"#6b7280",lineHeight:1.5},children:t.desc})]},n))}),e.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:[{icon:e.jsx(B,{size:13,color:"#22c55e"}),text:"Worker VPS servers do NOT need their own token database — all tokens stay on the Hub."},{icon:e.jsx(B,{size:13,color:"#22c55e"}),text:"Video generation (the heavy work) still runs locally on each worker — minimal extra load on the Hub."},{icon:e.jsx(B,{size:13,color:"#22c55e"}),text:"If the Hub is unreachable, the worker retries automatically for up to 2 minutes before failing."},{icon:e.jsx(Te,{size:13,color:"#f59e0b"}),text:"Token management (add/remove/view) is done only on the Hub server. Workers show no local tokens."}].map((t,n)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:12,color:"var(--text)"},children:[e.jsx("span",{style:{flexShrink:0,marginTop:1},children:t.icon}),t.text]},n))})]})]})}),T==="token_logs"&&(()=>{const t={info:"#3b82f6",success:"#22c55e",warning:"#f59e0b",error:"#ef4444"},n={info:"#eff6ff",success:"#f0fdf4",warning:"#fffbeb",error:"#fef2f2"},a=o=>o?o.charAt(0).toUpperCase()+o.slice(1):"Info";return e.jsxs("div",{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:16,marginBottom:24},children:[{label:"Errors",value:Ss.errors,color:"#ef4444",key:"error"},{label:"Warnings",value:Ss.warnings,color:"#f59e0b",key:"warning"},{label:"Successes",value:Ss.successes,color:"#22c55e",key:"success"},{label:"Info",value:Ss.infos,color:"#3b82f6",key:"info"}].map(o=>e.jsxs("div",{onClick:()=>{const r=je===o.key?"":o.key;Ao(r),$e(1,r,ke,me)},style:{background:"#fff",borderRadius:12,padding:"16px 20px",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",cursor:"pointer",border:`2px solid ${je===o.key?o.color:"#e5e7eb"}`},children:[e.jsx("div",{style:{fontSize:26,fontWeight:700,color:o.color},children:o.value}),e.jsx("div",{style:{fontSize:13,color:"#6b7280",marginTop:2},children:o.label})]},o.key))}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:18,flexWrap:"wrap"},children:[e.jsxs("div",{style:{position:"relative",flex:"1 1 200px"},children:[e.jsx(ot,{size:14,style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",color:"#9ca3af",pointerEvents:"none"}}),e.jsx("input",{className:"icon-input-l-sm",value:me,onChange:o=>qi(o.target.value),onKeyDown:o=>o.key==="Enter"&&$e(1,je,ke,me),placeholder:"Search email or message…",style:{paddingLeft:32,paddingRight:10,height:36,border:"1px solid #d1d5db",borderRadius:8,fontSize:13,width:"100%",boxSizing:"border-box"}})]}),e.jsxs("select",{value:je,onChange:o=>{Ao(o.target.value),$e(1,o.target.value,ke,me)},style:{height:36,border:"1px solid #d1d5db",borderRadius:8,fontSize:13,padding:"0 10px",background:"#fff"},children:[e.jsx("option",{value:"",children:"All Severities"}),e.jsx("option",{value:"error",children:"Error"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"info",children:"Info"})]}),e.jsx("input",{value:ke,onChange:o=>Li(o.target.value),onKeyDown:o=>o.key==="Enter"&&$e(1,je,ke,me),placeholder:"Filter by event type…",style:{height:36,border:"1px solid #d1d5db",borderRadius:8,fontSize:13,padding:"0 10px",minWidth:160}}),e.jsx("button",{onClick:()=>$e(1,je,ke,me),className:"btn btn-secondary",style:{height:36},children:e.jsx(Rn,{size:14})})]}),sn?e.jsxs("div",{style:{textAlign:"center",padding:"60px 0",color:"#6b7280"},children:[e.jsx(y,{size:28,style:{animation:"spin 1s linear infinite",marginBottom:12}}),e.jsx("div",{children:"Loading logs…"})]}):tn.length===0?e.jsx("div",{style:{textAlign:"center",padding:"60px 0",color:"#9ca3af"},children:"No logs found"}):e.jsx("div",{style:{background:"#fff",borderRadius:12,overflow:"hidden",boxShadow:"0 1px 3px rgba(0,0,0,0.07)",border:"1px solid #e5e7eb"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#f8fafc"},children:["Time","Email","Severity","Event Type","Message",""].map(o=>e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",fontSize:11,fontWeight:700,color:"#6b7280",textTransform:"uppercase",borderBottom:"1px solid #e5e7eb"},children:o},o))})}),e.jsx("tbody",{children:tn.map((o,r)=>
94e.jsxs("tr",{style:{borderBottom:r<tn.length-1?"1px solid #f1f5f9":"none",background:r%2===0?"#fff":"#fafbfc"},children:[e.jsx("td",{style:{padding:"10px 14px",color:"#6b7280",whiteSpace:"nowrap"},children:o.created_at?new Date(o.created_at).toLocaleString():"—"}),e.jsx("td",{style:{padding:"10px 14px",color:"#374151"},children:o.email||e.jsx("span",{style:{color:"#9ca3af"},children:"—"})}),e.jsx("td",{style:{padding:"10px 14px"},children:e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:n[o.severity]||"#f3f4f6",color:t[o.severity]||"#374151"},children:a(o.severity)})}),e.jsx("td",{style:{padding:"10px 14px",color:"#6b7280",fontFamily:"monospace",fontSize:12},children:o.event_type||"—"}),e.jsx("td",{style:{padding:"10px 14px",color:"#374151",maxWidth:380,wordBreak:"break-word"},children:o.message}),e.jsx("td",{style:{padding:"10px 14px",whiteSpace:"nowrap"},children:e.jsxs("button",{onClick:async()=>{qo(!0),Qt({...o,_loading:!0});try{const l=await f.get(`/api/admin/flow-veo-tokens/logs/${o.id}`);Qt(l.data)}catch{Qt(o)}finally{qo(!1)}},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,padding:"4px 10px",borderRadius:6,border:"1.5px solid #dbeafe",background:"#eff6ff",color:"#2563eb",cursor:"pointer"},children:[e.jsx(jt,{size:11})," View Details"]})})]},o.id))})]})}),nn>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:12,marginTop:20},children:[e.jsx("button",{onClick:()=>$e(Vt-1,je,ke,me),disabled:Vt<=1,className:"btn btn-secondary",style:{padding:"6px 14px"},children:e.jsx(ns,{size:14})}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Page ",Vt," of ",nn," (",Bi," total)"]}),e.jsx("button",{onClick:()=>$e(Vt+1,je,ke,me),disabled:Vt>=nn,className:"btn btn-secondary",style:{padding:"6px 14px"},children:e.jsx(os,{size:14})})]})]})})(),U&&(()=>{const t={info:"#3b82f6",success:"#22c55e",warning:"#f59e0b",error:"#ef4444"},n={info:"#eff6ff",success:"#f0fdf4",warning:"#fffbeb",error:"#fef2f2"},a=U.meta||{},o=U.debug_context||{},r=o.request||{},l=o.user||{},d=o.auth||{},u=o.worker_job||{},{request_url:s,request_method:c,request_headers:x,request_payload:h,http_status:m,response_headers:k,response_body:R,response_preview:J,error_message:P,error_code:_e,gcs_path:tt,blob_url:ze,chunks_count:Zt,execution_outputs_keys:yn,error_type:mn,error:jn,video_size_bytes:kn,videos_generated:vn,daily_quota:Ar,total_videos_generated:Xo,...ei}=a,Re=({title:Ce,color:X,children:st})=>e.jsxs("div",{style:{marginBottom:18},children:[e.jsxs("div",{style:{fontSize:11,fontWeight:800,color:X,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:8,display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{width:3,height:14,background:X,borderRadius:2}}),Ce]}),st]}),Xt=({data:Ce,bg:X="#f8fafc",border:st="#e5e7eb"})=>e.jsx("pre",{style:{background:X,border:`1px solid ${st}`,borderRadius:6,padding:"10px 14px",fontSize:12,margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:320,overflowY:"auto",fontFamily:"monospace",lineHeight:1.5},children:typeof Ce=="string"?Ce:JSON.stringify(Ce,null,2)}),b=({label:Ce,value:X})=>e.jsxs("div",{className:"flow-veo-detail-row",style:{display:"grid",gridTemplateColumns:"minmax(110px, 0.38fr) minmax(0, 1fr)",gap:12,padding:"7px 0",borderBottom:"1px solid #f3f4f6",alignItems:"start"},children:[e.jsx("span",{style:{fontSize:12,color:"#6b7280",fontWeight:600,minWidth:130,flexShrink:0},children:Ce}),e.jsx("span",{style:{fontSize:12,color:"#111827",wordBreak:"break-all",fontFamily:typeof X=="number"||typeof X=="string"&&/^\d+$/.test(X)?"monospace":"inherit"},children:X??"—"})]}),fe=({value:Ce,good:X,neutral:st=!1})=>e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:700,background:st?"#f3f4f6":X?"#dcfce7":"#fee2e2",color:st?"#6b7280":X?"#166534":"#991b1b",border:`1px solid ${st?"#d1d5db":X?"#bbf7d0":"#fecaca"}`},children:st?"Not recorded":X?"Valid":"Invalid"}),At=U.severity||"info";return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:1200,display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"24px 16px",overflowY:"auto"},onClick:()=>Qt(null),children:e.jsxs("div",{className:"flow-veo-log-detail-modal",style:{background:"#fff",borderRadius:14,width:"80vw",maxWidth:1400,maxHeight:"calc(100vh - 48px)",boxShadow:"0 24px 64px rgba(0,0,0,0.22)",marginBottom:24},onClick:Ce=>Ce.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"18px 24px",borderBottom:"1.5px solid #e5e7eb",background:n[At],borderRadius:"14px 14px 0 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{padding:"3px 12px",borderRadius:20,fontSize:12,fontWeight:700,background:t[At]+"22",color:t[At],border:`1.5px solid ${t[At]}44`},children:At.charAt(0).toUpperCase()+At.slice(1)}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"#374151",fontFamily:"monospace"},children:U.event_type||"—"}),e.jsxs("span",{style:{fontSize:12,color:"#9ca3af"},children:["#",U.id]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[Ei&&e.jsx(y,{size:14,color:"#6b7280",style:{animation:"spin 1s linear infinite"}}),e.jsx("span",{style:{fontSize:12,color:"#6b7280"}
94,children:U.created_at?new Date(U.created_at).toLocaleString():""}),e.jsx("button",{onClick:()=>Qt(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,display:"flex"},children:e.jsx(L,{size:20})})]})]}),e.jsxs("div",{className:"flow-veo-log-detail-body",style:{padding:"20px 24px"},children:[e.jsx(Re,{title:"Log Info",color:"#6366f1",children:e.jsxs("div",{className:"flow-veo-detail-grid",style:{background:"#fafbfc",borderRadius:8,padding:"8px 14px",border:"1px solid #e5e7eb"},children:[e.jsx(b,{label:"Log ID",value:U.id}),e.jsx(b,{label:"Token ID",value:U.token_id}),e.jsx(b,{label:"Email",value:U.email||"—"}),e.jsx(b,{label:"Event Type",value:U.event_type||"—"}),e.jsx(b,{label:"Timestamp",value:U.created_at?new Date(U.created_at).toLocaleString():"—"})]})}),e.jsx(Re,{title:"Message",color:"#374151",children:e.jsx("div",{style:{background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:8,padding:"10px 14px",fontSize:13,color:"#111827",lineHeight:1.6},children:U.message||"—"})}),(Object.keys(r).length>0||Object.keys(u).length>0||Object.keys(l).length>0)&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{title:"Generation Request",color:"#0f766e",children:e.jsxs("div",{className:"flow-veo-detail-grid",style:{background:"#f0fdfa",border:"1px solid #99f6e4",borderRadius:8,padding:"8px 14px"},children:[e.jsx(b,{label:"Worker Mode",value:o.worker_mode?e.jsx(fe,{value:o.worker_mode,good:!0}):e.jsx(fe,{neutral:!0})}),e.jsx(b,{label:"Worker ID",value:u.worker_id||"—"}),e.jsx(b,{label:"Job ID",value:u.job_id||"—"}),e.jsx(b,{label:"Job Status",value:u.status||"—"}),e.jsx(b,{label:"Tool / Source",value:r.tool_name||"—"}),e.jsx(b,{label:"Aspect Ratio",value:r.aspect_ratio||"—"}),e.jsx(b,{label:"Has Image",value:r.has_image?"Yes":"No"}),e.jsx(b,{label:"Video Style",value:r.video_style||"—"}),r.custom_style_description&&e.jsx(b,{label:"Custom Style",value:r.custom_style_description}),e.jsx(b,{label:"Prompt",value:o.prompt||h?.prompt||"—"})]})}),e.jsx(Re,{title:"Request Provenance",color:"#2563eb",children:e.jsxs("div",{className:"flow-veo-detail-grid",style:{background:"#eff6ff",border:"1px solid #bfdbfe",borderRadius:8,padding:"8px 14px"},children:[e.jsx(b,{label:"Origin",value:r.origin||"—"}),e.jsx(b,{label:"Host",value:r.host||"—"}),e.jsx(b,{label:"Referrer",value:r.referer||"—"}),e.jsx(b,{label:"Request URL",value:r.url||"—"}),e.jsx(b,{label:"Request Path",value:r.path||"—"}),e.jsx(b,{label:"Method",value:r.method||"—"}),e.jsx(b,{label:"Remote IP",value:r.remote_ip||"—"}),e.jsx(b,{label:"User Agent",value:r.user_agent||"—"})]})}),e.jsx(Re,{title:"User & Plan",color:"#7c3aed",children:e.jsxs("div",{className:"flow-veo-detail-grid",style:{background:"#faf5ff",border:"1px solid #ddd6fe",borderRadius:8,padding:"8px 14px"},children:[e.jsx(b,{label:"User ID",value:l.id??U.user_id??"—"}),e.jsx(b,{label:"Name",value:l.name||"—"}),e.jsx(b,{label:"Email",value:l.email||U.email||"—"}),e.jsx(b,{label:"Role",value:l.role||"—"}),e.jsx(b,{label:"Plan",value:l.plan_name||l.plan||"—"}),e.jsx(b,{label:"Plan Price",value:l.plan_price!==void 0?String(l.plan_price):"—"}),e.jsx(b,{label:"Subscription",value:`${l.subscription_start?new Date(l.subscription_start).toLocaleDateString():"—"} → ${l.subscription_end?new Date(l.subscription_end).toLocaleDateString():"—"}`}),e.jsx(b,{label:"Account Active",value:l.is_active!==void 0?e.jsx(fe,{value:l.is_active,good:l.is_active}):e.jsx(fe,{neutral:!0})})]})}),e.jsx(Re,{title:"Authorization & Session Checks",color:"#be123c",children:e.jsxs("div",{className:"flow-veo-detail-grid",style:{background:"#fff1f2",border:"1px solid #fecdd3",borderRadius:8,padding:"8px 14px"},children:[e.jsx(b,{label:"Authorization Header",value:e.jsx(fe,{neutral:!d.authorization_present,good:d.authorization_token_valid&&d.authorization_format_valid})}),e.jsx(b,{label:"Authorization User ID",value:d.authorization_user_id??"—"}),e.jsx(b,{label:"Authorization Token",value:e.jsx(fe,{neutral:d.authorization_token_valid===void 0,good:d.authorization_token_valid})}),e.jsx(b,{label:"Session Cookie",value:e.jsx(fe,{neutral:!d.session_present,good:d.session_token_valid})}),e.jsx(b,{label:"Session User ID",value:d.session_user_id??"—"}),e.jsx(b,{label:"Auth / Session Match",value:e.jsx(fe,{neutral:d.authorization_session_match===void 0,good:d.authorization_session_match})}),e.jsx(b,{label:"User ID Matches DB",value:e.jsx(fe,{neutral:d.user_id_matches_db===void 0,good:d.user_id_matches_db})}),e.jsx(b,{label:"User Active in DB",value:e.jsx(fe,{neutral:d.user_active_in_db===void 0,good:d.user_active_in_db})}),e.jsx(b,{label:"x-access-token",value:e.jsx(fe,{neutral:d.x_access_token_present===void 0,good:d.x_access_token_valid})}),d.x_access_token_host&&e.jsx(b,{label:"Worker Token Host",value:d.x_access_token_host})]})})]}),(s||c||x||h)&&e.jsxs(Re,{title:"API Request",color:"#7c3aed",children:[(s||c)&&e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:8,flexWrap:"wrap"},children:[c&&e.jsx("span",{style:{fontSize:12,fontWeight:700,padding:"3px 10px",borderRadius:6,background:"#ede9fe",color:"#7c3aed",fontFamily:"monospace"},children:c}),s&&e.jsx("span",{style:{fontSize:12,padding:"3px 10px",borderRadius:6,background:"#f5f3ff",color:"#374151",fontFamily:"monospace",wordBreak:"break-all"},children:s})]}),x&&e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#7c3aed",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Headers"}),e.jsx(Xt,{data:x,bg:"#f5f3ff",border:"#ddd6fe"})]}),h&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#7c3aed",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Payload / Body"}),e.jsx(Xt,{data:h,bg:"#faf5ff",border:"#e9d5ff"})]})]}),(m!==void 0||k||R||J)&&e.jsxs(Re,{title:"API Response",color:"#0369a1",children:[m!==void 0&&e.jsx("div",{style:{marginBottom:8},children:e.jsxs("span",{style:{fontSize:13,fontWeight:700,padding:"3px 12px",borderRadius:6,fontFamily:"monospace",background:m>=200&&m<300?"#f0fdf4":m>=400?"#fef2f2":"#fffbeb",color:m>=200&&m<300?"#166534":m>=400?"#dc2626":"#b45309",border:`1.5px solid ${m>=200&&m<300?"#bbf7d0":m>=400?"#fecaca":"#fde68a"}`},children:["HTTP ",m]})}),k&&e.jsxs("div",{style:{marginBottom:8},children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#0369a1",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Response Headers"}),e.jsx(Xt,{data:k,bg:"#f0f9ff",border:"#bae6fd"})]}),(R||J)&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,color:"#0369a1",marginBottom:4,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Response Body"}),e.jsx(Xt,{data:R||J,bg:"#f0f9ff",border:"#bae6fd"})]})]}),(P||_e||jn||mn||tt||ze||Zt!==void 0||yn||kn||vn!==void 0)&&e.jsx(Re,{title:"Additional Details",color:"#b45309",children:e.jsxs("div",{className:"flow-veo-detail-grid",style:{background:"#fffbeb",border:"1px solid #fde68a",borderRadius:8,padding:"8px 14px"},children:[P&&e.jsx(b,{label:"Error Message",value:P}),_e&&e.jsx(b,{label:"Error Code",value:_e}),jn&&e.jsx(b,{label:"Error",value:jn}),mn&&e.jsx(b,{label:"Error Type",value:mn}),tt&&e.jsx(b,{label:"GCS Path",value:tt}),ze&&e.jsx(b,{label:"Blob URL",value:ze}),Zt!==void 0&&e.jsx(b,{label:"Chunks Count",value:Zt}),yn&&e.jsx(b,{label:"Output Keys",value:JSON.stringify(yn)}),kn&&e.jsx(b,{label:"Video Size",value:`${(kn/1024/1024).toFixed(2)} MB`}),vn!==void 0&&e.jsx(b,{label:"Videos Today",value:`${vn} / ${Ar??"?"}`}),Xo!==void 0&&e.jsx(b,{label:"Total All-Time",value:Xo})]})}),Object.keys(ei).length>0&&e.jsx(Re,{title:"Raw Meta",color:"#6b7280",children:e.jsx(Xt,{data:ei})}),Object.keys(a).length===0&&Object.keys(o).length===0&&e.jsx("div",{style:{color:"#9ca3af",fontSize:13,fontStyle:"italic"},children:"No additional metadata stored for this log entry."})]})]})})})(),se&&(()=>{const t={info:"#3b82f6",success:"#22c55e",warning:"#f59e0b",error:"#ef4444"},n={info:"#eff6ff",success:"#f0fdf4",warning:"#fffbeb",error:"#fef2f2"},a=o=>o?o.charAt(0).toUpperCase()+o.slice(1):"Info";return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",zIndex:1100,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:()=>on(null),children:e.jsxs("div",{style:{background:"#fff",borderRadius:14,padding:28,width:820,maxWidth:"100%",maxHeight:"88vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.22)"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},children:[e.jsxs("h3",{style:{margin:0,fontSize:17,fontWeight:700,display:"flex",alignItems:"center",gap:8},children:[e.jsx(at,{size:18,color:"#b45309"})," Token Logs — ",se.email||`#${se.id}`]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:fr,className:"btn btn-secondary",style:{fontSize:12,color:"#ef4444",dis
94play:"flex",alignItems:"center",gap:5},children:[e.jsx(Ne,{size:13})," Clear"]}),e.jsx("button",{onClick:()=>on(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",padding:4,display:"flex"},children:e.jsx(L,{size:20})})]})]}),e.jsx("div",{style:{display:"flex",gap:0,marginBottom:16,borderBottom:"2px solid #e5e7eb"},children:[{key:"today",label:"Today Logs"},{key:"all",label:"All Logs"}].map(o=>e.jsx("button",{onClick:()=>pr(o.key),style:{padding:"8px 20px",fontSize:13,fontWeight:600,border:"none",background:"none",cursor:"pointer",borderBottom:Ye===o.key?"2px solid #7c3aed":"2px solid transparent",color:Ye===o.key?"#7c3aed":"#6b7280",marginBottom:-2,transition:"color 0.15s"},children:o.label},o.key))}),e.jsx("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[{label:"Total",value:zs.total,color:"#6366f1"},{label:"Errors",value:zs.errors,color:"#ef4444"},{label:"Warnings",value:zs.warnings,color:"#f59e0b"},{label:"Successes",value:zs.successes,color:"#22c55e"}].map(o=>e.jsxs("div",{style:{background:"#f8fafc",borderRadius:8,padding:"8px 16px",textAlign:"center",minWidth:80},children:[e.jsx("div",{style:{fontSize:20,fontWeight:700,color:o.color},children:o.value}),e.jsx("div",{style:{fontSize:11,color:"#6b7280"},children:o.label})]},o.label))}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[e.jsxs("div",{style:{position:"relative",flex:"1 1 180px"},children:[e.jsx(ot,{size:13,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:"#9ca3af",pointerEvents:"none"}}),e.jsx("input",{value:ut,onChange:o=>cn(o.target.value),onKeyDown:o=>o.key==="Enter"&&yt(se,1,Wt,ut,Ye),placeholder:"Search message…",style:{paddingLeft:30,paddingRight:10,height:34,border:"1px solid #d1d5db",borderRadius:8,fontSize:13,width:"100%",boxSizing:"border-box"}})]}),e.jsxs("select",{value:Wt,onChange:o=>{pn(o.target.value),yt(se,1,o.target.value,ut,Ye)},style:{height:34,border:"1px solid #d1d5db",borderRadius:8,fontSize:13,padding:"0 10px",background:"#fff"},children:[e.jsx("option",{value:"",children:"All Severities"}),e.jsx("option",{value:"error",children:"Error"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"info",children:"Info"})]}),e.jsx("button",{onClick:()=>yt(se,1,Wt,ut,Ye),className:"btn btn-secondary",style:{height:34},children:e.jsx(Rn,{size:13})})]}),Di?e.jsxs("div",{style:{textAlign:"center",padding:"40px 0",color:"#6b7280"},children:[e.jsx(y,{size:24,style:{animation:"spin 1s linear infinite",marginBottom:10}}),e.jsx("div",{style:{fontSize:13},children:"Loading…"})]}):rn.length===0?e.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"#9ca3af",fontSize:13},children:"No logs found for this token"}):e.jsx("div",{style:{background:"#f8fafc",borderRadius:10,border:"1px solid #e5e7eb",overflow:"hidden",maxHeight:420,overflowY:"auto"},children:rn.map((o,r)=>e.jsxs("div",{style:{padding:"10px 14px",borderBottom:r<rn.length-1?"1px solid #edf0f4":"none",display:"flex",gap:12,alignItems:"flex-start"},children:[e.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:10,fontWeight:600,background:n[o.severity]||"#f3f4f6",color:t[o.severity]||"#374151",whiteSpace:"nowrap",marginTop:1},children:a(o.severity)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:2},children:[o.event_type&&e.jsx("span",{style:{fontSize:11,color:"#6b7280",fontFamily:"monospace"},children:o.event_type}),e.jsx("span",{style:{fontSize:11,color:"#9ca3af",marginLeft:"auto",whiteSpace:"nowrap"},children:o.created_at?new Date(o.created_at).toLocaleString():""})]}),e.jsx("div",{style:{fontSize:13,color:"#374151",wordBreak:"break-word"},children:o.message}),o.meta&&(()=>{const{request_payload:l,...d}=o.meta,u=l&&Object.keys(l).length>0,s=Object.keys(d).length>0;return e.jsxs("details",{style:{marginTop:4},children:[e.jsx("summary",{style:{fontSize:11,color:"#9ca3af",cursor:"pointer"},children:"meta (JSON)"}),u&&e.jsxs("div",{style:{marginTop:4},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#7c3aed",textTransform:"uppercase",letterSpacing:.5,marginBottom:2},children:"User Input"}),e.jsx("pre",{style:{background:"#f5f3ff",border:"1px solid #ddd6fe",borderRadius:4,padding:"5px 10px",fontSize:11,marginTop:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(l,null,2)})]}),s&&e.jsxs("div",{style:{marginTop:u?6:4},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#0369a1",textTransform:"uppercase",letterSpacing:.5,marginBottom:2},children:"API Response"}),e.jsx("pre",{style:{background:"#f0f9ff",border:"1px solid #bae6fd",borderRadius:4,padding:"5px 10px",fontSize:11,marginTop:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(d,null,2)})]}),!u&&!s&&e.jsx("pre",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:4,padding:"6px 10px",fontSize:11,marginTop:4,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(o.meta,null,2)})]})})()]})]},o.id))}),ln>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:12,marginTop:16},children:[e.jsx("button",{onClick:()=>yt(se,Jt-1,Wt,ut,Ye),disabled:Jt<=1,className:"btn btn-secondary",style:{padding:"5px 12px"},children:e.jsx(ns,{size:14})}),e.jsxs("span",{style:{fontSize:13,color:"#6b7280"},children:["Page ",Jt," of ",ln," (",$i," total)"]}),e.jsx("button",{onClick:()=>yt(se,Jt+1,Wt,ut,Ye),disabled:Jt>=ln,className:"btn btn-secondary",style:{padding:"5px 12px"},children:e.jsx(os,{size:14})})]})]})})})()]})}
94export{oa 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.