@fudrouter/fsrouter 0.6.71 → 0.6.72
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.
- package/package.json +1 -1
- package/public/assets/{EndpointPageClient.CGB3HjDe.js → EndpointPageClient.LyNNvZ4z.js} +3 -3
- package/public/assets/{Loading.BhEzHe-X.js → Loading.Bj-WGl4k.js} +1 -1
- package/public/assets/{NoAuthProxyCard.Buvt0BVH.js → NoAuthProxyCard.qAv57b-0.js} +1 -1
- package/public/assets/{index.B-zMpSp_.js → index.CShjRV_B.js} +41 -41
- package/public/assets/{page.BINfJPNt.js → page.1qjqvrwX.js} +1 -1
- package/public/assets/{page.CfDkX9XZ.js → page.BSLJ4tx5.js} +1 -1
- package/public/assets/{page.D6TULIkh.js → page.BbO1pspY.js} +1 -1
- package/public/assets/page.BdmJ3yY3.js +5 -0
- package/public/assets/{page.Amtgxj_r.js → page.BnmTC5jG.js} +1 -1
- package/public/assets/{page.3QwV1pLl.js → page.C72FTTJr.js} +1 -1
- package/public/assets/{page.CdbMx9XI.js → page.CPZav1_c.js} +1 -1
- package/public/assets/{page.BONoTspJ.js → page.CQlVGoXg.js} +1 -1
- package/public/assets/{page.DgnlzpNx.js → page.CSs3-gdt.js} +1 -1
- package/public/assets/{page.BV28PqHr.js → page.CXd_R9yU.js} +1 -1
- package/public/assets/{page.5Aj6RvuD.js → page.CbkENBd5.js} +1 -1
- package/public/assets/{page.BAjUiqtJ.js → page.ChX1NqmC.js} +1 -1
- package/public/assets/page.Cj5h09Zo.js +1 -0
- package/public/assets/{page.CB__T51y.js → page.CnTop8Zt.js} +1 -1
- package/public/assets/{page.BMf0BFTW.js → page.CssmrzTT.js} +1 -1
- package/public/assets/{page.CVu_9TAu.js → page.CsxWmPoI.js} +1 -1
- package/public/assets/{page.ClXnUNhb.js → page.CzlQTyAL.js} +1 -1
- package/public/assets/{page.DAgwiopx.js → page.D1oKew1j.js} +1 -1
- package/public/assets/{page.BIG_uMBA.js → page.D5gj98Oe.js} +1 -1
- package/public/assets/{page.BW6Rv-_k.js → page.DBhu4Arl.js} +1 -1
- package/public/assets/page.DD_czjjP.js +1 -0
- package/public/assets/{page.BmOXfa4k.js → page.DPyOkPVo.js} +1 -1
- package/public/assets/{page.CTdMdgI4.js → page.DUI8kqOY.js} +1 -1
- package/public/assets/{page.BdPGDnx0.js → page.DVIHRbxB.js} +1 -1
- package/public/assets/{page.B9r7QI90.js → page.DX4Nno6M.js} +1 -1
- package/public/assets/{page.BCPmNscX.js → page.Dh5f0XJC.js} +1 -1
- package/public/assets/{page.u7XFxplU.js → page.DibhF7f-.js} +1 -1
- package/public/assets/{page.CDVZIbSe.js → page.DxMDTbSx.js} +1 -1
- package/public/assets/{page.Bb3E5EzI.js → page.Dx_GRRdT.js} +1 -1
- package/public/assets/{page.DhcizW_i.js → page.DzZLqI5Q.js} +1 -1
- package/public/assets/{page.CF5pD5lz.js → page.Ir7KvKcF.js} +1 -1
- package/public/assets/{page.Bj0au_ka.js → page.O2ddJYoT.js} +3 -3
- package/public/assets/{page.DIrcssm-.js → page.Qkkv8roc.js} +1 -1
- package/public/assets/{page.CrzjUbZg.js → page.i4KDuWcM.js} +1 -1
- package/public/assets/{page.1gncE-Vr.js → page.sOFOrxqq.js} +1 -1
- package/public/assets/{page.DskvkVIF.js → page.vla5Mzki.js} +1 -1
- package/public/index.html +1 -1
- package/public/assets/EndpointPageClient.Cee8kfmV.js +0 -6
- package/public/assets/EndpointPageClient.DdAfxJoK.js +0 -6
- package/public/assets/EndpointPageClient.GpJ_FKds.js +0 -6
- package/public/assets/Loading.DFkQ-Ly9.js +0 -1
- package/public/assets/Loading.DaQG3sHF.js +0 -1
- package/public/assets/Loading.QMOYJhLu.js +0 -1
- package/public/assets/NoAuthProxyCard.C18iZ3Fk.js +0 -89
- package/public/assets/NoAuthProxyCard.DyEjms20.js +0 -89
- package/public/assets/NoAuthProxyCard.VRP7gDcs.js +0 -89
- package/public/assets/index.CoYbjSIL.js +0 -89
- package/public/assets/index.DQDDDpp7.js +0 -89
- package/public/assets/index.KMEObSAk.js +0 -89
- package/public/assets/page.A7FRfarX.js +0 -1
- package/public/assets/page.B1a01Vfg.js +0 -1
- package/public/assets/page.B7h6EPVo.js +0 -1
- package/public/assets/page.BBMJAyy7.js +0 -1
- package/public/assets/page.BBSUQskO.js +0 -64
- package/public/assets/page.BFENid_V.js +0 -31
- package/public/assets/page.BJzBUr1v.js +0 -2
- package/public/assets/page.BKM5Up2Y.js +0 -1
- package/public/assets/page.BLUEyope.js +0 -1
- package/public/assets/page.BMeBT03D.js +0 -5
- package/public/assets/page.BQwH91-m.js +0 -1
- package/public/assets/page.BRgXbpJe.js +0 -1
- package/public/assets/page.BXq7Sixg.js +0 -1
- package/public/assets/page.Bbf1xxJj.js +0 -1
- package/public/assets/page.BcuklMLO.js +0 -2
- package/public/assets/page.Bi5OEfgq.js +0 -1
- package/public/assets/page.Bi9gIWN0.js +0 -1
- package/public/assets/page.BiLGOe6j.js +0 -1
- package/public/assets/page.BicDCwTa.js +0 -1
- package/public/assets/page.Bjd38gaf.js +0 -1
- package/public/assets/page.Bqk4tX-5.js +0 -1
- package/public/assets/page.BrrSjbBJ.js +0 -1
- package/public/assets/page.BsUeE2Y_.js +0 -1
- package/public/assets/page.BthVvW1e.js +0 -64
- package/public/assets/page.BxAWh20c.js +0 -1
- package/public/assets/page.C-2GmPmS.js +0 -4
- package/public/assets/page.C27wrrub.js +0 -1
- package/public/assets/page.C3FwsCq_.js +0 -23
- package/public/assets/page.C4RMU4Xv.js +0 -23
- package/public/assets/page.C7SC9vwX.js +0 -1
- package/public/assets/page.C8gTAwsH.js +0 -5
- package/public/assets/page.CECQKY1y.js +0 -5
- package/public/assets/page.CEN8xgCA.js +0 -1
- package/public/assets/page.CHG9mx5l.js +0 -1
- package/public/assets/page.CMUOu9fe.js +0 -1
- package/public/assets/page.CRex977Y.js +0 -5
- package/public/assets/page.CUsb0F5t.js +0 -1
- package/public/assets/page.CXE5AWV3.js +0 -1
- package/public/assets/page.CXIP8Wzi.js +0 -4
- package/public/assets/page.CXOuLQhq.js +0 -1
- package/public/assets/page.CXPMjDX9.js +0 -1
- package/public/assets/page.CXPPlybJ.js +0 -6
- package/public/assets/page.CYfjd9SF.js +0 -1
- package/public/assets/page.CZtbttgE.js +0 -1
- package/public/assets/page.CbOSwuwi.js +0 -1
- package/public/assets/page.CbWWyTC4.js +0 -1
- package/public/assets/page.CfXJWUgA.js +0 -1
- package/public/assets/page.CfdTLncK.js +0 -1
- package/public/assets/page.ChqEg6y-.js +0 -1
- package/public/assets/page.CmbatQd6.js +0 -4
- package/public/assets/page.Cp7XaHGI.js +0 -1
- package/public/assets/page.CqR-Z0pY.js +0 -1
- package/public/assets/page.CsLBZFbk.js +0 -1
- package/public/assets/page.CyqTG9Kn.js +0 -2
- package/public/assets/page.CzKSjT-r.js +0 -1
- package/public/assets/page.D1S50DvR.js +0 -1
- package/public/assets/page.D3b1o69R.js +0 -5
- package/public/assets/page.D5B_p_2E.js +0 -31
- package/public/assets/page.D8X-8LSd.js +0 -2
- package/public/assets/page.DA2dX7iN.js +0 -1
- package/public/assets/page.DBNjxgJS.js +0 -6
- package/public/assets/page.DEBBy5qz.js +0 -1
- package/public/assets/page.DEOXc6iv.js +0 -6
- package/public/assets/page.DG46DZcu.js +0 -1
- package/public/assets/page.DGAKp9YS.js +0 -1
- package/public/assets/page.DGico7sP.js +0 -1
- package/public/assets/page.DHBHS2oS.js +0 -1
- package/public/assets/page.DKdtfq8E.js +0 -2
- package/public/assets/page.DKj8qFYb.js +0 -1
- package/public/assets/page.DNofNt4p.js +0 -1
- package/public/assets/page.DVdv-E5d.js +0 -1
- package/public/assets/page.Da-kutqN.js +0 -1
- package/public/assets/page.DaW7T6nt.js +0 -1
- package/public/assets/page.DhPzWwGm.js +0 -1
- package/public/assets/page.Dju6Kwa5.js +0 -1
- package/public/assets/page.Dlh3Q_rt.js +0 -1
- package/public/assets/page.DmNhmYKk.js +0 -64
- package/public/assets/page.Dmvhu2ua.js +0 -1
- package/public/assets/page.Dp30ZzXE.js +0 -1
- package/public/assets/page.DsY8qNEU.js +0 -1
- package/public/assets/page.DtGEStU7.js +0 -1
- package/public/assets/page.DuXsnK8A.js +0 -1
- package/public/assets/page.DwU6Ubqf.js +0 -1
- package/public/assets/page.FmrKiZlG.js +0 -2
- package/public/assets/page.GSAm83Cv.js +0 -6
- package/public/assets/page.IgH-AWcu.js +0 -1
- package/public/assets/page.Ii8wGSnt.js +0 -1
- package/public/assets/page.KtURQA9Q.js +0 -1
- package/public/assets/page.NFGJtdfx.js +0 -1
- package/public/assets/page.QPaIzKAa.js +0 -1
- package/public/assets/page.QuBXfL80.js +0 -1
- package/public/assets/page.S02TdGZT.js +0 -1
- package/public/assets/page.V3CmUOJF.js +0 -1
- package/public/assets/page.VClP2n2B.js +0 -1
- package/public/assets/page.Vo9Oe8DJ.js +0 -1
- package/public/assets/page.WIMFvXoG.js +0 -1
- package/public/assets/page.XUya1XZj.js +0 -23
- package/public/assets/page.XqKIvnmq.js +0 -31
- package/public/assets/page.aAUPKg0H.js +0 -1
- package/public/assets/page.aRQdaBbf.js +0 -1
- package/public/assets/page.e-Zxfi03.js +0 -1
- package/public/assets/page.e-cA5aB5.js +0 -6
- package/public/assets/page.eNXd9f58.js +0 -6
- package/public/assets/page.gj2B5h2d.js +0 -1
- package/public/assets/page.gvZgqycR.js +0 -1
- package/public/assets/page.jvowBQYJ.js +0 -1
- package/public/assets/page.k_WzlZwU.js +0 -5
- package/public/assets/page.qK1RUb_S.js +0 -1
- package/public/assets/page.ryYPRTww.js +0 -1
- package/public/assets/page.xm98_0dX.js +0 -5
- package/public/assets/page.yjCJ-4Uh.js +0 -1
- package/public/providers/agentrouter.webp +0 -0
- package/public/providers/codebuddy-cn.webp +0 -0
- package/public/providers/gigachat.webp +0 -0
- package/public/providers/heroku.webp +0 -0
- package/public/providers/kimchi.webp +0 -0
- package/public/providers/llamagate.webp +0 -0
- package/public/providers/mimo-free.webp +0 -0
- package/public/providers/nanogpt.webp +0 -0
- package/public/providers/nscale.webp +0 -0
- package/public/providers/ovhcloud.webp +0 -0
- package/public/providers/predibase.webp +0 -0
- package/public/providers/zcode.webp +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import{j as e,B as m}from"./index.CoYbjSIL.js";import{b as r}from"./router.Cjj1--8t.js";import{C as Ye,T as Ge,B as qe}from"./NoAuthProxyCard.Buvt0BVH.js";import{L as Xe}from"./Loading.QMOYJhLu.js";import"./zustand.akaTi5uX.js";function it(){const[u,h]=r.useState("codebuddy"),X=(x,ee,f)=>e.jsxs("button",{onClick:()=>h(x),className:`flex items-center gap-2 pb-3 text-sm font-semibold transition-all border-b-2 cursor-pointer ${u===x?"border-primary text-primary":"border-transparent text-text-muted hover:text-text-main"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:ee}),f]});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex border-b border-border-subtle pb-px gap-6 flex-wrap",children:[X("codebuddy","smart_toy","Automation"),X("fsmail","mail","FSMail Temp Mail")]}),u==="codebuddy"&&e.jsx(et,{}),u==="fsmail"&&e.jsx(st,{})]})}function et(){const u={codebuddy:"CodeBuddy",kiro:"Kiro AI",qoder:"Qoder",leonardo:"Leonardo AI",weavy:"Weavy AI","kimi-coding":"Kimi Coding",cloudflare:"Cloudflare Workers AI",openvecta:"OpenVecta",flashloop:"Flashloop"},[h,X]=r.useState([]),[x,ee]=r.useState(""),[f,te]=r.useState(null),[N,I]=r.useState([]);r.useRef(null);const $=r.useRef(new Set),[se,ue]=r.useState(1),ae=r.useRef(-1),pe=10,Se=r.useRef(!1),[g,Ue]=r.useState(!1),[K,Ce]=r.useState(3),[$e,re]=r.useState(!1),[ne,he]=r.useState(!1),[A,Re]=r.useState(""),[_e,j]=r.useState(""),[i,R]=r.useState("cloudflare"),[G,be]=r.useState(!0),[O,U]=r.useState(!1),[Te,We]=r.useState(!1),[oe,fe]=r.useState(!1),[k,V]=r.useState([]),[ze,W]=r.useState(!1),[ge,le]=r.useState(""),[Be,Ae]=r.useState(""),[Fe,S]=r.useState(""),[Le,Q]=r.useState(!1),[z,L]=r.useState({general:!0,proxy:!1}),C=t=>{L(a=>({...a,[t]:!a[t]}))},Pe=(t,a,n,l)=>e.jsxs("button",{onClick:l,type:"button",className:"flex items-center gap-1.5 hover:text-primary text-text-main font-semibold text-xs transition-all cursor-pointer select-none py-1",children:[e.jsx("span",{className:`material-symbols-outlined text-[16px] text-text-muted transition-transform duration-200 ${n?"":"-rotate-90"}`,children:"expand_more"}),e.jsx("span",{children:t})]}),[_,Z]=r.useState(!1),[D,B]=r.useState(0),[F,je]=r.useState({}),[d,ie]=r.useState(!1),[T,J]=r.useState(new Set),[M,Je]=r.useState(!1),[ye,Oe]=r.useState(5),[we,He]=r.useState([]),[ce,de]=r.useState("");r.useEffect(()=>{if(typeof window<"u"){const t=localStorage.getItem("automation_target_provider");R(t||"cloudflare");const a=localStorage.getItem("automation_concurrency");a&&Ce(parseInt(a)||3);const n=localStorage.getItem("automation_auto_email");n&&Je(n==="1");const l=localStorage.getItem("automation_generate_count");l&&Oe(parseInt(l)||5);const b=localStorage.getItem("automation_open_settings");if(b)try{L(c=>({...c,...JSON.parse(b)}))}catch(c){console.error("Failed to parse saved automation open settings",c)}Ue(!0)}},[]),r.useEffect(()=>{g&&localStorage.setItem("automation_target_provider",i)},[i,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_concurrency",String(K))},[K,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_auto_email",M?"1":"0")},[M,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_generate_count",String(ye))},[ye,g]),r.useEffect(()=>{g&&localStorage.setItem("automation_open_settings",JSON.stringify(z))},[z,g]);const[y,Ve]=r.useState(""),[xe,De]=r.useState(1),Me=8;r.useEffect(()=>{fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"list-domains"})}).then(t=>t.json()).then(t=>{var a;(a=t.domains)!=null&&a.length&&(He(t.domains),de(n=>n||t.default_domain||t.domains[0]))}).catch(()=>{})},[]);const w=async(t=!1)=>{var a,n;try{const l=await fetch("/api/automation/codebuddy"),b=await l.json();if(l.ok){if(X(b.accounts||[]),ee(b.active_job_id||""),b.active_job_id&&Se.current&&(Se.current=!1,$.current.clear()),!Se.current)if(te(b.active_job||null),(n=(a=b.active_job)==null?void 0:a.results)!=null&&n.length){const c=b.active_job.results.filter(p=>p).map((p,ke)=>({idx:ke,email:p.email||`Account #${ke+1}`,status:p.status||"pending",step:p.status==="failed"?p.error||p.step||"-":p.step||"-",ok:p.ok})).filter(p=>!$.current.has(p.email.toLowerCase()));I(c)}else b.active_job_id;if(t){const c=b.settings||{};re(c.auto_fsrouter==="1"||c.auto_fsrouter===!0),be(!!c.browser_headless),U(!!c.debug_mode),We(c.leave_canva_team==="1"||c.leave_canva_team===!0),fe(!!c.proxy_enabled);try{const p=JSON.parse(c.proxy_pool||"[]");V(Array.isArray(p)?p:[])}catch{V([])}Ae(c.leonardo_invite_link||""),S(c.codebuddy_2captcha_api_key||"")}}}catch(l){console.error(l)}};r.useEffect(()=>{g&&w(!0)},[g]),r.useEffect(()=>{if(!g)return;const a=setInterval(()=>w(!1),x?3e3:15e3);return()=>clearInterval(a)},[g,x]),r.useEffect(()=>{if(N.length===0){ue(1),ae.current=-1;return}const t=N.findIndex(a=>a.status==="running");if(t!==-1&&t!==ae.current){ae.current=t;const a=Math.floor(t/pe)+1;ue(a)}},[N]),r.useEffect(()=>{if(O&&x){const t=setInterval(()=>{fetch("/api/automation/codebuddy/debug-vnc?action=status").then(a=>a.json()).then(a=>{a.available&&(Z(!0),B(Date.now()),clearInterval(t))}).catch(()=>{})},2e3);return()=>clearInterval(t)}else if(!x&&_){const t=setTimeout(()=>{Z(!1),B(0)},1e4);return()=>clearTimeout(t)}},[O,x]);const Qe=async()=>{Q(!0);try{(await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",auto_fsrouter:$e,browser_headless:G,debug_mode:O,leave_canva_team:Te,proxy_enabled:oe,proxy_pool:JSON.stringify(k),leonardo_invite_link:Be,codebuddy_2captcha_api_key:Fe})})).ok&&(j("Settings saved successfully."),setTimeout(()=>j(""),3e3),await w(!0))}catch(t){console.error(t)}finally{Q(!1)}},Ze=async()=>{var t,a;if(!A.trim()){j("Please enter at least one email:password line.");return}j("Adding accounts...");try{const n=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add-google",accounts_text:A,run_now:ne,concurrency:K,provider:i})}),l=await n.json();n.ok?(Re(""),j(`Created: ${((t=l.created)==null?void 0:t.length)||0}, Skipped: ${((a=l.skipped)==null?void 0:a.length)||0}${l.job_id?" (Job started)":""}`),w()):j(`Error: ${l.error}`)}catch(n){j(`Failed: ${n.message}`)}},Ee=async()=>{var t;j("Generating emails...");try{const a=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auto-generate-email",count:ye,provider:i,run_now:!0,concurrency:K,domain:ce||void 0})}),n=await a.json();a.ok?(j(`✓ Generated ${((t=n.created)==null?void 0:t.length)||0} temp mail accounts and started signup job.`),w()):j(`Error: ${n.error||"Failed to generate emails"}`)}catch(a){console.error(a),j("Failed to contact server.")}},Ie=async()=>{try{const t=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run-all",concurrency:K,provider:i})}),a=await t.json();t.ok?($.current.clear(),ee(a.job_id),w()):j(`Failed: ${a.error}`)}catch(t){j(`Failed: ${t.message}`)}},E=async()=>{try{const t=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"stop"})}),a=await t.json();t.ok?w():alert(a.error)}catch(t){console.error(t)}},ve=async t=>{try{const a=await fetch(`/api/automation/codebuddy/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run"})}),n=await a.json();a.ok?($.current.clear(),ee(n.job_id),w()):alert(n.error)}catch(a){console.error(a)}},Ne=async t=>{try{const a=await fetch(`/api/automation/codebuddy/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"add-to-fsrouter"})}),n=await a.json();a.ok?(alert(`✓ ${n.message||"Added successfully!"}`),w()):alert(`Failed: ${n.error}`)}catch(a){console.error(a)}},s=async()=>{const t=u[i]||"CodeBuddy";if(confirm(`Inject all Ready ${t} accounts into fsrouter?`))try{const a=await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"bulk-add-to-fsrouter",provider:i})}),n=await a.json();a.ok?(alert(n.message),w()):alert(`Failed: ${n.error}`)}catch(a){console.error(a)}},o=async t=>{if(!confirm("Hapus akun ini?"))return;const a=confirm("Apakah ingin menghapus juga koneksi akun ini di fsrouter?"),n=h.find(l=>l.id===t);try{await fetch(`/api/automation/codebuddy/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",deleteFromfsrouter:a})}),n&&($.current.add(n.email.toLowerCase()),I(l=>l.filter(b=>b.email.toLowerCase()!==n.email.toLowerCase()))),w()}catch(l){console.error(l)}},v=async(t,a=null)=>{const n=a?`${a.length} selected accounts`:`all accounts with status: ${t.join(", ")}`;if(!confirm(`Delete ${n}?`))return;const l=confirm("Apakah ingin menghapus juga koneksi akun-akun tersebut di fsrouter?"),b=h.filter(c=>a?a.includes(c.id):c.provider===i&&t.includes(c.api_key_status)).map(c=>c.email.toLowerCase());try{(await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a?{action:"bulk-delete-ids",ids:a,provider:i,deleteFromfsrouter:l}:{action:"bulk-delete",statuses:t,provider:i,deleteFromfsrouter:l})})).ok&&(b.forEach(p=>$.current.add(p)),I(p=>p.filter(ke=>!b.includes(ke.email.toLowerCase()))),J(new Set),w())}catch(c){console.error(c)}},P=h.filter(t=>t.provider===i&&(t.email.toLowerCase().includes(y.toLowerCase())||t.api_key&&t.api_key.toLowerCase().includes(y.toLowerCase()))),me=Math.ceil(P.length/Me),H=P.slice((xe-1)*Me,xe*Me),Y=Math.ceil(N.length/pe)||1,q=Math.min(se,Y),Ke=N.slice((q-1)*pe,q*pe);return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 space-y-6",children:[e.jsxs(Ye,{padding:"md",className:"space-y-4",children:[e.jsxs("h2",{className:"text-sm font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"person_add"}),(i==="leonardo"||i==="weavy"||i==="cloudflare")&&M?"Generate Temp Accounts":"Add Accounts"]}),e.jsxs("div",{className:"flex flex-col gap-1.5 pb-1",children:[e.jsx("label",{className:"text-xs font-semibold text-text-main",children:"Target Provider Connection"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:i==="weavy"?"/providers/weavy.jpeg":i==="kimi-coding"?"/providers/kimi.png":`/providers/${i}.png`,alt:i,className:"size-5 rounded object-contain",onError:t=>{t.target.style.display="none"}}),e.jsxs("select",{value:i,onChange:t=>{const a=t.target.value;R(a),De(1)},className:"flex-1 text-xs p-2 rounded-lg border border-border-subtle bg-surface text-text-main focus:outline-none focus:border-primary cursor-pointer",children:[e.jsx("option",{value:"cloudflare",children:"☁️ Cloudflare Workers AI"}),e.jsx("option",{value:"openvecta",children:"🟣 OpenVecta"}),e.jsx("option",{value:"flashloop",children:"⚡ Flashloop"})]})]})]}),(i==="leonardo"||i==="weavy"||i==="cloudflare"||i==="openvecta"||i==="flashloop")&&e.jsx("div",{className:"pt-1 border-t border-border-subtle",children:e.jsxs("label",{className:"flex items-center gap-2 text-xs text-text-main cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:t=>Je(t.target.checked),className:"rounded border-border-subtle accent-primary size-4"}),"Auto Generate Email (FSMail)"]})}),(i==="leonardo"||i==="weavy"||i==="cloudflare"||i==="openvecta"||i==="flashloop")&&M?e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Count to generate:"}),e.jsx("input",{type:"number",min:1,max:50,value:ye,onChange:t=>Oe(parseInt(t.target.value)||1),className:"w-16 text-xs p-1.5 rounded-lg border border-border-subtle bg-surface text-center text-text-main"})]}),we.length>=1&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Email domain:"}),e.jsx("select",{value:ce,onChange:t=>de(t.target.value),className:"flex-1 text-xs p-1.5 rounded-lg border border-border-subtle bg-surface text-text-main ml-2 max-w-[180px]",children:we.map(t=>e.jsxs("option",{value:t,children:["@",t]},t))})]}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:Ee,children:"Generate & Run"})]}):e.jsxs("div",{className:"space-y-4 pt-1",children:[e.jsxs("p",{className:"text-xs text-text-muted",children:["Format: ",e.jsx("code",{className:"bg-surface-2 px-1 rounded",children:"email:password"})," (one per line)."]}),e.jsx("textarea",{value:A,onChange:t=>Re(t.target.value),rows:4,placeholder:`user1@gmail.com:Passw0rd1
|
|
2
|
-
user2@gmail.com:Passw0rd2`,className:"w-full text-xs font-mono p-3 rounded-lg border border-border-subtle bg-surface focus:outline-none focus:border-primary resize-y text-text-main"}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs text-text-main cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ne,onChange:t=>he(t.target.checked),className:"rounded border-border-subtle accent-primary size-4"}),"Run immediately"]}),e.jsx(m,{variant:"primary",size:"sm",onClick:Ze,children:"Add Accounts"})]})]}),_e&&e.jsx("p",{className:"text-[11px] text-primary italic",children:_e})]}),e.jsxs(Ye,{padding:"md",className:"space-y-4",children:[e.jsxs("h2",{className:"text-sm font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"settings"}),"Automation Settings"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[Pe("General Settings","dns",z.general,()=>C("general")),z.general&&e.jsxs("div",{className:"pl-6 pr-2 py-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Headless Browser"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Jalankan di latar belakang tanpa membuka jendela baru"})]}),e.jsx(Ge,{checked:G,onChange:be})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Tampilkan Preview Panel"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Aktifkan live stream visual di bawah"})]}),e.jsx(Ge,{checked:O,onChange:U})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Auto Inject to fsrouter"}),e.jsx(Ge,{checked:$e,onChange:re})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[Pe("Outbound Proxy Settings","vpn_lock",z.proxy,()=>C("proxy")),z.proxy&&e.jsxs("div",{className:"pl-6 pr-2 py-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-xs font-medium text-text-main",children:"Enable Outbound Proxy"}),e.jsx(Ge,{checked:oe,onChange:fe})]}),oe&&e.jsxs("div",{className:"space-y-2 pt-1 border-t border-border-subtle",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[11px] text-text-muted",children:[k.length," ",k.length===1?"proxy":"proxies"," configured"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[k.length>0&&e.jsx("button",{onClick:async()=>{if(d)return;ie(!0);const t={};for(const a of k){t[a]={testing:!0},je({...t});try{const l=await(await fetch("/api/automation/codebuddy/test-proxy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxy:a})})).json();t[a]=l}catch{t[a]={ok:!1,error:"Request failed"}}je({...t})}ie(!1)},disabled:d,className:`text-[11px] px-3 py-1 rounded-lg border font-medium transition-colors ${d?"bg-surface-2 border-border-subtle text-text-muted cursor-wait":"bg-surface-2 border-border-subtle hover:border-green-500 text-green-400 hover:text-green-300"}`,children:d?"⏳ Testing...":"🧪 Test"}),e.jsx("button",{onClick:()=>{le(k.join(`
|
|
3
|
-
`)),W(!0)},className:"text-[11px] px-3 py-1 rounded-lg bg-surface-2 border border-border-subtle hover:border-primary text-primary font-medium transition-colors",children:"✏️ Edit"})]})]}),k.length>0&&e.jsx("div",{className:"text-[10px] bg-surface-2 rounded-lg p-2 max-h-[120px] overflow-y-auto font-mono space-y-1",children:k.map((t,a)=>{const n=F[t],l=t.replace(/:[^:@]*@/,":***@");return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-text-muted flex-1",title:l,children:l}),n&&e.jsx("span",{className:`shrink-0 whitespace-nowrap ${n.testing?"text-yellow-400":n.ok?"text-green-400":"text-red-400"}`,children:n.testing?"⏳":n.ok?`✅ ${n.ip} · ${n.latency}ms`:`❌ ${n.error}`})]},a)})})]})]})]}),e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:Qe,disabled:Le,children:Le?"Saving...":"Save Settings"})]})]})]}),e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[(x||N.length>0)&&e.jsxs("div",{className:"border border-border-subtle bg-surface-2 rounded-xl p-4 space-y-3 relative overflow-hidden",children:[f&&e.jsx("div",{className:"absolute top-0 left-0 h-1 bg-gradient-to-r from-primary to-green-500 transition-all duration-500",style:{width:`${f.progress||0}%`}}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[x?e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary animate-spin",children:"autorenew"}):(f==null?void 0:f.status)==="stopped"?e.jsx("span",{className:"material-symbols-outlined text-[18px] text-red-400",children:"cancel"}):e.jsx("span",{className:"material-symbols-outlined text-[18px] text-green-400",children:"check_circle"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-text-main",children:x?"Job Running":(f==null?void 0:f.status)==="stopped"?"Job Stopped":"Job Completed"}),f&&e.jsxs("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Progress: ",f.completed,"/",f.count," ·",e.jsxs("span",{className:"text-green-400 ml-1",children:["✓ ",f.success]}),e.jsxs("span",{className:"text-red-400 ml-1",children:["✗ ",f.failed]})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[!x&&N.length>0&&e.jsx(m,{variant:"ghost",size:"sm",onClick:async()=>{Se.current=!0,N.forEach(t=>$.current.add(t.email.toLowerCase())),I([]),te(null);try{await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"clear-logs"})})}catch{}},children:"Clear"}),x&&e.jsx(m,{variant:"danger",size:"sm",onClick:E,children:"■ Stop"})]})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto overflow-x-auto rounded-lg bg-black/40 border border-border/40 text-[11px] font-mono",children:e.jsxs("table",{className:"w-full min-w-[540px]",children:[e.jsx("thead",{className:"sticky top-0 bg-black/80 backdrop-blur-sm",children:e.jsxs("tr",{className:"text-text-muted text-left",children:[e.jsx("th",{className:"px-2 py-1 w-6",children:"#"}),e.jsx("th",{className:"px-2 py-1",children:"Email"}),e.jsx("th",{className:"px-2 py-1 w-16",children:"Status"}),e.jsx("th",{className:"px-2 py-1",children:"Step"}),e.jsx("th",{className:"px-2 py-1 w-14 text-right",children:"Time"}),e.jsx("th",{className:"px-2 py-1 w-12 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:N.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-2 py-2 text-center text-text-muted",children:"Waiting for log entries..."})}):Ke.map((t,a)=>{var c;const n=(c=t.step)==null?void 0:c.match(/\[([^\]]+s)\]$/),l=n?t.step.replace(n[0],"").trim():t.step,b=n?n[1]:"--";return e.jsxs("tr",{className:`border-t border-border/20 ${t.status==="failed"?"bg-red-500/5":t.status==="done"?"bg-green-500/5":""}`,children:[e.jsx("td",{className:"px-2 py-1 text-text-muted",children:t.idx+1}),e.jsx("td",{className:"px-2 py-1 text-text-main truncate max-w-[160px]",title:t.email,children:t.email}),e.jsxs("td",{className:"px-2 py-1 whitespace-nowrap",children:[t.status==="running"&&e.jsx("span",{className:"text-blue-400",children:"● run"}),t.status==="done"&&e.jsx("span",{className:"text-green-400",children:"✓ ok"}),t.status==="failed"&&e.jsx("span",{className:"text-red-400",children:"✗ fail"}),t.status==="pending"&&e.jsx("span",{className:"text-text-muted",children:"◌"})]}),e.jsx("td",{className:"px-2 py-1 text-text-muted truncate max-w-[280px]",title:t.status==="done"?t.balance!==void 0?`Success · ${t.balance} tokens${t.left_team===!0?" · Left team ✓":t.left_team===!1?" · Left team ✗":""}`:"Success":l,children:t.status==="done"?e.jsxs("span",{className:"text-green-400 font-medium",children:[t.balance!==void 0?`Success · ${t.balance} tokens`:"Success",t.left_team===!0&&e.jsx("span",{className:"text-purple-400 ml-1",children:"· Left team ✓"}),t.left_team===!1&&e.jsx("span",{className:"text-yellow-400 ml-1",children:"· Left team ✗"})]}):l}),e.jsx("td",{className:"px-2 py-1 text-right text-[10px] text-text-muted font-mono",children:b}),e.jsx("td",{className:"px-2 py-1 text-right whitespace-nowrap",children:t.status==="failed"&&e.jsx("button",{onClick:()=>{const p=h.find(ke=>ke.email.toLowerCase()===t.email.toLowerCase());p?ve(p.id):alert("Account tidak ditemukan.")},disabled:!!x,className:`text-[9px] font-bold px-1.5 py-0.5 rounded cursor-pointer transition-colors ${x?"text-text-muted bg-surface-3 cursor-not-allowed opacity-50":"text-brand-400 hover:text-brand-300 hover:bg-brand-500/15 bg-brand-500/5"}`,children:"Retry"})})]},a)})})]})}),Y>1&&e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-2",children:[e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>ue(t=>Math.max(1,t-1)),disabled:q===1,children:"Previous"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Page ",q," of ",Y," · (",N.length," items)"]}),e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>ue(t=>Math.min(Y,t+1)),disabled:q===Y,children:"Next"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("h2",{className:"text-sm font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"group"}),"Accounts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[h.filter(t=>t.provider===i).length," total"]}),e.jsxs(qe,{variant:"success",size:"sm",children:[h.filter(t=>t.provider===i&&t.api_key_status==="ready").length," ready"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("input",{type:"text",placeholder:"Search email...",value:y,onChange:t=>Ve(t.target.value),className:"text-xs p-2 rounded-lg border border-border-subtle bg-surface focus:outline-none focus:border-primary w-48"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("label",{className:"text-xs text-text-main flex items-center gap-1",children:["Limit:",e.jsx("input",{type:"number",min:1,max:20,value:K,onChange:t=>Ce(parseInt(t.target.value)||3),className:"w-12 text-center p-1 rounded border border-border-subtle bg-surface"})]}),e.jsx(m,{variant:"primary",size:"sm",onClick:Ie,disabled:!!x,children:"Run All Pending"}),e.jsx(m,{variant:"secondary",size:"sm",onClick:s,children:"⚡ Add All Ready → fsrouter"}),e.jsx(m,{variant:"danger",size:"sm",onClick:()=>v(["pending","failed"]),children:"🗑 Delete Pending/Failed"})]})]}),T.size>0&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-xs",children:[e.jsxs("span",{className:"text-primary font-semibold",children:[T.size," selected"]}),e.jsx("span",{className:"text-text-muted",children:"·"}),e.jsx("button",{onClick:async()=>{const t=[...T];J(new Set),await Promise.all(t.map(a=>ve(a)))},disabled:!!x,className:"text-brand-400 hover:text-brand-300 font-semibold disabled:opacity-40 disabled:cursor-not-allowed",children:"▶ Run Selected"}),e.jsx("span",{className:"text-text-muted",children:"·"}),e.jsx("button",{onClick:()=>v(null,[...T]),className:"text-red-400 hover:text-red-300 font-semibold",children:"🗑 Delete Selected"}),e.jsx("button",{onClick:()=>J(new Set),className:"ml-auto text-text-muted hover:text-text-main",children:"✕ Clear"})]}),e.jsx("div",{className:"rounded-xl border border-border-subtle bg-surface-2 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs text-left border-collapse min-w-[640px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface text-text-muted border-b border-border-subtle font-semibold",children:[e.jsx("th",{className:"p-2.5 w-8",children:e.jsx("input",{type:"checkbox",className:"rounded cursor-pointer accent-primary",checked:H.length>0&&H.every(t=>T.has(t.id)),onChange:t=>{t.target.checked?J(a=>new Set([...a,...H.map(n=>n.id)])):J(a=>{const n=new Set(a);return H.forEach(l=>n.delete(l.id)),n})}})}),e.jsx("th",{className:"p-2.5 w-10",children:"#"}),e.jsx("th",{className:"p-2.5",children:"Email"}),e.jsx("th",{className:"p-2.5 w-24",children:"Status"}),e.jsx("th",{className:"p-2.5",children:"API Key"}),e.jsx("th",{className:"p-2.5 text-right",children:"Actions"})]})}),e.jsxs("tbody",{children:[H.map(t=>e.jsxs("tr",{className:`border-b border-border-subtle transition-colors ${T.has(t.id)?"bg-primary/5":"hover:bg-surface/50"}`,children:[e.jsx("td",{className:"p-2.5",children:e.jsx("input",{type:"checkbox",className:"rounded cursor-pointer accent-primary",checked:T.has(t.id),onChange:a=>{J(n=>{const l=new Set(n);return a.target.checked?l.add(t.id):l.delete(t.id),l})}})}),e.jsxs("td",{className:"p-2.5 font-mono text-text-muted",children:["#",t.id]}),e.jsx("td",{className:"p-2.5 font-semibold text-text-main truncate max-w-[100px] sm:max-w-[140px] sm:max-w-[200px]",title:t.email,children:t.email}),e.jsxs("td",{className:"p-2.5",children:[e.jsx(qe,{variant:t.api_key_status==="ready"?"success":t.api_key_status==="failed"?"danger":t.api_key_status==="running"?"primary":"default",size:"sm",children:t.api_key_status}),t.last_error&&e.jsxs("p",{className:"text-[10px] text-red-500 mt-0.5 truncate max-w-[150px]",title:t.last_error,children:["⚠ ",t.last_error]})]}),e.jsx("td",{className:"p-2.5",children:t.api_key?e.jsx("code",{className:"bg-surface px-1.5 py-0.5 rounded font-mono text-[10px] text-text-main max-w-[100px] sm:max-w-[140px] block truncate",title:t.api_key,children:t.api_key}):e.jsx("span",{className:"text-text-muted",children:"—"})}),e.jsx("td",{className:"p-2.5 text-right whitespace-nowrap",children:e.jsxs("div",{className:"inline-flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>ve(t.id),disabled:!!x||t.api_key_status==="running",className:`inline-flex items-center gap-0.5 text-[11px] font-bold transition-all cursor-pointer ${x||t.api_key_status==="running"?"text-text-muted cursor-not-allowed opacity-40":"text-brand-400 hover:text-brand-300 hover:underline"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"play_arrow"}),"Process"]}),t.api_key_status==="ready"&&t.api_key&&e.jsxs("button",{onClick:()=>Ne(t.id),className:"inline-flex items-center gap-0.5 text-[11px] font-bold text-green-400 hover:text-green-300 hover:underline transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"add_link"}),"+fsrouter"]}),e.jsxs("button",{onClick:()=>o(t.id),className:"inline-flex items-center gap-0.5 text-[11px] font-bold text-red-400 hover:text-red-300 hover:underline transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"delete"}),"Delete"]})]})})]},t.id)),H.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"p-6 text-center text-text-muted",children:"No accounts found. Add manual accounts to get started."})})]})]})}),me>1&&e.jsxs("div",{className:"flex items-center justify-between gap-4 pt-2",children:[e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>De(t=>Math.max(1,t-1)),disabled:xe===1,children:"Previous"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["Page ",xe," of ",me]}),e.jsx(m,{variant:"secondary",size:"sm",onClick:()=>De(t=>Math.min(me,t+1)),disabled:xe===me,children:"Next"})]})]})]})]}),O&&e.jsxs(Ye,{padding:"md",className:"space-y-3 border border-brand-500/20 bg-brand-500/5 mt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-xs font-bold text-brand-400 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"bug_report"}),"🖥️ Live Browser Preview"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!_&&e.jsx("span",{className:"text-[10px] text-text-muted",children:x?"Starting...":"Run a job to see the browser"}),_&&e.jsxs("span",{className:"text-[10px] text-green-400 flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-400 animate-pulse"}),"Live · ~2fps"]})]})]}),e.jsx("div",{className:"relative rounded-lg overflow-hidden border border-border-subtle bg-black",style:{aspectRatio:"16/10"},children:_?e.jsx("img",{src:`/api/automation/codebuddy/debug-vnc?action=screenshot&t=${D}`,alt:"Browser preview",className:"w-full h-full object-contain",style:{minHeight:"400px",imageRendering:"auto"},onLoad:()=>{O&&x&&setTimeout(()=>B(Date.now()),400)},onError:()=>{setTimeout(()=>B(Date.now()),2e3)}},"debug-screenshot"):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[32px] text-text-muted",children:"desktop_windows"}),e.jsx("p",{className:"text-xs text-text-muted",children:x?"Starting browser preview...":"Run a job with Debug Mode to see live browser"})]})})})]}),ze&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>W(!1),children:e.jsxs("div",{className:"bg-surface border border-border-subtle rounded-2xl shadow-2xl w-full max-w-lg mx-4 max-h-[90vh] overflow-hidden",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"p-5 border-b border-border-subtle",children:[e.jsxs("h3",{className:"text-base font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary",children:"dns"}),"Edit Proxy Pool"]}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Enter one proxy per line. A random proxy will be selected for each automation run."})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("textarea",{value:ge,onChange:t=>le(t.target.value),placeholder:`socks5://user:pass@host:port
|
|
4
|
-
http://host:port
|
|
5
|
-
host:port:user:pass
|
|
6
|
-
host:port`,rows:10,className:"w-full text-xs p-3 rounded-xl border border-border-subtle bg-surface-2 focus:outline-none focus:border-primary text-text-main font-mono resize-none",spellCheck:!1}),e.jsxs("div",{className:"text-[10px] text-text-muted bg-surface-2 rounded-lg p-3 space-y-1",children:[e.jsx("div",{className:"font-semibold text-text-main mb-1",children:"Supported formats:"}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"socks5://user:pass@host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"http://user:pass@host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"socks5://host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"http://host:port"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"host:port:user:pass"})}),e.jsx("div",{children:e.jsx("code",{className:"text-primary",children:"host:port"})})]})]}),e.jsxs("div",{className:"p-5 border-t border-border-subtle flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[ge.split(`
|
|
7
|
-
`).filter(t=>t.trim()).length," proxies"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>W(!1),className:"px-4 py-2 text-xs rounded-lg border border-border-subtle text-text-muted hover:text-text-main transition-colors",children:"Cancel"}),e.jsx("button",{onClick:async()=>{const t=ge.split(`
|
|
8
|
-
`).map(a=>a.trim()).filter(Boolean);V(t),W(!1);try{await fetch("/api/automation/codebuddy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",proxy_enabled:!0,proxy_pool:JSON.stringify(t)})})}catch{}},className:"px-4 py-2 text-xs rounded-lg bg-primary text-white font-medium hover:opacity-90 transition-opacity",children:"Save Proxies"})]})]})]})})]})}function tt(u){if(!u)return"";const h=`
|
|
9
|
-
<style id="router-injected-styles">
|
|
10
|
-
html, body {
|
|
11
|
-
overflow-x: auto !important;
|
|
12
|
-
overflow-y: auto !important;
|
|
13
|
-
margin: 0 !important;
|
|
14
|
-
padding: 12px !important;
|
|
15
|
-
background-color: #ffffff !important;
|
|
16
|
-
color: #000000 !important;
|
|
17
|
-
}
|
|
18
|
-
img {
|
|
19
|
-
max-width: 100% !important;
|
|
20
|
-
height: auto !important;
|
|
21
|
-
}
|
|
22
|
-
</style>
|
|
23
|
-
`;return u.includes("<head>")?u.replace("<head>",`<head>${h}`):u.includes("<HEAD>")?u.replace("<HEAD>",`<HEAD>${h}`):u.includes("<body>")?u.replace("<body>",`<body>${h}`):u.includes("<BODY>")?u.replace("<BODY>",`<BODY>${h}`):h+u}function st(){const[u,h]=r.useState(!1),[X,x]=r.useState(!1),[ee,f]=r.useState(!0),[te,N]=r.useState(!1),[I,$]=r.useState(""),[se,ue]=r.useState([]),[ae,pe]=r.useState([]),[Se,g]=r.useState(null),[Ue,K]=r.useState(""),[Ce,$e]=r.useState([]),[re,ne]=r.useState(1),[he,A]=r.useState(!1),[Re,_e]=r.useState(!1),[j,i]=r.useState(!1),[R,G]=r.useState(""),[be,O]=r.useState(""),[U,Te]=r.useState(""),[We,oe]=r.useState(""),[fe,k]=r.useState("manual"),[V,ze]=r.useState(""),[W,ge]=r.useState(""),[le,Be]=r.useState(""),[Ae,Fe]=r.useState(""),[S,Le]=r.useState(""),[Q,z]=r.useState({}),[L,C]=r.useState(null),Pe=r.useRef(!1);r.useEffect(()=>{Pe.current=he,he||C(null)},[he]);const[_,Z]=r.useState("all"),[D,B]=r.useState(""),[F,je]=r.useState(null),[d,ie]=r.useState(null),[T,J]=r.useState("html"),[M,Je]=r.useState(""),[ye,Oe]=r.useState(!1),[we,He]=r.useState(""),[ce,de]=r.useState(""),y=async()=>{var s,o,v,P,me,H,Y,q,Ke;try{const t=await fetch("/api/automation/fsmail"),a=await t.json();if(t.ok){x(a.configured),N(a.connection_ok),$(a.connection_error),ue(a.domains||[]);const n=a.inboxes||[];pe(n),B(l=>l&&n.some(c=>c.address.toLowerCase()===l.toLowerCase())?l:n.length>0?n[0].address:""),g(a.webhook),K(a.webhook_url),$e(a.otps||[]),Pe.current||(G(((s=a.settings)==null?void 0:s.base_url)||""),O(((o=a.settings)==null?void 0:o.api_key)||""),Te(((v=a.settings)==null?void 0:v.default_domain)||""),oe(((P=a.settings)==null?void 0:P.webhook_secret)||""),ze(((me=a.settings)==null?void 0:me.cf_account_id)||""),ge(((H=a.settings)==null?void 0:H.cf_api_token)||""),Be(((Y=a.settings)==null?void 0:Y.cf_domain)||""),Fe(((q=a.settings)==null?void 0:q.cf_telegram_bot_token)||""),Le(((Ke=a.settings)==null?void 0:Ke.cf_workers_dev_url)||""))}}catch(t){console.error(t)}finally{f(!1)}};r.useEffect(()=>{y();const s=setInterval(y,5e3);return()=>clearInterval(s)},[]);const Ve=async()=>{try{(await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",base_url:R,api_key:be,default_domain:U,webhook_secret:We,cf_account_id:V,cf_api_token:W,cf_domain:le,cf_telegram_bot_token:Ae,cf_workers_dev_url:S})})).ok&&(A(!1),y())}catch(s){alert(`Save failed: ${s.message}`)}},xe=async()=>{h(!0),C(null);try{const s=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"test-connection",base_url:R,api_key:be})}),o=await s.json();s.ok?(C({ok:!0,message:"Koneksi ke worker berhasil!"}),y()):C({ok:!1,message:`Koneksi gagal: ${o.error}`})}catch(s){C({ok:!1,message:`Error: ${s.message}`})}finally{h(!1)}},De=async()=>{if(!V||!W||!le){alert("Account ID, API Token, dan Domain wajib diisi!");return}h(!0),C(null);try{const s=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auto-deploy",cf_account_id:V,cf_api_token:W,cf_domain:le,telegram_bot_token:Ae})}),o=await s.json();s.ok?(C({ok:!0,message:"Sukses! Worker telah di-deploy ke Cloudflare dan siap digunakan."}),G(o.base_url||""),O(o.api_key||""),Te(o.default_domain||""),oe(o.webhook_secret||""),Le(o.cf_workers_dev_url||""),y()):C({ok:!1,message:`Deploy gagal: ${o.error}`})}catch(s){C({ok:!1,message:`Error: ${s.message}`})}finally{h(!1)}},Me=async()=>{try{const s=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"webhook-register"})}),o=await s.json();s.ok?(alert("Webhook registered successfully!"),y()):alert(`Failed: ${o.error}`)}catch(s){alert(`Error: ${s.message}`)}},w=async s=>{s.preventDefault();try{const o=await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"inbox-create",alias:we,domain:ce})}),v=await o.json();if(o.ok){i(!1);const P=`${we}@${ce}`.toLowerCase();B(P),He(""),de(""),y()}else alert(v.error)}catch(o){alert(o.message)}},Qe=async s=>{if(confirm(`Hapus inbox ${s}?`))try{(await fetch("/api/automation/fsmail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"inbox-delete",alias:s})})).ok&&(D&&D.split("@")[0]===s&&B(""),d&&d.alias===s&&(je(null),ie(null)),y())}catch(o){console.error(o)}},Ze=async s=>{je(s),ie(null),ne(1);try{const o=await fetch(`/api/automation/fsmail/otps/${s}`),v=await o.json();o.ok&&(ie(v.otp),y())}catch(o){console.error(o)}},Ee=async(s,o)=>{if(s.stopPropagation(),!!confirm("Delete this email?"))try{await fetch(`/api/automation/fsmail/otps/${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete"})}),F===o&&(je(null),ie(null)),y()}catch(v){console.error(v)}},Ie=s=>{navigator.clipboard.writeText(s),z(o=>({...o,[s]:!0})),setTimeout(()=>{z(o=>({...o,[s]:!1}))},1500)},E=({value:s,text:o="Copy",className:v=""})=>{const P=Q[s];return e.jsxs("button",{type:"button",onClick:()=>Ie(s),className:`text-[10px] px-2 py-1 rounded cursor-pointer transition-all duration-150 flex items-center gap-1 border font-semibold ${P?"text-green-400 bg-green-500/10 border-green-500/20":"text-white/50 hover:text-white bg-white/5 hover:bg-white/10 border-transparent"} ${v}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:P?"check":"content_copy"}),P?"Copied":o]})},ve=Ce.filter(s=>{if(!D||s.address.toLowerCase()!==D.toLowerCase()||_==="unread"&&s.used_at||_==="read"&&!s.used_at||_==="otp"&&!s.otp_code)return!1;if(M){const o=M.toLowerCase();return s.sender.toLowerCase().includes(o)||s.subject.toLowerCase().includes(o)||s.otp_code&&s.otp_code.includes(o)}return!0}),Ne=s=>Ce.filter(o=>!(!D||o.address.toLowerCase()!==D.toLowerCase()||s==="unread"&&o.used_at||s==="read"&&!o.used_at||s==="otp"&&!o.otp_code)).length;return e.jsxs("div",{className:"border border-border-subtle rounded-2xl overflow-hidden bg-vibrancy backdrop-blur-xl flex flex-col h-[calc(100vh-210px)] min-h-[500px] shadow-[var(--shadow-warm)]",children:[ee?e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center space-y-3",children:e.jsx(Xe,{size:"lg",label:"Memuat setelan Temp Mail..."})}):X?e.jsxs("div",{className:"flex-1 flex divide-x divide-border-subtle min-h-0",children:[e.jsxs("aside",{className:"w-60 shrink-0 bg-surface/40 flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-4 border-b border-border-subtle flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-xs font-bold text-text-main flex items-center gap-1.5",title:!te&&I?I:void 0,children:[e.jsx("span",{className:`inline-block size-2 rounded-full ${te?"bg-green-500":"bg-red-500 animate-ping"}`}),te?"Connected":"Disconnected"]}),e.jsx("button",{onClick:()=>A(!0),className:"text-text-muted hover:text-text-main cursor-pointer",title:"Settings",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"settings"})})]}),!te&&I&&e.jsxs("div",{className:"px-4 py-2.5 bg-red-500/10 border-b border-red-500/20 text-[10px] text-red-400 break-all space-y-1",children:[e.jsxs("div",{className:"font-semibold flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"error"}),"Koneksi Gagal:"]}),e.jsx("div",{className:"opacity-80",children:I}),S&&R!==S&&e.jsx("button",{onClick:()=>{G(S),A(!0),k("manual")},className:"text-primary hover:underline text-[9px] font-semibold block mt-1 text-left",children:"💡 Gunakan domain workers.dev fallback"})]}),e.jsx("div",{className:"p-4",children:e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:()=>{de(U||(se.length>0?se[0]:"")),i(!0)},children:"+ New Inbox"})}),e.jsxs("nav",{className:"flex flex-col px-2 space-y-0.5",children:[e.jsxs("button",{onClick:()=>{Z("all")},className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="all"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:[e.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),e.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),"Inbox"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("all")})]}),e.jsxs("button",{onClick:()=>Z("unread"),className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="unread"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),"Unread"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("unread")})]}),e.jsxs("button",{onClick:()=>Z("read"),className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="read"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:[e.jsx("path",{d:"M2 17V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2Z"}),e.jsx("path",{d:"M2 7l10 7 10-7"})]}),"Read"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("read")})]}),e.jsxs("button",{onClick:()=>Z("otp"),className:`flex items-center justify-between px-3 py-1.5 rounded-lg text-xs font-semibold cursor-pointer ${_==="otp"?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4 opacity-80",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),"With OTP"]}),e.jsx("span",{className:"bg-surface-3 px-1.5 py-0.5 rounded-full text-[10px] text-text-muted",children:Ne("otp")})]})]}),e.jsx("div",{className:"px-4 py-3 border-t border-b border-border-subtle/45 mt-4 bg-surface/10",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",placeholder:"Search inboxes...",value:M,onChange:s=>Je(s.target.value),className:"w-full text-xs pl-8 pr-3 py-1.5 rounded-lg border border-border-subtle bg-surface focus:outline-none focus:border-primary text-text-main"}),e.jsx("span",{className:"absolute left-2.5 top-2.5 text-text-muted/60",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar px-2 pt-4",children:e.jsxs("div",{children:[e.jsxs("p",{className:"px-3 text-[10px] font-semibold text-text-muted uppercase tracking-wider mb-2",children:["Active Inboxes (",ae.length,")"]}),e.jsxs("div",{className:"space-y-0.5",children:[ae.filter(s=>s.address.toLowerCase().includes(M.toLowerCase())).map(s=>e.jsxs("div",{onClick:()=>{B(s.address),Z("all")},className:`group/inbox flex items-center justify-between px-3 py-2 rounded-lg text-xs font-medium cursor-pointer transition-colors ${D.toLowerCase()===s.address.toLowerCase()?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface"}`,children:[e.jsx("span",{className:"truncate w-32",title:s.address,children:s.address}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 ml-1",children:[e.jsx("button",{onClick:o=>{o.stopPropagation(),Ie(s.address)},className:`size-6 flex items-center justify-center rounded-md transition-all duration-150 ${Q[s.address]?"text-green-400 bg-green-500/15":"text-text-muted hover:text-primary hover:bg-primary/15"}`,title:"Copy address",children:Q[s.address]?e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),e.jsx("button",{onClick:o=>{o.stopPropagation(),Qe(s.alias)},className:"size-6 flex items-center justify-center rounded-md text-text-muted hover:text-red-400 hover:bg-red-500/15 transition-all duration-150",title:"Delete inbox",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]},s.address)),ae.length===0&&e.jsx("p",{className:"px-3 text-[11px] text-text-muted italic",children:"No inboxes. Click New Inbox above."})]})]})})]}),e.jsxs("section",{className:"w-80 shrink-0 flex flex-col min-h-0 bg-surface/10",children:[e.jsxs("div",{className:"p-3 border-b border-border-subtle flex items-center justify-between gap-2 bg-surface/10",children:[e.jsx("span",{className:"text-xs font-bold text-text-muted uppercase tracking-wider pl-1",children:"Messages"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>{Oe(!0),y().finally(()=>Oe(!1))},className:`p-1.5 hover:bg-surface rounded-lg cursor-pointer text-text-muted transition-colors duration-150 ${ye?"animate-spin":""}`,title:"Refresh",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"}),e.jsx("path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"}),e.jsx("path",{d:"M16 16h5v5"})]})}),e.jsx("button",{onClick:s=>{F&&Ee(s,F)},disabled:!F,className:`p-1.5 rounded-lg cursor-pointer transition-colors duration-150 ${F?"text-red-500 hover:bg-red-500/10":"text-text-muted/30 cursor-not-allowed"}`,title:"Delete selected email",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-4",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),e.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),e.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar p-2 space-y-1.5",children:D?ve.length===0?e.jsx("div",{className:"text-center p-8 text-text-muted text-xs italic",children:"No messages found."}):ve.map(s=>e.jsxs("div",{onClick:()=>Ze(s.id),className:`group p-3 rounded-xl border border-border-subtle cursor-pointer transition-colors relative flex flex-col gap-1 ${F===s.id?"bg-primary/10 border-primary":s.used_at?"bg-surface/40 hover:bg-surface":"bg-surface font-semibold shadow-[var(--shadow-soft)] hover:bg-surface/80"}`,children:[e.jsxs("div",{className:"flex justify-between items-baseline gap-2",children:[e.jsx("span",{className:"text-xs text-text-main truncate w-36",children:s.sender}),e.jsx("span",{className:"text-[9px] text-text-muted shrink-0",children:new Date(s.received_at*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("h4",{className:"text-xs text-text-main truncate",children:s.subject}),s.otp_code&&e.jsx("div",{className:"mt-1",children:e.jsxs("span",{className:"bg-amber-500/10 text-amber-500 border border-amber-500/20 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold tracking-wider",children:["🔑 ",s.otp_code]})}),e.jsx("button",{onClick:o=>Ee(o,s.id),className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 text-text-muted hover:text-red-500 transition-all p-1 hover:bg-red-500/10 rounded cursor-pointer",title:"Delete email",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3.5",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]},s.id)):e.jsx("div",{className:"text-center p-8 text-text-muted text-xs italic",children:"Select an inbox to view messages."})})]}),e.jsx("article",{className:"flex-1 flex flex-col min-h-0 bg-surface/5",children:F===null?e.jsx("div",{className:"flex-1 flex items-center justify-center text-text-muted text-xs italic",children:"Select an email to read its contents."}):d===null?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-text-muted text-xs",children:[e.jsx("span",{className:"animate-spin mr-2",children:"⏳"})," Loading email details..."]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"p-6 border-b border-border-subtle space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-start gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-text-main",children:d.subject}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["From: ",e.jsx("span",{className:"font-semibold text-text-main",children:d.sender})]}),e.jsxs("p",{className:"text-xs text-text-muted",children:["To: ",e.jsx("span",{className:"font-semibold text-text-main",children:d.address})]})]}),e.jsxs("div",{className:"text-right flex flex-col items-end gap-2 shrink-0",children:[e.jsx("span",{className:"text-[11px] text-text-muted",children:new Date(d.received_at*1e3).toLocaleString()}),e.jsxs("button",{onClick:s=>Ee(s,d.id),className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-bold rounded-lg border bg-red-500/10 text-red-400 hover:bg-red-500/20 border-red-500/20 transition-all active:scale-95 cursor-pointer mt-1",title:"Delete this email",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),e.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),"Delete Email"]})]})]}),d.otp_code&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/25 rounded-xl p-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-amber-500 uppercase tracking-widest font-bold",children:"Verification OTP"}),e.jsx("p",{className:"text-2xl font-black font-mono tracking-widest text-text-main mt-1",children:d.otp_code})]}),e.jsx(m,{variant:Q[d.otp_code]?"success":"secondary",size:"sm",onClick:()=>Ie(d.otp_code),children:Q[d.otp_code]?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"check"}),"Copied!"]}):"Copy Code"})]}),d.verify_url&&e.jsxs("div",{className:"bg-primary/10 border border-primary/20 rounded-xl p-3 flex items-center justify-between gap-3 text-xs",children:[e.jsxs("span",{className:"truncate flex-1 text-text-main",title:d.verify_url,children:["🔗 ",d.verify_url]}),e.jsx("a",{href:d.verify_url,target:"_blank",rel:"noreferrer",className:"bg-primary hover:bg-primary/95 text-white px-3 py-1.5 rounded-lg font-semibold shrink-0",children:"Open Link"})]})]}),e.jsxs("div",{className:"flex justify-between items-center border-b border-border-subtle bg-surface/20 px-6 shrink-0",children:[e.jsxs("div",{className:"flex",children:[d.body_html&&e.jsx("button",{onClick:()=>J("html"),className:`px-4 py-2.5 text-xs font-semibold border-b-2 cursor-pointer ${T==="html"?"border-primary text-primary":"border-transparent text-text-muted"}`,children:"HTML View"}),e.jsx("button",{onClick:()=>J("text"),className:`px-4 py-2.5 text-xs font-semibold border-b-2 cursor-pointer ${T==="text"||!d.body_html?"border-primary text-primary":"border-transparent text-text-muted"}`,children:"Plain Text"})]}),T==="html"&&d.body_html&&e.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-xs text-text-muted select-none",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-white/40",children:"zoom_in"}),e.jsx("button",{onClick:()=>ne(s=>Math.max(.4,s-.1)),className:"px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 border border-white/10 active:bg-white/20 transition-colors text-[10px] font-bold cursor-pointer text-white",title:"Zoom Out",children:"A-"}),e.jsxs("span",{className:"font-mono text-[10px] w-10 text-center text-white/80",children:[Math.round(re*100),"%"]}),e.jsx("button",{onClick:()=>ne(s=>Math.min(1.5,s+.1)),className:"px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 border border-white/10 active:bg-white/20 transition-colors text-[10px] font-bold cursor-pointer text-white",title:"Zoom In",children:"A+"}),e.jsx("button",{onClick:()=>ne(1),className:"px-2 py-0.5 rounded bg-white/5 hover:bg-white/10 border border-white/10 active:bg-white/20 transition-colors text-[10px] font-semibold cursor-pointer text-white ml-1",children:"Reset"})]})]}),e.jsx("div",{className:"flex-1 overflow-auto custom-scrollbar p-6 relative min-h-[450px]",children:T==="html"&&d.body_html?e.jsx("div",{className:"w-full h-full relative overflow-auto custom-scrollbar",children:e.jsx("iframe",{srcDoc:tt(d.body_html),title:"Email Preview",sandbox:"allow-popups allow-popups-to-escape-sandbox",style:{transform:`scale(${re})`,transformOrigin:"top left",width:`${100/re}%`,height:`${100/re}%`},className:"border border-border-subtle rounded-xl bg-white absolute inset-0"})}):e.jsx("pre",{className:"text-xs font-sans whitespace-pre-wrap leading-relaxed text-text-main",children:d.body_text})})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center space-y-4",children:[e.jsx("div",{className:"size-16 rounded-full bg-primary/10 text-primary flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"mail_lock"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-text-main",children:"FSMail Client Not Configured"}),e.jsx("p",{className:"text-xs text-text-muted mt-1 max-w-sm",children:"Please enter your FSMail Cloudflare worker credentials and endpoint in settings to enable temp emails."})]}),e.jsx(m,{variant:"primary",onClick:()=>A(!0),children:"⚙ Configure Settings"})]}),he&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 backdrop-blur-sm p-4 pt-[6vh] overflow-y-auto",children:e.jsxs("div",{className:"bg-neutral-900 border border-white/10 rounded-2xl w-full max-w-md text-white max-h-[80vh] flex flex-col overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-white/5 shrink-0",children:[e.jsx("h3",{className:"text-base font-bold",children:"FSMail Settings"}),e.jsx("button",{onClick:()=>A(!1),className:"text-white/60 hover:text-white cursor-pointer flex items-center",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"p-5 overflow-y-auto custom-scrollbar flex-1 space-y-4",children:[e.jsxs("div",{className:"flex border border-white/10 rounded-lg p-0.5 bg-white/5 text-xs shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>k("manual"),className:`flex-1 py-1.5 rounded-md font-semibold cursor-pointer text-center transition-all ${fe==="manual"?"bg-primary text-white":"text-white/60 hover:text-white"}`,children:"Manual Input"}),e.jsx("button",{type:"button",onClick:()=>k("auto"),className:`flex-1 py-1.5 rounded-md font-semibold cursor-pointer text-center transition-all ${fe==="auto"?"bg-primary text-white":"text-white/60 hover:text-white"}`,children:"⚡ Auto Deploy (Cloudflare)"})]}),fe==="manual"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Base URL Worker"}),e.jsx("input",{type:"text",placeholder:"https://mail.yourdomain.com",value:R,onChange:s=>G(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"}),S&&R!==S&&e.jsxs("div",{className:"mt-1.5 p-2 bg-primary/10 border border-primary/20 rounded-lg text-[10px] text-primary space-y-1 text-left",children:[e.jsx("div",{children:"💡 Coba gunakan URL workers.dev fallback:"}),e.jsx("div",{className:"font-mono text-[9px] break-all bg-black/40 p-1 rounded select-all",children:S}),e.jsx("button",{type:"button",onClick:()=>G(S),className:"underline hover:no-underline font-semibold block",children:"Klik untuk gunakan URL ini"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"API Key (X-API-Key)"}),e.jsx("input",{type:"password",placeholder:"tm_...",value:be,onChange:s=>O(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Default Domain"}),e.jsx("input",{type:"text",placeholder:"yourdomain.com",value:U,onChange:s=>Te(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Webhook Secret"}),e.jsx("input",{type:"password",placeholder:"Leave empty to auto-generate",value:We,onChange:s=>oe(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:xe,disabled:u,children:u?"Testing...":"⚡ Test Connection"}),L&&e.jsxs("div",{className:`p-2.5 rounded-lg text-xs font-medium flex items-start gap-2 ${L.ok?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:L.ok?"check_circle":"error"}),e.jsx("span",{className:"break-all text-left",children:L.message})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>A(!1),children:"Cancel"}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:Ve,children:"Save Settings"})]})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-white/60 block",children:"Cloudflare Account ID"}),e.jsxs("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline cursor-pointer flex items-center gap-0.5",children:["Temukan disini ",e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"open_in_new"})]})]}),e.jsx("input",{type:"text",placeholder:"Paste Account ID Anda",value:V,onChange:s=>ze(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-white/60 block",children:"Cloudflare API Token (Workers & D1)"}),e.jsxs("a",{href:"https://dash.cloudflare.com/profile/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline cursor-pointer flex items-center gap-0.5",children:["Buat disini ",e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"open_in_new"})]})]}),e.jsx("input",{type:"password",placeholder:"Paste API Token Anda",value:W,onChange:s=>ge(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Domain Worker (misal: mail.domainanda.com)"}),e.jsx("input",{type:"text",placeholder:"mail.domainanda.com",value:le,onChange:s=>Be(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx("label",{className:"text-[11px] text-white/60 block",children:"Telegram Bot Token (Opsional)"}),e.jsxs("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline cursor-pointer flex items-center gap-0.5",children:["Dapatkan di @BotFather ",e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"open_in_new"})]})]}),e.jsx("input",{type:"password",placeholder:"Token Bot dari @BotFather",value:Ae,onChange:s=>Fe(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]})]}),e.jsxs("div",{className:"space-y-3",children:[L&&e.jsxs("div",{className:`p-2.5 rounded-lg text-xs font-medium flex items-start gap-2 ${L.ok?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:L.ok?"check_circle":"error"}),e.jsx("span",{className:"break-all text-left",children:L.message})]}),S&&e.jsxs("div",{className:"p-2.5 bg-white/5 border border-white/10 rounded-lg text-[10px] text-white/70 space-y-1 text-left",children:[e.jsx("span",{className:"font-semibold text-primary block",children:"Workers.dev fallback URL:"}),e.jsx("span",{className:"font-mono text-[9px] break-all block bg-black/40 p-1 rounded select-all",children:S}),e.jsx("span",{className:"block leading-relaxed",children:"Jika custom domain Anda terputus (misal karena DNS belum merambat), Anda dapat menggunakan URL fallback ini di tab Manual Input."})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(m,{variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>A(!1),children:"Cancel"}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:De,disabled:u,children:u?"Deploying...":"⚡ Auto Deploy & Setup"})]})]})]}),e.jsxs("div",{className:"space-y-3 pt-2 border-t border-white/5 shrink-0",children:[e.jsx("a",{href:"/dashboard/automation/fsmail-tutorial",target:"_blank",rel:"noopener noreferrer",className:"w-full py-2 rounded-lg bg-neutral-900 border border-primary/20 hover:border-primary/50 text-primary text-xs font-semibold flex items-center justify-center gap-1.5 transition-colors cursor-pointer",children:"📖 Buka Panduan Lengkap Deploy"}),e.jsxs("details",{className:"group bg-white/5 border border-white/10 rounded-xl overflow-hidden",children:[e.jsxs("summary",{className:"list-none flex items-center justify-between p-3 cursor-pointer select-none text-[11px] font-semibold text-white/80 hover:text-white transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"help"}),"Cara Setup Temp Mail (FSMail)"]}),e.jsx("span",{className:"material-symbols-outlined text-[16px] transition-transform group-open:rotate-180",children:"expand_more"})]}),e.jsxs("div",{className:"p-3 pt-0 border-t border-white/5 text-[11px] text-white/70 space-y-2 leading-relaxed max-h-40 overflow-y-auto custom-scrollbar",children:[e.jsxs("p",{className:"mt-2",children:["FSMail adalah sistem email sementara berbasis ",e.jsx("strong",{children:"Cloudflare Worker"}),". Ikuti langkah berikut untuk mengaturnya:"]}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1.5 text-white/60",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Deploy Worker:"})," Deploy kode worker FSMail di akun Cloudflare Anda."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Set API Key:"})," Pada dashboard Worker Anda, tambahkan Environment Variable ",e.jsx("code",{className:"bg-white/10 px-1 py-0.5 rounded font-mono text-amber-300",children:"API_KEY"})," dengan nilai token rahasia Anda."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Email Routing:"})," Aktifkan Cloudflare Email Routing pada domain Anda, lalu arahkan semua email masuk ke worker tersebut."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Hubungkan:"})," Masukkan ",e.jsx("strong",{className:"text-white",children:"Base URL Worker"})," (misal: ",e.jsx("code",{className:"text-amber-200",children:"https://mail.domain.com"}),") dan ",e.jsx("strong",{className:"text-white",children:"API Key"})," ke form di atas, lalu tekan ",e.jsx("strong",{className:"text-white",children:"Test Connection"}),"."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-white/80",children:"Aktifkan Webhook:"})," Setelah koneksi berhasil dan pengaturan disimpan, klik tombol ",e.jsx("strong",{className:"text-white",children:"Register Webhook"})," di bawah untuk mengaktifkan sinkronisasi email secara real-time."]})]})]})]}),X&&e.jsxs("div",{className:"border-t border-white/10 pt-3 mt-2 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-white/40 uppercase font-bold tracking-wider",children:"Worker Integration"}),e.jsx("pre",{className:"text-[10px] bg-white/5 p-2 rounded overflow-x-auto text-amber-300 font-mono",children:Ue}),e.jsx(m,{variant:"primary",size:"sm",fullWidth:!0,onClick:Me,children:"Register Webhook"})]})]})]})]})}),Re&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-neutral-950 border border-white/10 rounded-2xl w-full max-w-2xl text-white max-h-[85vh] flex flex-col overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex justify-between items-center p-5 border-b border-white/5 shrink-0 bg-neutral-900",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"auto_stories"}),e.jsx("h3",{className:"text-base font-bold",children:"Panduan Lengkap Deploy Temp Mail"})]}),e.jsx("button",{onClick:()=>_e(!1),className:"text-white/60 hover:text-white cursor-pointer flex items-center",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"p-6 overflow-y-auto custom-scrollbar flex-1 space-y-6 text-sm leading-relaxed text-white/80",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"1"}),"Prasyarat & Login Cloudflare"]}),e.jsx("p",{className:"mb-2",children:"Pastikan Node.js sudah terinstal. Login ke akun Cloudflare Anda melalui terminal dengan menjalankan perintah berikut:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npx wrangler login"}),e.jsx(E,{value:"npx wrangler login"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"2"}),"Install Dependencies"]}),e.jsx("p",{className:"mb-2",children:"Masuk ke direktori tempmail lokal di sistem Anda dan install dependensi NPM:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"cd /home/data/Project/fsrouter/tempmail && npm install"}),e.jsx(E,{value:"cd /home/data/Project/fsrouter/tempmail && npm install"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"3"}),"Buat Database D1"]}),e.jsx("p",{className:"mb-2",children:"Buat database SQL D1 baru untuk menyimpan inbox dan pesan email masuk:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300 mb-3",children:[e.jsx("span",{children:"npx wrangler d1 create tempmail"}),e.jsx(E,{value:"npx wrangler d1 create tempmail"})]}),e.jsxs("div",{className:"bg-blue-500/10 border border-blue-500/20 rounded-lg p-3 text-xs text-blue-300 flex items-start gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] shrink-0 mt-0.5",children:"info"}),e.jsxs("span",{children:["Salin ",e.jsx("strong",{children:"database_id"})," hasil output perintah di atas, lalu buka file ",e.jsx("a",{href:"file:///home/data/Project/fsrouter/tempmail/wrangler.jsonc",className:"underline font-semibold hover:text-blue-200",children:"wrangler.jsonc"})," dan ganti nilai ",e.jsx("code",{children:"database_id"})," di dalamnya."]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"4"}),"Jalankan Migrasi Database"]}),e.jsx("p",{className:"mb-2",children:"Inisialisasi tabel database temp mail di lokal dan jarak jauh (remote Cloudflare):"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npm run db:migrate:local && npm run db:migrate:remote"}),e.jsx(E,{value:"npm run db:migrate:local && npm run db:migrate:remote"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"5"}),"Simpan Secret Bot Telegram"]}),e.jsx("p",{className:"mb-2",children:"Set token Telegram bot Anda dan webhook secret token ke Cloudflare Workers:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npx wrangler secret put TELEGRAM_BOT_TOKEN"}),e.jsx(E,{value:"npx wrangler secret put TELEGRAM_BOT_TOKEN"})]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"}),e.jsx(E,{value:"npx wrangler secret put TELEGRAM_WEBHOOK_SECRET"})]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"6"}),"Konfigurasi `wrangler.jsonc` & Deploy"]}),e.jsxs("p",{className:"mb-2",children:["Sesuaikan nilai di bagian ",e.jsx("code",{children:"vars"})," (domain dan base URL) pada file ",e.jsx("a",{href:"file:///home/data/Project/fsrouter/tempmail/wrangler.jsonc",className:"underline font-semibold hover:text-white",children:"wrangler.jsonc"}),", lalu deploy worker:"]}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{children:"npm run deploy"}),e.jsx(E,{value:"npm run deploy"})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"7"}),"Set Webhook Telegram Bot"]}),e.jsx("p",{className:"mb-2",children:"Daftarkan URL Worker Anda agar bot Telegram dapat memproses command masuk:"}),e.jsxs("div",{className:"flex items-center justify-between bg-white/5 p-3 rounded-lg border border-white/10 font-mono text-xs text-amber-300",children:[e.jsx("span",{className:"truncate mr-2",children:`curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{"url":"https://<worker-host>/telegram/webhook","secret_token":"<WEBHOOK_SECRET>"}'`}),e.jsx(E,{value:`curl -X POST "https://api.telegram.org/bot<BOT_TOKEN>/setWebhook" -H "Content-Type: application/json" -d '{"url":"https://<worker-host>/telegram/webhook","secret_token":"<WEBHOOK_SECRET>"}'`})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"bg-primary/20 text-primary px-2 py-0.5 rounded text-xs",children:"8"}),"Cloudflare Email Routing"]}),e.jsxs("p",{children:["Masuk ke Cloudflare Dashboard domain Anda, klik menu ",e.jsx("strong",{children:"Email Routing"}),", aktifkan fitur tersebut, lalu buat rule ",e.jsx("strong",{children:"Catch-all"})," dengan aksi ",e.jsx("strong",{children:"Send to a Worker"})," mengarah ke nama Worker Anda."]})]})]}),e.jsx("div",{className:"p-5 border-t border-white/5 shrink-0 bg-neutral-900 flex justify-end",children:e.jsx(m,{variant:"primary",size:"sm",onClick:()=>_e(!1),children:"Selesai Membaca"})})]})}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("form",{onSubmit:w,className:"bg-neutral-900 border border-white/10 rounded-2xl w-full max-w-sm p-6 space-y-4 text-white",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-base font-bold",children:"New Inbox"}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"text-white/60 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Alias (optional, empty = random)"}),e.jsx("input",{type:"text",placeholder:"e.g. business-inbox",value:we,onChange:s=>He(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-white/60 block mb-1",children:"Domain"}),se.length>0?e.jsxs("select",{value:ce,onChange:s=>de(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-neutral-900 focus:outline-none focus:border-primary text-white",children:[e.jsxs("option",{value:"",children:["— Default (",U||se[0],") —"]}),se.map(s=>e.jsx("option",{value:s,children:s},s))]}):e.jsx("input",{type:"text",placeholder:U||"yourdomain.com",value:ce,onChange:s=>de(s.target.value),className:"w-full text-xs p-2.5 rounded-lg border border-white/10 bg-white/5 focus:outline-none focus:border-primary text-white"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(m,{type:"button",variant:"secondary",size:"sm",fullWidth:!0,onClick:()=>i(!1),children:"Cancel"}),e.jsx(m,{type:"submit",variant:"primary",size:"sm",fullWidth:!0,children:"Create Inbox"})]})]})]})})]})}export{it as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as s,B as Be,k as je,l as Ie,h as Le}from"./index.KMEObSAk.js";import{b as d}from"./router.Cjj1--8t.js";import{B as qe}from"./NoAuthProxyCard.DyEjms20.js";import"./zustand.akaTi5uX.js";const O={sessions:"basic-chat.sessions",activeSessionId:"basic-chat.activeSessionId",activeProviderId:"basic-chat.activeProviderId",draft:"basic-chat.draft"};function J(){var e;return(e=globalThis.crypto)!=null&&e.randomUUID?globalThis.crypto.randomUUID():`chat_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Fe(e,a){try{return JSON.parse(e)}catch{return a}}function S(e){if(typeof e=="string")return e;if(e==null)return"";if(Array.isArray(e))return e.map(S).filter(Boolean).join(" ");if(typeof e=="object"){if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function He(e=""){return String(e).replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase()).trim()||"Unknown"}function Je(e){if(!e)return"Now";const a=new Date(e).getTime();if(Number.isNaN(a))return"Now";const m=Math.max(1,Math.round((Date.now()-a)/6e4));if(m<60)return`${m}m`;const u=Math.round(m/60);return u<24?`${u}h`:`${Math.round(u/24)}d`}function Ne(e=""){const a=S(e).replace(/\s+/g," ").trim();return a?a.length>52?`${a.slice(0,52).trimEnd()}…`:a:"New chat"}function Ke(e){const a=S(e.content).trim(),m=Array.isArray(e.attachments)?e.attachments:[];if(m.length===0)return a;const u=[];a&&u.push({type:"text",text:a});for(const w of m)w!=null&&w.dataUrl&&u.push({type:"image_url",image_url:{url:w.dataUrl}});return u.length>0?u:a}function We(e){var w,A;if(!e||typeof e!="object")return"";const a=(w=e.choices)==null?void 0:w[0];return[((a==null?void 0:a.delta)||{}).content,(A=a==null?void 0:a.message)==null?void 0:A.content,e.output_text,e.text].map(S).filter(Boolean)[0]||""}async function Ye(e){return await new Promise((a,m)=>{const u=new FileReader;u.onload=()=>a(String(u.result||"")),u.onerror=()=>m(u.error||new Error("Failed to read file")),u.readAsDataURL(e)})}function Ve(e){return{...e,messages:Array.isArray(e.messages)?e.messages.map(a=>({...a})):[]}}function de(e){return(e==null?void 0:e.name)||He((e==null?void 0:e.provider)||(e==null?void 0:e.id)||"provider")}function Ge(e,a){return e!=null&&e.id?{id:`${a.provider}/${e.id}`,requestModel:`${a.provider}/${e.id}`,name:e.name||e.id,providerId:a.provider,providerName:de(a),source:"static"}:null}function Qe(e,a){const m=typeof e=="string"?e:(e==null?void 0:e.id)||(e==null?void 0:e.name)||(e==null?void 0:e.model)||"";if(!m)return null;const u=typeof e=="string"?e:(e==null?void 0:e.name)||(e==null?void 0:e.displayName)||m;let w=m;return(je(a.provider)||Ie(a.provider))&&!m.includes("/")&&(w=`${a.provider}/${m}`),{id:w,requestModel:w,name:u,providerId:a.provider,providerName:de(a),source:"live"}}function Xe(e){return Array.isArray(e==null?void 0:e.models)?e.models:Array.isArray(e==null?void 0:e.data)?e.data:Array.isArray(e==null?void 0:e.results)?e.results:Array.isArray(e)?e:[]}function Ze(e){const a=new Map;for(const m of e)m!=null&&m.id&&(a.has(m.id)||a.set(m.id,m));return Array.from(a.values())}function et(){const[e,a]=d.useState([]),[m,u]=d.useState(!0),[w,A]=d.useState(""),[h,D]=d.useState(()=>{if(typeof window>"u")return[];try{const t=Fe(globalThis.localStorage.getItem(O.sessions),[]);return Array.isArray(t)?t.map(r=>({...r,messages:Array.isArray(r.messages)?r.messages:[]})):[]}catch{return[]}}),[g,M]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeSessionId)||""),[R,P]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeProviderId)||""),[I,U]=d.useState(""),[_,ce]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.draft)||""),[z,Q]=d.useState([]),[me,ue]=d.useState(!1),[Se,pe]=d.useState(""),[fe,X]=d.useState(""),[K,Ae]=d.useState(!1),[Me,Z]=d.useState(!1),[De,ee]=d.useState(!1),xe=d.useRef(null),B=d.useRef(null),te=d.useRef(!1),se=d.useRef(null),re=d.useRef(null);d.useEffect(()=>{Ae(!0)},[]),d.useEffect(()=>{let t=!1;async function r(){u(!0),A("");try{const n=await(await fetch("/api/providers",{cache:"no-store"})).json().catch(()=>({})),o=Array.isArray(n.connections)?n.connections.filter(c=>(c==null?void 0:c.isActive)!==!1):[];if(o.length===0){t||(a([]),A("No providers connected yet."));return}const x=new Map;for(const c of o){const p=c.provider||c.id,b=de(c),$=je(p)?"openai-compatible":Ie(p)?"anthropic-compatible":p;x.has(p)||x.set(p,{providerId:p,providerName:b,providerType:$,connections:[],models:[]});const N=x.get(p);N.providerName=N.providerName||b,N.providerType=N.providerType||$,N.connections.push(c);const W=Le(p).map(Y=>Ge(Y,c)).filter(Boolean);N.models.push(...W)}const k=await Promise.all(o.map(async c=>{try{const p=await fetch(`/api/providers/${c.id}/models`,{cache:"no-store"}),b=await p.json().catch(()=>({}));if(!p.ok)return{connection:c,models:[]};const $=Xe(b).map(N=>Qe(N,c)).filter(Boolean);return{connection:c,models:$}}catch{return{connection:c,models:[]}}}));for(const c of k){const p=c.connection.provider||c.connection.id,b=x.get(p);b&&b.models.push(...c.models)}const q=Array.from(x.values()).map(c=>({...c,models:Ze(c.models).sort((p,b)=>p.name.localeCompare(b.name))})).filter(c=>c.models.length>0).sort((c,p)=>c.providerName.localeCompare(p.providerName));t||(a(q),q.length===0&&A("Providers connected but no models available."))}catch(i){t||(A(S(i==null?void 0:i.message)||"Failed to load providers/models."),a([]))}finally{t||u(!1)}}return r(),()=>{t=!0}},[]),d.useEffect(()=>{const t=r=>{se.current&&!se.current.contains(r.target)&&Z(!1),re.current&&!re.current.contains(r.target)&&ee(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const y=d.useMemo(()=>{const t=new Map;for(const r of e)for(const i of r.models)t.set(i.id,{...i,providerId:r.providerId,providerName:r.providerName});return t},[e]),E=d.useMemo(()=>e.find(t=>t.providerId===R)||e[0]||null,[e,R]),v=d.useMemo(()=>{var t;if(I&&y.has(I))return y.get(I);if(g){const r=h.find(i=>i.id===g);if(r!=null&&r.modelId&&y.has(r.modelId))return y.get(r.modelId)}return((t=E==null?void 0:E.models)==null?void 0:t[0])||null},[I,y,E,h,g]),ie=d.useMemo(()=>h.find(t=>t.id===g)||null,[h,g]),he=(ie==null?void 0:ie.messages)||[],ge=d.useMemo(()=>[...h].sort((t,r)=>new Date(r.updatedAt).getTime()-new Date(t.updatedAt).getTime()),[h]),ae=!me&&!!v&&(_.trim().length>0||z.length>0);d.useEffect(()=>{if(K)try{globalThis.localStorage.setItem(O.sessions,JSON.stringify(h)),globalThis.localStorage.setItem(O.activeSessionId,g),globalThis.localStorage.setItem(O.activeProviderId,R),globalThis.localStorage.setItem(O.draft,_)}catch{}},[K,h,g,R,_]),d.useEffect(()=>{if(!K||m||te.current||e.length===0)return;const t=e.find(n=>n.providerId===R)||e[0],r=I&&y.has(I)?y.get(I):t.models[0];if(h.length>0){const n=h.find(x=>x.id===g)||h[0],o=n!=null&&n.modelId&&y.has(n.modelId)?y.get(n.modelId):r;te.current=!0,M(n.id),P((o==null?void 0:o.providerId)||t.providerId),U((o==null?void 0:o.id)||r.id);return}const i={id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:r.id,modelName:r.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]};te.current=!0,D([i]),M(i.id),P(t.providerId),U(r.id)},[K,m,e,y,h,g,R,I]);const L=(t,r)=>{D(i=>i.map(n=>n.id===t?r(Ve(n)):n))},ne=t=>t?{id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]}:null,ke=t=>{const r=h.find(i=>i.id===t);r&&(M(t),P(r.providerId||R),U(r.modelId||I),ee(!1))},Te=()=>{if(!g)return;const t=h.filter(i=>i.id!==g),r=t[0]||null;D(t),r?(M(r.id),P(r.providerId),U(r.modelId)):(M(""),P(""),U(""))},Ce=t=>{const r=y.get(t);if(!r)return;const i=h.find(n=>n.id===g);if(i&&i.messages.length>0){const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}else if(i)D(n=>n.map(o=>o.id===i.id?{...o,providerId:r.providerId,providerName:r.providerName,modelId:r.id,modelName:r.name}:o)),M(i.id);else{const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}P(r.providerId),U(r.id),Z(!1)},Oe=async t=>{const r=Array.from(t.target.files||[]);if(r.length===0)return;const i=r.filter(o=>o.type.startsWith("image/"));if(i.length===0){t.target.value="";return}const n=await Promise.all(i.map(async o=>({id:J(),name:o.name,type:o.type,size:o.size,dataUrl:await Ye(o)})));Q(o=>[...o,...n]),t.target.value=""},Re=t=>{Q(r=>r.filter(i=>i.id!==t))},Ee=()=>{var t;(t=B.current)==null||t.abort()},$e=(t,r)=>{const i=Ne(r);L(t,n=>({...n,title:n.title==="New chat"?i:n.title,updatedAt:new Date().toISOString()}))},we=async()=>{var p,b,$,N,W,Y;const t=v||((p=E==null?void 0:E.models)==null?void 0:p[0])||null;if(!t)return;const r=_.trim();if(!r&&z.length===0)return;let i=g,n=h.find(l=>l.id===i);if(!n){if(n=ne(t),!n)return;i=n.id,D(l=>[n,...l]),M(i)}const o={id:J(),role:"user",content:r,attachments:z.map(l=>({id:l.id,name:l.name,type:l.type,dataUrl:l.dataUrl})),createdAt:new Date().toISOString()},x=J(),k={id:x,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"},q=[...n.messages||[],o,k];D(l=>l.map(j=>j.id===i?{...j,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,messages:q,updatedAt:new Date().toISOString(),title:j.title==="New chat"?Ne(r):j.title}:j)),ce(""),Q([]),ue(!0),pe(x),X(""),(b=B.current)==null||b.abort(),B.current=new AbortController;const c=q.filter(l=>!(l.role==="assistant"&&l.id===x)).map(l=>({role:l.role,content:l.role==="user"?Ke(l):l.content}));try{const l=await fetch("/api/dashboard/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:t.requestModel||t.id,messages:c,stream:!0}),signal:B.current.signal});if(!l.ok){const f=await l.json().catch(()=>({}));throw new Error(S(f.error||f.message||`Request failed (${l.status})`))}const j=($=l.body)==null?void 0:$.getReader();if(!j){const f=await l.json().catch(()=>({})),C=S(((Y=(W=(N=f==null?void 0:f.choices)==null?void 0:N[0])==null?void 0:W.message)==null?void 0:Y.content)||(f==null?void 0:f.output_text)||(f==null?void 0:f.error)||(f==null?void 0:f.message)||"");L(i,F=>({...F,messages:F.messages.map(H=>H.id===x?{...H,content:C,status:"done"}:H),updatedAt:new Date().toISOString()}));return}const V=new TextDecoder;let T="",G="";for(;;){const{value:f,done:C}=await j.read();if(C)break;T+=V.decode(f,{stream:!0});const F=T.split(/\r?\n/);T=F.pop()||"";for(const H of F){const ve=H.trim();if(!ve.startsWith("data:"))continue;const oe=ve.slice(5).trim();if(!(!oe||oe==="[DONE]"))try{const ze=JSON.parse(oe),be=We(ze);if(!be)continue;G+=be,X(G),L(i,ye=>({...ye,messages:ye.messages.map(le=>le.id===x?{...le,content:G,status:"streaming"}:le),updatedAt:new Date().toISOString()}))}catch{}}}L(i,f=>({...f,messages:f.messages.map(C=>C.id===x?{...C,content:G||C.content,status:"done"}:C),updatedAt:new Date().toISOString()})),$e(i,r)}catch(l){if(l.name!=="AbortError"){const j=S((l==null?void 0:l.message)||l);L(i,V=>({...V,messages:V.messages.map(T=>T.id===x?{...T,content:T.content||`Error: ${j}`,status:"error"}:T),updatedAt:new Date().toISOString()})),A(j||"Failed to send message.")}}finally{ue(!1),pe(""),X(""),B.current=null}},Pe=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ae&&we())},Ue=v?`${v.name}`:"Select model",_e=v?v.requestModel:"Choose from connected providers";return s.jsx("div",{className:"relative flex-1 flex flex-col h-full min-h-0 min-w-0 bg-[#212121] text-white overflow-hidden",children:s.jsxs("div",{className:"relative mx-auto flex flex-1 h-full min-h-0 w-full max-w-4xl flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-4 py-3 lg:px-6",children:[s.jsxs("div",{ref:se,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>Z(t=>!t),className:"flex items-center gap-3 rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-left transition hover:bg-white/8",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold text-white",children:Ue}),s.jsx("span",{className:"material-symbols-outlined text-[18px] text-white/70",children:"expand_more"})]}),s.jsx("p",{className:"truncate text-xs text-white/55",children:_e})]})}),Me?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+10px)] z-30 w-[min(520px,calc(100vw-2rem))] overflow-hidden rounded-[20px] border border-white/10 bg-[#262626] shadow-2xl shadow-black/50",children:[s.jsxs("div",{className:"border-b border-white/10 px-4 py-3",children:[s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Models"}),s.jsx("p",{className:"text-sm text-white/75",children:"Only from connected providers"})]}),s.jsx("div",{className:"max-h-[60vh] overflow-y-auto p-2 custom-scrollbar",children:e.map(t=>s.jsxs("div",{className:"mb-2 rounded-[16px] border border-white/10 bg-black/20 p-2",children:[s.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[s.jsx("p",{className:"text-sm font-semibold text-white",children:t.providerName}),s.jsx(qe,{size:"sm",variant:"default",children:t.models.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:t.models.map(r=>{const i=r.id===I;return s.jsx("button",{type:"button",onClick:()=>Ce(r.id),className:`rounded-[14px] border px-3 py-3 text-left transition ${i?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:r.name}),s.jsx("p",{className:"truncate text-[11px] text-white/45",children:r.requestModel})]}),i?s.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-300",children:"check_circle"}):null]})},r.id)})})]},t.providerId))})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>ee(t=>!t),className:"rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white/80 transition hover:bg-white/8",children:"History"}),s.jsx(Be,{variant:"ghost",size:"sm",icon:"delete",onClick:Te,disabled:!g||h.length===0,children:"Clear"})]})]}),De?s.jsxs("div",{ref:re,className:"absolute right-4 top-[72px] z-20 w-[min(360px,calc(100vw-2rem))] rounded-[20px] border border-white/10 bg-[#262626] p-2 shadow-2xl shadow-black/50 lg:right-6",children:[s.jsx("div",{className:"px-3 py-2",children:s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Recent chats"})}),s.jsx("div",{className:"max-h-[48vh] space-y-2 overflow-y-auto p-1 custom-scrollbar",children:ge.length===0?s.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/5 p-4 text-sm text-white/55",children:"No conversations yet."}):ge.map(t=>{var n;const r=t.id===g,i=[...t.messages||[]].reverse().find(o=>o.role==="user")||((n=t.messages)==null?void 0:n[0]);return s.jsx("button",{type:"button",onClick:()=>ke(t.id),className:`w-full rounded-[16px] border px-3 py-3 text-left transition ${r?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:t.title}),s.jsx("p",{className:"mt-1 truncate text-xs text-white/50",children:S(i==null?void 0:i.content)||"Empty chat"})]}),s.jsx("span",{className:"text-[10px] text-white/40 shrink-0",children:Je(t.updatedAt)})]})},t.id)})})]}):null,w?s.jsx("div",{className:"mt-4 rounded-[18px] border border-rose-500/20 bg-rose-500/10 px-4 py-3 text-rose-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),s.jsx("p",{className:"text-sm leading-6",children:w})]})}):null,s.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[s.jsxs("div",{className:"flex-1 overflow-y-auto py-4 custom-scrollbar",children:[he.length===0?s.jsx("div",{className:"flex min-h-[50vh] items-center justify-center px-4 text-center",children:s.jsxs("div",{className:"max-w-xl space-y-4",children:[s.jsx("div",{className:"mx-auto flex size-16 items-center justify-center rounded-[20px] border border-white/10 bg-white/5 text-white/80",children:s.jsx("span",{className:"material-symbols-outlined text-[30px]",children:"chat"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-white",children:"Start a conversation"}),s.jsx("p",{className:"text-sm leading-6 text-white/60",children:"Simple chat interface to interact with any AI model from connected providers. Select a model and start chatting!"})]})]})}):null,s.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 px-4",children:he.map(t=>{var x;const r=t.role==="user",i=t.role==="assistant",n=i&&t.id===Se&&t.status==="streaming",o=S(t.content)||(i?fe:"");return s.jsx("div",{className:`flex w-full ${r?"justify-end":"justify-start"} mb-6`,children:s.jsxs("div",{className:`max-w-[min(88%,42rem)] ${r?"rounded-3xl bg-[#2f2f2f] px-5 py-3.5 text-white":"text-white/90"}`,children:[s.jsx("div",{className:"mb-1 flex items-center justify-between gap-3",children:s.jsx("span",{className:"text-xs font-semibold",children:r?"You":(v==null?void 0:v.name)||"Assistant"})}),(x=t.attachments)!=null&&x.length?s.jsx("div",{className:"mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3 mt-2",children:t.attachments.map(k=>s.jsx("a",{href:k.dataUrl,target:"_blank",rel:"noreferrer",className:"overflow-hidden rounded-[18px] border border-white/10 bg-black/20",children:s.jsx("img",{src:k.dataUrl,alt:k.name,className:"h-28 w-full object-cover"})},k.id))}):null,s.jsxs("div",{className:"whitespace-pre-wrap break-words text-[15px] leading-7",children:[o,i&&n&&!fe?s.jsx("span",{className:"inline-block animate-pulse",children:"▋"}):null]})]})},t.id)})})]}),s.jsxs("div",{className:"shrink-0 pt-2",children:[z.length>0?s.jsx("div",{className:"mx-auto mb-3 flex w-full max-w-3xl flex-wrap gap-2 px-4",children:z.map(t=>s.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-white/80 max-w-[12rem] truncate",children:t.name}),s.jsx("button",{type:"button",onClick:()=>Re(t.id),className:"text-white/55 hover:text-white","aria-label":"Remove attachment",children:s.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]},t.id))}):null,s.jsx("div",{className:"mx-auto w-full max-w-3xl px-4 pb-2",children:s.jsxs("div",{className:"rounded-[26px] bg-[#2f2f2f] px-3 pt-3 pb-2 shadow-[0_0_15px_rgba(0,0,0,0.10)] ring-1 ring-white/5",children:[s.jsx("textarea",{value:_,onChange:t=>ce(t.target.value),onKeyDown:Pe,placeholder:"Message AI",rows:1,className:"w-full resize-none bg-transparent px-2 text-[15px] leading-6 text-white outline-none placeholder:text-white/40 custom-scrollbar max-h-[25vh] overflow-y-auto"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{var t;return(t=xe.current)==null?void 0:t.click()},disabled:!v||m,className:"p-2 text-white/50 hover:text-white transition rounded-full hover:bg-white/5",children:s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"attach_file"})}),s.jsx("input",{ref:xe,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Oe}),s.jsx("span",{className:"text-xs font-medium text-white/30 truncate max-w-[120px]",children:v?v.name:"No model"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[me?s.jsx("button",{type:"button",onClick:Ee,className:"p-2 text-white bg-white/10 hover:bg-white/20 transition rounded-full h-8 w-8 flex items-center justify-center",children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"stop"})}):null,s.jsx("button",{onClick:we,disabled:!ae,className:`h-8 w-8 rounded-full flex items-center justify-center transition ${ae?"bg-white text-black hover:opacity-90":"bg-white/10 text-white/30 cursor-not-allowed"}`,children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})})]})]})]})})]}),s.jsx("p",{className:"mx-auto mt-2 max-w-3xl px-4 pb-4 text-center text-[11px] text-white/30",children:"Model list is filtered from connected providers."})]})]})})}function at(){return s.jsx(et,{})}export{at as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{u as kn,j as h,B as Je,C as In,M as An}from"./index.DQDDDpp7.js";import{b as a,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as Jt,I as Tn,M as On}from"./NoAuthProxyCard.C18iZ3Fk.js";import{C as Lt}from"./Loading.DaQG3sHF.js";import"./zustand.akaTi5uX.js";function Ln(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Se(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?Se(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 Se(e)?!1:e instanceof X(e).HTMLElement}function Qt(e){return e instanceof X(e).SVGElement}function Re(e){return e?Se(e)?e.document:bt(e)?xt(e)?e:Ue(e)||Qt(e)?e.ownerDocument:document:document:document}const re=nt?a.useLayoutEffect:a.useEffect;function wt(e){const t=a.useRef(e);return re(()=>{t.current=e}),a.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 zn(){const e=a.useRef(null),t=a.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=a.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=a.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=a.useRef();return a.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=wt(e),n=a.useRef(null),r=a.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=a.useRef();return a.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return a.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function Zt(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 l=Object.entries(i);for(const[c,u]of l){const f=s[c];f!=null&&(s[c]=f+e*u)}return s},{...t})}}const De=Zt(1),Be=Zt(-1);function Pn(e){return"clientX"in e&&"clientY"in e}function yt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Bn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Bn(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 Pn(e)?{x:e.clientX,y:e.clientY}:null}const Fe=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[Fe.Translate.toString(e),Fe.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 Fn(e){return e.matches(zt)?e:e.querySelector(zt)}const $n={display:"none"};function Un(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:$n},n)}function Xn(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 Wn(){const[e,t]=a.useState("");return{announce:a.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const en=a.createContext(null);function Yn(e){const t=a.useContext(en);a.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Hn(){const[e]=a.useState(()=>new Set),t=a.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[a.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var l;return(l=i[o])==null?void 0:l.call(i,s)})},[e]),t]}const Kn={draggable:`
|
|
2
|
-
To pick up a draggable item, press the space bar.
|
|
3
|
-
While dragging, use the arrow keys to move the item.
|
|
4
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
-
`},Vn={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function _n(e){let{announcements:t=Vn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Kn}=e;const{announce:s,announcement:i}=Wn(),l=We("DndLiveRegion"),[c,u]=a.useState(!1);if(a.useEffect(()=>{u(!0)},[]),Yn(a.useMemo(()=>({onDragStart(d){let{active:g}=d;s(t.onDragStart({active:g}))},onDragMove(d){let{active:g,over:p}=d;t.onDragMove&&s(t.onDragMove({active:g,over:p}))},onDragOver(d){let{active:g,over:p}=d;s(t.onDragOver({active:g,over:p}))},onDragEnd(d){let{active:g,over:p}=d;s(t.onDragEnd({active:g,over:p}))},onDragCancel(d){let{active:g,over:p}=d;s(t.onDragCancel({active:g,over:p}))}}),[s,t])),!c)return null;const f=U.createElement(U.Fragment,null,U.createElement(Un,{id:r,value:o.draggable}),U.createElement(Xn,{id:l,announcement:i}));return n?Te.createPortal(f,n):f}var L;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(L||(L={}));function Ze(){}function Pt(e,t){return a.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function qn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Z=Object.freeze({x:0,y:0});function tn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function nn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Gn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Bt(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function rn(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Ft(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const Jn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Ft(t,t.left,t.top),s=[];for(const i of r){const{id:l}=i,c=n.get(l);if(c){const u=tn(Ft(c),o);s.push({id:l,data:{droppableContainer:i,value:u}})}}return s.sort(nn)},Qn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Bt(t),s=[];for(const i of r){const{id:l}=i,c=n.get(l);if(c){const u=Bt(c),f=o.reduce((g,p,R)=>g+tn(u[R],p),0),d=Number((f/4).toFixed(4));s.push({id:l,data:{droppableContainer:i,value:d}})}}return s.sort(nn)};function Zn(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,l=s-n;if(r<o&&n<s){const c=t.width*t.height,u=e.width*e.height,f=i*l,d=f/(c+u-f);return Number(d.toFixed(4))}return 0}const er=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,l=n.get(i);if(l){const c=Zn(l,t);c>0&&o.push({id:i,data:{droppableContainer:s,value:c}})}}return o.sort(Gn)};function tr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function on(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Z}function nr(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,l)=>({...i,top:i.top+e*l.y,bottom:i.bottom+e*l.y,left:i.left+e*l.x,right:i.right+e*l.x}),{...n})}}const rr=nr(1);function or(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function sr(e,t,n){const r=or(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:l}=r,c=e.left-i-(1-o)*parseFloat(n),u=e.top-l-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,d=s?e.height/s:e.height;return{width:f,height:d,top:u,right:c+f,bottom:u+d,left:c}}const ir={ignoreTransform:!1};function Ee(e,t){t===void 0&&(t=ir);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=X(e).getComputedStyle(e);u&&(n=sr(n,u,f))}const{top:r,left:o,width:s,height:i,bottom:l,right:c}=n;return{top:r,left:o,width:s,height:i,bottom:l,right:c}}function $t(e){return Ee(e,{ignoreTransform:!0})}function ar(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function lr(e,t){return t===void 0&&(t=X(e).getComputedStyle(e)),t.position==="fixed"}function cr(e,t){t===void 0&&(t=X(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function rt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(xt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Ue(o)||Qt(o)||n.includes(o))return n;const s=X(e).getComputedStyle(o);return o!==e&&cr(o,s)&&n.push(o),lr(o,s)?n:r(o.parentNode)}return e?r(e):n}function sn(e){const[t]=rt(e,1);return t??null}function ut(e){return!nt||!e?null:Se(e)?e:bt(e)?xt(e)||e===Re(e).scrollingElement?window:Ue(e)?e:null:null}function an(e){return Se(e)?e.scrollX:e.scrollLeft}function ln(e){return Se(e)?e.scrollY:e.scrollTop}function pt(e){return{x:an(e),y:ln(e)}}var z;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(z||(z={}));function cn(e){return!nt||!e?!1:e===document.scrollingElement}function un(e){const t={x:0,y:0},n=cn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:l,maxScroll:r,minScroll:t}}const ur={x:.2,y:.2};function dr(e,t,n,r,o){let{top:s,left:i,right:l,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=ur);const{isTop:u,isBottom:f,isLeft:d,isRight:g}=un(e),p={x:0,y:0},R={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!u&&s<=t.top+m.height?(p.y=z.Backward,R.y=r*Math.abs((t.top+m.height-s)/m.height)):!f&&c>=t.bottom-m.height&&(p.y=z.Forward,R.y=r*Math.abs((t.bottom-m.height-c)/m.height)),!g&&l>=t.right-m.width?(p.x=z.Forward,R.x=r*Math.abs((t.right-m.width-l)/m.width)):!d&&i<=t.left+m.width&&(p.x=z.Backward,R.x=r*Math.abs((t.left+m.width-i)/m.width)),{direction:p,speed:R}}function fr(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function dn(e){return e.reduce((t,n)=>De(t,pt(n)),Z)}function hr(e){return e.reduce((t,n)=>t+an(n),0)}function gr(e){return e.reduce((t,n)=>t+ln(n),0)}function pr(e,t){if(t===void 0&&(t=Ee),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);sn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const vr=[["x",["left","right"],hr],["y",["top","bottom"],gr]];class Ct{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=rt(n),o=dn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,l]of vr)for(const c of i)Object.defineProperty(this,c,{get:()=>{const u=l(r),f=o[s]-u;return this.rect[c]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Oe{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function mr(e){const{EventTarget:t}=X(e);return e instanceof t?e:Re(e)}function dt(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var J;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(J||(J={}));function Ut(e){e.preventDefault()}function br(e){e.stopPropagation()}var M;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(M||(M={}));const fn={start:[M.Space,M.Enter],cancel:[M.Esc],end:[M.Space,M.Enter,M.Tab]},xr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case M.Right:return{...n,x:n.x+25};case M.Left:return{...n,x:n.x-25};case M.Down:return{...n,y:n.y+25};case M.Up:return{...n,y:n.y-25}}};class Dt{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Oe(Re(n)),this.windowListeners=new Oe(X(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(J.Resize,this.handleCancel),this.windowListeners.add(J.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(J.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&pr(r),n(Z)}handleKeyDown(t){if(yt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=fn,coordinateGetter:i=xr,scrollBehavior:l="smooth"}=o,{code:c}=t;if(s.end.includes(c)){this.handleEnd(t);return}if(s.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:Z;this.referenceCoordinates||(this.referenceCoordinates=f);const d=i(t,{active:n,context:r.current,currentCoordinates:f});if(d){const g=Be(d,f),p={x:0,y:0},{scrollableAncestors:R}=r.current;for(const m of R){const x=t.code,{isTop:S,isRight:D,isLeft:y,isBottom:N,maxScroll:v,minScroll:w}=un(m),b=fr(m),E={x:Math.min(x===M.Right?b.right-b.width/2:b.right,Math.max(x===M.Right?b.left:b.left+b.width/2,d.x)),y:Math.min(x===M.Down?b.bottom-b.height/2:b.bottom,Math.max(x===M.Down?b.top:b.top+b.height/2,d.y))},T=x===M.Right&&!D||x===M.Left&&!y,O=x===M.Down&&!N||x===M.Up&&!S;if(T&&E.x!==d.x){const k=m.scrollLeft+g.x,W=x===M.Right&&k<=v.x||x===M.Left&&k>=w.x;if(W&&!g.y){m.scrollTo({left:k,behavior:l});return}W?p.x=m.scrollLeft-k:p.x=x===M.Right?m.scrollLeft-v.x:m.scrollLeft-w.x,p.x&&m.scrollBy({left:-p.x,behavior:l});break}else if(O&&E.y!==d.y){const k=m.scrollTop+g.y,W=x===M.Down&&k<=v.y||x===M.Up&&k>=w.y;if(W&&!g.x){m.scrollTo({top:k,behavior:l});return}W?p.y=m.scrollTop-k:p.y=x===M.Down?m.scrollTop-v.y:m.scrollTop-w.y,p.y&&m.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(t,De(Be(d,this.referenceCoordinates),p))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Dt.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=fn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const l=s.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),o==null||o({event:e.nativeEvent}),!0)}return!1}}];function Xt(e){return!!(e&&"distance"in e)}function Wt(e){return!!(e&&"delay"in e)}class St{constructor(t,n,r){var o;r===void 0&&(r=mr(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=Re(i),this.documentListeners=new Oe(this.document),this.listeners=new Oe(r),this.windowListeners=new Oe(X(i)),this.initialCoordinates=(o=gt(s))!=null?o:Z,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(J.Resize,this.handleCancel),this.windowListeners.add(J.DragStart,Ut),this.windowListeners.add(J.VisibilityChange,this.handleCancel),this.windowListeners.add(J.ContextMenu,Ut),this.documentListeners.add(J.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Wt(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Xt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(J.Click,br,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(J.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:l}}=s;if(!o)return;const c=(n=gt(t))!=null?n:Z,u=Be(o,c);if(!r&&l){if(Xt(l)){if(l.tolerance!=null&&dt(u,l.tolerance))return this.handleCancel();if(dt(u,l.distance))return this.handleStart()}if(Wt(l)&&dt(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),i(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===M.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const wr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Rt extends St{constructor(t){const{event:n}=t,r=Re(n.target);super(t,wr,r)}}Rt.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const yr={move:{name:"mousemove"},end:{name:"mouseup"}};var vt;(function(e){e[e.RightClick=2]="RightClick"})(vt||(vt={}));class Cr extends St{constructor(t){super(t,yr,Re(t.event.target))}}Cr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===vt.RightClick?!1:(r==null||r({event:n}),!0)}}];const ft={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Dr extends St{constructor(t){super(t,ft)}static setup(){return window.addEventListener(ft.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ft.move.name,t)};function t(){}}}Dr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var Le;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Le||(Le={}));var et;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(et||(et={}));function Sr(e){let{acceleration:t,activator:n=Le.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:l=et.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:g}=e;const p=Er({delta:d,disabled:!s}),[R,m]=zn(),x=a.useRef({x:0,y:0}),S=a.useRef({x:0,y:0}),D=a.useMemo(()=>{switch(n){case Le.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Le.DraggableRect:return o}},[n,o,c]),y=a.useRef(null),N=a.useCallback(()=>{const w=y.current;if(!w)return;const b=x.current.x*S.current.x,E=x.current.y*S.current.y;w.scrollBy(b,E)},[]),v=a.useMemo(()=>l===et.TreeOrder?[...u].reverse():u,[l,u]);a.useEffect(()=>{if(!s||!u.length||!D){m();return}for(const w of v){if((r==null?void 0:r(w))===!1)continue;const b=u.indexOf(w),E=f[b];if(!E)continue;const{direction:T,speed:O}=dr(w,E,D,t,g);for(const k of["x","y"])p[k][T[k]]||(O[k]=0,T[k]=0);if(O.x>0||O.y>0){m(),y.current=w,R(N,i),x.current=O,S.current=T;return}}x.current={x:0,y:0},S.current={x:0,y:0},m()},[t,N,r,m,s,i,JSON.stringify(D),JSON.stringify(p),R,u,v,f,JSON.stringify(g)])}const Rr={x:{[z.Backward]:!1,[z.Forward]:!1},y:{[z.Backward]:!1,[z.Forward]:!1}};function Er(e){let{delta:t,disabled:n}=e;const r=ht(t);return Xe(o=>{if(n||!r||!o)return Rr;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[z.Backward]:o.x[z.Backward]||s.x===-1,[z.Forward]:o.x[z.Forward]||s.x===1},y:{[z.Backward]:o.y[z.Backward]||s.y===-1,[z.Forward]:o.y[z.Forward]||s.y===1}}},[n,t,r])}function Nr(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Xe(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Mr(e,t){return a.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var $e;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})($e||($e={}));var mt;(function(e){e.Optimized="optimized"})(mt||(mt={}));const Yt=new Map;function jr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=a.useState(null),{frequency:l,measure:c,strategy:u}=o,f=a.useRef(e),d=x(),g=Pe(d),p=a.useCallback(function(S){S===void 0&&(S=[]),!g.current&&i(D=>D===null?S:D.concat(S.filter(y=>!D.includes(y))))},[g]),R=a.useRef(null),m=Xe(S=>{if(d&&!n)return Yt;if(!S||S===Yt||f.current!==e||s!=null){const D=new Map;for(let y of e){if(!y)continue;if(s&&s.length>0&&!s.includes(y.id)&&y.rect.current){D.set(y.id,y.rect.current);continue}const N=y.node.current,v=N?new Ct(c(N),N):null;y.rect.current=v,v&&D.set(y.id,v)}return D}return S},[e,s,n,d,c]);return a.useEffect(()=>{f.current=e},[e]),a.useEffect(()=>{d||p()},[n,d]),a.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),a.useEffect(()=>{d||typeof l!="number"||R.current!==null||(R.current=setTimeout(()=>{p(),R.current=null},l))},[l,d,p,...r]),{droppableRects:m,measureDroppableContainers:p,measuringScheduled:s!=null};function x(){switch(u){case $e.Always:return!1;case $e.BeforeDragging:return n;default:return!n}}}function hn(e,t){return Xe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function kr(e,t){return hn(e,t)}function Ir(e){let{callback:t,disabled:n}=e;const r=wt(t),o=a.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return a.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function ot(e){let{callback:t,disabled:n}=e;const r=wt(t),o=a.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return a.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ar(e){return new Ct(Ee(e),e)}function Ht(e,t,n){t===void 0&&(t=Ar);const[r,o]=a.useState(null);function s(){o(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??n)!=null?u:null}const f=t(e);return JSON.stringify(c)===JSON.stringify(f)?c:f})}const i=Ir({callback(c){if(e)for(const u of c){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){s();break}}}}),l=ot({callback:s});return re(()=>{s(),e?(l==null||l.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(l==null||l.disconnect(),i==null||i.disconnect())},[e]),r}function Tr(e){const t=hn(e);return on(e,t)}const Kt=[];function Or(e){const t=a.useRef(e),n=Xe(r=>e?r&&r!==Kt&&e&&t.current&&e.parentNode===t.current.parentNode?r:rt(e):Kt,[e]);return a.useEffect(()=>{t.current=e},[e]),n}function Lr(e){const[t,n]=a.useState(null),r=a.useRef(e),o=a.useCallback(s=>{const i=ut(s.target);i&&n(l=>l?(l.set(i,pt(i)),new Map(l)):null)},[]);return a.useEffect(()=>{const s=r.current;if(e!==s){i(s);const l=e.map(c=>{const u=ut(c);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,pt(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=e}return()=>{i(e),i(s)};function i(l){l.forEach(c=>{const u=ut(c);u==null||u.removeEventListener("scroll",o)})}},[o,e]),a.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>De(s,i),Z):dn(e):Z,[e,t])}function Vt(e,t){t===void 0&&(t=[]);const n=a.useRef(null);return a.useEffect(()=>{n.current=null},t),a.useEffect(()=>{const r=e!==Z;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?Be(e,n.current):Z}function zr(e){a.useEffect(()=>{if(!nt)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n==null||n()}},e.map(t=>{let{sensor:n}=t;return n}))}function Pr(e,t){return a.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function gn(e){return a.useMemo(()=>e?ar(e):null,[e])}const _t=[];function Br(e,t){t===void 0&&(t=Ee);const[n]=e,r=gn(n?X(n):null),[o,s]=a.useState(_t);function i(){s(()=>e.length?e.map(c=>cn(c)?r:new Ct(t(c),c)):_t)}const l=ot({callback:i});return re(()=>{l==null||l.disconnect(),i(),e.forEach(c=>l==null?void 0:l.observe(c))},[e]),o}function Fr(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ue(t)?t:e}function $r(e){let{measure:t}=e;const[n,r]=a.useState(null),o=a.useCallback(u=>{for(const{target:f}of u)if(Ue(f)){r(d=>{const g=t(f);return d?{...d,width:g.width,height:g.height}:g});break}},[t]),s=ot({callback:o}),i=a.useCallback(u=>{const f=Fr(u);s==null||s.disconnect(),f&&(s==null||s.observe(f)),r(f?t(f):null)},[t,s]),[l,c]=Qe(i);return a.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const Ur=[{sensor:Rt,options:{}},{sensor:Dt,options:{}}],Xr={current:{}},Ge={draggable:{measure:$t},droppable:{measure:$t,strategy:$e.WhileDragging,frequency:mt.Optimized},dragOverlay:{measure:Ee}};class ze extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Wr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ze,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Ze},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ge,measureDroppableContainers:Ze,windowRect:null,measuringScheduled:!1},Yr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ze,draggableNodes:new Map,over:null,measureDroppableContainers:Ze},st=a.createContext(Yr),pn=a.createContext(Wr);function Hr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ze}}}function Kr(e,t){switch(t.type){case L.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case L.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case L.DragEnd:case L.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case L.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new ze(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case L.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new ze(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case L.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new ze(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Vr(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=a.useContext(st),s=ht(r),i=ht(n==null?void 0:n.id);return a.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!yt(s)||document.activeElement===s.target)return;const l=o.get(i);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[c.current,u.current]){if(!f)continue;const d=Fn(f);if(d){d.focus();break}}})}},[r,t,o,i,s]),null}function _r(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function qr(e){return a.useMemo(()=>({draggable:{...Ge.draggable,...e==null?void 0:e.draggable},droppable:{...Ge.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Ge.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function Gr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=a.useRef(!1),{x:i,y:l}=typeof o=="boolean"?{x:o,y:o}:o;re(()=>{if(!i&&!l||!t){s.current=!1;return}if(s.current||!r)return;const u=t==null?void 0:t.node.current;if(!u||u.isConnected===!1)return;const f=n(u),d=on(f,r);if(i||(d.x=0),l||(d.y=0),s.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const g=sn(u);g&&g.scrollBy({top:d.y,left:d.x})}},[t,i,l,r,n])}const vn=a.createContext({...Z,scaleX:1,scaleY:1});var pe;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(pe||(pe={}));const Jr=a.memo(function(t){var n,r,o,s;let{id:i,accessibility:l,autoScroll:c=!0,children:u,sensors:f=Ur,collisionDetection:d=er,measuring:g,modifiers:p,...R}=t;const m=a.useReducer(Kr,void 0,Hr),[x,S]=m,[D,y]=Hn(),[N,v]=a.useState(pe.Uninitialized),w=N===pe.Initialized,{draggable:{active:b,nodes:E,translate:T},droppable:{containers:O}}=x,k=b!=null?E.get(b):null,W=a.useRef({initial:null,translated:null}),Y=a.useMemo(()=>{var B;return b!=null?{id:b,data:(B=k==null?void 0:k.data)!=null?B:Xr,rect:W}:null},[b,k]),H=a.useRef(null),[C,j]=a.useState(null),[A,oe]=a.useState(null),F=Pe(R,Object.values(R)),Q=We("DndDescribedBy",i),Ye=a.useMemo(()=>O.getEnabled(),[O]),$=qr(g),{droppableRects:se,measureDroppableContainers:ve,measuringScheduled:Ne}=jr(Ye,{dragging:w,dependencies:[T.x,T.y],config:$.droppable}),q=Nr(E,b),He=a.useMemo(()=>A?gt(A):null,[A]),ce=jn(),ie=kr(q,$.draggable.measure);Gr({activeNode:b!=null?E.get(b):null,config:ce.layoutShiftCompensation,initialRect:ie,measure:$.draggable.measure});const I=Ht(q,$.draggable.measure,ie),Me=Ht(q?q.parentElement:null),ee=a.useRef({activatorEvent:null,active:null,activeNode:q,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=O.getNodeFor((n=ee.current.over)==null?void 0:n.id),ae=$r({measure:$.dragOverlay.measure}),be=(r=ae.nodeRef.current)!=null?r:q,xe=w?(o=ae.rect)!=null?o:I:null,Nt=!!(ae.nodeRef.current&&ae.rect),Mt=Tr(Nt?null:I),it=gn(be?X(be):null),ue=Or(w?me??q:null),Ke=Br(ue),Ve=_r(p,{transform:{x:T.x-Mt.x,y:T.y-Mt.y,scaleX:1,scaleY:1},activatorEvent:A,active:Y,activeNodeRect:I,containerNodeRect:Me,draggingNodeRect:xe,over:ee.current.over,overlayNodeRect:ae.rect,scrollableAncestors:ue,scrollableAncestorRects:Ke,windowRect:it}),jt=He?De(He,T):null,kt=Lr(ue),Cn=Vt(kt),Dn=Vt(kt,[I]),we=De(Ve,Cn),ye=xe?rr(xe,Ve):null,je=Y&&ye?d({active:Y,collisionRect:ye,droppableRects:se,droppableContainers:Ye,pointerCoordinates:jt}):null,It=rn(je,"id"),[de,At]=a.useState(null),Sn=Nt?Ve:De(Ve,Dn),Rn=tr(Sn,(s=de==null?void 0:de.rect)!=null?s:null,I),at=a.useRef(null),Tt=a.useCallback((B,K)=>{let{sensor:V,options:fe}=K;if(H.current==null)return;const G=E.get(H.current);if(!G)return;const _=B.nativeEvent,te=new V({active:H.current,activeNode:G,event:_,options:fe,context:ee,onAbort(P){if(!E.get(P))return;const{onDragAbort:ne}=F.current,le={id:P};ne==null||ne(le),D({type:"onDragAbort",event:le})},onPending(P,he,ne,le){if(!E.get(P))return;const{onDragPending:Ie}=F.current,ge={id:P,constraint:he,initialCoordinates:ne,offset:le};Ie==null||Ie(ge),D({type:"onDragPending",event:ge})},onStart(P){const he=H.current;if(he==null)return;const ne=E.get(he);if(!ne)return;const{onDragStart:le}=F.current,ke={activatorEvent:_,active:{id:he,data:ne.data,rect:W}};Te.unstable_batchedUpdates(()=>{le==null||le(ke),v(pe.Initializing),S({type:L.DragStart,initialCoordinates:P,active:he}),D({type:"onDragStart",event:ke}),j(at.current),oe(_)})},onMove(P){S({type:L.DragMove,coordinates:P})},onEnd:Ce(L.DragEnd),onCancel:Ce(L.DragCancel)});at.current=te;function Ce(P){return async function(){const{active:ne,collisions:le,over:ke,scrollAdjustedTranslate:Ie}=ee.current;let ge=null;if(ne&&Ie){const{cancelDrop:Ae}=F.current;ge={activatorEvent:_,active:ne,collisions:le,delta:Ie,over:ke},P===L.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(ge))&&(P=L.DragCancel)}H.current=null,Te.unstable_batchedUpdates(()=>{S({type:P}),v(pe.Uninitialized),At(null),j(null),oe(null),at.current=null;const Ae=P===L.DragEnd?"onDragEnd":"onDragCancel";if(ge){const lt=F.current[Ae];lt==null||lt(ge),D({type:Ae,event:ge})}})}}},[E]),En=a.useCallback((B,K)=>(V,fe)=>{const G=V.nativeEvent,_=E.get(fe);if(H.current!==null||!_||G.dndKit||G.defaultPrevented)return;const te={active:_};B(V,K.options,te)===!0&&(G.dndKit={capturedBy:K.sensor},H.current=fe,Tt(V,K))},[E,Tt]),Ot=Mr(f,En);zr(f),re(()=>{I&&N===pe.Initializing&&v(pe.Initialized)},[I,N]),a.useEffect(()=>{const{onDragMove:B}=F.current,{active:K,activatorEvent:V,collisions:fe,over:G}=ee.current;if(!K||!V)return;const _={active:K,activatorEvent:V,collisions:fe,delta:{x:we.x,y:we.y},over:G};Te.unstable_batchedUpdates(()=>{B==null||B(_),D({type:"onDragMove",event:_})})},[we.x,we.y]),a.useEffect(()=>{const{active:B,activatorEvent:K,collisions:V,droppableContainers:fe,scrollAdjustedTranslate:G}=ee.current;if(!B||H.current==null||!K||!G)return;const{onDragOver:_}=F.current,te=fe.get(It),Ce=te&&te.rect.current?{id:te.id,rect:te.rect.current,data:te.data,disabled:te.disabled}:null,P={active:B,activatorEvent:K,collisions:V,delta:{x:G.x,y:G.y},over:Ce};Te.unstable_batchedUpdates(()=>{At(Ce),_==null||_(P),D({type:"onDragOver",event:P})})},[It]),re(()=>{ee.current={activatorEvent:A,active:Y,activeNode:q,collisionRect:ye,collisions:je,droppableRects:se,draggableNodes:E,draggingNode:be,draggingNodeRect:xe,droppableContainers:O,over:de,scrollableAncestors:ue,scrollAdjustedTranslate:we},W.current={initial:xe,translated:ye}},[Y,q,je,ye,E,be,xe,se,O,de,ue,we]),Sr({...ce,delta:T,draggingRect:ye,pointerCoordinates:jt,scrollableAncestors:ue,scrollableAncestorRects:Ke});const Nn=a.useMemo(()=>({active:Y,activeNode:q,activeNodeRect:I,activatorEvent:A,collisions:je,containerNodeRect:Me,dragOverlay:ae,draggableNodes:E,droppableContainers:O,droppableRects:se,over:de,measureDroppableContainers:ve,scrollableAncestors:ue,scrollableAncestorRects:Ke,measuringConfiguration:$,measuringScheduled:Ne,windowRect:it}),[Y,q,I,A,je,Me,ae,E,O,se,de,ve,ue,Ke,$,Ne,it]),Mn=a.useMemo(()=>({activatorEvent:A,activators:Ot,active:Y,activeNodeRect:I,ariaDescribedById:{draggable:Q},dispatch:S,draggableNodes:E,over:de,measureDroppableContainers:ve}),[A,Ot,Y,I,S,Q,E,de,ve]);return U.createElement(en.Provider,{value:y},U.createElement(st.Provider,{value:Mn},U.createElement(pn.Provider,{value:Nn},U.createElement(vn.Provider,{value:Rn},u)),U.createElement(Vr,{disabled:(l==null?void 0:l.restoreFocus)===!1})),U.createElement(_n,{...l,hiddenTextDescribedById:Q}));function jn(){const B=(C==null?void 0:C.autoScrollEnabled)===!1,K=typeof c=="object"?c.enabled===!1:c===!1,V=w&&!B&&!K;return typeof c=="object"?{...c,enabled:V}:{enabled:V}}}),Qr=a.createContext(null),qt="button",Zr="Draggable";function eo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=We(Zr),{activators:i,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:g}=a.useContext(st),{role:p=qt,roleDescription:R="draggable",tabIndex:m=0}=o??{},x=(c==null?void 0:c.id)===t,S=a.useContext(x?vn:Qr),[D,y]=Qe(),[N,v]=Qe(),w=Pr(i,t),b=Pe(n);re(()=>(d.set(t,{id:t,key:s,node:D,activatorNode:N,data:b}),()=>{const T=d.get(t);T&&T.key===s&&d.delete(t)}),[d,t]);const E=a.useMemo(()=>({role:p,tabIndex:m,"aria-disabled":r,"aria-pressed":x&&p===qt?!0:void 0,"aria-roledescription":R,"aria-describedby":f.draggable}),[r,p,m,x,R,f.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:E,isDragging:x,listeners:r?void 0:w,node:D,over:g,setNodeRef:y,setActivatorNodeRef:v,transform:S}}function to(){return a.useContext(pn)}const no="Droppable",ro={timeout:25};function oo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=We(no),{active:i,dispatch:l,over:c,measureDroppableContainers:u}=a.useContext(st),f=a.useRef({disabled:n}),d=a.useRef(!1),g=a.useRef(null),p=a.useRef(null),{disabled:R,updateMeasurementsFor:m,timeout:x}={...ro,...o},S=Pe(m??r),D=a.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(S.current)?S.current:[S.current]),p.current=null},x)},[x]),y=ot({callback:D,disabled:R||!i}),N=a.useCallback((E,T)=>{y&&(T&&(y.unobserve(T),d.current=!1),E&&y.observe(E))},[y]),[v,w]=Qe(N),b=Pe(t);return a.useEffect(()=>{!y||!v.current||(y.disconnect(),d.current=!1,y.observe(v.current))},[v,y]),a.useEffect(()=>(l({type:L.RegisterDroppable,element:{id:r,key:s,disabled:n,node:v,rect:g,data:b}}),()=>l({type:L.UnregisterDroppable,key:s,id:r})),[r]),a.useEffect(()=>{n!==f.current.disabled&&(l({type:L.SetDroppableDisabled,id:r,key:s,disabled:n}),f.current.disabled=n)},[r,s,n,l]),{active:i,rect:g,isOver:(c==null?void 0:c.id)===r,node:v,over:c,setNodeRef:w}}function Et(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function so(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function _e(e){return e!==null&&e>=0}function io(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ao(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const mn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=Et(t,r,n),i=t[o],l=s[o];return!l||!i?null:{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}},qe={scaleX:1,scaleY:1},lo=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const l=(t=s[n])!=null?t:r;if(!l)return null;if(o===n){const u=s[i];return u?{x:0,y:n<i?u.top+u.height-(l.top+l.height):u.top-l.top,...qe}:null}const c=co(s,o,n);return o>n&&o<=i?{x:0,y:-l.height-c,...qe}:o<n&&o>=i?{x:0,y:l.height+c,...qe}:{x:0,y:0,...qe}};function co(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const bn="Sortable",xn=U.createContext({activeIndex:-1,containerId:bn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:mn,disabled:{draggable:!1,droppable:!1}});function uo(e){let{children:t,id:n,items:r,strategy:o=mn,disabled:s=!1}=e;const{active:i,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:f}=to(),d=We(bn,n),g=l.rect!==null,p=a.useMemo(()=>r.map(w=>typeof w=="object"&&"id"in w?w.id:w),[r]),R=i!=null,m=i?p.indexOf(i.id):-1,x=u?p.indexOf(u.id):-1,S=a.useRef(p),D=!io(p,S.current),y=x!==-1&&m===-1||D,N=ao(s);re(()=>{D&&R&&f(p)},[D,p,R,f]),a.useEffect(()=>{S.current=p},[p]);const v=a.useMemo(()=>({activeIndex:m,containerId:d,disabled:N,disableTransforms:y,items:p,overIndex:x,useDragOverlay:g,sortedRects:so(p,c),strategy:o}),[m,d,N.draggable,N.droppable,y,p,x,c,g,o]);return U.createElement(xn.Provider,{value:v},t)}const fo=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Et(n,r,o).indexOf(t)},ho=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:l,previousContainerId:c,transition:u}=e;return!u||!r||l!==s&&o===i?!1:n?!0:i!==o&&t===c},go={duration:200,easing:"ease"},wn="transform",po=Fe.Transition.toString({property:wn,duration:0,easing:"linear"}),vo={roleDescription:"sortable"};function mo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=a.useState(null),l=a.useRef(n);return re(()=>{if(!t&&n!==l.current&&r.current){const c=o.current;if(c){const u=Ee(r.current,{ignoreTransform:!0}),f={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(f.x||f.y)&&i(f)}}n!==l.current&&(l.current=n)},[t,n,r,o]),a.useEffect(()=>{s&&i(null)},[s]),s}function bo(e){let{animateLayoutChanges:t=ho,attributes:n,disabled:r,data:o,getNewIndex:s=fo,id:i,strategy:l,resizeObserverConfig:c,transition:u=go}=e;const{items:f,containerId:d,activeIndex:g,disabled:p,disableTransforms:R,sortedRects:m,overIndex:x,useDragOverlay:S,strategy:D}=a.useContext(xn),y=xo(r,p),N=f.indexOf(i),v=a.useMemo(()=>({sortable:{containerId:d,index:N,items:f},...o}),[d,o,N,f]),w=a.useMemo(()=>f.slice(f.indexOf(i)),[f,i]),{rect:b,node:E,isOver:T,setNodeRef:O}=oo({id:i,data:v,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:w,...c}}),{active:k,activatorEvent:W,activeNodeRect:Y,attributes:H,setNodeRef:C,listeners:j,isDragging:A,over:oe,setActivatorNodeRef:F,transform:Q}=eo({id:i,data:v,attributes:{...vo,...n},disabled:y.draggable}),Ye=Ln(O,C),$=!!k,se=$&&!R&&_e(g)&&_e(x),ve=!S&&A,Ne=ve&&se?Q:null,He=se?Ne??(l??D)({rects:m,activeNodeRect:Y,activeIndex:g,overIndex:x,index:N}):null,ce=_e(g)&&_e(x)?s({id:i,items:f,activeIndex:g,overIndex:x}):N,ie=k==null?void 0:k.id,I=a.useRef({activeId:ie,items:f,newIndex:ce,containerId:d}),Me=f!==I.current.items,ee=t({active:k,containerId:d,isDragging:A,isSorting:$,id:i,index:N,items:f,newIndex:I.current.newIndex,previousItems:I.current.items,previousContainerId:I.current.containerId,transition:u,wasDragging:I.current.activeId!=null}),me=mo({disabled:!ee,index:N,node:E,rect:b});return a.useEffect(()=>{$&&I.current.newIndex!==ce&&(I.current.newIndex=ce),d!==I.current.containerId&&(I.current.containerId=d),f!==I.current.items&&(I.current.items=f)},[$,ce,d,f]),a.useEffect(()=>{if(ie===I.current.activeId)return;if(ie!=null&&I.current.activeId==null){I.current.activeId=ie;return}const be=setTimeout(()=>{I.current.activeId=ie},50);return()=>clearTimeout(be)},[ie]),{active:k,activeIndex:g,attributes:H,data:v,rect:b,index:N,newIndex:ce,items:f,isOver:T,isSorting:$,isDragging:A,listeners:j,node:E,overIndex:x,over:oe,setNodeRef:Ye,setActivatorNodeRef:F,setDroppableNodeRef:O,setDraggableNodeRef:C,transform:me??He,transition:ae()};function ae(){if(me||Me&&I.current.newIndex===N)return po;if(!(ve&&!yt(W)||!u)&&($||ee))return Fe.Transition.toString({...u,property:wn})}}function xo(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(r=e==null?void 0:e.droppable)!=null?r:t.droppable}}function tt(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const wo=[M.Down,M.Right,M.Up,M.Left],yo=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:l}}=t;if(wo.includes(e.code)){if(e.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const g=o.get(d.id);if(g)switch(e.code){case M.Down:r.top<g.top&&c.push(d);break;case M.Up:r.top>g.top&&c.push(d);break;case M.Left:r.left>g.left&&c.push(d);break;case M.Right:r.left<g.left&&c.push(d);break}});const u=Qn({collisionRect:r,droppableRects:o,droppableContainers:c});let f=rn(u,"id");if(f===(i==null?void 0:i.id)&&u.length>1&&(f=u[1].id),f!=null){const d=s.get(n.id),g=s.get(f),p=g?o.get(g.id):null,R=g==null?void 0:g.node.current;if(R&&p&&d&&g){const x=rt(R).some((w,b)=>l[b]!==w),S=yn(d,g),D=Co(d,g),y=x||!S?{x:0,y:0}:{x:D?r.width-p.width:0,y:D?r.height-p.height:0},N={x:p.left,y:p.top};return y.x&&y.y?N:Be(N,y)}}}};function yn(e,t){return!tt(e)||!tt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Co(e,t){return!tt(e)||!tt(t)||!yn(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Do(e,t,n){const r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}const So=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return!n||!t?r:Do(r,n,t)},Ro=e=>{let{transform:t}=e;return{...t,x:0}},Eo=/^[a-zA-Z0-9_.\-]+$/;function Oo(){const[e,t]=a.useState([]),[n,r]=a.useState(!0),[o,s]=a.useState(!1),[i,l]=a.useState(null),[c,u]=a.useState([]),[f,d]=a.useState({}),[g,p]=a.useState(null),{copied:R,copy:m}=kn();a.useEffect(()=>{x()},[]);const x=async()=>{try{const[v,w,b]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings")]),E=await v.json(),T=await w.json(),O=b.ok?await b.json():{};v.ok&&t((E.combos||[]).filter(k=>!k.kind)),w.ok&&u(T.connections||[]),d(O.comboStrategies||{})}catch(v){console.log("Error fetching data:",v)}finally{r(!1)}},S=async v=>{try{const w=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});if(w.ok)await x(),s(!1);else{const b=await w.json();alert(b.error||"Failed to create combo")}}catch(w){console.log("Error creating combo:",w)}},D=async(v,w)=>{try{const b=await fetch(`/api/combos/${v}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(b.ok)await x(),l(null);else{const E=await b.json();alert(E.error||"Failed to update combo")}}catch(b){console.log("Error updating combo:",b)}},y=async v=>{p({title:"Delete Combo",message:"Delete this combo?",onConfirm:async()=>{p(null);try{(await fetch(`/api/combos/${v}`,{method:"DELETE"})).ok&&t(e.filter(b=>b.id!==v))}catch(w){console.log("Error deleting combo:",w)}}})},N=async(v,w)=>{try{const b={...f};w&&w!=="fallback"?b[v]={fallbackStrategy:w}:delete b[v],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:b})}),d(b)}catch(b){console.log("Error updating combo strategy:",b)}};return n?h.jsxs("div",{className:"flex flex-col gap-6",children:[h.jsx(Lt,{}),h.jsx(Lt,{})]}):h.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[h.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsx("h1",{className:"text-2xl font-semibold",children:"Combos"}),h.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with fallback support"})]}),h.jsx(Je,{icon:"add",onClick:()=>s(!0),className:"w-full sm:w-auto",children:"Create Combo"})]}),e.length===0?h.jsx(Jt,{children:h.jsxs("div",{className:"text-center py-12",children:[h.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:h.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),h.jsx("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),h.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Create model combos with fallback support"}),h.jsx(Je,{icon:"add",onClick:()=>s(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):h.jsx("div",{className:"flex flex-col gap-4",children:e.map(v=>{var w;return h.jsx(No,{combo:v,copied:R,onCopy:m,onEdit:()=>l(v),onDelete:()=>y(v.id),currentStrategy:((w=f[v.name])==null?void 0:w.fallbackStrategy)||"fallback",onUpdateStrategy:b=>N(v.name,b)},v.id)})}),h.jsx(Gt,{isOpen:o,onClose:()=>s(!1),onSave:S,activeProviders:c},"create"),h.jsx(Gt,{isOpen:!!i,combo:i,onClose:()=>l(null),onSave:v=>D(i.id,v),activeProviders:c},(i==null?void 0:i.id)||"new"),h.jsx(In,{isOpen:!!g,onClose:()=>p(null),onConfirm:g==null?void 0:g.onConfirm,title:(g==null?void 0:g.title)||"Confirm",message:g==null?void 0:g.message,variant:"danger"})]})}function No({combo:e,copied:t,onCopy:n,onEdit:r,onDelete:o,currentStrategy:s,onUpdateStrategy:i}){return h.jsx(Jt,{padding:"sm",className:"group",children:h.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[h.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[h.jsx("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:h.jsx("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),h.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[e.models.length===0?h.jsx("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((l,c)=>h.jsx("code",{className:"max-w-full truncate rounded bg-black/5 px-1.5 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[220px]",children:l},c)),e.models.length>3&&h.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]})]})]}),h.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3 sm:shrink-0",children:[h.jsxs("div",{className:"flex items-center justify-between gap-1.5 rounded-lg bg-black/[0.02] px-2 py-1 dark:bg-white/[0.02] sm:justify-start sm:bg-transparent sm:px-0 sm:py-0 sm:dark:bg-transparent",children:[h.jsx("span",{className:"text-xs text-text-muted font-medium mr-1",children:"Strategy:"}),h.jsxs("select",{value:s,onChange:l=>i(l.target.value),className:"text-xs font-medium rounded border border-black/10 bg-transparent py-1 px-2 outline-none dark:border-white/10 dark:bg-black/20 text-text-main cursor-pointer",children:[h.jsx("option",{value:"fallback",className:"dark:bg-zinc-900",children:"Fallback (Priority)"}),h.jsx("option",{value:"round-robin",className:"dark:bg-zinc-900",children:"Round Robin"}),h.jsx("option",{value:"fusion",className:"dark:bg-zinc-900",children:"Fusion (Synthesis)"})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[h.jsxs("button",{onClick:l=>{l.stopPropagation(),n(e.name,`combo-${e.id}`)},className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Copy combo name",children:[h.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t===`combo-${e.id}`?"check":"content_copy"}),h.jsx("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),h.jsxs("button",{onClick:r,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted transition-colors hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",title:"Edit",children:[h.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),h.jsx("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),h.jsxs("button",{onClick:o,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 transition-colors hover:bg-red-500/10",title:"Delete",children:[h.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),h.jsx("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]})})}function Mo({id:e,index:t,model:n,isFirst:r,isLast:o,onEdit:s,onMoveUp:i,onMoveDown:l,onRemove:c}){const{attributes:u,listeners:f,setNodeRef:d,transform:g,isDragging:p}=bo({id:e}),R={transform:Fe.Transform.toString(g),opacity:p?.4:1,zIndex:p?999:void 0},[m,x]=a.useState(!1),[S,D]=a.useState(n),y=()=>{const v=S.trim();v&&v!==n?s(v):D(n),x(!1)},N=v=>{v.key==="Enter"&&y(),v.key==="Escape"&&(D(n),x(!1))};return h.jsxs("div",{ref:d,style:R,className:`group flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1 bg-black/[0.02] hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04] transition-colors ${p?"shadow-md ring-1 ring-primary/30":""}`,children:[h.jsx("button",{...u,...f,type:"button",className:"cursor-grab touch-none p-0.5 rounded text-text-muted hover:text-primary active:cursor-grabbing shrink-0",title:"Drag to reorder",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("circle",{cx:"9",cy:"4",r:"2"}),h.jsx("circle",{cx:"15",cy:"4",r:"2"}),h.jsx("circle",{cx:"9",cy:"12",r:"2"}),h.jsx("circle",{cx:"15",cy:"12",r:"2"}),h.jsx("circle",{cx:"9",cy:"20",r:"2"}),h.jsx("circle",{cx:"15",cy:"20",r:"2"})]})}),h.jsx("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),m?h.jsx("input",{autoFocus:!0,value:S,onChange:v=>D(v.target.value),onBlur:y,onKeyDown:N,className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):h.jsx("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>x(!0),title:"Click to edit",children:n}),h.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[h.jsx("button",{onClick:i,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:h.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),h.jsx("button",{onClick:l,disabled:o,className:`p-0.5 rounded ${o?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:h.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),h.jsx("button",{onClick:c,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:h.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function Gt({isOpen:e,combo:t,onClose:n,onSave:r,activeProviders:o,kindFilter:s=null}){const[i,l]=a.useState((t==null?void 0:t.name)||""),[c,u]=a.useState((t==null?void 0:t.models)||[]),[f,d]=a.useState(!1),[g,p]=a.useState(!1),[R,m]=a.useState(""),[x,S]=a.useState({}),D=qn(Pt(Rt,{activationConstraint:{distance:5}}),Pt(Dt,{coordinateGetter:yo})),y=c.map((C,j)=>({uid:`item-${j}`,model:C})),N=C=>{const{active:j,over:A}=C;if(A&&j.id!==A.id){const oe=y.findIndex(Q=>Q.uid===j.id),F=y.findIndex(Q=>Q.uid===A.id);oe!==-1&&F!==-1&&u(Q=>Et(Q,oe,F))}},v=async()=>{try{const C=await fetch("/api/models/alias");if(!C.ok)return;const j=await C.json();S(j.aliases||{})}catch(C){console.error("Error fetching modal data:",C)}};a.useEffect(()=>{e&&v()},[e]);const w=C=>C.trim()?Eo.test(C)?(m(""),!0):(m("Only letters, numbers, -, _ and . allowed"),!1):(m("Name is required"),!1),b=C=>{const j=C.target.value;l(j),j?w(j):m("")},E=C=>{c.includes(C.value)||u([...c,C.value])},T=C=>{u(c.filter(j=>j!==C.value))},O=C=>{u(c.filter((j,A)=>A!==C))},k=C=>{if(C===0)return;const j=[...c];[j[C-1],j[C]]=[j[C],j[C-1]],u(j)},W=C=>{if(C===c.length-1)return;const j=[...c];[j[C],j[C+1]]=[j[C+1],j[C]],u(j)},Y=async()=>{w(i)&&(p(!0),await r({name:i.trim(),models:c}),p(!1))},H=!!t;return h.jsxs(h.Fragment,{children:[h.jsx(An,{isOpen:e,onClose:n,title:H?"Edit Combo":"Create Combo",children:h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsxs("div",{children:[h.jsx(Tn,{label:"Combo Name",value:i,onChange:b,placeholder:"my-combo",error:R}),h.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),c.length===0?h.jsxs("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[h.jsx("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),h.jsx("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):h.jsx(Jr,{sensors:D,collisionDetection:Jn,onDragEnd:N,modifiers:[Ro,So],children:h.jsx(uo,{items:y.map(C=>C.uid),strategy:lo,children:h.jsx("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:y.map(({uid:C,model:j},A)=>h.jsx(Mo,{id:C,index:A,model:j,isFirst:A===0,isLast:A===y.length-1,onEdit:oe=>{const F=[...c];F[A]=oe,u(F)},onMoveUp:()=>k(A),onMoveDown:()=>W(A),onRemove:()=>O(A)},C))})})}),h.jsxs("button",{onClick:()=>d(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[h.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),h.jsxs("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[h.jsx(Je,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),h.jsx(Je,{onClick:Y,fullWidth:!0,size:"sm",disabled:!i.trim()||!!R||g,children:g?"Saving...":H?"Save":"Create"})]})]})}),h.jsx(On,{isOpen:f,onClose:()=>d(!1),onSelect:E,onDeselect:T,activeProviders:o,modelAliases:x,title:"Add Model to Combo",kindFilter:s,addedModelValues:c,closeOnSelect:!1})]})}export{Oo as default};
|