@fudrouter/fsrouter 0.6.84 → 0.6.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/open-sse/handlers/ttsProviders/index.js +1 -1
  2. package/dist/open-sse/services/usage/nous.js +36 -0
  3. package/dist/open-sse/services/usage.js +2 -0
  4. package/dist/open-sse/shared/clineAuth.js +21 -2
  5. package/dist/open-sse/utils/error.js +14 -0
  6. package/dist/routes/providers/[id]/test/testUtils.js +11 -11
  7. package/dist/routes/usage/[connectionId]/route.js +1 -1
  8. package/open-sse/handlers/ttsProviders/index.js +1 -1
  9. package/open-sse/services/usage/nous.js +36 -0
  10. package/open-sse/services/usage.js +2 -0
  11. package/open-sse/shared/clineAuth.js +21 -2
  12. package/open-sse/utils/error.js +14 -0
  13. package/package.json +1 -1
  14. package/public/.vite/manifest.json +85 -85
  15. package/public/assets/EndpointPageClient.B6118Vl0.js +6 -0
  16. package/public/assets/Loading.CKcPqzyp.js +1 -0
  17. package/public/assets/NoAuthProxyCard.C8gs3p9D.js +89 -0
  18. package/public/assets/index.CemlR_k0.js +89 -0
  19. package/public/assets/page.B8uovCa-.js +2 -0
  20. package/public/assets/page.B9AYvEAq.js +1 -0
  21. package/public/assets/page.BC8_Skab.js +1 -0
  22. package/public/assets/page.BGiDmMTs.js +1 -0
  23. package/public/assets/page.BH0jk80k.js +1 -0
  24. package/public/assets/page.BIo8aNfA.js +64 -0
  25. package/public/assets/page.BJ6h2zDl.js +1 -0
  26. package/public/assets/page.BO2F41Lc.js +23 -0
  27. package/public/assets/page.BPX2jyWY.js +1 -0
  28. package/public/assets/page.BSjBIFVt.js +1 -0
  29. package/public/assets/page.B_Tgnl-b.js +5 -0
  30. package/public/assets/page.BaHkKogf.js +1 -0
  31. package/public/assets/page.BdfPcUya.js +1 -0
  32. package/public/assets/page.BrhMwL3Z.js +2 -0
  33. package/public/assets/page.BwjqeY_m.js +6 -0
  34. package/public/assets/page.CDVWVylS.js +1 -0
  35. package/public/assets/page.CEw2SuPk.js +4 -0
  36. package/public/assets/page.CQU7BVUj.js +1 -0
  37. package/public/assets/page.CvBBDiKu.js +1 -0
  38. package/public/assets/page.CzOg3TqA.js +5 -0
  39. package/public/assets/page.D2Y19JAi.js +1 -0
  40. package/public/assets/page.DAzdg8fd.js +1 -0
  41. package/public/assets/page.DIb0IloM.js +1 -0
  42. package/public/assets/page.DO1n3ZJL.js +1 -0
  43. package/public/assets/page.DOsZhkAT.js +1 -0
  44. package/public/assets/page.DP_7ZXFk.js +1 -0
  45. package/public/assets/page.DliO3TaK.js +1 -0
  46. package/public/assets/page.DnJi9BLz.js +1 -0
  47. package/public/assets/page.DomMS7Cy.js +1 -0
  48. package/public/assets/page.DraAfhp6.js +31 -0
  49. package/public/assets/page.FJ3Dx8uu.js +1 -0
  50. package/public/assets/page.LtaYaOOQ.js +6 -0
  51. package/public/assets/page.SRSYeHUs.js +1 -0
  52. package/public/assets/page.rQUdj203.js +1 -0
  53. package/public/assets/page.sVpnihMe.js +1 -0
  54. package/public/assets/page.x5y6h1mx.js +1 -0
  55. package/public/assets/page.z06UnjTW.js +1 -0
  56. package/public/index.html +1 -1
@@ -0,0 +1,23 @@
1
+ import{j as e,B as m}from"./index.CemlR_k0.js";import{b as r}from"./router.Cjj1--8t.js";import{C as Ye,T as Ge,B as qe}from"./NoAuthProxyCard.C8gs3p9D.js";import{L as Xe}from"./Loading.CKcPqzyp.js";import"./zustand.akaTi5uX.js";function it(){const[u,h]=r.useState("codebuddy"),X=(x,ee,f)=>e.jsxs("button",{onClick:()=>h(x),className:`flex items-center gap-2 pb-3 text-sm font-semibold transition-all border-b-2 cursor-pointer ${u===x?"border-primary text-primary":"border-transparent text-text-muted hover:text-text-main"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:ee}),f]});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex border-b border-border-subtle pb-px gap-6 flex-wrap",children:[X("codebuddy","smart_toy","Automation"),X("fsmail","mail","FSMail Temp Mail")]}),u==="codebuddy"&&e.jsx(et,{}),u==="fsmail"&&e.jsx(st,{})]})}function et(){const u={codebuddy:"CodeBuddy",kiro:"Kiro AI",qoder:"Qoder",leonardo:"Leonardo AI",weavy:"Weavy AI","kimi-coding":"Kimi Coding",cloudflare:"Cloudflare Workers AI",openvecta:"OpenVecta",flashloop:"Flashloop"},[h,X]=r.useState([]),[x,ee]=r.useState(""),[f,te]=r.useState(null),[N,I]=r.useState([]);r.useRef(null);const $=r.useRef(new Set),[se,ue]=r.useState(1),ae=r.useRef(-1),pe=10,Se=r.useRef(!1),[g,Ue]=r.useState(!1),[K,Ce]=r.useState(3),[$e,re]=r.useState(!1),[ne,he]=r.useState(!1),[A,Re]=r.useState(""),[_e,j]=r.useState(""),[i,R]=r.useState("cloudflare"),[G,be]=r.useState(!0),[O,U]=r.useState(!1),[Te,We]=r.useState(!1),[oe,fe]=r.useState(!1),[k,V]=r.useState([]),[ze,W]=r.useState(!1),[ge,le]=r.useState(""),[Be,Ae]=r.useState(""),[Fe,S]=r.useState(""),[Le,Q]=r.useState(!1),[z,L]=r.useState({general:!0,proxy:!1}),C=t=>{L(a=>({...a,[t]:!a[t]}))},Pe=(t,a,n,l)=>e.jsxs("button",{onClick:l,type:"button",className:"flex items-center gap-1.5 hover:text-primary text-text-main font-semibold text-xs transition-all cursor-pointer select-none py-1",children:[e.jsx("span",{className:`material-symbols-outlined text-[16px] text-text-muted transition-transform duration-200 ${n?"":"-rotate-90"}`,children:"expand_more"}),e.jsx("span",{children:t})]}),[_,Z]=r.useState(!1),[D,B]=r.useState(0),[F,je]=r.useState({}),[d,ie]=r.useState(!1),[T,J]=r.useState(new Set),[M,Je]=r.useState(!1),[ye,Oe]=r.useState(5),[we,He]=r.useState([]),[ce,de]=r.useState("");r.useEffect(()=>{if(typeof window<"u"){const t=localStorage.getItem("automation_target_provider");R(t||"cloudflare");const a=localStorage.getItem("automation_concurrency");a&&Ce(parseInt(a)||3);const n=localStorage.getItem("automation_auto_email");n&&Je(n==="1");const l=localStorage.getItem("automation_generate_count");l&&Oe(parseInt(l)||5);const b=localStorage.getItem("automation_open_settings");if(b)try{L(c=>({...c,...JSON.parse(b)}))}catch(c){console.error("Failed to parse saved automation open settings",c)}Ue(!0)}},[]),r.useEffect(()=>{g&&localStorage.setItem("automation_target_provider",i)},[i,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_concurrency",String(K))},[K,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_auto_email",M?"1":"0")},[M,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_generate_count",String(ye))},[ye,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_open_settings",JSON.stringify(z))},[z,g]);const[y,Ve]=r.useState(""),[xe,De]=r.useState(1),Me=8;r.useEffect(()=>{fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-domains"})}).then(t=>t.json()).then(t=>{var a;(a=t.domains)!=null&&a.length&&(He(t.domains),de(n=>n||t.default_domain||t.domains[0]))}).catch(()=>{})},[]);const w=async(t=!1)=>{var a,n;try{const l=await fetch("/api/automation/codebuddy"),b=await l.json();if(l.ok){if(X(b.accounts||[]),ee(b.active_job_id||""),b.active_job_id&&Se.current&&(Se.current=!1,$.current.clear()),!Se.current)if(te(b.active_job||null),(n=(a=b.active_job)==null?void 0:a.results)!=null&&n.length){const c=b.active_job.results.filter(p=>p).map((p,ke)=>({idx:ke,email:p.email||`Account #${ke+1}`,status:p.status||"pending",step:p.status==="failed"?p.error||p.step||"-":p.step||"-",ok:p.ok})).filter(p=>!$.current.has(p.email.toLowerCase()));I(c)}else b.active_job_id;if(t){const c=b.settings||{};re(c.auto_fsrouter==="1"||c.auto_fsrouter===!0),be(!!c.browser_headless),U(!!c.debug_mode),We(c.leave_canva_team==="1"||c.leave_canva_team===!0),fe(!!c.proxy_enabled);try{const p=JSON.parse(c.proxy_pool||"[]");V(Array.isArray(p)?p:[])}catch{V([])}Ae(c.leonardo_invite_link||""),S(c.codebuddy_2captcha_api_key||"")}}}catch(l){console.error(l)}};r.useEffect(()=>{g&&w(!0)},[g]),r.useEffect(()=>{if(!g)return;const a=setInterval(()=>w(!1),x?3e3:15e3);return()=>clearInterval(a)},[g,x]),r.useEffect(()=>{if(N.length===0){ue(1),ae.current=-1;return}const t=N.findIndex(a=>a.status==="running");if(t!==-1&&t!==ae.current){ae.current=t;const a=Math.floor(t/pe)+1;ue(a)}},[N]),r.useEffect(()=>{if(O&&x){const t=setInterval(()=>{fetch("/api/automation/codebuddy/debug-vnc?action=status").then(a=>a.json()).then(a=>{a.available&&(Z(!0),B(Date.now()),clearInterval(t))}).catch(()=>{})},2e3);return()=>clearInterval(t)}else if(!x&&_){const t=setTimeout(()=>{Z(!1),B(0)},1e4);return()=>clearTimeout(t)}},[O,x]);const Qe=async()=>{Q(!0);try{(await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",auto_fsrouter:$e,browser_headless:G,debug_mode:O,leave_canva_team:Te,proxy_enabled:oe,proxy_pool:JSON.stringify(k),leonardo_invite_link:Be,codebuddy_2captcha_api_key:Fe})})).ok&&(j("Settings saved successfully."),setTimeout(()=>j(""),3e3),await w(!0))}catch(t){console.error(t)}finally{Q(!1)}},Ze=async()=>{var t,a;if(!A.trim()){j("Please enter at least one email:password line.");return}j("Adding accounts...");try{const n=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add-google",accounts_text:A,run_now:ne,concurrency:K,provider:i})}),l=await n.json();n.ok?(Re(""),j(`Created: ${((t=l.created)==null?void 0:t.length)||0}, Skipped: ${((a=l.skipped)==null?void 0:a.length)||0}${l.job_id?" (Job started)":""}`),w()):j(`Error: ${l.error}`)}catch(n){j(`Failed: ${n.message}`)}},Ee=async()=>{var t;j("Generating emails...");try{const a=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auto-generate-email",count:ye,provider:i,run_now:!0,concurrency:K,domain:ce||void 0})}),n=await a.json();a.ok?(j(`✓ Generated ${((t=n.created)==null?void 0:t.length)||0} temp mail accounts and started signup job.`),w()):j(`Error: ${n.error||"Failed to generate emails"}`)}catch(a){console.error(a),j("Failed to contact server.")}},Ie=async()=>{try{const t=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run-all",concurrency:K,provider:i})}),a=await t.json();t.ok?($.current.clear(),ee(a.job_id),w()):j(`Failed: ${a.error}`)}catch(t){j(`Failed: ${t.message}`)}},E=async()=>{try{const t=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"stop"})}),a=await t.json();t.ok?w():alert(a.error)}catch(t){console.error(t)}},ve=async t=>{try{const a=await fetch(`/api/automation/codebuddy/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run"})}),n=await a.json();a.ok?($.current.clear(),ee(n.job_id),w()):alert(n.error)}catch(a){console.error(a)}},Ne=async t=>{try{const a=await fetch(`/api/automation/codebuddy/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add-to-fsrouter"})}),n=await a.json();a.ok?(alert(`✓ ${n.message||"Added successfully!"}`),w()):alert(`Failed: ${n.error}`)}catch(a){console.error(a)}},s=async()=>{const t=u[i]||"CodeBuddy";if(confirm(`Inject all Ready ${t} accounts into fsrouter?`))try{const a=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"bulk-add-to-fsrouter",provider:i})}),n=await a.json();a.ok?(alert(n.message),w()):alert(`Failed: ${n.error}`)}catch(a){console.error(a)}},o=async t=>{if(!confirm("Hapus akun ini?"))return;const a=confirm("Apakah ingin menghapus juga koneksi akun ini di fsrouter?"),n=h.find(l=>l.id===t);try{await fetch(`/api/automation/codebuddy/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",deleteFromfsrouter:a})}),n&&($.current.add(n.email.toLowerCase()),I(l=>l.filter(b=>b.email.toLowerCase()!==n.email.toLowerCase()))),w()}catch(l){console.error(l)}},v=async(t,a=null)=>{const n=a?`${a.length} selected accounts`:`all accounts with status: ${t.join(", ")}`;if(!confirm(`Delete ${n}?`))return;const l=confirm("Apakah ingin menghapus juga koneksi akun-akun tersebut di fsrouter?"),b=h.filter(c=>a?a.includes(c.id):c.provider===i&&t.includes(c.api_key_status)).map(c=>c.email.toLowerCase());try{(await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a?{action:"bulk-delete-ids",ids:a,provider:i,deleteFromfsrouter:l}:{action:"bulk-delete",statuses:t,provider:i,deleteFromfsrouter:l})})).ok&&(b.forEach(p=>$.current.add(p)),I(p=>p.filter(ke=>!b.includes(ke.email.toLowerCase()))),J(new Set),w())}catch(c){console.error(c)}},P=h.filter(t=>t.provider===i&&(t.email.toLowerCase().includes(y.toLowerCase())||t.api_key&&t.api_key.toLowerCase().includes(y.toLowerCase()))),me=Math.ceil(P.length/Me),H=P.slice((xe-1)*Me,xe*Me),Y=Math.ceil(N.length/pe)||1,q=Math.min(se,Y),Ke=N.slice((q-1)*pe,q*pe);return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 space-y-6",children:[e.jsxs(Ye,{padding:"md",className:"space-y-4",children:[e.jsxs("h2",{className:"text-sm font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"person_add"}),(i==="leonardo"||i==="weavy"||i==="cloudflare")&&M?"Generate Temp Accounts":"Add Accounts"]}),e.jsxs("div",{className:"flex flex-col gap-1.5 pb-1",children:[e.jsx("label",{className:"text-xs font-semibold text-text-main",children:"Target Provider Connection"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:i==="weavy"?"/providers/weavy.jpeg":i==="kimi-coding"?"/providers/kimi.png":`/providers/${i}.png`,alt:i,className:"size-5 rounded object-contain",onError:t=>{t.target.style.display="none"}}),e.jsxs("select",{value:i,onChange:t=>{const a=t.target.value;R(a),De(1)},className:"flex-1 text-xs p-2 rounded-lg border border-border-subtle bg-surface text-text-main focus:outline-none focus:border-primary cursor-pointer",children:[e.jsx("option",{value:"cloudflare",children:"☁️ Cloudflare Workers AI"}),e.jsx("option",{value:"openvecta",children:"🟣 OpenVecta"}),e.jsx("option",{value:"flashloop",children:"⚡ Flashloop"})]})]})]}),(i==="leonardo"||i==="weavy"||i==="cloudflare"||i==="openvecta"||i==="flashloop")&&e.jsx("div",{className:"pt-1 border-t border-border-subtle",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-text-main cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:t=>Je(t.target.checked),className:"rounded border-border-subtle accent-primary size-4"}),"Auto Generate Email (FSMail)"]})}),(i==="leonardo"||i==="weavy"||i==="cloudflare"||i==="openvecta"||i==="flashloop")&&M?e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Count to generate:"}),e.jsx("input",{type:"number",min:1,max:50,value:ye,onChange:t=>Oe(parseInt(t.target.value)||1),className:"w-16 text-xs p-1.5 rounded-lg border border-border-subtle bg-surface text-center text-text-main"})]}),we.length>=1&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Email domain:"}),e.jsx("select",{value:ce,onChange:t=>de(t.target.value),className:"flex-1 text-xs p-1.5 rounded-lg border border-border-subtle bg-surface text-text-main ml-2 max-w-[180px]",children:we.map(t=>e.jsxs("option",{value:t,children:["@",t]},t))})]}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:Ee,children:"Generate & Run"})]}):e.jsxs("div",{className:"space-y-4 pt-1",children:[e.jsxs("p",{className:"text-xs text-text-muted",children:["Format: ",e.jsx("code",{className:"bg-surface-2 px-1 rounded",children:"email:password"})," (one per line)."]}),e.jsx("textarea",{value:A,onChange:t=>Re(t.target.value),rows:4,placeholder:`user1@gmail.com:Passw0rd1
2
+ user2@gmail.com:Passw0rd2`,className:"w-full text-xs font-mono p-3 rounded-lg border border-border-subtle bg-surface focus:outline-none focus:border-primary resize-y text-text-main"}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-text-main cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne,onChange:t=>he(t.target.checked),className:"rounded border-border-subtle accent-primary size-4"}),"Run immediately"]}),e.jsx(m,{variant:"primary",size:"sm",onClick:Ze,children:"Add Accounts"})]})]}),_e&&e.jsx("p",{className:"text-[11px] text-primary italic",children:_e})]}),e.jsxs(Ye,{padding:"md",className:"space-y-4",children:[e.jsxs("h2",{className:"text-sm font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"settings"}),"Automation Settings"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[Pe("General Settings","dns",z.general,()=>C("general")),z.general&&e.jsxs("div",{className:"pl-6 pr-2 py-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Headless Browser"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Jalankan di latar belakang tanpa membuka jendela baru"})]}),e.jsx(Ge,{checked:G,onChange:be})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Tampilkan Preview Panel"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Aktifkan live stream visual di bawah"})]}),e.jsx(Ge,{checked:O,onChange:U})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Auto Inject to fsrouter"}),e.jsx(Ge,{checked:$e,onChange:re})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[Pe("Outbound Proxy Settings","vpn_lock",z.proxy,()=>C("proxy")),z.proxy&&e.jsxs("div",{className:"pl-6 pr-2 py-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Enable Outbound Proxy"}),e.jsx(Ge,{checked:oe,onChange:fe})]}),oe&&e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border-subtle",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[11px] text-text-muted",children:[k.length," ",k.length===1?"proxy":"proxies"," configured"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[k.length>0&&e.jsx("button",{onClick:async()=>{if(d)return;ie(!0);const t={};for(const a of k){t[a]={testing:!0},je({...t});try{const l=await(await fetch("/api/automation/codebuddy/test-proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:a})})).json();t[a]=l}catch{t[a]={ok:!1,error:"Request failed"}}je({...t})}ie(!1)},disabled:d,className:`text-[11px] px-3 py-1 rounded-lg border font-medium transition-colors ${d?"bg-surface-2 border-border-subtle text-text-muted cursor-wait":"bg-surface-2 border-border-subtle hover:border-green-500 text-green-400 hover:text-green-300"}`,children:d?"⏳ Testing...":"🧪 Test"}),e.jsx("button",{onClick:()=>{le(k.join(`
3
+ `)),W(!0)},className:"text-[11px] px-3 py-1 rounded-lg bg-surface-2 border border-border-subtle hover:border-primary text-primary font-medium transition-colors",children:"✏️ Edit"})]})]}),k.length>0&&e.jsx("div",{className:"text-[10px] bg-surface-2 rounded-lg p-2 max-h-[120px] overflow-y-auto font-mono space-y-1",children:k.map((t,a)=>{const n=F[t],l=t.replace(/:[^:@]*@/,":***@");return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-text-muted flex-1",title:l,children:l}),n&&e.jsx("span",{className:`shrink-0 whitespace-nowrap ${n.testing?"text-yellow-400":n.ok?"text-green-400":"text-red-400"}`,children:n.testing?"⏳":n.ok?`✅ ${n.ip} · ${n.latency}ms`:`❌ ${n.error}`})]},a)})})]})]})]}),e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:Qe,disabled:Le,children:Le?"Saving...":"Save Settings"})]})]})]}),e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[(x||N.length>0)&&e.jsxs("div",{className:"border border-border-subtle bg-surface-2 rounded-xl p-4 space-y-3 relative overflow-hidden",children:[f&&e.jsx("div",{className:"absolute top-0 left-0 h-1 bg-gradient-to-r from-primary to-green-500 transition-all duration-500",style:{width:`${f.progress||0}%`}}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[x?e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary animate-spin",children:"autorenew"}):(f==null?void 0:f.status)==="stopped"?e.jsx("span",{className:"material-symbols-outlined text-[18px] text-red-400",children:"cancel"}):e.jsx("span",{className:"material-symbols-outlined text-[18px] text-green-400",children:"check_circle"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-text-main",children:x?"Job Running":(f==null?void 0:f.status)==="stopped"?"Job Stopped":"Job Completed"}),f&&e.jsxs("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Progress: ",f.completed,"/",f.count," ·",e.jsxs("span",{className:"text-green-400 ml-1",children:["✓ ",f.success]}),e.jsxs("span",{className:"text-red-400 ml-1",children:["✗ ",f.failed]})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[!x&&N.length>0&&e.jsx(m,{variant:"ghost",size:"sm",onClick:async()=>{Se.current=!0,N.forEach(t=>$.current.add(t.email.toLowerCase())),I([]),te(null);try{await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear-logs"})})}catch{}},children:"Clear"}),x&&e.jsx(m,{variant:"danger",size:"sm",onClick:E,children:"■ Stop"})]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-auto rounded-lg bg-black/40 border border-border/40 text-[11px] font-mono",children:e.jsxs("table",{className:"w-full min-w-[540px]",children:[e.jsx("thead",{className:"sticky top-0 bg-black/80 backdrop-blur-sm",children:e.jsxs("tr",{className:"text-text-muted text-left",children:[e.jsx("th",{className:"px-2 py-1 w-6",children:"#"}),e.jsx("th",{className:"px-2 py-1",children:"Email"}),e.jsx("th",{className:"px-2 py-1 w-16",children:"Status"}),e.jsx("th",{className:"px-2 py-1",children:"Step"}),e.jsx("th",{className:"px-2 py-1 w-14 text-right",children:"Time"}),e.jsx("th",{className:"px-2 py-1 w-12 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:N.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-2 py-2 text-center text-text-muted",children:"Waiting for log entries..."})}):Ke.map((t,a)=>{var c;const n=(c=t.step)==null?void 0:c.match(/\[([^\]]+s)\]$/),l=n?t.step.replace(n[0],"").trim():t.step,b=n?n[1]:"--";return e.jsxs("tr",{className:`border-t border-border/20 ${t.status==="failed"?"bg-red-500/5":t.status==="done"?"bg-green-500/5":""}`,children:[e.jsx("td",{className:"px-2 py-1 text-text-muted",children:t.idx+1}),e.jsx("td",{className:"px-2 py-1 text-text-main truncate max-w-[160px]",title:t.email,children:t.email}),e.jsxs("td",{className:"px-2 py-1 whitespace-nowrap",children:[t.status==="running"&&e.jsx("span",{className:"text-blue-400",children:"● run"}),t.status==="done"&&e.jsx("span",{className:"text-green-400",children:"✓ ok"}),t.status==="failed"&&e.jsx("span",{className:"text-red-400",children:"✗ fail"}),t.status==="pending"&&e.jsx("span",{className:"text-text-muted",children:"◌"})]}),e.jsx("td",{className:"px-2 py-1 text-text-muted truncate max-w-[280px]",title:t.status==="done"?t.balance!==void 0?`Success · ${t.balance} tokens${t.left_team===!0?" · Left team ✓":t.left_team===!1?" · Left team ✗":""}`:"Success":l,children:t.status==="done"?e.jsxs("span",{className:"text-green-400 font-medium",children:[t.balance!==void 0?`Success · ${t.balance} tokens`:"Success",t.left_team===!0&&e.jsx("span",{className:"text-purple-400 ml-1",children:"· Left team ✓"}),t.left_team===!1&&e.jsx("span",{className:"text-yellow-400 ml-1",children:"· Left team ✗"})]}):l}),e.jsx("td",{className:"px-2 py-1 text-right text-[10px] text-text-muted font-mono",children:b}),e.jsx("td",{className:"px-2 py-1 text-right whitespace-nowrap",children:t.status==="failed"&&e.jsx("button",{onClick:()=>{const p=h.find(ke=>ke.email.toLowerCase()===t.email.toLowerCase());p?ve(p.id):alert("Account tidak ditemukan.")},disabled:!!x,className:`text-[9px] font-bold px-1.5 py-0.5 rounded cursor-pointer transition-colors ${x?"text-text-muted bg-surface-3 cursor-not-allowed opacity-50":"text-brand-400 hover:text-brand-300 hover:bg-brand-500/15 bg-brand-500/5"}`,children:"Retry"})})]},a)})})]})}),Y>1&&e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-2",children:[e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>ue(t=>Math.max(1,t-1)),disabled:q===1,children:"Previous"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Page ",q," of ",Y," · (",N.length," items)"]}),e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>ue(t=>Math.min(Y,t+1)),disabled:q===Y,children:"Next"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("h2",{className:"text-sm font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"group"}),"Accounts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[h.filter(t=>t.provider===i).length," total"]}),e.jsxs(qe,{variant:"success",size:"sm",children:[h.filter(t=>t.provider===i&&t.api_key_status==="ready").length," ready"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("input",{type:"text",placeholder:"Search email...",value:y,onChange:t=>Ve(t.target.value),className:"text-xs p-2 rounded-lg border border-border-subtle bg-surface focus:outline-none focus:border-primary w-48"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("label",{className:"text-xs text-text-main flex items-center gap-1",children:["Limit:",e.jsx("input",{type:"number",min:1,max:20,value:K,onChange:t=>Ce(parseInt(t.target.value)||3),className:"w-12 text-center p-1 rounded border border-border-subtle bg-surface"})]}),e.jsx(m,{variant:"primary",size:"sm",onClick:Ie,disabled:!!x,children:"Run All Pending"}),e.jsx(m,{variant:"secondary",size:"sm",onClick:s,children:"⚡ Add All Ready → fsrouter"}),e.jsx(m,{variant:"danger",size:"sm",onClick:()=>v(["pending","failed"]),children:"🗑 Delete Pending/Failed"})]})]}),T.size>0&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-xs",children:[e.jsxs("span",{className:"text-primary font-semibold",children:[T.size," selected"]}),e.jsx("span",{className:"text-text-muted",children:"·"}),e.jsx("button",{onClick:async()=>{const t=[...T];J(new Set),await Promise.all(t.map(a=>ve(a)))},disabled:!!x,className:"text-brand-400 hover:text-brand-300 font-semibold disabled:opacity-40 disabled:cursor-not-allowed",children:"▶ Run Selected"}),e.jsx("span",{className:"text-text-muted",children:"·"}),e.jsx("button",{onClick:()=>v(null,[...T]),className:"text-red-400 hover:text-red-300 font-semibold",children:"🗑 Delete Selected"}),e.jsx("button",{onClick:()=>J(new Set),className:"ml-auto text-text-muted hover:text-text-main",children:"✕ Clear"})]}),e.jsx("div",{className:"rounded-xl border border-border-subtle bg-surface-2 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs text-left border-collapse min-w-[640px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface text-text-muted border-b border-border-subtle font-semibold",children:[e.jsx("th",{className:"p-2.5 w-8",children:e.jsx("input",{type:"checkbox",className:"rounded cursor-pointer accent-primary",checked:H.length>0&&H.every(t=>T.has(t.id)),onChange:t=>{t.target.checked?J(a=>new Set([...a,...H.map(n=>n.id)])):J(a=>{const n=new Set(a);return H.forEach(l=>n.delete(l.id)),n})}})}),e.jsx("th",{className:"p-2.5 w-10",children:"#"}),e.jsx("th",{className:"p-2.5",children:"Email"}),e.jsx("th",{className:"p-2.5 w-24",children:"Status"}),e.jsx("th",{className:"p-2.5",children:"API Key"}),e.jsx("th",{className:"p-2.5 text-right",children:"Actions"})]})}),e.jsxs("tbody",{children:[H.map(t=>e.jsxs("tr",{className:`border-b border-border-subtle transition-colors ${T.has(t.id)?"bg-primary/5":"hover:bg-surface/50"}`,children:[e.jsx("td",{className:"p-2.5",children:e.jsx("input",{type:"checkbox",className:"rounded cursor-pointer accent-primary",checked:T.has(t.id),onChange:a=>{J(n=>{const l=new Set(n);return a.target.checked?l.add(t.id):l.delete(t.id),l})}})}),e.jsxs("td",{className:"p-2.5 font-mono text-text-muted",children:["#",t.id]}),e.jsx("td",{className:"p-2.5 font-semibold text-text-main truncate max-w-[100px] sm:max-w-[140px] sm:max-w-[200px]",title:t.email,children:t.email}),e.jsxs("td",{className:"p-2.5",children:[e.jsx(qe,{variant:t.api_key_status==="ready"?"success":t.api_key_status==="failed"?"danger":t.api_key_status==="running"?"primary":"default",size:"sm",children:t.api_key_status}),t.last_error&&e.jsxs("p",{className:"text-[10px] text-red-500 mt-0.5 truncate max-w-[150px]",title:t.last_error,children:["⚠ ",t.last_error]})]}),e.jsx("td",{className:"p-2.5",children:t.api_key?e.jsx("code",{className:"bg-surface px-1.5 py-0.5 rounded font-mono text-[10px] text-text-main max-w-[100px] sm:max-w-[140px] block truncate",title:t.api_key,children:t.api_key}):e.jsx("span",{className:"text-text-muted",children:"—"})}),e.jsx("td",{className:"p-2.5 text-right whitespace-nowrap",children:e.jsxs("div",{className:"inline-flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>ve(t.id),disabled:!!x||t.api_key_status==="running",className:`inline-flex items-center gap-0.5 text-[11px] font-bold transition-all cursor-pointer ${x||t.api_key_status==="running"?"text-text-muted cursor-not-allowed opacity-40":"text-brand-400 hover:text-brand-300 hover:underline"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"play_arrow"}),"Process"]}),t.api_key_status==="ready"&&t.api_key&&e.jsxs("button",{onClick:()=>Ne(t.id),className:"inline-flex items-center gap-0.5 text-[11px] font-bold text-green-400 hover:text-green-300 hover:underline transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"add_link"}),"+fsrouter"]}),e.jsxs("button",{onClick:()=>o(t.id),className:"inline-flex items-center gap-0.5 text-[11px] font-bold text-red-400 hover:text-red-300 hover:underline transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"delete"}),"Delete"]})]})})]},t.id)),H.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-6 text-center text-text-muted",children:"No accounts found. Add manual accounts to get started."})})]})]})}),me>1&&e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-2",children:[e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>De(t=>Math.max(1,t-1)),disabled:xe===1,children:"Previous"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Page ",xe," of ",me]}),e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>De(t=>Math.min(me,t+1)),disabled:xe===me,children:"Next"})]})]})]})]}),O&&e.jsxs(Ye,{padding:"md",className:"space-y-3 border border-brand-500/20 bg-brand-500/5 mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-xs font-bold text-brand-400 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"bug_report"}),"🖥️ Live Browser Preview"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!_&&e.jsx("span",{className:"text-[10px] text-text-muted",children:x?"Starting...":"Run a job to see the browser"}),_&&e.jsxs("span",{className:"text-[10px] text-green-400 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Live · ~2fps"]})]})]}),e.jsx("div",{className:"relative rounded-lg overflow-hidden border border-border-subtle bg-black",style:{aspectRatio:"16/10"},children:_?e.jsx("img",{src:`/api/automation/codebuddy/debug-vnc?action=screenshot&t=${D}`,alt:"Browser preview",className:"w-full h-full object-contain",style:{minHeight:"400px",imageRendering:"auto"},onLoad:()=>{O&&x&&setTimeout(()=>B(Date.now()),400)},onError:()=>{setTimeout(()=>B(Date.now()),2e3)}},"debug-screenshot"):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[32px] text-text-muted",children:"desktop_windows"}),e.jsx("p",{className:"text-xs text-text-muted",children:x?"Starting browser preview...":"Run a job with Debug Mode to see live browser"})]})})})]}),ze&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>W(!1),children:e.jsxs("div",{className:"bg-surface border border-border-subtle rounded-2xl shadow-2xl w-full max-w-lg mx-4 max-h-[90vh] overflow-hidden",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"p-5 border-b border-border-subtle",children:[e.jsxs("h3",{className:"text-base font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"dns"}),"Edit Proxy Pool"]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Enter one proxy per line. A random proxy will be selected for each automation run."})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("textarea",{value:ge,onChange:t=>le(t.target.value),placeholder:`socks5://user:pass@host:port
4
+ http://host:port
5
+ host:port:user:pass
6
+ host:port`,rows:10,className:"w-full text-xs p-3 rounded-xl border border-border-subtle bg-surface-2 focus:outline-none focus:border-primary text-text-main font-mono resize-none",spellCheck:!1}),e.jsxs("div",{className:"text-[10px] text-text-muted bg-surface-2 rounded-lg p-3 space-y-1",children:[e.jsx("div",{className:"font-semibold text-text-main mb-1",children:"Supported formats:"}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"socks5://user:pass@host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"http://user:pass@host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"socks5://host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"http://host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"host:port:user:pass"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"host:port"})})]})]}),e.jsxs("div",{className:"p-5 border-t border-border-subtle flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[ge.split(`
7
+ `).filter(t=>t.trim()).length," proxies"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>W(!1),className:"px-4 py-2 text-xs rounded-lg border border-border-subtle text-text-muted hover:text-text-main transition-colors",children:"Cancel"}),e.jsx("button",{onClick:async()=>{const t=ge.split(`
8
+ `).map(a=>a.trim()).filter(Boolean);V(t),W(!1);try{await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",proxy_enabled:!0,proxy_pool:JSON.stringify(t)})})}catch{}},className:"px-4 py-2 text-xs rounded-lg bg-primary text-white font-medium hover:opacity-90 transition-opacity",children:"Save Proxies"})]})]})]})})]})}function tt(u){if(!u)return"";const h=`
9
+ <style id="router-injected-styles">
10
+ html, body {
11
+ overflow-x: auto !important;
12
+ overflow-y: auto !important;
13
+ margin: 0 !important;
14
+ padding: 12px !important;
15
+ background-color: #ffffff !important;
16
+ color: #000000 !important;
17
+ }
18
+ img {
19
+ max-width: 100% !important;
20
+ height: auto !important;
21
+ }
22
+ </style>
23
+ `;return u.includes("<head>")?u.replace("<head>",`<head>${h}`):u.includes("<HEAD>")?u.replace("<HEAD>",`<HEAD>${h}`):u.includes("<body>")?u.replace("<body>",`<body>${h}`):u.includes("<BODY>")?u.replace("<BODY>",`<BODY>${h}`):h+u}function st(){const[u,h]=r.useState(!1),[X,x]=r.useState(!1),[ee,f]=r.useState(!0),[te,N]=r.useState(!1),[I,$]=r.useState(""),[se,ue]=r.useState([]),[ae,pe]=r.useState([]),[Se,g]=r.useState(null),[Ue,K]=r.useState(""),[Ce,$e]=r.useState([]),[re,ne]=r.useState(1),[he,A]=r.useState(!1),[Re,_e]=r.useState(!1),[j,i]=r.useState(!1),[R,G]=r.useState(""),[be,O]=r.useState(""),[U,Te]=r.useState(""),[We,oe]=r.useState(""),[fe,k]=r.useState("manual"),[V,ze]=r.useState(""),[W,ge]=r.useState(""),[le,Be]=r.useState(""),[Ae,Fe]=r.useState(""),[S,Le]=r.useState(""),[Q,z]=r.useState({}),[L,C]=r.useState(null),Pe=r.useRef(!1);r.useEffect(()=>{Pe.current=he,he||C(null)},[he]);const[_,Z]=r.useState("all"),[D,B]=r.useState(""),[F,je]=r.useState(null),[d,ie]=r.useState(null),[T,J]=r.useState("html"),[M,Je]=r.useState(""),[ye,Oe]=r.useState(!1),[we,He]=r.useState(""),[ce,de]=r.useState(""),y=async()=>{var s,o,v,P,me,H,Y,q,Ke;try{const t=await fetch("/api/automation/fsmail"),a=await t.json();if(t.ok){x(a.configured),N(a.connection_ok),$(a.connection_error),ue(a.domains||[]);const n=a.inboxes||[];pe(n),B(l=>l&&n.some(c=>c.address.toLowerCase()===l.toLowerCase())?l:n.length>0?n[0].address:""),g(a.webhook),K(a.webhook_url),$e(a.otps||[]),Pe.current||(G(((s=a.settings)==null?void 0:s.base_url)||""),O(((o=a.settings)==null?void 0:o.api_key)||""),Te(((v=a.settings)==null?void 0:v.default_domain)||""),oe(((P=a.settings)==null?void 0:P.webhook_secret)||""),ze(((me=a.settings)==null?void 0:me.cf_account_id)||""),ge(((H=a.settings)==null?void 0:H.cf_api_token)||""),Be(((Y=a.settings)==null?void 0:Y.cf_domain)||""),Fe(((q=a.settings)==null?void 0:q.cf_telegram_bot_token)||""),Le(((Ke=a.settings)==null?void 0:Ke.cf_workers_dev_url)||""))}}catch(t){console.error(t)}finally{f(!1)}};r.useEffect(()=>{y();const s=setInterval(y,5e3);return()=>clearInterval(s)},[]);const Ve=async()=>{try{(await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",base_url:R,api_key:be,default_domain:U,webhook_secret:We,cf_account_id:V,cf_api_token:W,cf_domain:le,cf_telegram_bot_token:Ae,cf_workers_dev_url:S})})).ok&&(A(!1),y())}catch(s){alert(`Save failed: ${s.message}`)}},xe=async()=>{h(!0),C(null);try{const s=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test-connection",base_url:R,api_key:be})}),o=await s.json();s.ok?(C({ok:!0,message:"Koneksi ke worker berhasil!"}),y()):C({ok:!1,message:`Koneksi gagal: ${o.error}`})}catch(s){C({ok:!1,message:`Error: ${s.message}`})}finally{h(!1)}},De=async()=>{if(!V||!W||!le){alert("Account ID, API Token, dan Domain wajib diisi!");return}h(!0),C(null);try{const s=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auto-deploy",cf_account_id:V,cf_api_token:W,cf_domain:le,telegram_bot_token:Ae})}),o=await s.json();s.ok?(C({ok:!0,message:"Sukses! Worker telah di-deploy ke Cloudflare dan siap digunakan."}),G(o.base_url||""),O(o.api_key||""),Te(o.default_domain||""),oe(o.webhook_secret||""),Le(o.cf_workers_dev_url||""),y()):C({ok:!1,message:`Deploy gagal: ${o.error}`})}catch(s){C({ok:!1,message:`Error: ${s.message}`})}finally{h(!1)}},Me=async()=>{try{const s=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"webhook-register"})}),o=await s.json();s.ok?(alert("Webhook registered successfully!"),y()):alert(`Failed: ${o.error}`)}catch(s){alert(`Error: ${s.message}`)}},w=async s=>{s.preventDefault();try{const o=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"inbox-create",alias:we,domain:ce})}),v=await o.json();if(o.ok){i(!1);const P=`${we}@${ce}`.toLowerCase();B(P),He(""),de(""),y()}else alert(v.error)}catch(o){alert(o.message)}},Qe=async s=>{if(confirm(`Hapus inbox ${s}?`))try{(await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"inbox-delete",alias:s})})).ok&&(D&&D.split("@")[0]===s&&B(""),d&&d.alias===s&&(je(null),ie(null)),y())}catch(o){console.error(o)}},Ze=async s=>{je(s),ie(null),ne(1);try{const o=await fetch(`/api/automation/fsmail/otps/${s}`),v=await o.json();o.ok&&(ie(v.otp),y())}catch(o){console.error(o)}},Ee=async(s,o)=>{if(s.stopPropagation(),!!confirm("Delete this email?"))try{await fetch(`/api/automation/fsmail/otps/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete"})}),F===o&&(je(null),ie(null)),y()}catch(v){console.error(v)}},Ie=s=>{navigator.clipboard.writeText(s),z(o=>({...o,[s]:!0})),setTimeout(()=>{z(o=>({...o,[s]:!1}))},1500)},E=({value:s,text:o="Copy",className:v=""})=>{const P=Q[s];return e.jsxs("button",{type:"button",onClick:()=>Ie(s),className:`text-[10px] px-2 py-1 rounded cursor-pointer transition-all duration-150 flex items-center gap-1 border font-semibold ${P?"text-green-400 bg-green-500/10 border-green-500/20":"text-white/50 hover:text-white bg-white/5 hover:bg-white/10 border-transparent"} ${v}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:P?"check":"content_copy"}),P?"Copied":o]})},ve=Ce.filter(s=>{if(!D||s.address.toLowerCase()!==D.toLowerCase()||_==="unread"&&s.used_at||_==="read"&&!s.used_at||_==="otp"&&!s.otp_code)return!1;if(M){const o=M.toLowerCase();return s.sender.toLowerCase().includes(o)||s.subject.toLowerCase().includes(o)||s.otp_code&&s.otp_code.includes(o)}return!0}),Ne=s=>Ce.filter(o=>!(!D||o.address.toLowerCase()!==D.toLowerCase()||s==="unread"&&o.used_at||s==="read"&&!o.used_at||s==="otp"&&!o.otp_code)).length;return e.jsxs("div",{className:"border border-border-subtle rounded-2xl overflow-hidden bg-vibrancy backdrop-blur-xl flex flex-col h-[calc(100vh-210px)] min-h-[500px] shadow-[var(--shadow-warm)]",children:[ee?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center space-y-3",children:e.jsx(Xe,{size:"lg",label:"Memuat setelan Temp Mail..."})}):X?e.jsxs("div",{className:"flex-1 flex divide-x divide-border-subtle min-h-0",children:[e.jsxs("aside",{className:"w-60 shrink-0 bg-surface/40 flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-4 border-b border-border-subtle flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs font-bold text-text-main flex items-center gap-1.5",title:!te&&I?I:void 0,children:[e.jsx("span",{className:`inline-block size-2 rounded-full ${te?"bg-green-500":"bg-red-500 animate-ping"}`}),te?"Connected":"Disconnected"]}),e.jsx("button",{onClick:()=>A(!0),className:"text-text-muted hover:text-text-main cursor-pointer",title:"Settings",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"settings"})})]}),!te&&I&&e.jsxs("div",{className:"px-4 py-2.5 bg-red-500/10 border-b border-red-500/20 text-[10px] text-red-400 break-all space-y-1",children:[e.jsxs("div",{className:"font-semibold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"error"}),"Koneksi Gagal:"]}),e.jsx("div",{className:"opacity-80",children:I}),S&&R!==S&&e.jsx("button",{onClick:()=>{G(S),A(!0),k("manual")},className:"text-primary hover:underline text-[9px] font-semibold block mt-1 text-left",children:"💡 Gunakan domain workers.dev fallback"})]}),e.jsx("div",{className:"p-4",children:e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:()=>{de(U||(se.length>0?se[0]:"")),i(!0)},children:"+ New Inbox"})}),e.jsxs("nav",{className:"flex flex-col px-2 space-y-0.5",children:[e.jsxs("button",{onClick:()=>{Z("all")},className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="all"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:[e.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),e.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),"Inbox"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("all")})]}),e.jsxs("button",{onClick:()=>Z("unread"),className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="unread"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Unread"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("unread")})]}),e.jsxs("button",{onClick:()=>Z("read"),className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="read"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:[e.jsx("path",{d:"M2 17V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2Z"}),e.jsx("path",{d:"M2 7l10 7 10-7"})]}),"Read"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("read")})]}),e.jsxs("button",{onClick:()=>Z("otp"),className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="otp"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),"With OTP"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("otp")})]})]}),e.jsx("div",{className:"px-4 py-3 border-t border-b border-border-subtle/45 mt-4 bg-surface/10",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",placeholder:"Search inboxes...",value:M,onChange:s=>Je(s.target.value),className:"w-full text-xs pl-8 pr-3 py-1.5 rounded-lg border border-border-subtle bg-surface focus:outline-none focus:border-primary text-text-main"}),e.jsx("span",{className:"absolute left-2.5 top-2.5 text-text-muted/60",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-2 pt-4",children:e.jsxs("div",{children:[e.jsxs("p",{className:"px-3 text-[10px] font-semibold text-text-muted uppercase tracking-wider mb-2",children:["Active Inboxes (",ae.length,")"]}),e.jsxs("div",{className:"space-y-0.5",children:[ae.filter(s=>s.address.toLowerCase().includes(M.toLowerCase())).map(s=>e.jsxs("div",{onClick:()=>{B(s.address),Z("all")},className:`group/inbox flex items-center justify-between px-3 py-2 rounded-lg text-xs font-medium cursor-pointer transition-colors ${D.toLowerCase()===s.address.toLowerCase()?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsx("span",{className:"truncate w-32",title:s.address,children:s.address}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 ml-1",children:[e.jsx("button",{onClick:o=>{o.stopPropagation(),Ie(s.address)},className:`size-6 flex items-center justify-center rounded-md transition-all duration-150 ${Q[s.address]?"text-green-400 bg-green-500/15":"text-text-muted hover:text-primary hover:bg-primary/15"}`,title:"Copy address",children:Q[s.address]?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),e.jsx("button",{onClick:o=>{o.stopPropagation(),Qe(s.alias)},className:"size-6 flex items-center justify-center rounded-md text-text-muted hover:text-red-400 hover:bg-red-500/15 transition-all duration-150",title:"Delete inbox",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]},s.address)),ae.length===0&&e.jsx("p",{className:"px-3 text-[11px] text-text-muted italic",children:"No inboxes. Click New Inbox above."})]})]})})]}),e.jsxs("section",{className:"w-80 shrink-0 flex flex-col min-h-0 bg-surface/10",children:[e.jsxs("div",{className:"p-3 border-b border-border-subtle flex items-center justify-between gap-2 bg-surface/10",children:[e.jsx("span",{className:"text-xs font-bold text-text-muted uppercase tracking-wider pl-1",children:"Messages"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{Oe(!0),y().finally(()=>Oe(!1))},className:`p-1.5 hover:bg-surface rounded-lg cursor-pointer text-text-muted transition-colors duration-150 ${ye?"animate-spin":""}`,title:"Refresh",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"}),e.jsx("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),e.jsx("path",{d:"M16 16h5v5"})]})}),e.jsx("button",{onClick:s=>{F&&Ee(s,F)},disabled:!F,className:`p-1.5 rounded-lg cursor-pointer transition-colors duration-150 ${F?"text-red-500 hover:bg-red-500/10":"text-text-muted/30 cursor-not-allowed"}`,title:"Delete selected email",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),e.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),e.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-2 space-y-1.5",children:D?ve.length===0?e.jsx("div",{className:"text-center p-8 text-text-muted text-xs italic",children:"No messages found."}):ve.map(s=>e.jsxs("div",{onClick:()=>Ze(s.id),className:`group p-3 rounded-xl border border-border-subtle cursor-pointer transition-colors relative flex flex-col gap-1 ${F===s.id?"bg-primary/10 border-primary":s.used_at?"bg-surface/40 hover:bg-surface":"bg-surface font-semibold shadow-[var(--shadow-soft)] hover:bg-surface/80"}`,children:[e.jsxs("div",{className:"flex justify-between items-baseline gap-2",children:[e.jsx("span",{className:"text-xs text-text-main truncate w-36",children:s.sender}),e.jsx("span",{className:"text-[9px] text-text-muted shrink-0",children:new Date(s.received_at*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("h4",{className:"text-xs text-text-main truncate",children:s.subject}),s.otp_code&&e.jsx("div",{className:"mt-1",children:e.jsxs("span",{className:"bg-amber-500/10 text-amber-500 border border-amber-500/20 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold tracking-wider",children:["🔑 ",s.otp_code]})}),e.jsx("button",{onClick:o=>Ee(o,s.id),className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 text-text-muted hover:text-red-500 transition-all p-1 hover:bg-red-500/10 rounded cursor-pointer",title:"Delete email",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]},s.id)):e.jsx("div",{className:"text-center p-8 text-text-muted text-xs italic",children:"Select an inbox to view messages."})})]}),e.jsx("article",{className:"flex-1 flex flex-col min-h-0 bg-surface/5",children:F===null?e.jsx("div",{className:"flex-1 flex items-center justify-center text-text-muted text-xs italic",children:"Select an email to read its contents."}):d===null?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-text-muted text-xs",children:[e.jsx("span",{className:"animate-spin mr-2",children:"⏳"})," Loading email details..."]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-6 border-b border-border-subtle space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-start gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-text-main",children:d.subject}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["From: ",e.jsx("span",{className:"font-semibold text-text-main",children:d.sender})]}),e.jsxs("p",{className:"text-xs text-text-muted",children:["To: ",e.jsx("span",{className:"font-semibold text-text-main",children:d.address})]})]}),e.jsxs("div",{className:"text-right flex flex-col items-end gap-2 shrink-0",children:[e.jsx("span",{className:"text-[11px] text-text-muted",children:new Date(d.received_at*1e3).toLocaleString()}),e.jsxs("button",{onClick:s=>Ee(s,d.id),className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-bold rounded-lg border bg-red-500/10 text-red-400 hover:bg-red-500/20 border-red-500/20 transition-all active:scale-95 cursor-pointer mt-1",title:"Delete this email",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete Email"]})]})]}),d.otp_code&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/25 rounded-xl p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-amber-500 uppercase tracking-widest font-bold",children:"Verification OTP"}),e.jsx("p",{className:"text-2xl font-black font-mono tracking-widest text-text-main mt-1",children:d.otp_code})]}),e.jsx(m,{variant:Q[d.otp_code]?"success":"secondary",size:"sm",onClick:()=>Ie(d.otp_code),children:Q[d.otp_code]?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"check"}),"Copied!"]}):"Copy Code"})]}),d.verify_url&&e.jsxs("div",{className:"bg-primary/10 border border-primary/20 rounded-xl p-3 flex items-center justify-between gap-3 text-xs",children:[e.jsxs("span",{className:"truncate flex-1 text-text-main",title:d.verify_url,children:["🔗 ",d.verify_url]}),e.jsx("a",{href:d.verify_url,target:"_blank",rel:"noreferrer",className:"bg-primary hover:bg-primary/95 text-white px-3 py-1.5 rounded-lg font-semibold shrink-0",children:"Open Link"})]})]}),e.jsxs("div",{className:"flex justify-between items-center border-b border-border-subtle bg-surface/20 px-6 shrink-0",children:[e.jsxs("div",{className:"flex",children:[d.body_html&&e.jsx("button",{onClick:()=>J("html"),className:`px-4 py-2.5 text-xs font-semibold border-b-2 cursor-pointer ${T==="html"?"border-primary text-primary":"border-transparent text-text-muted"}`,children:"HTML View"}),e.jsx("button",{onClick:()=>J("text"),className:`px-4 py-2.5 text-xs font-semibold border-b-2 cursor-pointer ${T==="text"||!d.body_html?"border-primary text-primary":"border-transparent text-text-muted"}`,children:"Plain Text"})]}),T==="html"&&d.body_html&&e.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-xs text-text-muted select-none",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-white/40",children:"zoom_in"}),e.jsx("button",{onClick:()=>ne(s=>Math.max(.4,s-.1)),className:"px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 border border-white/10 active:bg-white/20 transition-colors text-[10px] font-bold cursor-pointer text-white",title:"Zoom Out",children:"A-"}),e.jsxs("span",{className:"font-mono text-[10px] w-10 text-center text-white/80",children:[Math.round(re*100),"%"]}),e.jsx("button",{onClick:()=>ne(s=>Math.min(1.5,s+.1)),className:"px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 border border-white/10 active:bg-white/20 transition-colors text-[10px] font-bold cursor-pointer text-white",title:"Zoom In",children:"A+"}),e.jsx("button",{onClick:()=>ne(1),className:"px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 border border-white/10 active:bg-white/20 transition-colors text-[10px] font-semibold cursor-pointer text-white ml-1",children:"Reset"})]})]}),e.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar p-6 relative min-h-[450px]",children:T==="html"&&d.body_html?e.jsx("div",{className:"w-full h-full relative overflow-auto custom-scrollbar",children:e.jsx("iframe",{srcDoc:tt(d.body_html),title:"Email Preview",sandbox:"allow-popups allow-popups-to-escape-sandbox",style:{transform:`scale(${re})`,transformOrigin:"top left",width:`${100/re}%`,height:`${100/re}%`},className:"border border-border-subtle rounded-xl bg-white absolute inset-0"})}):e.jsx("pre",{className:"text-xs font-sans whitespace-pre-wrap leading-relaxed text-text-main",children:d.body_text})})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center space-y-4",children:[e.jsx("div",{className:"size-16 rounded-full bg-primary/10 text-primary flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"mail_lock"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-text-main",children:"FSMail Client Not Configured"}),e.jsx("p",{className:"text-xs text-text-muted mt-1 max-w-sm",children:"Please enter your FSMail Cloudflare worker credentials and endpoint in settings to enable temp emails."})]}),e.jsx(m,{variant:"primary",onClick:()=>A(!0),children:"⚙ Configure Settings"})]}),he&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 backdrop-blur-sm p-4 pt-[6vh] overflow-y-auto",children:e.jsxs("div",{className:"bg-neutral-900 border border-white/10 rounded-2xl w-full max-w-md text-white max-h-[80vh] flex flex-col overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-white/5 shrink-0",children:[e.jsx("h3",{className:"text-base font-bold",children:"FSMail Settings"}),e.jsx("button",{onClick:()=>A(!1),className:"text-white/60 hover:text-white cursor-pointer flex items-center",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"p-5 overflow-y-auto custom-scrollbar flex-1 space-y-4",children:[e.jsxs("div",{className:"flex border border-white/10 rounded-lg p-0.5 bg-white/5 text-xs shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>k("manual"),className:`flex-1 py-1.5 rounded-md font-semibold cursor-pointer text-center transition-all ${fe==="manual"?"bg-primary text-white":"text-white/60 hover:text-white"}`,children:"Manual Input"}),e.jsx("button",{type:"button",onClick:()=>k("auto"),className:`flex-1 py-1.5 rounded-md font-semibold cursor-pointer text-center transition-all ${fe==="auto"?"bg-primary text-white":"text-white/60 hover:text-white"}`,children:"⚡ Auto Deploy (Cloudflare)"})]}),fe==="manual"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Base URL Worker"}),e.jsx("input",{type:"text",placeholder:"https://mail.yourdomain.com",value:R,onChange:s=>G(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"}),S&&R!==S&&e.jsxs("div",{className:"mt-1.5 p-2 bg-primary/10 border border-primary/20 rounded-lg text-[10px] text-primary space-y-1 text-left",children:[e.jsx("div",{children:"💡 Coba gunakan URL workers.dev fallback:"}),e.jsx("div",{className:"font-mono text-[9px] break-all bg-black/40 p-1 rounded select-all",children:S}),e.jsx("button",{type:"button",onClick:()=>G(S),className:"underline hover:no-underline font-semibold block",children:"Klik untuk gunakan URL ini"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"API Key (X-API-Key)"}),e.jsx("input",{type:"password",placeholder:"tm_...",value:be,onChange:s=>O(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Default Domain"}),e.jsx("input",{type:"text",placeholder:"yourdomain.com",value:U,onChange:s=>Te(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Webhook Secret"}),e.jsx("input",{type:"password",placeholder:"Leave empty to auto-generate",value:We,onChange:s=>oe(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:xe,disabled:u,children:u?"Testing...":"⚡ Test Connection"}),L&&e.jsxs("div",{className:`p-2.5 rounded-lg text-xs font-medium flex items-start gap-2 ${L.ok?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:L.ok?"check_circle":"error"}),e.jsx("span",{className:"break-all text-left",children:L.message})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>A(!1),children:"Cancel"}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:Ve,children:"Save Settings"})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-white/60 block",children:"Cloudflare Account ID"}),e.jsxs("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline cursor-pointer flex items-center gap-0.5",children:["Temukan disini ",e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"open_in_new"})]})]}),e.jsx("input",{type:"text",placeholder:"Paste Account ID Anda",value:V,onChange:s=>ze(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-white/60 block",children:"Cloudflare API Token (Workers & D1)"}),e.jsxs("a",{href:"https://dash.cloudflare.com/profile/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline cursor-pointer flex items-center gap-0.5",children:["Buat disini ",e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"open_in_new"})]})]}),e.jsx("input",{type:"password",placeholder:"Paste API Token Anda",value:W,onChange:s=>ge(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Domain Worker (misal: mail.domainanda.com)"}),e.jsx("input",{type:"text",placeholder:"mail.domainanda.com",value:le,onChange:s=>Be(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-white/60 block",children:"Telegram Bot Token (Opsional)"}),e.jsxs("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline cursor-pointer flex items-center gap-0.5",children:["Dapatkan di @BotFather ",e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"open_in_new"})]})]}),e.jsx("input",{type:"password",placeholder:"Token Bot dari @BotFather",value:Ae,onChange:s=>Fe(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]})]}),e.jsxs("div",{className:"space-y-3",children:[L&&e.jsxs("div",{className:`p-2.5 rounded-lg text-xs font-medium flex items-start gap-2 ${L.ok?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:L.ok?"check_circle":"error"}),e.jsx("span",{className:"break-all text-left",children:L.message})]}),S&&e.jsxs("div",{className:"p-2.5 bg-white/5 border border-white/10 rounded-lg text-[10px] text-white/70 space-y-1 text-left",children:[e.jsx("span",{className:"font-semibold text-primary block",children:"Workers.dev fallback URL:"}),e.jsx("span",{className:"font-mono text-[9px] break-all block bg-black/40 p-1 rounded select-all",children:S}),e.jsx("span",{className:"block leading-relaxed",children:"Jika custom domain Anda terputus (misal karena DNS belum merambat), Anda dapat menggunakan URL fallback ini di tab Manual Input."})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>A(!1),children:"Cancel"}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:De,disabled:u,children:u?"Deploying...":"⚡ Auto Deploy & Setup"})]})]})]}),e.jsxs("div",{className:"space-y-3 pt-2 border-t border-white/5 shrink-0",children:[e.jsx("a",{href:"/dashboard/automation/fsmail-tutorial",target:"_blank",rel:"noopener noreferrer",className:"w-full py-2 rounded-lg bg-neutral-900 border border-primary/20 hover:border-primary/50 text-primary text-xs font-semibold flex items-center justify-center gap-1.5 transition-colors cursor-pointer",children:"📖 Buka Panduan Lengkap Deploy"}),e.jsxs("details",{className:"group bg-white/5 border border-white/10 rounded-xl overflow-hidden",children:[e.jsxs("summary",{className:"list-none flex items-center justify-between p-3 cursor-pointer select-none text-[11px] font-semibold text-white/80 hover:text-white transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"help"}),"Cara Setup Temp Mail (FSMail)"]}),e.jsx("span",{className:"material-symbols-outlined text-[16px] transition-transform group-open:rotate-180",children:"expand_more"})]}),e.jsxs("div",{className:"p-3 pt-0 border-t border-white/5 text-[11px] text-white/70 space-y-2 leading-relaxed max-h-40 overflow-y-auto custom-scrollbar",children:[e.jsxs("p",{className:"mt-2",children:["FSMail adalah sistem email sementara berbasis ",e.jsx("strong",{children:"Cloudflare Worker"}),". Ikuti langkah berikut untuk mengaturnya:"]}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1.5 text-white/60",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Deploy Worker:"})," Deploy kode worker FSMail di akun Cloudflare Anda."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Set API Key:"})," Pada dashboard Worker Anda, tambahkan Environment Variable ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-amber-300",children:"API_KEY"})," dengan nilai token rahasia Anda."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Email Routing:"})," Aktifkan Cloudflare Email Routing pada domain Anda, lalu arahkan semua email masuk ke worker tersebut."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Hubungkan:"})," Masukkan ",e.jsx("strong",{className:"text-white",children:"Base URL Worker"})," (misal: ",e.jsx("code",{className:"text-amber-200",children:"https://mail.domain.com"}),") dan ",e.jsx("strong",{className:"text-white",children:"API Key"})," ke form di atas, lalu tekan ",e.jsx("strong",{className:"text-white",children:"Test Connection"}),"."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Aktifkan Webhook:"})," Setelah koneksi berhasil dan pengaturan disimpan, klik tombol ",e.jsx("strong",{className:"text-white",children:"Register Webhook"})," di bawah untuk mengaktifkan sinkronisasi email secara real-time."]})]})]})]}),X&&e.jsxs("div",{className:"border-t border-white/10 pt-3 mt-2 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-white/40 uppercase font-bold tracking-wider",children:"Worker Integration"}),e.jsx("pre",{className:"text-[10px] bg-white/5 p-2 rounded overflow-x-auto text-amber-300 font-mono",children:Ue}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:Me,children:"Register Webhook"})]})]})]})]})}),Re&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-neutral-950 border border-white/10 rounded-2xl w-full max-w-2xl text-white max-h-[85vh] flex flex-col overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-white/5 shrink-0 bg-neutral-900",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"auto_stories"}),e.jsx("h3",{className:"text-base font-bold",children:"Panduan Lengkap Deploy Temp Mail"})]}),e.jsx("button",{onClick:()=>_e(!1),className:"text-white/60 hover:text-white cursor-pointer flex items-center",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"p-6 overflow-y-auto custom-scrollbar flex-1 space-y-6 text-sm leading-relaxed text-white/80",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"1"}),"Prasyarat & Login Cloudflare"]}),e.jsx("p",{className:"mb-2",children:"Pastikan Node.js sudah terinstal. Login ke akun Cloudflare Anda melalui terminal dengan menjalankan perintah berikut:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npx wrangler login"}),e.jsx(E,{value:"npx wrangler login"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"2"}),"Install Dependencies"]}),e.jsx("p",{className:"mb-2",children:"Masuk ke direktori tempmail lokal di sistem Anda dan install dependensi NPM:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"cd /home/data/Project/fsrouter/tempmail && npm install"}),e.jsx(E,{value:"cd /home/data/Project/fsrouter/tempmail && npm install"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"3"}),"Buat Database D1"]}),e.jsx("p",{className:"mb-2",children:"Buat database SQL D1 baru untuk menyimpan inbox dan pesan email masuk:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 mb-3",children:[e.jsx("span",{children:"npx wrangler d1 create tempmail"}),e.jsx(E,{value:"npx wrangler d1 create tempmail"})]}),e.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-lg p-3 text-xs text-blue-300 flex items-start gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:"info"}),e.jsxs("span",{children:["Salin ",e.jsx("strong",{children:"database_id"})," hasil output perintah di atas, lalu buka file ",e.jsx("a",{href:"file:///home/data/Project/fsrouter/tempmail/wrangler.jsonc",className:"underline font-semibold hover:text-blue-200",children:"wrangler.jsonc"})," dan ganti nilai ",e.jsx("code",{children:"database_id"})," di dalamnya."]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"4"}),"Jalankan Migrasi Database"]}),e.jsx("p",{className:"mb-2",children:"Inisialisasi tabel database temp mail di lokal dan jarak jauh (remote Cloudflare):"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npm run db:migrate:local && npm run db:migrate:remote"}),e.jsx(E,{value:"npm run db:migrate:local && npm run db:migrate:remote"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"5"}),"Simpan Secret Bot Telegram"]}),e.jsx("p",{className:"mb-2",children:"Set token Telegram bot Anda dan webhook secret token ke Cloudflare Workers:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npx wrangler secret put TELEGRAM_BOT_TOKEN"}),e.jsx(E,{value:"npx wrangler secret put TELEGRAM_BOT_TOKEN"})]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"}),e.jsx(E,{value:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"})]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"6"}),"Konfigurasi `wrangler.jsonc` & Deploy"]}),e.jsxs("p",{className:"mb-2",children:["Sesuaikan nilai di bagian ",e.jsx("code",{children:"vars"})," (domain dan base URL) pada file ",e.jsx("a",{href:"file:///home/data/Project/fsrouter/tempmail/wrangler.jsonc",className:"underline font-semibold hover:text-white",children:"wrangler.jsonc"}),", lalu deploy worker:"]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npm run deploy"}),e.jsx(E,{value:"npm run deploy"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"7"}),"Set Webhook Telegram Bot"]}),e.jsx("p",{className:"mb-2",children:"Daftarkan URL Worker Anda agar bot Telegram dapat memproses command masuk:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{className:"truncate mr-2",children:`curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{"url":"https://<worker-host>/telegram/webhook","secret_token":"<WEBHOOK_SECRET>"}'`}),e.jsx(E,{value:`curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{"url":"https://<worker-host>/telegram/webhook","secret_token":"<WEBHOOK_SECRET>"}'`})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"8"}),"Cloudflare Email Routing"]}),e.jsxs("p",{children:["Masuk ke Cloudflare Dashboard domain Anda, klik menu ",e.jsx("strong",{children:"Email Routing"}),", aktifkan fitur tersebut, lalu buat rule ",e.jsx("strong",{children:"Catch-all"})," dengan aksi ",e.jsx("strong",{children:"Send to a Worker"})," mengarah ke nama Worker Anda."]})]})]}),e.jsx("div",{className:"p-5 border-t border-white/5 shrink-0 bg-neutral-900 flex justify-end",children:e.jsx(m,{variant:"primary",size:"sm",onClick:()=>_e(!1),children:"Selesai Membaca"})})]})}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("form",{onSubmit:w,className:"bg-neutral-900 border border-white/10 rounded-2xl w-full max-w-sm p-6 space-y-4 text-white",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-bold",children:"New Inbox"}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-white/60 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Alias (optional, empty = random)"}),e.jsx("input",{type:"text",placeholder:"e.g. business-inbox",value:we,onChange:s=>He(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Domain"}),se.length>0?e.jsxs("select",{value:ce,onChange:s=>de(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-neutral-900 focus:outline-none focus:border-primary text-white",children:[e.jsxs("option",{value:"",children:["— Default (",U||se[0],") —"]}),se.map(s=>e.jsx("option",{value:s,children:s},s))]}):e.jsx("input",{type:"text",placeholder:U||"yourdomain.com",value:ce,onChange:s=>de(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(m,{type:"button",variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>i(!1),children:"Cancel"}),e.jsx(m,{type:"submit",variant:"primary",size:"sm",fullWidth:!0,children:"Create Inbox"})]})]})]})})]})}export{it as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.CemlR_k0.js";import{b as r}from"./router.Cjj1--8t.js";import{C as j}from"./Loading.CKcPqzyp.js";import"./zustand.akaTi5uX.js";function P(){return e.jsx(r.Suspense,{fallback:e.jsx(j,{}),children:e.jsx(v,{})})}function v(){const[o,u]=r.useState([]),[p,b]=r.useState(!0),[s,f]=r.useState(""),[a,n]=r.useState(null),[i,d]=r.useState(!1),[l,x]=r.useState(""),[c,m]=r.useState(null);r.useEffect(()=>{fetch("/api/media-providers/moderation").then(t=>t.json()).then(t=>{u(Array.isArray(t)?t:[]),t.length>0&&x(t[0].id)}).catch(()=>{}).finally(()=>b(!1))},[]);const h=async()=>{if(s.trim()){d(!0),m(null),n(null);try{const t=await fetch("/api/media/moderation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:s,providerId:l||void 0})});if(!t.ok)throw new Error(`HTTP ${t.status}`);const g=await t.json();n(g)}catch(t){m(t.message)}finally{d(!1)}}};return e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"shield"}),e.jsx("h1",{className:"text-xl font-semibold text-text-main",children:"Moderations"})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Moderation Providers"}),p?e.jsx("p",{className:"text-xs text-text-muted",children:"Loading providers..."}):o.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:"No moderation providers configured. Add one in Media Providers."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(t=>e.jsx("button",{onClick:()=>x(t.id),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer ${l===t.id?"bg-primary/10 text-primary border border-primary/30":"bg-surface-2 text-text-muted hover:text-text-main border border-transparent"}`,children:t.name||t.id},t.id))})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Test Moderation"}),e.jsx("textarea",{value:s,onChange:t=>f(t.target.value),placeholder:"Enter text to moderate...",rows:4,className:"w-full rounded-lg border border-border-subtle bg-surface-2 px-3 py-2 text-sm text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/50 resize-none mb-3"}),e.jsx("button",{onClick:h,disabled:i||!s.trim(),className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer",children:i?"Testing...":"Run Moderation"})]}),c&&e.jsx("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-4",children:e.jsx("p",{className:"text-sm text-red-400",children:c})}),a&&e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Result"}),e.jsx("pre",{className:"text-xs text-text-muted overflow-auto max-h-96 bg-surface-2 rounded-lg p-3 font-mono whitespace-pre-wrap",children:JSON.stringify(a,null,2)})]})]})}export{P as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.CemlR_k0.js";import{b as n}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function x(){const[s,a]=n.useState(null),[c,r]=n.useState(!1),i=async m=>{const o=m.target.files[0];if(!o)return;r(!0);const l=new FormData;l.append("file",o);try{const t=await fetch("/api/ocr",{method:"POST",body:l});a(await t.json())}catch(t){a({error:t.message})}r(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"OCR"}),e.jsx("p",{className:"text-text-muted",children:"Extract text from images using Mistral OCR API"}),e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:i,className:"block"}),c&&e.jsx("p",{children:"Processing..."}),s&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto max-h-96",children:JSON.stringify(s,null,2)})]})}export{x as default};
@@ -0,0 +1,5 @@
1
+ import{j as e,N as pe,y as fe,B as A,P as be,g as ge}from"./index.CemlR_k0.js";import{h as je,d as we,b as c,L as ve}from"./router.Cjj1--8t.js";import{C as S,I as ye,T as Ne,M as ke}from"./NoAuthProxyCard.C8gs3p9D.js";import"./zustand.akaTi5uX.js";function Se(o){if(typeof o!="string")return{providerId:"",model:""};const g=o.indexOf("/");return g<0?{providerId:o,model:""}:{providerId:o.slice(0,g),model:o.slice(g+1)}}const Re=/^[a-zA-Z0-9_.\-]+$/,Ee={webSearch:"Web Search",webFetch:"Web Fetch",image:"Text to Image",tts:"Text To Speech"},V={webSearch:"/v1/search",webFetch:"/v1/web/fetch",image:"/v1/images/generations",tts:"/v1/audio/speech"},L={webSearch:o=>({model:o,query:"What is the latest news about AI?",search_type:"web",max_results:5}),webFetch:o=>({model:o,url:"https://example.com",format:"markdown"}),image:o=>({model:o,prompt:"A cute cat playing piano",n:1,size:"1024x1024"}),tts:o=>({model:o,input:"Hello, this is a test.",voice:"alloy"})};function X(o){return o==="webSearch"||o==="webFetch"?"/dashboard/media-providers/web":`/dashboard/media-providers/${o}`}function Le(){var K;const{id:o}=je(),g=we(),[r,P]=c.useState(null),[q,O]=c.useState(!0),[N,_]=c.useState(""),[G,R]=c.useState(""),[m,j]=c.useState([]),[Y,$]=c.useState(!1),[Z,M]=c.useState(!1),[D,Q]=c.useState([]),[I,B]=c.useState(!1),[l,w]=c.useState(null),[z,E]=c.useState(""),[U,ee]=c.useState(""),[te,se]=c.useState([]),[ae,ne]=c.useState({}),H=async()=>{var t,s,a;try{const[n,i,k,y,x,p]=await Promise.all([fetch(`/api/combos/${o}`,{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"}),fetch("/api/usage/logs",{cache:"no-store"}),fetch("/api/keys",{cache:"no-store"}),fetch("/api/providers",{cache:"no-store"}),fetch("/api/models/alias",{cache:"no-store"})]);if(p.ok&&ne((await p.json()).aliases||{}),y.ok){const b=await y.json();ee(((t=(b.keys||[]).find(d=>d.isActive!==!1))==null?void 0:t.key)||"")}if(x.ok&&se((await x.json()).connections||[]),!n.ok){P(null),O(!1);return}const h=await n.json();P(h),_(h.name),j(h.models||[]);const f=i.ok?await i.json():{};$(((a=(s=f.comboStrategies)==null?void 0:s[h.name])==null?void 0:a.fallbackStrategy)==="round-robin");const u=k.ok?await k.json():[];Q(u.filter(b=>typeof b=="string"&&b.includes(h.name)).slice(0,50))}catch{}O(!1)};c.useEffect(()=>{H()},[o]);const F=t=>t.trim()?Re.test(t)?(R(""),!0):(R("Only letters, numbers, -, _ and ."),!1):(R("Name is required"),!1),v=async t=>{const s=await fetch(`/api/combos/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok){const a=await s.json();return alert(a.error||"Failed to save"),!1}return!0},oe=async()=>{if(!F(N)||N===r.name)return;await v({name:N})&&await H()},re=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||m.includes(s))return;const a=[...m,s];j(a),await v({models:a})},le=async t=>{const s=(t==null?void 0:t.value)||t;if(!s||!m.includes(s))return;const a=m.filter(n=>n!==s);j(a),await v({models:a})},ie=async t=>{const s=m.filter((a,n)=>n!==t);j(s),await v({models:s})},J=async(t,s)=>{const a=[...m],n=t+s;n<0||n>=a.length||([a[t],a[n]]=[a[n],a[t]],j(a),await v({models:a}))},ce=async t=>{$(t);const s=await fetch("/api/settings",{cache:"no-store"}),n={...(s.ok?await s.json():{}).comboStrategies||{}};t?n[r.name]={fallbackStrategy:"round-robin"}:delete n[r.name],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:n})})},de=async()=>{if(!confirm(`Delete combo "${r.name}"?`))return;(await fetch(`/api/combos/${o}`,{method:"DELETE"})).ok&&g(X(r.kind))},me=async()=>{var s,a,n;if(B(!0),w(null),E(""),l!=null&&l.audioUrl)try{URL.revokeObjectURL(l.audioUrl)}catch{}if((s=l==null?void 0:l.imageUrl)!=null&&s.startsWith("blob:"))try{URL.revokeObjectURL(l.imageUrl)}catch{}const t=Date.now();try{const i=V[r.kind],k=L[r.kind](r.name),y={"Content-Type":"application/json"};U&&(y.Authorization=`Bearer ${U}`);const x=await fetch(`/api${i}`,{method:"POST",headers:y,body:JSON.stringify(k)}),p=Date.now()-t;if(!x.ok){const d=await x.json().catch(()=>({}));E(((a=d==null?void 0:d.error)==null?void 0:a.message)||(d==null?void 0:d.error)||`HTTP ${x.status}`),w({json:JSON.stringify(d,null,2),latencyMs:p});return}const h=x.headers.get("content-type")||"";if(h.startsWith("image/")){const d=await x.blob();w({imageUrl:URL.createObjectURL(d),latencyMs:p});return}if(h.startsWith("audio/")||h==="application/octet-stream"){const d=await x.blob();w({audioUrl:URL.createObjectURL(d),latencyMs:p});return}const f=await x.json(),u=(n=f==null?void 0:f.data)==null?void 0:n[0],b=u!=null&&u.b64_json?`data:image/png;base64,${u.b64_json}`:(u==null?void 0:u.url)||"";w({json:JSON.stringify(C(f),null,2),imageUrl:b,latencyMs:p})}catch(i){E(i.message||"Network error")}B(!1)};function C(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(C);const s={};for(const[a,n]of Object.entries(t))s[a]=a==="b64_json"&&typeof n=="string"&&n.length>100?`<${n.length} chars base64>`:C(n);return s}if(q)return e.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."});if(!r)return null;const W=Ee[r.kind]||((K=pe.find(t=>t.id===r.kind))==null?void 0:K.label)||"Combo",T=V[r.kind],xe=r.kind&&L[r.kind]?L[r.kind](r.name):null,he=T?`curl -X POST ${fe()}${T} \\
2
+ -H "Content-Type: application/json" \\
3
+ -H "Authorization: Bearer ${U||"YOUR_KEY"}" \\
4
+ -d '${JSON.stringify(xe)}'`:"",ue=X(r.kind);return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ve,{to:ue,className:"text-text-muted hover:text-primary",children:e.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),e.jsx("div",{className:"size-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-primary",children:"layers"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-xs text-text-muted",children:[W," Combo"]}),e.jsx("code",{className:"text-lg font-semibold font-mono",children:r.name})]})]}),e.jsx(A,{variant:"outline",icon:"delete",onClick:de,className:"text-red-500 border-red-200 hover:bg-red-50",children:"Delete"})]}),e.jsxs(S,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Settings"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{label:"Combo Name",value:N,onChange:t=>{_(t.target.value),F(t.target.value)},onBlur:oe,error:G}),e.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and ."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Round Robin"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Rotate providers across requests instead of strict fallback order."})]}),e.jsx(Ne,{checked:Y,onChange:ce})]})]})]}),e.jsxs(S,{children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Providers"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Tried in order (top-down) or rotated when round-robin is on."})]}),e.jsx(A,{size:"sm",icon:"add",onClick:()=>M(!0),children:"Add Provider"})]}),m.length===0?e.jsx("div",{className:"text-center py-6 border border-dashed border-border rounded-lg text-text-muted text-sm",children:"No providers yet."}):e.jsx("div",{className:"flex flex-col gap-2",children:m.map((t,s)=>{const{providerId:a,model:n}=Se(t),i=ge[a];return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-black/[0.02] dark:bg-white/[0.02]",children:[e.jsx("span",{className:"text-xs text-text-muted w-5 text-center",children:s+1}),e.jsx(be,{src:`/providers/${a}.png`,alt:(i==null?void 0:i.name)||a,size:24,className:"object-contain rounded shrink-0",fallbackText:(i==null?void 0:i.textIcon)||a.slice(0,2).toUpperCase(),fallbackColor:i==null?void 0:i.color}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:(i==null?void 0:i.name)||a}),n&&e.jsx("code",{className:"text-[10px] text-text-muted font-mono truncate block",children:n})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>J(s,-1),disabled:s===0,className:`p-1 rounded ${s===0?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})}),e.jsx("button",{onClick:()=>J(s,1),disabled:s===m.length-1,className:`p-1 rounded ${s===m.length-1?"text-text-muted/20":"text-text-muted hover:text-primary hover:bg-black/5"}`,title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_downward"})}),e.jsx("button",{onClick:()=>ie(s),className:"p-1 rounded text-text-muted hover:text-red-500 hover:bg-red-500/10",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]})]},`${t}-${s}`)})})]}),r.kind&&T&&e.jsxs(S,{children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Test Example"}),e.jsx(A,{size:"sm",icon:"play_arrow",onClick:me,disabled:I||m.length===0,children:I?"Running...":"Run"})]}),e.jsx("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-x-auto whitespace-pre-wrap break-all",children:he}),z&&e.jsx("p",{className:"mt-3 text-xs text-red-500 break-words",children:z}),l&&e.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[l.latencyMs!=null&&e.jsxs("span",{className:"text-[11px] text-text-muted",children:["⚡ ",l.latencyMs,"ms"]}),l.imageUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-end mb-1.5",children:e.jsxs("a",{href:l.imageUrl,download:"image.png",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),e.jsx("img",{src:l.imageUrl,alt:"Generated",className:"max-w-full rounded-lg border border-border"})]}),l.audioUrl&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-end mb-1.5",children:e.jsxs("a",{href:l.audioUrl,download:"speech.mp3",className:"inline-flex items-center gap-1 text-xs text-text-muted hover:text-primary transition-colors",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"download"}),"Download"]})}),e.jsx("audio",{controls:!0,src:l.audioUrl,className:"w-full"})]}),l.json&&e.jsx("pre",{className:"text-xs font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[300px] whitespace-pre-wrap break-all",children:l.json})]})]}),e.jsxs(S,{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Usage Logs"}),D.length===0?e.jsx("p",{className:"text-xs text-text-muted italic",children:"No usage yet."}):e.jsx("pre",{className:"text-[11px] font-mono bg-black/[0.03] dark:bg-white/[0.03] p-3 rounded-lg overflow-auto max-h-[400px] whitespace-pre-wrap",children:D.join(`
5
+ `)})]}),e.jsx(ke,{isOpen:Z,onClose:()=>M(!1),onSelect:re,onDeselect:le,activeProviders:te,modelAliases:ae,title:`Add ${W} Model`,kindFilter:r.kind,addedModelValues:m,closeOnSelect:!1})]})}export{Le as default};
@@ -0,0 +1 @@
1
+ import{j as e,P as i,u as d}from"./index.CemlR_k0.js";import{b as l,d as n}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function c(){const[t,r]=l.useState(!1),s=n();return e.jsxs("nav",{className:"fixed top-0 z-50 w-full bg-[#181411]/80 backdrop-blur-md border-b border-[#3a2f27]",children:[e.jsxs("div",{className:"max-w-7xl mx-auto px-6 h-16 flex items-center justify-between",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-3 cursor-pointer bg-transparent border-none p-0",onClick:()=>s("/"),"aria-label":"Navigate to home",children:[e.jsx("img",{src:"/logo_fsrouter.png",alt:"FSRouter v2",className:"size-8 rounded object-cover"}),e.jsx("h2",{className:"text-white text-xl font-bold tracking-tight",children:"FSRouter"})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-8",children:[e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#features",children:"Features"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#how-it-works",children:"How it Works"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Docs"}),e.jsxs("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors flex items-center gap-1",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:["GitHub ",e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"open_in_new"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>s("/dashboard"),className:"hidden sm:flex h-9 items-center justify-center rounded-lg px-4 bg-[#f97815] hover:bg-[#e0650a] transition-all text-[#181411] text-sm font-bold shadow-[0_0_15px_rgba(249,120,21,0.4)] hover:shadow-[0_0_20px_rgba(249,120,21,0.6)]",children:"Get Started"}),e.jsx("button",{className:"md:hidden text-white",onClick:()=>r(!t),children:e.jsx("span",{className:"material-symbols-outlined",children:t?"close":"menu"})})]})]}),t&&e.jsx("div",{className:"md:hidden border-t border-[#3a2f27] bg-[#181411]/95 backdrop-blur-md",children:e.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#features",onClick:()=>r(!1),children:"Features"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"#how-it-works",onClick:()=>r(!1),children:"How it Works"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Docs"}),e.jsx("a",{className:"text-gray-300 hover:text-white text-sm font-medium transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("button",{onClick:()=>s("/dashboard"),className:"h-9 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-sm font-bold",children:"Get Started"})]})})]})}function x(){return e.jsxs("section",{className:"relative pt-32 pb-20 px-6 min-h-[90vh] flex flex-col items-center justify-center overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-[1000px] h-[500px] bg-[#f97815]/10 rounded-full blur-[120px] pointer-events-none"}),e.jsxs("div",{className:"relative z-10 max-w-4xl w-full text-center flex flex-col items-center gap-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-[#3a2f27] bg-[#23180f]/50 px-3 py-1 text-xs font-medium text-[#f97815]",children:[e.jsx("span",{className:"flex h-2 w-2 rounded-full bg-[#f97815] animate-pulse"}),"v1.0 is now live"]}),e.jsxs("h1",{className:"text-5xl md:text-7xl font-black leading-[1.1] tracking-tight",children:["One Endpoint for ",e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:"All AI Providers"})]}),e.jsx("p",{className:"text-lg md:text-xl text-gray-400 max-w-2xl mx-auto font-light",children:"AI endpoint proxy with web dashboard - A JavaScript port of CLIProxyAPI. Works seamlessly with Claude Code, OpenAI Codex, Cline, RooCode, and other CLI tools."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 w-full",children:[e.jsxs("button",{className:"h-12 px-8 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-base font-bold transition-all shadow-[0_0_15px_rgba(249,120,21,0.4)] flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"Get Started"]}),e.jsxs("a",{href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",className:"h-12 px-8 rounded-lg border border-[#3a2f27] bg-[#23180f] hover:bg-[#3a2f27] text-white text-base font-bold transition-all flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined",children:"code"}),"View on GitHub"]})]})]})]})}const m=[{id:"claude",name:"Claude Code",image:"/providers/claude.png"},{id:"codex",name:"OpenAI Codex",image:"/providers/codex.png"},{id:"cline",name:"Cline",image:"/providers/cline.png"},{id:"cursor",name:"Cursor",image:"/providers/cursor.png"}],o=[{id:"openai",name:"OpenAI",color:"bg-emerald-500",textColor:"text-white"},{id:"anthropic",name:"Anthropic",color:"bg-orange-400",textColor:"text-white"},{id:"gemini",name:"Gemini",color:"bg-blue-500",textColor:"text-white"},{id:"github",name:"GitHub Copilot",color:"bg-gray-700",textColor:"text-white"}];function h(){const[t,r]=l.useState(0);return l.useEffect(()=>{const s=setInterval(()=>{r(a=>(a+1)%o.length)},2e3);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"mt-16 w-full max-w-4xl relative h-[360px] hidden md:flex items-center justify-center animate-[float_6s_ease-in-out_infinite]",children:[e.jsxs("div",{className:"relative z-20 w-32 h-32 rounded-full bg-[#23180f] border-2 border-[#f97815] shadow-[0_0_40px_rgba(249,120,21,0.3)] flex flex-col items-center justify-center gap-1 group cursor-pointer hover:scale-105 transition-transform duration-500",children:[e.jsx("span",{className:"material-symbols-outlined text-4xl text-[#f97815]",children:"hub"}),e.jsx("span",{className:"text-xs font-bold text-white tracking-widest uppercase",children:"FSRouter"}),e.jsx("div",{className:"absolute inset-0 rounded-full border border-[#f97815]/30 animate-ping opacity-20"})]}),e.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 flex flex-col gap-7",children:m.map(s=>e.jsx("div",{className:"flex items-center gap-3 opacity-70 hover:opacity-100 transition-opacity group",children:e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[#23180f] border border-[#3a2f27] flex items-center justify-center overflow-hidden p-2 hover:border-[#f97815]/50 transition-all hover:scale-105",children:e.jsx(i,{src:s.image,alt:s.name,size:48,className:"object-contain rounded-xl max-w-[48px] max-h-[48px]",fallbackText:s.name.slice(0,2).toUpperCase()})})},s.id))}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full z-10 pointer-events-none stroke-yellow-700",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 50 C 250 70, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 140 C 250 140, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 210 C 250 210, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"}),e.jsx("path",{className:"animate-[dash_2s_linear_infinite]",d:"M 60 300 C 250 280, 250 180, 360 180",fill:"none",strokeDasharray:"5,5",strokeWidth:"2"})]}),e.jsxs("svg",{className:"absolute inset-0 w-full h-full z-10 pointer-events-none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M 440 180 C 550 180, 550 50, 740 50",fill:"none",stroke:t===0?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===0?"3":"2",className:t===0?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 130, 740 130",fill:"none",stroke:t===1?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===1?"3":"2",className:t===1?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 230, 740 230",fill:"none",stroke:t===2?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===2?"3":"2",className:t===2?"animate-pulse":""}),e.jsx("path",{d:"M 440 180 C 550 180, 550 310, 740 310",fill:"none",stroke:t===3?"#f97815":"rgb(75, 85, 99)",strokeWidth:t===3?"3":"2",className:t===3?"animate-pulse":""})]}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex flex-col justify-between py-6",children:o.map((s,a)=>e.jsx("div",{className:`px-4 py-2 rounded-lg ${s.color} ${s.textColor} flex items-center justify-center font-bold text-xs shadow-lg hover:scale-110 transition-all cursor-help min-w-[140px] ${t===a?"ring-4 ring-[#f97815]/50 scale-110":""}`,title:s.name,children:s.name},s.id))}),e.jsx("div",{className:"md:hidden mt-8 w-full p-4 rounded-lg bg-[#23180f] border border-[#3a2f27]",children:e.jsx("p",{className:"text-sm text-center text-gray-400",children:"Interactive diagram visible on desktop"})})]})}function u(){return e.jsx("section",{className:"py-24 border-y border-[#3a2f27] bg-[#23180f]/30",id:"how-it-works",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"How FSRouter Works"}),e.jsx("p",{className:"text-gray-400 max-w-xl text-lg",children:"Data flows seamlessly from your application through our intelligent routing layer to the best provider for the job."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 relative",children:[e.jsx("div",{className:"hidden md:block absolute top-12 left-[16%] right-[16%] h-[2px] bg-linear-to-r from-gray-700 via-[#f97815] to-gray-700 -z-10"}),e.jsxs("div",{className:"flex flex-col gap-6 relative group",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border border-[#3a2f27] flex items-center justify-center shadow-xl group-hover:border-gray-500 transition-colors z-10 mx-auto md:mx-0",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-gray-300",children:"terminal"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2",children:"1. CLI & SDKs"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Your requests start from your favorite tools or our unified SDK. Just change the base URL."})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 relative group md:items-center md:text-center",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border-2 border-[#f97815] flex items-center justify-center shadow-[0_0_30px_rgba(249,120,21,0.2)] z-10 mx-auto",children:e.jsx("span",{className:"material-symbols-outlined text-4xl text-[#f97815] animate-pulse",children:"hub"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2 text-[#f97815]",children:"2. FSRouter Hub"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Our engine analyzes the prompt, checks provider health, and routes for lowest latency or cost."})]})]}),e.jsxs("div",{className:"flex flex-col gap-6 relative group md:items-end md:text-right",children:[e.jsx("div",{className:"w-24 h-24 rounded-2xl bg-[#181411] border border-[#3a2f27] flex items-center justify-center shadow-xl group-hover:border-gray-500 transition-colors z-10 mx-auto md:mx-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"}),e.jsx("div",{className:"w-6 h-6 rounded bg-white/10"})]})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold mb-2",children:"3. AI Providers"}),e.jsx("p",{className:"text-sm text-gray-400",children:"The request is fulfilled by OpenAI, Anthropic, Gemini, or others instantly."})]})]})]})]})})}const f=[{icon:"link",title:"Unified Endpoint",desc:"Access all providers via a single standard API URL.",colors:{border:"hover:border-blue-500/50",bg:"hover:bg-blue-500/5",iconBg:"bg-blue-500/10",iconText:"text-blue-500",titleHover:"group-hover:text-blue-400"}},{icon:"bolt",title:"Easy Setup",desc:"Get up and running in minutes with npx command.",colors:{border:"hover:border-orange-500/50",bg:"hover:bg-orange-500/5",iconBg:"bg-orange-500/10",iconText:"text-orange-500",titleHover:"group-hover:text-orange-400"}},{icon:"shield_with_heart",title:"Model Fallback",desc:"Automatically switch providers on failure or high latency.",colors:{border:"hover:border-rose-500/50",bg:"hover:bg-rose-500/5",iconBg:"bg-rose-500/10",iconText:"text-rose-500",titleHover:"group-hover:text-rose-400"}},{icon:"monitoring",title:"Usage Tracking",desc:"Detailed analytics and cost monitoring across all models.",colors:{border:"hover:border-purple-500/50",bg:"hover:bg-purple-500/5",iconBg:"bg-purple-500/10",iconText:"text-purple-500",titleHover:"group-hover:text-purple-400"}},{icon:"key",title:"OAuth & API Keys",desc:"Securely manage credentials in one vault.",colors:{border:"hover:border-amber-500/50",bg:"hover:bg-amber-500/5",iconBg:"bg-amber-500/10",iconText:"text-amber-500",titleHover:"group-hover:text-amber-400"}},{icon:"cloud_sync",title:"Cloud Sync",desc:"Sync your configurations across devices instantly.",colors:{border:"hover:border-sky-500/50",bg:"hover:bg-sky-500/5",iconBg:"bg-sky-500/10",iconText:"text-sky-500",titleHover:"group-hover:text-sky-400"}},{icon:"terminal",title:"CLI Support",desc:"Works with Claude Code, Codex, Cline, Cursor, and more.",colors:{border:"hover:border-emerald-500/50",bg:"hover:bg-emerald-500/5",iconBg:"bg-emerald-500/10",iconText:"text-emerald-500",titleHover:"group-hover:text-emerald-400"}},{icon:"dashboard",title:"Dashboard",desc:"Visual dashboard for real-time traffic analysis.",colors:{border:"hover:border-fuchsia-500/50",bg:"hover:bg-fuchsia-500/5",iconBg:"bg-fuchsia-500/10",iconText:"text-fuchsia-500",titleHover:"group-hover:text-fuchsia-400"}}];function g(){return e.jsx("section",{className:"py-24 px-6",id:"features",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4",children:"Powerful Features"}),e.jsx("p",{className:"text-gray-400 max-w-xl text-lg",children:"Everything you need to manage your AI infrastructure in one place, built for scale."})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:f.map(t=>e.jsxs("div",{className:`p-6 rounded-xl bg-[#23180f] border border-[#3a2f27] ${t.colors.border} ${t.colors.bg} transition-all duration-300 group`,children:[e.jsx("div",{className:`w-10 h-10 rounded-lg ${t.colors.iconBg} flex items-center justify-center mb-4 ${t.colors.iconText} group-hover:scale-110 transition-transform duration-300`,children:e.jsx("span",{className:"material-symbols-outlined",children:t.icon})}),e.jsx("h3",{className:`text-lg font-bold mb-2 ${t.colors.titleHover} transition-colors`,children:t.title}),e.jsx("p",{className:"text-sm text-gray-400 leading-relaxed",children:t.desc})]},t.title))})]})})}function b(){const{copied:t,copy:r}=d(),s=a=>{r(a,"landing")};return e.jsx("section",{className:"py-24 px-6 bg-[#120f0d]",children:e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-16 items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-6",children:"Get Started in 30 Seconds"}),e.jsx("p",{className:"text-gray-400 text-lg mb-8",children:"Install FSRouter, configure your providers via web dashboard, and start routing AI requests."}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Install FSRouter"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Run npx command to start the server instantly"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Open Dashboard"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Configure providers and API keys via web interface"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"flex-none w-8 h-8 rounded-full bg-[#f97815]/20 text-[#f97815] flex items-center justify-center font-bold",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-lg",children:"Route Requests"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Point your CLI tools to http://localhost:20128"})]})]})]})]}),e.jsx("div",{className:"flex-1 w-full",children:e.jsxs("div",{className:"rounded-xl overflow-hidden bg-[#1e1e1e] border border-[#3a2f27] shadow-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 bg-[#252526] border-b border-gray-700",children:[e.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),e.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"}),e.jsx("div",{className:"ml-2 text-xs text-gray-500 font-mono",children:"terminal"})]}),e.jsxs("div",{className:"p-6 font-mono text-sm leading-relaxed overflow-x-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 group cursor-pointer",onClick:()=>s("npx fsrouter"),children:[e.jsx("span",{className:"text-green-400",children:"$"}),e.jsx("span",{className:"text-white",children:"npx fsrouter"}),e.jsx("span",{className:"ml-auto text-gray-500 text-xs opacity-0 group-hover:opacity-100",children:t==="landing"?"✓ Copied":"Copy"})]}),e.jsxs("div",{className:"text-gray-400 mb-6",children:[e.jsx("span",{className:"text-[#f97815]",children:">"})," Starting FSRouter...",e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:">"})," Server running on ",e.jsx("span",{className:"text-blue-400",children:"http://localhost:20128"}),e.jsx("br",{}),e.jsx("span",{className:"text-[#f97815]",children:">"})," Dashboard: ",e.jsx("span",{className:"text-blue-400",children:"http://localhost:20128/dashboard"}),e.jsx("br",{}),e.jsx("span",{className:"text-green-400",children:">"})," Ready to route! ✓"]}),e.jsx("div",{className:"text-xs text-gray-500 mb-2 border-t border-gray-700 pt-4",children:"📝 Configure providers in dashboard or use environment variables"}),e.jsxs("div",{className:"text-gray-400 text-xs",children:[e.jsx("span",{className:"text-purple-400",children:"Data Location:"}),e.jsx("br",{}),e.jsx("span",{className:"text-gray-500",children:" macOS/Linux:"})," ~/.fsrouter/db/data.sqlite",e.jsx("br",{}),e.jsx("span",{className:"text-gray-500",children:" Windows:"})," %APPDATA%/fsrouter/db/data.sqlite"]})]})]})})]})})})}function p(){return e.jsx("footer",{className:"border-t border-[#3a2f27] bg-[#120f0d] pt-16 pb-8 px-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-8 mb-16",children:[e.jsxs("div",{className:"col-span-2 lg:col-span-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"size-6 rounded bg-[#f97815] flex items-center justify-center text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hub"})}),e.jsx("h3",{className:"text-white text-lg font-bold",children:"FSRouter"})]}),e.jsx("p",{className:"text-gray-500 text-sm max-w-xs mb-6",children:"The unified endpoint for AI generation. Connect, route, and manage your AI providers with ease."}),e.jsx("div",{className:"flex gap-4",children:e.jsx("a",{className:"text-gray-400 hover:text-white transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:e.jsx("span",{className:"material-symbols-outlined",children:"code"})})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Product"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"#features",children:"Features"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"/dashboard",children:"Dashboard"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"Changelog"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Resources"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter#readme",target:"_blank",rel:"noopener noreferrer",children:"Documentation"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://www.npmjs.com/package/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"NPM"})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Legal"}),e.jsx("a",{className:"text-gray-400 hover:text-[#f97815] text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:"MIT License"})]})]}),e.jsxs("div",{className:"border-t border-[#3a2f27] pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[e.jsx("p",{className:"text-gray-600 text-sm",children:"© 2025 FSRouter. All rights reserved."}),e.jsxs("div",{className:"flex gap-6",children:[e.jsx("a",{className:"text-gray-600 hover:text-white text-sm transition-colors",href:"https://github.com/nexusrouters/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"GitHub"}),e.jsx("a",{className:"text-gray-600 hover:text-white text-sm transition-colors",href:"https://www.npmjs.com/package/fsrouter",target:"_blank",rel:"noopener noreferrer",children:"NPM"})]})]})]})})}function w(){const t=n();return e.jsxs("div",{className:"relative text-white font-sans overflow-x-hidden antialiased selection:bg-[#f97815] selection:text-white",children:[e.jsxs("div",{className:"fixed inset-0 z-0 overflow-hidden pointer-events-none bg-[#181411]",children:[e.jsx("div",{className:"absolute inset-0 opacity-[0.06]",style:{backgroundImage:"linear-gradient(to right, #f97815 1px, transparent 1px), linear-gradient(to bottom, #f97815 1px, transparent 1px)",backgroundSize:"50px 50px"}}),e.jsx("div",{className:"absolute top-0 left-1/4 w-[700px] h-[700px] bg-[#f97815]/12 rounded-full blur-[130px] animate-blob"}),e.jsx("div",{className:"absolute top-1/3 right-1/4 w-[600px] h-[600px] bg-purple-500/10 rounded-full blur-[130px] animate-blob",style:{animationDelay:"2s",animationDuration:"22s"}}),e.jsx("div",{className:"absolute bottom-0 left-1/2 w-[650px] h-[650px] bg-blue-500/8 rounded-full blur-[130px] animate-blob",style:{animationDelay:"4s",animationDuration:"25s"}}),e.jsx("div",{className:"absolute inset-0",style:{background:"radial-gradient(circle at center, transparent 0%, rgba(24, 20, 17, 0.4) 100%)"}})]}),e.jsxs("div",{className:"relative z-10",children:[e.jsx(c,{}),e.jsxs("main",{children:[e.jsxs("div",{className:"relative",children:[e.jsx(x,{}),e.jsx("div",{className:"flex justify-center pb-20",children:e.jsx(h,{})})]}),e.jsx(b,{}),e.jsx(u,{}),e.jsx(g,{}),e.jsxs("section",{className:"py-32 px-6 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-linear-to-t from-[#f97815]/5 to-transparent pointer-events-none"}),e.jsxs("div",{className:"max-w-4xl mx-auto text-center relative z-10",children:[e.jsx("h2",{className:"text-4xl md:text-5xl font-black mb-6",children:"Ready to Simplify Your AI Infrastructure?"}),e.jsx("p",{className:"text-xl text-gray-400 mb-10 max-w-2xl mx-auto",children:"Join developers who are streamlining their AI integrations with FSRouter. Open source and free to start."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsx("button",{onClick:()=>t("/dashboard"),className:"w-full sm:w-auto h-14 px-10 rounded-lg bg-[#f97815] hover:bg-[#e0650a] text-[#181411] text-lg font-bold transition-all shadow-[0_0_20px_rgba(249,120,21,0.5)]",children:"Start Free"}),e.jsx("button",{onClick:()=>window.open("https://github.com/nexusrouters/fsrouter#readme","_blank"),className:"w-full sm:w-auto h-14 px-10 rounded-lg border border-[#3a2f27] hover:bg-[#23180f] text-white text-lg font-bold transition-all",children:"Read Documentation"})]})]})]})]}),e.jsx(p,{})]})]})}export{w as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.CemlR_k0.js";import"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function i(){return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center size-8 rounded-lg bg-primary/10",children:e.jsx("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"menu_book"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-semibold text-text-main",children:"API Reference"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Image & Video Generation — all providers, models, and parameters"})]})]}),e.jsxs("a",{href:"/image-video-docs.html",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-text-muted hover:text-text-main hover:bg-surface-2 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"open_in_new"}),"Open in new tab"]})]}),e.jsx("iframe",{src:"/image-video-docs.html",className:"flex-1 w-full border-0 min-h-0",title:"Image & Video API Reference"})]})}export{i as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.1VBQU7rF.js","assets/router.Cjj1--8t.js"])))=>i.map(i=>d[i]);
2
+ import{u as z,j as t,B as c,_ as F}from"./index.CemlR_k0.js";import{b as x}from"./router.Cjj1--8t.js";import{C as $}from"./NoAuthProxyCard.C8gs3p9D.js";import"./zustand.akaTi5uX.js";const B=x.lazy(()=>F(()=>import("./index.1VBQU7rF.js"),__vite__mapDeps([0,1]))),v=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],I={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function W(){const[i,h]=x.useState({}),[g,u]=x.useState({1:!0}),[p,S]=x.useState({}),[o,w]=x.useState(null),l=(e,s)=>S(a=>({...a,[e]:s})),d=(e,s)=>h(a=>({...a,[e]:s})),O=e=>u(s=>({...s,[e]:!s[e]})),j=e=>u(s=>{const a={};return v.forEach(n=>{a[n.id]=!1}),a[e]=!0,a}),_=async e=>{const s=v.find(a=>a.id===e);l(`load-${e}`,!0);try{const n=await(await fetch(`/api/translator/load?file=${s.file}`)).json();n.success?(d(e,n.content),e===1&&await N(n.content)):alert(n.error||"File not found")}catch(a){alert(a.message)}l(`load-${e}`,!1)},N=async e=>{try{const s=typeof e=="string"?JSON.parse(e):e,n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:s})})).json();n.success&&w(n.result)}catch{}},f=(e,s)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:s})}).catch(()=>{}),T=async()=>{l("toOpenAI",!0);try{const e=i[1],s=JSON.parse(e);f("1_req_client.json",e),f("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:s.body||s},null,2));const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:s})})).json();if(!n.success){alert(n.error);return}const r=JSON.stringify(n.result.body,null,2);d(3,r),j(3)}catch(e){alert(e.message)}l("toOpenAI",!1)},C=async()=>{l("toTarget",!0);try{const e=i[3],s=JSON.parse(e);f("3_req_openai.json",e);const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...s,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model}})})).json();if(!n.success){alert(n.error);return}const r={...n.result,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model};d(4,JSON.stringify(r,null,2)),j(4)}catch(e){alert(e.message)}l("toTarget",!1)},J=async()=>{l("send",!0);try{const e=i[4],s=JSON.parse(e);f("4_req_target.json",e);const a=s.provider||(o==null?void 0:o.provider),n=s.model||(o==null?void 0:o.model);if(!a||!n){alert("Missing provider or model. Please run step 1 first to detect them.");return}const r=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,model:n,body:s.body||s})});if(!r.ok){const b=await r.json().catch(()=>({error:r.statusText}));alert(b.error||"Send failed");return}const E=r.body.getReader(),A=new TextDecoder;let y="";for(;;){const{done:b,value:L}=await E.read();if(b)break;y+=A.decode(L,{stream:!0})}d(5,y),j(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:y})})}catch(e){alert(e.message)}finally{l("send",!1)}},{copy:P}=z(),R=async e=>{i[e]&&P(i[e],`translator-step-${e}`)},k=e=>{try{const s=JSON.parse(i[e]);d(e,JSON.stringify(s,null,2))}catch{}},q=e=>e===1?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toOpenAI,onClick:T,children:"→ OpenAI"}):e===3?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toTarget,onClick:C,children:"→ Target"}):e===4?t.jsx(c,{size:"sm",icon:"send",loading:p.send,onClick:J,children:"Send"}):null;return t.jsxs("div",{className:"p-8 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),t.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),o&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[t.jsx(m,{label:"src",value:o.sourceFormat,color:"blue"}),t.jsx("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),t.jsx(m,{label:"dst",value:o.targetFormat,color:"orange"}),t.jsx(m,{label:"provider",value:o.provider,color:"green"}),t.jsx(m,{label:"model",value:o.model,color:"purple"})]})]}),v.map(e=>{const s=q(e.id),a=!!g[e.id],n=i[e.id]||"";return t.jsx($,{children:t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{onClick:()=>O(e.id),className:"flex items-center gap-2 flex-1 text-left group",children:[t.jsx("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:a?"expand_more":"chevron_right"}),t.jsx("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:e.id}),t.jsx("h3",{className:"text-sm font-semibold text-text-main",children:e.label}),t.jsx("span",{className:"text-xs text-text-muted/60 font-mono",children:e.file}),n&&t.jsxs("span",{className:"text-xs text-green-500",children:["(",n.length," chars)"]})]}),!a&&t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(c,{size:"sm",variant:"ghost",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id)}),s]})]}),a&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border border-border rounded-lg overflow-hidden",children:t.jsx(B,{height:"400px",defaultLanguage:e.lang==="text"?"plaintext":"json",value:n,onChange:r=>{d(e.id,r||""),e.id===1&&N(r||"")},theme:"vs-dark",options:I})}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(c,{size:"sm",variant:"outline",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id),children:"Load"}),t.jsx(c,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>k(e.id),children:"Format"}),t.jsx(c,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>R(e.id),children:"Copy"}),s]})]})]})},e.id)})]})}function m({label:i,value:h,color:g}){const u={blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"};return t.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${u[g]}`,children:[t.jsxs("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[i,":"]}),h]})}export{W as default};
@@ -0,0 +1,6 @@
1
+ import{j as e}from"./index.CemlR_k0.js";import{b as l}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function b({value:r,label:d="Copy"}){const[t,i]=l.useState(!1),a=async()=>{if(r)try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),1500)}catch{const n=document.createElement("textarea");n.value=r,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n),i(!0),setTimeout(()=>i(!1),1500)}};return e.jsx("button",{onClick:a,disabled:!r,title:r?r.slice(0,60)+(r.length>60?"…":""):"Tidak tersedia",style:{padding:"2px 10px",fontSize:11,borderRadius:4,border:"1px solid",cursor:r?"pointer":"not-allowed",borderColor:t?"#22c55e":r?"#6366f1":"#374151",background:t?"#166534":r?"#1e1b4b":"#111827",color:t?"#86efac":r?"#a5b4fc":"#4b5563",transition:"all 0.15s",whiteSpace:"nowrap",minWidth:60},children:t?"✓ Copied!":d})}function y({value:r,maxLen:d=22}){const[t,i]=l.useState(!1);if(!r)return e.jsx("span",{style:{color:"#6b7280",fontSize:12},children:"—"});const a=t?r:r.slice(0,d)+"…";return e.jsxs("span",{style:{fontFamily:"monospace",fontSize:11,color:"#d1d5db"},children:[a,e.jsx("button",{onClick:()=>i(n=>!n),style:{marginLeft:4,fontSize:10,color:"#6366f1",background:"none",border:"none",cursor:"pointer"},children:t?"hide":"show"})]})}function w(r){const d=r.map(s=>({email:s.email,firebase_refresh_token:s.firebaseRefreshToken,firebase_api_key:s.firebaseApiKey,jwt:s.jwt,jwt_expires_at:s.jwtExpiresAt,balance:s.balance})),t=JSON.stringify(d,null,2),i=new Blob([t],{type:"application/json"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-tokens-${Date.now()}.json`,n.click(),URL.revokeObjectURL(a)}function S(r){const t=`email,firebase_refresh_token,firebase_api_key
2
+ `+r.filter(s=>s.firebaseRefreshToken&&s.firebaseApiKey).map(s=>`${s.email},${s.firebaseRefreshToken},${s.firebaseApiKey}`).join(`
3
+ `),i=new Blob([t],{type:"text/csv"}),a=URL.createObjectURL(i),n=document.createElement("a");n.href=a,n.download=`weavy-refresh-tokens-${Date.now()}.csv`,n.click(),URL.revokeObjectURL(a)}function C(){const[r,d]=l.useState([]),[t,i]=l.useState(null),[a,n]=l.useState(!0),[s,g]=l.useState(""),[x,m]=l.useState(""),[p,j]=l.useState("all"),h=l.useCallback(async()=>{n(!0),g("");try{const c=await(await fetch("/api/providers/weavy/pool")).json();if(!c.ok)throw new Error(c.error||"Failed");d(c.pool||[]),i(c.stats||null)}catch(o){g(o.message)}finally{n(!1)}},[]);l.useEffect(()=>{h()},[h]);const u=r.filter(o=>{const c=!x||o.email.toLowerCase().includes(x.toLowerCase()),k=p==="all"?!0:p==="hasToken"?!!o.firebaseRefreshToken:p==="noToken"?!o.firebaseRefreshToken:p==="validJwt"?o.jwtValid:!0;return c&&k}),v={background:"#111827",border:"1px solid #1f2937",borderRadius:8,padding:"10px 14px",marginBottom:8},f=(o,c,k="#6366f1")=>e.jsxs("div",{style:{background:"#0f172a",borderRadius:8,padding:"12px 20px",border:"1px solid #1f2937",textAlign:"center",minWidth:100},children:[e.jsx("div",{style:{fontSize:28,fontWeight:700,color:k},children:c}),e.jsx("div",{style:{fontSize:11,color:"#9ca3af",marginTop:2},children:o})]});return e.jsxs("div",{style:{minHeight:"100vh",background:"#030712",color:"#e5e7eb",padding:"24px 32px",fontFamily:"Inter, sans-serif"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{margin:0,fontSize:22,fontWeight:700,color:"#f9fafb"},children:"🪄 Weavy Token Pool"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#6b7280"},children:"Copy firebase_refresh_token + firebase_api_key ke kliperspro atau sistem lain"})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:h,style:{padding:"6px 14px",borderRadius:6,background:"#1f2937",border:"1px solid #374151",color:"#d1d5db",cursor:"pointer",fontSize:13},children:"↻ Refresh"}),e.jsx("button",{onClick:()=>S(r),style:{padding:"6px 14px",borderRadius:6,background:"#1e1b4b",border:"1px solid #4338ca",color:"#a5b4fc",cursor:"pointer",fontSize:13},children:"⬇ Export CSV"}),e.jsx("button",{onClick:()=>w(r),style:{padding:"6px 14px",borderRadius:6,background:"#14532d",border:"1px solid #166534",color:"#86efac",cursor:"pointer",fontSize:13},children:"⬇ Export JSON"})]})]}),t&&e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:24,flexWrap:"wrap"},children:[f("Total Akun",t.total,"#e5e7eb"),f("Aktif",t.active,"#22c55e"),f("JWT Valid",t.jwtValid,"#6366f1"),f("Punya Refresh Token",t.hasRefreshToken,"#f59e0b")]}),t&&t.hasRefreshToken===0&&e.jsxs("div",{style:{background:"#431407",border:"1px solid #7c2d12",borderRadius:8,padding:"12px 16px",marginBottom:20,fontSize:13,color:"#fed7aa"},children:["⚠️ ",e.jsx("strong",{children:"firebase_refresh_token masih kosong"})," untuk semua akun. Jalankan ulang signup untuk akun-akun ini agar refresh token tertangkap dari IndexedDB."]}),e.jsxs("div",{style:{background:"#0c1a2e",border:"1px solid #1e3a5f",borderRadius:8,padding:"12px 16px",marginBottom:20,fontSize:12},children:[e.jsx("strong",{style:{color:"#60a5fa"},children:"📋 Cara pakai di kliperspro (production):"}),e.jsx("pre",{style:{margin:"8px 0 0",color:"#93c5fd",fontSize:11,overflow:"auto"},children:`POST https://securetoken.googleapis.com/v1/token?key=<firebase_api_key>
4
+ Body: grant_type=refresh_token&refresh_token=<firebase_refresh_token>
5
+ → Response: { id_token: "<JWT baru>", refresh_token: "<update ini>" }
6
+ → Gunakan id_token sebagai: Authorization: Bearer <JWT>`})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[e.jsx("input",{value:x,onChange:o=>m(o.target.value),placeholder:"Cari email…",style:{flex:1,minWidth:200,background:"#111827",border:"1px solid #374151",borderRadius:6,padding:"6px 12px",color:"#e5e7eb",fontSize:13}}),["all","hasToken","noToken","validJwt"].map(o=>e.jsx("button",{onClick:()=>j(o),style:{padding:"6px 12px",borderRadius:6,fontSize:12,cursor:"pointer",border:"1px solid",borderColor:p===o?"#6366f1":"#374151",background:p===o?"#1e1b4b":"#111827",color:p===o?"#a5b4fc":"#9ca3af"},children:{all:"Semua",hasToken:"✅ Punya Token",noToken:"❌ Tanpa Token",validJwt:"🔑 JWT Valid"}[o]},o))]}),a?e.jsx("div",{style:{textAlign:"center",color:"#6b7280",padding:40},children:"Memuat…"}):s?e.jsxs("div",{style:{color:"#f87171",padding:20},children:["Error: ",s]}):e.jsxs("div",{children:[e.jsxs("div",{style:{color:"#6b7280",fontSize:12,marginBottom:8},children:["Menampilkan ",u.length," dari ",r.length," akun"]}),u.map(o=>e.jsxs("div",{style:{...v,opacity:o.isActive?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:13,minWidth:220,color:o.isActive?"#f9fafb":"#6b7280"},children:o.email}),e.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:4,fontWeight:600,background:o.jwtValid?"#14532d":"#7f1d1d",color:o.jwtValid?"#86efac":"#fca5a5"},children:o.jwtValid?`JWT valid ${Math.ceil(o.jwtSecondsLeft/60)}m`:"JWT expired"}),e.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:4,fontWeight:600,background:o.firebaseRefreshToken?"#1c1917":"#1f2937",color:o.firebaseRefreshToken?"#fbbf24":"#4b5563"},children:o.firebaseRefreshToken?"🔑 refresh_token ✓":"❌ no refresh_token"}),e.jsxs("span",{style:{fontSize:11,color:"#6b7280"},children:["💰 ",o.balance," credits"]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(b,{value:o.firebaseRefreshToken,label:"Copy refresh_token"}),e.jsx(b,{value:o.firebaseApiKey,label:"Copy api_key"}),e.jsx(b,{value:o.jwt,label:"Copy JWT"}),e.jsx(b,{value:o.firebaseRefreshToken&&o.firebaseApiKey?JSON.stringify({email:o.email,firebase_refresh_token:o.firebaseRefreshToken,firebase_api_key:o.firebaseApiKey},null,2):"",label:"Copy All"})]})]}),e.jsxs("div",{style:{marginTop:6,display:"flex",gap:16,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"#9ca3af"},children:"refresh_token: "}),e.jsx(y,{value:o.firebaseRefreshToken})]}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"#9ca3af"},children:"api_key: "}),e.jsx(y,{value:o.firebaseApiKey,maxLen:16})]}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,color:"#9ca3af"},children:"JWT: "}),e.jsx(y,{value:o.jwt})]})]})]},o.id)),u.length===0&&e.jsx("div",{style:{textAlign:"center",color:"#6b7280",padding:40},children:"Tidak ada akun ditemukan"})]})]})}export{C as default};
@@ -0,0 +1 @@
1
+ import{N as B,K as I,j as e,B as E,g as A,P as z}from"./index.CemlR_k0.js";import{h as _,d as M,b,L as T}from"./router.Cjj1--8t.js";import{A as R,C as D,B as j,T as K}from"./NoAuthProxyCard.C8gs3p9D.js";import"./zustand.akaTi5uX.js";const F=new Set([]),L={image:"image-combo",tts:"tts-combo"};function P(s){const o=Object.entries(s).some(([i,d])=>i.startsWith("modelLock_")&&d&&new Date(d).getTime()>Date.now());return s.testStatus==="unavailable"&&!o?"active":s.testStatus}function $({provider:s,kind:o,connections:i,isCustom:d,onToggle:l}){var C;const n=A[s.id],y=!!(n!=null&&n.noAuth),p=i.filter(a=>a.provider===s.id),v=p.filter(a=>{const x=P(a);return x==="active"||x==="success"}).length,h=p.filter(a=>{const x=P(a);return x==="error"||x==="expired"||x==="unavailable"}).length,m=p.length,r=m>0&&p.every(a=>a.isActive===!1),u=a=>{a.preventDefault(),a.stopPropagation(),l&&l(s.id,r)},k=()=>y?e.jsx(j,{variant:"success",size:"sm",children:"Ready"}):r?e.jsx(j,{variant:"default",size:"sm",children:"Disabled"}):m===0?e.jsx("span",{className:"text-xs text-text-muted",children:"No connections"}):e.jsxs(e.Fragment,{children:[v>0&&e.jsxs(j,{variant:"success",size:"sm",dot:!0,children:[v," Connected"]}),h>0&&e.jsxs(j,{variant:"error",size:"sm",dot:!0,children:[h," Error"]}),v===0&&h===0&&e.jsxs(j,{variant:"default",size:"sm",children:[m," Added"]})]});return e.jsx(T,{to:`/dashboard/media-providers/${o}/${s.id}`,className:"group",children:e.jsx(D,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${r?"opacity-50":""}`,children:e.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"size-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${((C=s.color)==null?void 0:C.length)>7?s.color:(s.color??"#888")+"15"}`},children:e.jsx(z,{src:`/providers/${s.id}.png`,alt:s.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:s.textIcon||s.id.slice(0,2).toUpperCase(),fallbackColor:s.color})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[d&&e.jsx(j,{variant:"default",size:"sm",children:"Custom"}),k()]})]})]}),m>0&&e.jsx("div",{className:"shrink-0 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100",onClick:u,children:e.jsx(K,{size:"sm",checked:!r,onChange:()=>{},title:r?"Enable provider":"Disable provider"})})]})})})}function U({combos:s}){return s.length===0?null:e.jsx("div",{className:"flex flex-col gap-2",children:s.map(o=>e.jsx(T,{to:`/dashboard/media-providers/combo/${o.id}`,children:e.jsx(D,{padding:"xs",className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors cursor-pointer",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"}),e.jsx("code",{className:"text-sm font-mono font-medium flex-1 truncate",children:o.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:shrink-0",children:[o.models.slice(0,6).map((i,d)=>{const l=typeof i=="string"?i.split("/")[0]:"",n=A[l];return e.jsx("div",{title:(n==null?void 0:n.name)||i,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${(n==null?void 0:n.color)??"#888"}15`},children:e.jsx(z,{src:`/providers/${l}.png`,alt:(n==null?void 0:n.name)||l,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:(n==null?void 0:n.textIcon)||l.slice(0,2).toUpperCase(),fallbackColor:n==null?void 0:n.color})},`${i}-${d}`)}),o.models.length>6&&e.jsxs("span",{className:"text-[10px] text-text-muted ml-1",children:["+",o.models.length-6]})]}),e.jsx("span",{className:"text-[11px] text-text-muted shrink-0",children:o.models.length}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},o.id))})}function G(){const{kind:s}=_(),o=M(),[i,d]=b.useState([]),[l,n]=b.useState([]),[y,p]=b.useState([]),[v,h]=b.useState(!1);b.useEffect(()=>{(s==="webSearch"||s==="webFetch")&&o("/dashboard/media-providers/web")},[s,o]);const m=B.find(t=>t.id===s),r=s==="embedding",u=F.has(s);if(b.useEffect(()=>{m&&(fetch("/api/providers",{cache:"no-store"}).then(t=>t.json()).then(t=>d(t.connections||[])).catch(()=>{}),r&&fetch("/api/provider-nodes",{cache:"no-store"}).then(t=>t.json()).then(t=>n((t.nodes||[]).filter(c=>c.type==="custom-embedding"))).catch(()=>{}),u&&fetch("/api/combos",{cache:"no-store"}).then(t=>t.json()).then(t=>p(t.combos||[])).catch(()=>{}))},[r,u,m]),!m)return null;const k=I(s),C=y.filter(t=>t.kind===s),a=l.map(t=>({id:t.id,name:t.name||"Custom Embedding",color:"#6366F1",textIcon:"CE"})),x=[...k,...a],S=async(t,c)=>{const w=i.filter(f=>f.provider===t);d(f=>f.map(g=>g.provider===t?{...g,isActive:c}:g)),await Promise.allSettled(w.map(f=>fetch(`/api/providers/${f.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:c})})))},O=async()=>{const t=L[s]||`${s}-combo`;let c=t,w=1;const f=new Set(y.map(N=>N.name));for(;f.has(c);)c=`${t}-${w++}`;const g=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c,models:[],kind:s})});if(g.ok){const N=await g.json();o(`/dashboard/media-providers/combo/${N.id}`)}else{const N=await g.json();alert(N.error||"Failed to create combo")}};return e.jsxs("div",{className:"flex flex-col gap-6",children:[(r||u)&&e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[u&&e.jsx(E,{size:"sm",icon:"add",onClick:O,children:"Create Combo"}),r&&e.jsx(E,{size:"sm",icon:"add",onClick:()=>h(!0),children:"Add Custom Embedding"})]}),u&&C.length>0&&e.jsx(U,{combos:C}),x.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed border-border rounded-xl text-text-muted text-sm",children:["No providers support ",e.jsx("strong",{children:m.label})," yet."]}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[k.map(t=>e.jsx($,{provider:t,kind:s,connections:i,onToggle:S},t.id)),a.map(t=>e.jsx($,{provider:t,kind:s,connections:i,isCustom:!0,onToggle:S},t.id))]}),r&&e.jsx(R,{isOpen:v,onClose:()=>h(!1),onCreated:t=>{n(c=>[...c,t]),h(!1)}})]})}export{G as default};