@fudrouter/fsrouter 0.6.73 → 0.6.75

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 (52) hide show
  1. package/dist/lib/headroom/detect.js +97 -7
  2. package/dist/lib/headroom/process.js +136 -4
  3. package/dist/routes/headroom/extras/route.js +58 -0
  4. package/dist/routes/headroom/restart/route.js +33 -0
  5. package/package.json +1 -1
  6. package/public/assets/EndpointPageClient.BnlQVTIB.js +6 -0
  7. package/public/assets/{Loading.Bj-WGl4k.js → Loading.C1il44u0.js} +1 -1
  8. package/public/assets/{NoAuthProxyCard.qAv57b-0.js → NoAuthProxyCard.WHGGEUIp.js} +1 -1
  9. package/public/assets/index.COMgQZYj.css +1 -0
  10. package/public/assets/index.D4FwOBBU.js +89 -0
  11. package/public/assets/{page.Qkkv8roc.js → page.0Rt4rWPG.js} +1 -1
  12. package/public/assets/{page.Dx_GRRdT.js → page.1numFcXc.js} +1 -1
  13. package/public/assets/{page.vla5Mzki.js → page.1w9bTOPd.js} +1 -1
  14. package/public/assets/{page.CzlQTyAL.js → page.3ARdH6tE.js} +1 -1
  15. package/public/assets/{page.sOFOrxqq.js → page.A4gD6oiw.js} +1 -1
  16. package/public/assets/{page.D5gj98Oe.js → page.AhxgKhsm.js} +1 -1
  17. package/public/assets/{page.DUI8kqOY.js → page.B1og8_GD.js} +1 -1
  18. package/public/assets/{page.CssmrzTT.js → page.B5nk3H0f.js} +1 -1
  19. package/public/assets/{page.DX4Nno6M.js → page.BGDrqCcI.js} +1 -1
  20. package/public/assets/{page.DzZLqI5Q.js → page.BJIIZWfZ.js} +1 -1
  21. package/public/assets/{page.BdmJ3yY3.js → page.BdB6udZG.js} +1 -1
  22. package/public/assets/{page.Ir7KvKcF.js → page.BfGkHTDS.js} +1 -1
  23. package/public/assets/{page.CPZav1_c.js → page.Bfr4417O.js} +1 -1
  24. package/public/assets/{page.ChX1NqmC.js → page.BpcyRUKz.js} +1 -1
  25. package/public/assets/{page.O2ddJYoT.js → page.BvcbHe5b.js} +1 -1
  26. package/public/assets/{page.C72FTTJr.js → page.C6WsIDgW.js} +1 -1
  27. package/public/assets/{page.Dh5f0XJC.js → page.CCEJ5tPH.js} +1 -1
  28. package/public/assets/{page.DxMDTbSx.js → page.CMUifPIU.js} +1 -1
  29. package/public/assets/{page.1qjqvrwX.js → page.CR7Yees9.js} +1 -1
  30. package/public/assets/{page.CsxWmPoI.js → page.CXCEdPh6.js} +1 -1
  31. package/public/assets/{page.DPyOkPVo.js → page.CsroRewc.js} +1 -1
  32. package/public/assets/{page.CQlVGoXg.js → page.CtLa-V_T.js} +1 -1
  33. package/public/assets/{page.BnmTC5jG.js → page.DINPUA6N.js} +1 -1
  34. package/public/assets/page.DSEK9UW0.js +1 -0
  35. package/public/assets/{page.i4KDuWcM.js → page.DSTzvOQ8.js} +1 -1
  36. package/public/assets/{page.CSs3-gdt.js → page.DT7cpJ8d.js} +1 -1
  37. package/public/assets/{page.DVIHRbxB.js → page.DT_RnrSs.js} +1 -1
  38. package/public/assets/{page.Cj5h09Zo.js → page.DU7jwIPk.js} +1 -1
  39. package/public/assets/{page.DBhu4Arl.js → page.DcmbyZGV.js} +1 -1
  40. package/public/assets/{page.CbkENBd5.js → page.DjguJpCk.js} +1 -1
  41. package/public/assets/{page.CnTop8Zt.js → page.Dr6yAoTO.js} +1 -1
  42. package/public/assets/{page.CXd_R9yU.js → page.FR_Izkgi.js} +1 -1
  43. package/public/assets/{page.BSLJ4tx5.js → page.GhgvWftU.js} +1 -1
  44. package/public/assets/{page.BbO1pspY.js → page.UoGOSKkx.js} +1 -1
  45. package/public/assets/page.cAR8tR7Z.js +1 -0
  46. package/public/assets/{page.DibhF7f-.js → page.feKgaG20.js} +1 -1
  47. package/public/assets/{page.D1oKew1j.js → page.t4nKFefI.js} +1 -1
  48. package/public/index.html +2 -2
  49. package/public/assets/EndpointPageClient.LyNNvZ4z.js +0 -6
  50. package/public/assets/index.BuPfZebu.css +0 -1
  51. package/public/assets/index.CShjRV_B.js +0 -89
  52. package/public/assets/page.DD_czjjP.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as e,B as m}from"./index.CShjRV_B.js";import{b as r}from"./router.Cjj1--8t.js";import{C as Ye,T as Ge,B as qe}from"./NoAuthProxyCard.qAv57b-0.js";import{L as Xe}from"./Loading.Bj-WGl4k.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
1
+ import{j as e,B as m}from"./index.D4FwOBBU.js";import{b as r}from"./router.Cjj1--8t.js";import{C as Ye,T as Ge,B as qe}from"./NoAuthProxyCard.WHGGEUIp.js";import{L as Xe}from"./Loading.C1il44u0.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
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
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
4
  http://host:port
@@ -1 +1 @@
1
- import{g as v,j as e,B as c,m as j}from"./index.CShjRV_B.js";import{d as N,b as u,L as h}from"./router.Cjj1--8t.js";import{C as p,S as k,I as x,T as A}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";const P=Object.values(v).map(a=>({value:a.id,label:a.name})),S=Object.values(j).map(a=>({value:a.id,label:a.name}));function E(){const a=N(),[b,m]=u.useState(!1),[t,y]=u.useState({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[s,n]=u.useState({}),i=(r,o)=>{y(l=>({...l,[r]:o})),s[r]&&n(l=>({...l,[r]:null}))},f=()=>{const r={};return t.provider||(r.provider="Please select a provider"),t.authMethod==="api_key"&&!t.apiKey&&(r.apiKey="API Key is required"),n(r),Object.keys(r).length===0},g=async r=>{if(r.preventDefault(),!!f()){m(!0);try{const o=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(o.ok)a("/dashboard/providers");else{const l=await o.json();n({submit:l.error||"Failed to create provider"})}}catch{n({submit:"An error occurred. Please try again."})}finally{m(!1)}}},d=v[t.provider];return e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs(h,{to:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),e.jsx("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),e.jsx(p,{children:e.jsxs("form",{onSubmit:g,className:"flex flex-col gap-6",children:[e.jsx(k,{label:"Provider",options:P,value:t.provider,onChange:r=>i("provider",r.target.value),placeholder:"Select a provider",error:s.provider,required:!0}),d&&e.jsxs(p.Section,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:e.jsx("span",{className:"material-symbols-outlined text-xl",style:{color:d.color},children:d.icon})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:d.name}),e.jsx("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"text-sm font-medium",children:["Authentication Method ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-3",children:S.map(r=>e.jsxs("button",{type:"button",onClick:()=>i("authMethod",r.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${t.authMethod===r.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[e.jsx("span",{className:"material-symbols-outlined",children:r.value==="api_key"?"key":"lock"}),e.jsx("span",{className:"font-medium",children:r.label})]},r.value))})]}),t.authMethod==="api_key"&&e.jsx(x,{label:"API Key",type:"password",placeholder:"Enter your API key",value:t.apiKey,onChange:r=>i("apiKey",r.target.value),error:s.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),t.authMethod==="oauth2"&&e.jsxs(p.Section,{children:[e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),e.jsx(c,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),e.jsx(x,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:t.displayName,onChange:r=>i("displayName",r.target.value),hint:"Optional. A friendly name to identify this configuration."}),e.jsx(A,{checked:t.isActive,onChange:r=>i("isActive",r),label:"Active",description:"Enable this provider for use in your applications"}),s.submit&&e.jsx("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:s.submit}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-border",children:[e.jsx(h,{to:"/dashboard/providers",className:"flex-1",children:e.jsx(c,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),e.jsx(c,{type:"submit",loading:b,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}export{E as default};
1
+ import{g as v,j as e,B as c,m as j}from"./index.D4FwOBBU.js";import{d as N,b as u,L as h}from"./router.Cjj1--8t.js";import{C as p,S as k,I as x,T as A}from"./NoAuthProxyCard.WHGGEUIp.js";import"./zustand.akaTi5uX.js";const P=Object.values(v).map(a=>({value:a.id,label:a.name})),S=Object.values(j).map(a=>({value:a.id,label:a.name}));function E(){const a=N(),[b,m]=u.useState(!1),[t,y]=u.useState({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[s,n]=u.useState({}),i=(r,o)=>{y(l=>({...l,[r]:o})),s[r]&&n(l=>({...l,[r]:null}))},f=()=>{const r={};return t.provider||(r.provider="Please select a provider"),t.authMethod==="api_key"&&!t.apiKey&&(r.apiKey="API Key is required"),n(r),Object.keys(r).length===0},g=async r=>{if(r.preventDefault(),!!f()){m(!0);try{const o=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(o.ok)a("/dashboard/providers");else{const l=await o.json();n({submit:l.error||"Failed to create provider"})}}catch{n({submit:"An error occurred. Please try again."})}finally{m(!1)}}},d=v[t.provider];return e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs(h,{to:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),e.jsx("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),e.jsx(p,{children:e.jsxs("form",{onSubmit:g,className:"flex flex-col gap-6",children:[e.jsx(k,{label:"Provider",options:P,value:t.provider,onChange:r=>i("provider",r.target.value),placeholder:"Select a provider",error:s.provider,required:!0}),d&&e.jsxs(p.Section,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:e.jsx("span",{className:"material-symbols-outlined text-xl",style:{color:d.color},children:d.icon})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:d.name}),e.jsx("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"text-sm font-medium",children:["Authentication Method ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-3",children:S.map(r=>e.jsxs("button",{type:"button",onClick:()=>i("authMethod",r.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${t.authMethod===r.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[e.jsx("span",{className:"material-symbols-outlined",children:r.value==="api_key"?"key":"lock"}),e.jsx("span",{className:"font-medium",children:r.label})]},r.value))})]}),t.authMethod==="api_key"&&e.jsx(x,{label:"API Key",type:"password",placeholder:"Enter your API key",value:t.apiKey,onChange:r=>i("apiKey",r.target.value),error:s.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),t.authMethod==="oauth2"&&e.jsxs(p.Section,{children:[e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),e.jsx(c,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),e.jsx(x,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:t.displayName,onChange:r=>i("displayName",r.target.value),hint:"Optional. A friendly name to identify this configuration."}),e.jsx(A,{checked:t.isActive,onChange:r=>i("isActive",r),label:"Active",description:"Enable this provider for use in your applications"}),s.submit&&e.jsx("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:s.submit}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-border",children:[e.jsx(h,{to:"/dashboard/providers",className:"flex-1",children:e.jsx(c,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),e.jsx(c,{type:"submit",loading:b,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}export{E as default};
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as s}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[a,o]=s.useState(""),[l,r]=s.useState(null),[n,c]=s.useState(!1),i=async()=>{c(!0);try{const t=await fetch("/api/web/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a})});r(await t.json())}catch(t){r({error:t.message})}c(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Web Fetch"}),e.jsx("p",{className:"text-text-muted",children:"Fetch web content via Firecrawl, Jina, Tavily, or TinyFish"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 p-3 rounded-lg border",placeholder:"https://example.com",value:a,onChange:t=>o(t.target.value)}),e.jsx("button",{onClick:i,disabled:n,className:"px-4 py-2 bg-primary text-white rounded-lg",children:n?"Fetching...":"Fetch"})]}),l&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto max-h-96",children:JSON.stringify(l,null,2)})]})}export{u as default};
1
+ import{j as e}from"./index.D4FwOBBU.js";import{b as s}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[a,o]=s.useState(""),[l,r]=s.useState(null),[n,c]=s.useState(!1),i=async()=>{c(!0);try{const t=await fetch("/api/web/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a})});r(await t.json())}catch(t){r({error:t.message})}c(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Web Fetch"}),e.jsx("p",{className:"text-text-muted",children:"Fetch web content via Firecrawl, Jina, Tavily, or TinyFish"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 p-3 rounded-lg border",placeholder:"https://example.com",value:a,onChange:t=>o(t.target.value)}),e.jsx("button",{onClick:i,disabled:n,className:"px-4 py-2 bg-primary text-white rounded-lg",children:n?"Fetching...":"Fetch"})]}),l&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto max-h-96",children:JSON.stringify(l,null,2)})]})}export{u as default};
@@ -1 +1 @@
1
- import{K as g,j as e,B as P,g as w,P as C}from"./index.CShjRV_B.js";import{d as z,b as p,L as k}from"./router.Cjj1--8t.js";import{C as y,B as b}from"./NoAuthProxyCard.qAv57b-0.js";import"./zustand.akaTi5uX.js";function v(t){const a=Object.entries(t).some(([n,r])=>n.startsWith("modelLock_")&&r&&new Date(r).getTime()>Date.now());return t.testStatus==="unavailable"&&!a?"active":t.testStatus}function F({provider:t,kind:a,connections:n}){var c;const r=w[t.id],i=!!(r!=null&&r.noAuth),s=n.filter(o=>o.provider===t.id),m=s.filter(o=>{const l=v(o);return l==="active"||l==="success"}).length,d=s.filter(o=>{const l=v(o);return l==="error"||l==="expired"||l==="unavailable"}).length,x=s.length,f=x>0&&s.every(o=>o.isActive===!1),u=()=>i?e.jsx(b,{variant:"success",size:"sm",children:"Ready"}):f?e.jsx(b,{variant:"default",size:"sm",children:"Disabled"}):x===0?e.jsx("span",{className:"text-xs text-text-muted",children:"No connections"}):e.jsxs(e.Fragment,{children:[m>0&&e.jsxs(b,{variant:"success",size:"sm",dot:!0,children:[m," Connected"]}),d>0&&e.jsxs(b,{variant:"error",size:"sm",dot:!0,children:[d," Error"]}),m===0&&d===0&&e.jsxs(b,{variant:"default",size:"sm",children:[x," Added"]})]});return e.jsx(k,{to:`/dashboard/media-providers/${a}/${t.id}`,className:"group",children:e.jsx(y,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${f?"opacity-50":""}`,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=t.color)==null?void 0:c.length)>7?t.color:(t.color??"#888")+"15"}`},children:e.jsx(C,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:t.name}),e.jsx("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:u()})]})]})})})}function A({combos:t}){return t.length===0?e.jsx("p",{className:"text-xs text-text-muted italic",children:"No combos yet."}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(a=>e.jsx(k,{to:`/dashboard/media-providers/combo/${a.id}`,children:e.jsx(y,{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:a.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:shrink-0",children:[a.models.slice(0,6).map((n,r)=>{const i=typeof n=="string"?n.split("/")[0]:"",s=w[i];return e.jsx("div",{title:(s==null?void 0:s.name)||n,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${(s==null?void 0:s.color)??"#888"}15`},children:e.jsx(C,{src:`/providers/${i}.png`,alt:(s==null?void 0:s.name)||i,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:(s==null?void 0:s.textIcon)||i.slice(0,2).toUpperCase(),fallbackColor:s==null?void 0:s.color})},`${n}-${r}`)}),a.models.length>6&&e.jsxs("span",{className:"text-[10px] text-text-muted ml-1",children:["+",a.models.length-6]})]}),e.jsx("span",{className:"text-[11px] text-text-muted shrink-0",children:a.models.length}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},a.id))})}function N({title:t,icon:a,kind:n,providers:r,connections:i,combos:s,onCreateCombo:m}){return e.jsxs("div",{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",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:a}),e.jsx("h2",{className:"text-base font-semibold",children:t}),e.jsxs("span",{className:"text-xs text-text-muted",children:["(",r.length," providers · ",s.length," combos)"]})]}),e.jsx(P,{size:"sm",icon:"add",onClick:m,children:"Create Combo"})]}),s.length>0&&e.jsx("div",{className:"mb-4",children:e.jsx(A,{combos:s})}),r.length===0?e.jsx("div",{className:"text-center py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:"No providers."}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.map(d=>e.jsx(F,{provider:d,kind:n,connections:i},d.id))})]})}function T(){const t=z(),[a,n]=p.useState([]),[r,i]=p.useState([]),s=async()=>{try{const[c,o]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/combos",{cache:"no-store"})]);c.ok&&n((await c.json()).connections||[]),o.ok&&i((await o.json()).combos||[])}catch{}};p.useEffect(()=>{s()},[]);const m=g("webSearch"),d=g("webFetch"),x=r.filter(c=>c.kind==="webSearch"),f=r.filter(c=>c.kind==="webFetch"),u=async c=>{const o=c==="webSearch"?"search-combo":"fetch-combo";let l=o,S=1;const $=new Set(r.map(h=>h.name));for(;$.has(l);)l=`${o}-${S++}`;const j=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l,models:[],kind:c})});if(j.ok){const h=await j.json();t(`/dashboard/media-providers/combo/${h.id}`)}else{const h=await j.json();alert(h.error||"Failed to create combo")}};return e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(N,{title:"Web Search",icon:"search",kind:"webSearch",providers:m,connections:a,combos:x,onCreateCombo:()=>u("webSearch")}),e.jsx("div",{className:"border-t border-border"}),e.jsx(N,{title:"Web Fetch",icon:"travel_explore",kind:"webFetch",providers:d,connections:a,combos:f,onCreateCombo:()=>u("webFetch")})]})}export{T as default};
1
+ import{K as g,j as e,B as P,g as w,P as C}from"./index.D4FwOBBU.js";import{d as z,b as p,L as k}from"./router.Cjj1--8t.js";import{C as y,B as b}from"./NoAuthProxyCard.WHGGEUIp.js";import"./zustand.akaTi5uX.js";function v(t){const a=Object.entries(t).some(([n,r])=>n.startsWith("modelLock_")&&r&&new Date(r).getTime()>Date.now());return t.testStatus==="unavailable"&&!a?"active":t.testStatus}function F({provider:t,kind:a,connections:n}){var c;const r=w[t.id],i=!!(r!=null&&r.noAuth),s=n.filter(o=>o.provider===t.id),m=s.filter(o=>{const l=v(o);return l==="active"||l==="success"}).length,d=s.filter(o=>{const l=v(o);return l==="error"||l==="expired"||l==="unavailable"}).length,x=s.length,f=x>0&&s.every(o=>o.isActive===!1),u=()=>i?e.jsx(b,{variant:"success",size:"sm",children:"Ready"}):f?e.jsx(b,{variant:"default",size:"sm",children:"Disabled"}):x===0?e.jsx("span",{className:"text-xs text-text-muted",children:"No connections"}):e.jsxs(e.Fragment,{children:[m>0&&e.jsxs(b,{variant:"success",size:"sm",dot:!0,children:[m," Connected"]}),d>0&&e.jsxs(b,{variant:"error",size:"sm",dot:!0,children:[d," Error"]}),m===0&&d===0&&e.jsxs(b,{variant:"default",size:"sm",children:[x," Added"]})]});return e.jsx(k,{to:`/dashboard/media-providers/${a}/${t.id}`,className:"group",children:e.jsx(y,{padding:"xs",className:`h-full hover:bg-black/[0.01] dark:hover:bg-white/[0.01] transition-colors cursor-pointer ${f?"opacity-50":""}`,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=t.color)==null?void 0:c.length)>7?t.color:(t.color??"#888")+"15"}`},children:e.jsx(C,{src:`/providers/${t.id}.png`,alt:t.name,size:30,className:"object-contain rounded-lg max-w-[30px] max-h-[30px]",fallbackText:t.textIcon||t.id.slice(0,2).toUpperCase(),fallbackColor:t.color})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:t.name}),e.jsx("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:u()})]})]})})})}function A({combos:t}){return t.length===0?e.jsx("p",{className:"text-xs text-text-muted italic",children:"No combos yet."}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(a=>e.jsx(k,{to:`/dashboard/media-providers/combo/${a.id}`,children:e.jsx(y,{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:a.name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:shrink-0",children:[a.models.slice(0,6).map((n,r)=>{const i=typeof n=="string"?n.split("/")[0]:"",s=w[i];return e.jsx("div",{title:(s==null?void 0:s.name)||n,className:"size-5 rounded flex items-center justify-center",style:{backgroundColor:`${(s==null?void 0:s.color)??"#888"}15`},children:e.jsx(C,{src:`/providers/${i}.png`,alt:(s==null?void 0:s.name)||i,size:18,className:"object-contain rounded max-w-[18px] max-h-[18px]",fallbackText:(s==null?void 0:s.textIcon)||i.slice(0,2).toUpperCase(),fallbackColor:s==null?void 0:s.color})},`${n}-${r}`)}),a.models.length>6&&e.jsxs("span",{className:"text-[10px] text-text-muted ml-1",children:["+",a.models.length-6]})]}),e.jsx("span",{className:"text-[11px] text-text-muted shrink-0",children:a.models.length}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[16px]",children:"chevron_right"})]})})},a.id))})}function N({title:t,icon:a,kind:n,providers:r,connections:i,combos:s,onCreateCombo:m}){return e.jsxs("div",{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",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:a}),e.jsx("h2",{className:"text-base font-semibold",children:t}),e.jsxs("span",{className:"text-xs text-text-muted",children:["(",r.length," providers · ",s.length," combos)"]})]}),e.jsx(P,{size:"sm",icon:"add",onClick:m,children:"Create Combo"})]}),s.length>0&&e.jsx("div",{className:"mb-4",children:e.jsx(A,{combos:s})}),r.length===0?e.jsx("div",{className:"text-center py-8 border border-dashed border-border rounded-xl text-text-muted text-sm",children:"No providers."}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:r.map(d=>e.jsx(F,{provider:d,kind:n,connections:i},d.id))})]})}function T(){const t=z(),[a,n]=p.useState([]),[r,i]=p.useState([]),s=async()=>{try{const[c,o]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/combos",{cache:"no-store"})]);c.ok&&n((await c.json()).connections||[]),o.ok&&i((await o.json()).combos||[])}catch{}};p.useEffect(()=>{s()},[]);const m=g("webSearch"),d=g("webFetch"),x=r.filter(c=>c.kind==="webSearch"),f=r.filter(c=>c.kind==="webFetch"),u=async c=>{const o=c==="webSearch"?"search-combo":"fetch-combo";let l=o,S=1;const $=new Set(r.map(h=>h.name));for(;$.has(l);)l=`${o}-${S++}`;const j=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l,models:[],kind:c})});if(j.ok){const h=await j.json();t(`/dashboard/media-providers/combo/${h.id}`)}else{const h=await j.json();alert(h.error||"Failed to create combo")}};return e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(N,{title:"Web Search",icon:"search",kind:"webSearch",providers:m,connections:a,combos:x,onCreateCombo:()=>u("webSearch")}),e.jsx("div",{className:"border-t border-border"}),e.jsx(N,{title:"Web Fetch",icon:"travel_explore",kind:"webFetch",providers:d,connections:a,combos:f,onCreateCombo:()=>u("webFetch")})]})}export{T as default};
@@ -1,4 +1,4 @@
1
- import{u as On,j as f,B as Je,C as Ln,p as Jt,s as Qt,q as Zt,P as en,M as zn}from"./index.CShjRV_B.js";import{b as l,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as tn,I as Pn,M as Bn}from"./NoAuthProxyCard.qAv57b-0.js";import{C as Lt}from"./Loading.Bj-WGl4k.js";import"./zustand.akaTi5uX.js";function $n(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function De(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function X(e){var t,n;return e?De(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=X(e);return e instanceof t}function Ue(e){return De(e)?!1:e instanceof X(e).HTMLElement}function nn(e){return e instanceof X(e).SVGElement}function Re(e){return e?De(e)?e.document:bt(e)?xt(e)?e:Ue(e)||nn(e)?e.ownerDocument:document:document:document}const re=nt?l.useLayoutEffect:l.useEffect;function yt(e){const t=l.useRef(e);return re(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Fn(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=yt(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return l.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function rn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,d]of a){const h=s[c];h!=null&&(s[c]=h+e*d)}return s},{...t})}}const Se=rn(1),Be=rn(-1);function Un(e){return"clientX"in e&&"clientY"in e}function wt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Xn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Xn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Un(e)?{x:e.clientX,y:e.clientY}:null}const $e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[$e.Translate.toString(e),$e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),zt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Wn(e){return e.matches(zt)?e:e.querySelector(zt)}const Yn={display:"none"};function Vn(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:Yn},n)}function Hn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return U.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Kn(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const on=l.createContext(null);function _n(e){const t=l.useContext(on);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function qn(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const Gn={draggable:`
1
+ import{u as On,j as f,B as Je,C as Ln,p as Jt,s as Qt,q as Zt,P as en,M as zn}from"./index.D4FwOBBU.js";import{b as l,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as tn,I as Pn,M as Bn}from"./NoAuthProxyCard.WHGGEUIp.js";import{C as Lt}from"./Loading.C1il44u0.js";import"./zustand.akaTi5uX.js";function $n(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function De(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function X(e){var t,n;return e?De(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=X(e);return e instanceof t}function Ue(e){return De(e)?!1:e instanceof X(e).HTMLElement}function nn(e){return e instanceof X(e).SVGElement}function Re(e){return e?De(e)?e.document:bt(e)?xt(e)?e:Ue(e)||nn(e)?e.ownerDocument:document:document:document}const re=nt?l.useLayoutEffect:l.useEffect;function yt(e){const t=l.useRef(e);return re(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Fn(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=yt(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return l.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function rn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,d]of a){const h=s[c];h!=null&&(s[c]=h+e*d)}return s},{...t})}}const Se=rn(1),Be=rn(-1);function Un(e){return"clientX"in e&&"clientY"in e}function wt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Xn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Xn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Un(e)?{x:e.clientX,y:e.clientY}:null}const $e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[$e.Translate.toString(e),$e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),zt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Wn(e){return e.matches(zt)?e:e.querySelector(zt)}const Yn={display:"none"};function Vn(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:Yn},n)}function Hn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return U.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Kn(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const on=l.createContext(null);function _n(e){const t=l.useContext(on);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function qn(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const Gn={draggable:`
2
2
  To pick up a draggable item, press the space bar.
3
3
  While dragging, use the arrow keys to move the item.
4
4
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as o}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[i,n]=o.useState({}),l=t=>{navigator.clipboard.writeText(t),n(r=>({...r,[t]:!0})),setTimeout(()=>{n(r=>({...r,[t]:!1}))},1500)},a=({value:t,text:r="Copy",className:d=""})=>{const s=i[t];return e.jsxs("button",{type:"button",onClick:()=>l(t),className:`text-xs px-3 py-1 rounded cursor-pointer transition-all duration-150 flex items-center gap-1 border font-semibold shrink-0 ${s?"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"} ${d}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:s?"check":"content_copy"}),s?"Copied":r]})};return e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4 text-white space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[28px]",children:"auto_stories"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Panduan Lengkap Deploy Temp Mail"}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Panduan integrasi Cloudflare Worker & D1 Database untuk fsrouter"})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("a",{href:"/dashboard/automation",className:"px-3.5 py-1.5 rounded-lg bg-white/5 border border-white/10 text-xs font-semibold hover:bg-white/10 transition-colors cursor-pointer",children:"Kembali ke Dashboard"})})]}),e.jsxs("div",{className:"space-y-6 text-sm leading-relaxed text-white/80",children:[e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-xl p-4 text-xs text-primary/95 flex items-start gap-3",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"lightbulb"}),e.jsxs("p",{children:[e.jsx("strong",{children:"Info Penting:"})," Panduan ini ditujukan jika Anda ingin melakukan deployment secara manual ke Cloudflare menggunakan CLI. Jika Anda ingin setup otomatis, silakan kembali ke Dashboard dan gunakan form ",e.jsx("strong",{children:"⚡ Auto Deploy (Cloudflare)"})," untuk setup 1-klik."]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"1"}),"Prasyarat & Login Cloudflare"]}),e.jsx("p",{children:"Pastikan Node.js telah terinstal di komputer Anda. Buka terminal lalu autentikasikan akun Cloudflare Anda menggunakan Wrangler CLI:"}),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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler login"}),e.jsx(a,{value:"npx wrangler login"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"2"}),"Masuk Folder & Install Dependencies"]}),e.jsx("p",{children:"Buka terminal pada direktori worker lokal Anda (`tempmail`) lalu install package dependencies:"}),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 gap-4",children:[e.jsx("span",{className:"break-all",children:"cd /home/data/Project/fsrouter/tempmail && npm install"}),e.jsx(a,{value:"cd /home/data/Project/fsrouter/tempmail && npm install"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"3"}),"Buat Database Cloudflare D1"]}),e.jsxs("p",{children:["Buat database baru bernama ",e.jsx("code",{children:"tempmail"})," pada Cloudflare D1 untuk menyimpan data kotak surat dan isi pesan:"]}),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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler d1 create tempmail"}),e.jsx(a,{value:"npx wrangler d1 create tempmail"})]}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3.5 text-xs text-amber-300 flex items-start gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"warning"}),e.jsxs("span",{children:["Perintah di atas akan menghasilkan **database_id** (UUID). Salin ID tersebut, kemudian buka berkas ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-white",children:"wrangler.jsonc"})," di folder proyek tempmail Anda, ganti nilai ",e.jsx("code",{children:"database_id"})," di baris terbawah dengan ID baru Anda."]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"4"}),"Jalankan Migrasi Database D1"]}),e.jsx("p",{children:"Buat struktur tabel database yang diperlukan dengan menerapkan migrasi database baik secara lokal maupun langsung di 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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler d1 migrations apply tempmail --remote"}),e.jsx(a,{value:"npx wrangler d1 migrations apply tempmail --remote"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"5"}),"Buat API Access Key untuk fsrouter"]}),e.jsx("p",{children:"fsrouter berkomunikasi dengan Worker menggunakan API Key yang aman. Jalankan perintah SQL berikut untuk mendaftarkan fsrouter admin ke database D1 Anda:"}),e.jsxs("div",{className:"space-y-3",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 gap-4",children:[e.jsx("span",{className:"break-all overflow-hidden text-ellipsis",children:`npx wrangler d1 execute tempmail --remote --command="INSERT OR IGNORE INTO chats (chat_id, username, first_name, last_name, created_at, updated_at) VALUES ('fsrouter', 'fsrouter_admin', 'FSRouter', 'Admin', datetime('now'), datetime('now')); INSERT OR REPLACE INTO api_access (user_id, api_key, quota_daily, quota_used, quota_date, granted_by, granted_at, expires_at) VALUES ('fsrouter', 'tm_YOUR_SECURE_API_KEY', 0, 0, strftime('%Y-%m-%d', 'now'), 'admin', datetime('now'), '2099-12-31T23:59:59Z');"`}),e.jsx(a,{value:`npx wrangler d1 execute tempmail --remote --command="INSERT OR IGNORE INTO chats (chat_id, username, first_name, last_name, created_at, updated_at) VALUES ('fsrouter', 'fsrouter_admin', 'FSRouter', 'Admin', datetime('now'), datetime('now')); INSERT OR REPLACE INTO api_access (user_id, api_key, quota_daily, quota_used, quota_date, granted_by, granted_at, expires_at) VALUES ('fsrouter', 'tm_YOUR_SECURE_API_KEY', 0, 0, strftime('%Y-%m-%d', 'now'), 'admin', datetime('now'), '2099-12-31T23:59:59Z');"`})]}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3.5 text-xs text-amber-300 flex items-start gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"info"}),e.jsxs("span",{children:["Ganti ",e.jsx("code",{children:"tm_YOUR_SECURE_API_KEY"})," dengan API Key acak pilihan Anda (misalnya menggunakan format ",e.jsx("code",{children:"tm_"})," diikuti oleh karakter hex acak). Salin API Key ini ke pengaturan fsrouter Anda."]})]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"6"}),"Atur Secret Tokens (Telegram & Webhook)"]}),e.jsx("p",{children:"Simpan token bot Telegram dan webhook secret ke dalam Cloudflare secret variables secara aman:"}),e.jsxs("div",{className:"space-y-3",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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler secret put TELEGRAM_BOT_TOKEN"}),e.jsx(a,{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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"}),e.jsx(a,{value:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"})]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"7"}),"Deploy ke Cloudflare Workers"]}),e.jsxs("p",{children:["Buka file ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-white",children:"wrangler.jsonc"}),", sesuaikan parameter ",e.jsx("code",{children:"vars"})," (domain, base URL) agar sesuai dengan domain milik Anda. Setelah itu, deploy ke 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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler deploy"}),e.jsx(a,{value:"npx wrangler deploy"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"8"}),"Daftarkan Webhook Telegram Bot (Opsional)"]}),e.jsx("p",{children:"Daftarkan URL domain worker Anda ke API Telegram agar bot Anda dapat menerima chat command secara instan:"}),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 gap-4",children:[e.jsx("span",{className:"break-all",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(a,{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",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"9"}),"Konfigurasi Cloudflare Email Routing & DNS (Paling Penting!)"]}),e.jsx("p",{children:"Ini adalah langkah krusial agar email dapat diterima dan diproses oleh Worker yang telah dideploy. Masuk ke panel Cloudflare Anda, lalu ikuti panduan berikut:"}),e.jsxs("div",{className:"space-y-4 border-l-2 border-primary/30 pl-4 mt-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white text-xs flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),"Bagian A: Sinkronkan dan Kunci Rekaman DNS"]}),e.jsxs("p",{className:"text-xs text-white/70 mt-1",children:["Jika status DNS Anda tertulis ",e.jsx("code",{className:"bg-white/10 text-white px-1 rounded",children:"Not configured"})," atau ada rekaman dengan status ",e.jsx("code",{className:"bg-amber-500/10 text-amber-300 px-1 rounded border border-amber-500/20",children:"Unlocked"})," (misalnya TXT SPF):"]}),e.jsxs("ul",{className:"list-disc list-inside text-xs text-white/70 mt-1.5 space-y-1 ml-2",children:[e.jsxs("li",{children:["Buka menu ",e.jsx("strong",{children:"Email Routing"})," di panel domain Cloudflare Anda."]}),e.jsx("li",{children:"Pilih tab **`Settings`** di sebelah atas."}),e.jsx("li",{children:"Di sebelah kanan judul **`DNS records`**, klik tombol **`Lock`** (ikon gembok). Cloudflare akan otomatis mengunci dan menerapkan semua MX dan TXT records yang dibutuhkan untuk rute email."})]})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white text-xs flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),"Bagian B: Buat Aturan Rute Catch-All"]}),e.jsx("p",{className:"text-xs text-white/70 mt-1",children:"Agar semua email masuk diteruskan ke database Worker Anda:"}),e.jsxs("ul",{className:"list-disc list-inside text-xs text-white/70 mt-1.5 space-y-1 ml-2",children:[e.jsx("li",{children:"Klik tab **`Routing rules`** (tab ketiga dari kiri)."}),e.jsx("li",{children:"Scroll ke bawah ke bagian **Catch-all address**."}),e.jsx("li",{children:"Klik **Edit** / **Configure**."}),e.jsx("li",{children:"Pada kolom **Action** (Aksi), pilih opsi **`Send to a Worker`** (Kirim ke Worker)."}),e.jsx("li",{children:"Pada kolom **Destination** (Worker tujuan), pilih nama Worker yang baru saja dideploy (contohnya: **`tempmail-pixelnest`**)."}),e.jsx("li",{children:"Klik **Save** untuk menyimpan aturan perutean."})]})]})]})]})]})]})}export{u as default};
1
+ import{j as e}from"./index.D4FwOBBU.js";import{b as o}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[i,n]=o.useState({}),l=t=>{navigator.clipboard.writeText(t),n(r=>({...r,[t]:!0})),setTimeout(()=>{n(r=>({...r,[t]:!1}))},1500)},a=({value:t,text:r="Copy",className:d=""})=>{const s=i[t];return e.jsxs("button",{type:"button",onClick:()=>l(t),className:`text-xs px-3 py-1 rounded cursor-pointer transition-all duration-150 flex items-center gap-1 border font-semibold shrink-0 ${s?"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"} ${d}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:s?"check":"content_copy"}),s?"Copied":r]})};return e.jsxs("div",{className:"max-w-3xl mx-auto py-8 px-4 text-white space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[28px]",children:"auto_stories"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Panduan Lengkap Deploy Temp Mail"}),e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Panduan integrasi Cloudflare Worker & D1 Database untuk fsrouter"})]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("a",{href:"/dashboard/automation",className:"px-3.5 py-1.5 rounded-lg bg-white/5 border border-white/10 text-xs font-semibold hover:bg-white/10 transition-colors cursor-pointer",children:"Kembali ke Dashboard"})})]}),e.jsxs("div",{className:"space-y-6 text-sm leading-relaxed text-white/80",children:[e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-xl p-4 text-xs text-primary/95 flex items-start gap-3",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"lightbulb"}),e.jsxs("p",{children:[e.jsx("strong",{children:"Info Penting:"})," Panduan ini ditujukan jika Anda ingin melakukan deployment secara manual ke Cloudflare menggunakan CLI. Jika Anda ingin setup otomatis, silakan kembali ke Dashboard dan gunakan form ",e.jsx("strong",{children:"⚡ Auto Deploy (Cloudflare)"})," untuk setup 1-klik."]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"1"}),"Prasyarat & Login Cloudflare"]}),e.jsx("p",{children:"Pastikan Node.js telah terinstal di komputer Anda. Buka terminal lalu autentikasikan akun Cloudflare Anda menggunakan Wrangler CLI:"}),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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler login"}),e.jsx(a,{value:"npx wrangler login"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"2"}),"Masuk Folder & Install Dependencies"]}),e.jsx("p",{children:"Buka terminal pada direktori worker lokal Anda (`tempmail`) lalu install package dependencies:"}),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 gap-4",children:[e.jsx("span",{className:"break-all",children:"cd /home/data/Project/fsrouter/tempmail && npm install"}),e.jsx(a,{value:"cd /home/data/Project/fsrouter/tempmail && npm install"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"3"}),"Buat Database Cloudflare D1"]}),e.jsxs("p",{children:["Buat database baru bernama ",e.jsx("code",{children:"tempmail"})," pada Cloudflare D1 untuk menyimpan data kotak surat dan isi pesan:"]}),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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler d1 create tempmail"}),e.jsx(a,{value:"npx wrangler d1 create tempmail"})]}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3.5 text-xs text-amber-300 flex items-start gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"warning"}),e.jsxs("span",{children:["Perintah di atas akan menghasilkan **database_id** (UUID). Salin ID tersebut, kemudian buka berkas ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-white",children:"wrangler.jsonc"})," di folder proyek tempmail Anda, ganti nilai ",e.jsx("code",{children:"database_id"})," di baris terbawah dengan ID baru Anda."]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"4"}),"Jalankan Migrasi Database D1"]}),e.jsx("p",{children:"Buat struktur tabel database yang diperlukan dengan menerapkan migrasi database baik secara lokal maupun langsung di 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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler d1 migrations apply tempmail --remote"}),e.jsx(a,{value:"npx wrangler d1 migrations apply tempmail --remote"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"5"}),"Buat API Access Key untuk fsrouter"]}),e.jsx("p",{children:"fsrouter berkomunikasi dengan Worker menggunakan API Key yang aman. Jalankan perintah SQL berikut untuk mendaftarkan fsrouter admin ke database D1 Anda:"}),e.jsxs("div",{className:"space-y-3",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 gap-4",children:[e.jsx("span",{className:"break-all overflow-hidden text-ellipsis",children:`npx wrangler d1 execute tempmail --remote --command="INSERT OR IGNORE INTO chats (chat_id, username, first_name, last_name, created_at, updated_at) VALUES ('fsrouter', 'fsrouter_admin', 'FSRouter', 'Admin', datetime('now'), datetime('now')); INSERT OR REPLACE INTO api_access (user_id, api_key, quota_daily, quota_used, quota_date, granted_by, granted_at, expires_at) VALUES ('fsrouter', 'tm_YOUR_SECURE_API_KEY', 0, 0, strftime('%Y-%m-%d', 'now'), 'admin', datetime('now'), '2099-12-31T23:59:59Z');"`}),e.jsx(a,{value:`npx wrangler d1 execute tempmail --remote --command="INSERT OR IGNORE INTO chats (chat_id, username, first_name, last_name, created_at, updated_at) VALUES ('fsrouter', 'fsrouter_admin', 'FSRouter', 'Admin', datetime('now'), datetime('now')); INSERT OR REPLACE INTO api_access (user_id, api_key, quota_daily, quota_used, quota_date, granted_by, granted_at, expires_at) VALUES ('fsrouter', 'tm_YOUR_SECURE_API_KEY', 0, 0, strftime('%Y-%m-%d', 'now'), 'admin', datetime('now'), '2099-12-31T23:59:59Z');"`})]}),e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-lg p-3.5 text-xs text-amber-300 flex items-start gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 mt-0.5",children:"info"}),e.jsxs("span",{children:["Ganti ",e.jsx("code",{children:"tm_YOUR_SECURE_API_KEY"})," dengan API Key acak pilihan Anda (misalnya menggunakan format ",e.jsx("code",{children:"tm_"})," diikuti oleh karakter hex acak). Salin API Key ini ke pengaturan fsrouter Anda."]})]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"6"}),"Atur Secret Tokens (Telegram & Webhook)"]}),e.jsx("p",{children:"Simpan token bot Telegram dan webhook secret ke dalam Cloudflare secret variables secara aman:"}),e.jsxs("div",{className:"space-y-3",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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler secret put TELEGRAM_BOT_TOKEN"}),e.jsx(a,{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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"}),e.jsx(a,{value:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"})]})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"7"}),"Deploy ke Cloudflare Workers"]}),e.jsxs("p",{children:["Buka file ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-white",children:"wrangler.jsonc"}),", sesuaikan parameter ",e.jsx("code",{children:"vars"})," (domain, base URL) agar sesuai dengan domain milik Anda. Setelah itu, deploy ke 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 gap-4",children:[e.jsx("span",{className:"break-all",children:"npx wrangler deploy"}),e.jsx(a,{value:"npx wrangler deploy"})]})]}),e.jsxs("div",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"8"}),"Daftarkan Webhook Telegram Bot (Opsional)"]}),e.jsx("p",{children:"Daftarkan URL domain worker Anda ke API Telegram agar bot Anda dapat menerima chat command secara instan:"}),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 gap-4",children:[e.jsx("span",{className:"break-all",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(a,{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",{className:"bg-neutral-900 border border-white/5 rounded-xl p-6 space-y-4",children:[e.jsxs("h4",{className:"text-base font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary w-6 h-6 rounded-full flex items-center justify-center text-xs",children:"9"}),"Konfigurasi Cloudflare Email Routing & DNS (Paling Penting!)"]}),e.jsx("p",{children:"Ini adalah langkah krusial agar email dapat diterima dan diproses oleh Worker yang telah dideploy. Masuk ke panel Cloudflare Anda, lalu ikuti panduan berikut:"}),e.jsxs("div",{className:"space-y-4 border-l-2 border-primary/30 pl-4 mt-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white text-xs flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),"Bagian A: Sinkronkan dan Kunci Rekaman DNS"]}),e.jsxs("p",{className:"text-xs text-white/70 mt-1",children:["Jika status DNS Anda tertulis ",e.jsx("code",{className:"bg-white/10 text-white px-1 rounded",children:"Not configured"})," atau ada rekaman dengan status ",e.jsx("code",{className:"bg-amber-500/10 text-amber-300 px-1 rounded border border-amber-500/20",children:"Unlocked"})," (misalnya TXT SPF):"]}),e.jsxs("ul",{className:"list-disc list-inside text-xs text-white/70 mt-1.5 space-y-1 ml-2",children:[e.jsxs("li",{children:["Buka menu ",e.jsx("strong",{children:"Email Routing"})," di panel domain Cloudflare Anda."]}),e.jsx("li",{children:"Pilih tab **`Settings`** di sebelah atas."}),e.jsx("li",{children:"Di sebelah kanan judul **`DNS records`**, klik tombol **`Lock`** (ikon gembok). Cloudflare akan otomatis mengunci dan menerapkan semua MX dan TXT records yang dibutuhkan untuk rute email."})]})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white text-xs flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),"Bagian B: Buat Aturan Rute Catch-All"]}),e.jsx("p",{className:"text-xs text-white/70 mt-1",children:"Agar semua email masuk diteruskan ke database Worker Anda:"}),e.jsxs("ul",{className:"list-disc list-inside text-xs text-white/70 mt-1.5 space-y-1 ml-2",children:[e.jsx("li",{children:"Klik tab **`Routing rules`** (tab ketiga dari kiri)."}),e.jsx("li",{children:"Scroll ke bawah ke bagian **Catch-all address**."}),e.jsx("li",{children:"Klik **Edit** / **Configure**."}),e.jsx("li",{children:"Pada kolom **Action** (Aksi), pilih opsi **`Send to a Worker`** (Kirim ke Worker)."}),e.jsx("li",{children:"Pada kolom **Destination** (Worker tujuan), pilih nama Worker yang baru saja dideploy (contohnya: **`tempmail-pixelnest`**)."}),e.jsx("li",{children:"Klik **Save** untuk menyimpan aturan perutean."})]})]})]})]})]})]})}export{u as default};
@@ -1 +1 @@
1
- import{j as e}from"./index.CShjRV_B.js";import{b as n,f as h}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[s]=h(),[a,l]=n.useState("processing");return n.useEffect(()=>{const r=s.get("code"),i=s.get("state"),o=s.get("error"),d=s.get("error_description"),c={code:r,state:i,error:o,errorDescription:d,fullUrl:window.location.href},m=[window.location.origin,"http://localhost:1455","http://localhost:51121"];if(window.opener)for(const t of m)try{window.opener.postMessage({type:"oauth_callback",data:c},t)}catch(x){console.log("postMessage failed:",x)}try{const t=new BroadcastChannel("oauth_callback");t.postMessage(c),t.close()}catch(t){console.log("BroadcastChannel failed:",t)}try{localStorage.setItem("oauth_callback",JSON.stringify({...c,timestamp:Date.now()}))}catch(t){console.log("localStorage failed:",t)}if(!(r||o)){setTimeout(()=>l("manual"),0);return}l("success"),setTimeout(()=>{window.close(),setTimeout(()=>l("done"),500)},1500)},[s]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[a==="processing"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),e.jsx("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),(a==="success"||a==="done")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),e.jsx("p",{className:"text-text-muted",children:a==="success"?"This window will close automatically...":"You can close this tab now."})]}),a==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),e.jsx("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),e.jsx("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:e.jsx("code",{className:"text-xs break-all",children:typeof window<"u"?window.location.href:""})})]})]})})}function b(){return e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("p",{className:"text-text-muted",children:"Loading..."})]})}),children:e.jsx(u,{})})}export{b as default};
1
+ import{j as e}from"./index.D4FwOBBU.js";import{b as n,f as h}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[s]=h(),[a,l]=n.useState("processing");return n.useEffect(()=>{const r=s.get("code"),i=s.get("state"),o=s.get("error"),d=s.get("error_description"),c={code:r,state:i,error:o,errorDescription:d,fullUrl:window.location.href},m=[window.location.origin,"http://localhost:1455","http://localhost:51121"];if(window.opener)for(const t of m)try{window.opener.postMessage({type:"oauth_callback",data:c},t)}catch(x){console.log("postMessage failed:",x)}try{const t=new BroadcastChannel("oauth_callback");t.postMessage(c),t.close()}catch(t){console.log("BroadcastChannel failed:",t)}try{localStorage.setItem("oauth_callback",JSON.stringify({...c,timestamp:Date.now()}))}catch(t){console.log("localStorage failed:",t)}if(!(r||o)){setTimeout(()=>l("manual"),0);return}l("success"),setTimeout(()=>{window.close(),setTimeout(()=>l("done"),500)},1500)},[s]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[a==="processing"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),e.jsx("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),(a==="success"||a==="done")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),e.jsx("p",{className:"text-text-muted",children:a==="success"?"This window will close automatically...":"You can close this tab now."})]}),a==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),e.jsx("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),e.jsx("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:e.jsx("code",{className:"text-xs break-all",children:typeof window<"u"?window.location.href:""})})]})]})})}function b(){return e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("p",{className:"text-text-muted",children:"Loading..."})]})}),children:e.jsx(u,{})})}export{b as default};