@fudrouter/fsrouter 0.6.117 → 0.6.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/routes/v1/models/route.js +12 -4
  2. package/package.json +1 -1
  3. package/public/assets/EndpointPageClient.Di2YqgPf.js +6 -0
  4. package/public/assets/Loading.D9qCFX3R.js +1 -0
  5. package/public/assets/NoAuthProxyCard.DMCykSRG.js +89 -0
  6. package/public/assets/index.C5VWu_q7.js +89 -0
  7. package/public/assets/page.BFEjgGXd.js +2 -0
  8. package/public/assets/page.BIksOupz.js +1 -0
  9. package/public/assets/page.BN35ziqx.js +6 -0
  10. package/public/assets/page.BY-Z5lJc.js +1 -0
  11. package/public/assets/page.BYuvYI81.js +1 -0
  12. package/public/assets/page.BZn6EjgR.js +1 -0
  13. package/public/assets/page.BqDkuLBL.js +1 -0
  14. package/public/assets/page.Brx8iIwy.js +31 -0
  15. package/public/assets/page.ByoxqtTd.js +1 -0
  16. package/public/assets/page.C-2PY_Ek.js +6 -0
  17. package/public/assets/page.CBJ3PIz6.js +1 -0
  18. package/public/assets/page.CC2igP7g.js +5 -0
  19. package/public/assets/page.CJV7n_Cb.js +1 -0
  20. package/public/assets/page.CadeLR3B.js +2 -0
  21. package/public/assets/page.Cn9VXlxl.js +1 -0
  22. package/public/assets/page.Cnk5NKtT.js +1 -0
  23. package/public/assets/page.Ctr5GGfe.js +23 -0
  24. package/public/assets/page.CvY1-VAN.js +5 -0
  25. package/public/assets/page.DD2_vWM3.js +1 -0
  26. package/public/assets/page.DFOtpzzq.js +7 -0
  27. package/public/assets/page.DGqaAFu_.js +1 -0
  28. package/public/assets/page.DSCWOtet.js +1 -0
  29. package/public/assets/page.DUXPs518.js +1 -0
  30. package/public/assets/page.DV-sp6Ji.js +1 -0
  31. package/public/assets/page.DarYN1Wo.js +1 -0
  32. package/public/assets/page.DsnVF9ld.js +1 -0
  33. package/public/assets/page.DuJrvy6q.js +1 -0
  34. package/public/assets/page.DvVWtaJ8.js +1 -0
  35. package/public/assets/page.Dvoll2rR.js +64 -0
  36. package/public/assets/page.K41VgPhA.js +1 -0
  37. package/public/assets/page.LA8kHbDi.js +4 -0
  38. package/public/assets/page.UGWWqB47.js +1 -0
  39. package/public/assets/page.eObJ7Eqq.js +1 -0
  40. package/public/assets/page.hGYtnZEk.js +1 -0
  41. package/public/assets/page.hr04hSjp.js +1 -0
  42. package/public/assets/page.imKuq2A5.js +1 -0
  43. package/public/assets/page.zF9qqJjX.js +1 -0
  44. package/public/index.html +4 -4
@@ -0,0 +1,6 @@
1
+ import{a as ot,j as e,B as i,M as I,C as lt}from"./index.C5VWu_q7.js";import{b as l}from"./router.Cjj1--8t.js";import{C as Pe,B as k,T as ie,I as y}from"./NoAuthProxyCard.DMCykSRG.js";import{C as Se}from"./Loading.D9qCFX3R.js";import"./zustand.akaTi5uX.js";function at(x){return x==="active"?"success":x==="error"?"error":"default"}function nt(x){if(!x)return"Never";const W=new Date(x);return Number.isNaN(W.getTime())?"Never":W.toLocaleString()}function ce(x={}){return{name:x.name||"",proxyUrl:x.proxyUrl||"",noProxy:x.noProxy||"",isActive:x.isActive!==!1,strictProxy:x.strictProxy===!0}}function ht(){const[x,W]=l.useState([]),[De,A]=l.useState(!1),[$,B]=l.useState(""),[b,L]=l.useState([]),[E,Y]=l.useState(null),[c,U]=l.useState([]),[Te,Ie]=l.useState(!0),[Ae,K]=l.useState(!1),[$e,Q]=l.useState(!1),[Ee,de]=l.useState(!1),[Ue,xe]=l.useState(!1),[Oe,me]=l.useState(!1),[O,M]=l.useState(!1),[V,he]=l.useState(null),[u,C]=l.useState(ce()),[X,ue]=l.useState(""),[F,Z]=l.useState({vercelToken:"",projectName:"vercel-relay"}),[j,_]=l.useState({accountId:"",apiToken:"",projectName:"cloudflare-relay"}),[N,q]=l.useState({denoToken:"",orgDomain:"",projectName:""}),[R,pe]=l.useState(!1),[J,fe]=l.useState(!1),[p,S]=l.useState(!1),[ee,ye]=l.useState(null),[h,H]=l.useState([]),[v,ge]=l.useState(!1),[be,te]=l.useState({current:0,total:0}),[z,D]=l.useState(!1),[g,w]=l.useState(null),se=l.useRef(null),n=ot();l.useEffect(()=>{const t=s=>{se.current&&!se.current.contains(s.target)&&M(!1)};return O&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[O]);const f=l.useCallback(async()=>{try{const t=await fetch("/api/proxy-pools?includeUsage=true",{cache:"no-store"}),s=await t.json();t.ok&&U(s.proxyPools||[])}catch(t){console.log("Error fetching proxy pools:",t)}finally{Ie(!1)}},[]),G=l.useCallback(async()=>{try{const t=await fetch("/api/proxy-combos",{cache:"no-store"}),s=await t.json();t.ok&&W(s.combos||[])}catch{}},[]);l.useEffect(()=>{f(),G()},[f,G]);const je=()=>{he(null),C(ce())},ve=()=>{je(),K(!0)},Me=t=>{he(t),C(ce(t)),K(!0)},re=()=>{K(!1),je()},Fe=async()=>{const t={name:u.name.trim(),proxyUrl:u.proxyUrl.trim(),noProxy:u.noProxy.trim(),isActive:u.isActive===!0,strictProxy:u.strictProxy===!0};if(!(!t.name||!t.proxyUrl)){pe(!0);try{const s=!!V,r=await fetch(s?`/api/proxy-pools/${V.id}`:"/api/proxy-pools",{method:s?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r.ok)await f(),re(),n.success(V?"Proxy pool updated":"Proxy pool created");else{const o=await r.json();n.error(o.error||"Failed to save proxy pool")}}catch(s){console.log("Error saving proxy pool:",s)}finally{pe(!1)}}},Re=async t=>{w({title:"Delete Proxy Pool",message:`Delete proxy pool "${t.name}"?`,onConfirm:async()=>{w(null);try{const s=await fetch(`/api/proxy-pools/${t.id}`,{method:"DELETE"});if(s.ok){U(o=>o.filter(a=>a.id!==t.id)),n.success("Proxy pool deleted");return}const r=await s.json();s.status===409?n.warning(`Cannot delete: ${r.boundConnectionCount||0} connection(s) are still using this pool.`):n.error(r.error||"Failed to delete proxy pool")}catch(s){console.log("Error deleting proxy pool:",s),n.error("Failed to delete proxy pool")}}})},ze=async t=>{ye(t);try{const s=await fetch(`/api/proxy-pools/${t}/test`,{method:"POST"}),r=await s.json();if(!s.ok){n.error(r.error||"Failed to test proxy");return}await f(),n.success(r.ok?"Proxy test passed":"Proxy test failed")}catch(s){console.log("Error testing proxy pool:",s),n.error("Failed to test proxy")}finally{ye(null)}},We=async t=>{const s=!t.isActive;U(r=>r.map(o=>o.id===t.id?{...o,isActive:s}:o));try{(await fetch(`/api/proxy-pools/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:s})})).ok||(U(o=>o.map(a=>a.id===t.id?{...a,isActive:t.isActive}:a)),n.error("Failed to update active state"))}catch(r){console.log("Error toggling active:",r),U(o=>o.map(a=>a.id===t.id?{...a,isActive:t.isActive}:a))}},oe=c.length>0&&h.length===c.length,Be=t=>H(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t]),Le=()=>H(oe?[]:c.map(t=>t.id)),ke=()=>H([]),Ce=async t=>{const s=h.length>0?h:c.map(r=>r.id);if(s.length!==0){D(!0);try{let r=0,o=0;for(const a of s)try{(await fetch(`/api/proxy-pools/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok?r+=1:o+=1}catch{o+=1}await f(),n.success(`${t?"Activated":"Deactivated"} ${r}${o?`, failed ${o}`:""}`)}finally{D(!1)}}},Ve=async()=>{h.length!==0&&w({title:"Delete Proxy Pools",message:`Delete ${h.length} proxy pool(s)?`,onConfirm:async()=>{w(null),D(!0);try{let t=0,s=0,r=0;for(const o of h)try{const a=await fetch(`/api/proxy-pools/${o}`,{method:"DELETE"});a.ok?t+=1:a.status===409?s+=1:r+=1}catch{r+=1}await f(),ke(),n.success(`Deleted ${t}${s?`, ${s} bound`:""}${r?`, ${r} failed`:""}`)}finally{D(!1)}}})},_e=async()=>{const t=h.length>0?c.filter(d=>h.includes(d.id)):c;if(t.length===0)return;ge(!0),te({current:0,total:t.length});let s=0;const r=[];let o=0;const a=10,m=[...t],P=async()=>{for(;m.length>0;){const d=m.shift();if(!d)break;try{const T=await fetch(`/api/proxy-pools/${d.id}/test`,{method:"POST"}),we=await T.json();T.ok&&we.ok?s+=1:r.push(d.id)}catch{r.push(d.id)}finally{o+=1,te({current:o,total:t.length})}}};await Promise.all(Array.from({length:Math.min(a,t.length)},P)),await f(),ge(!1),te({current:0,total:0}),r.length>0?w({title:"Disable Dead Proxies",message:`Alive: ${s}, Dead: ${r.length}.
2
+
3
+ Disable ${r.length} dead proxies?`,onConfirm:async()=>{w(null),D(!0);try{for(const d of r)try{await fetch(`/api/proxy-pools/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})})}catch{}await f(),n.success(`Disabled ${r.length} dead proxies`)}finally{D(!1)}}}):n.success(`Health check done. Alive: ${s}, Dead: ${r.length}`)};l.useEffect(()=>{H(t=>t.filter(s=>c.some(r=>r.id===s)))},[c]);const qe=()=>{ue(""),Q(!0)},Ne=()=>{J||Q(!1)},Je=()=>{Z({vercelToken:"",projectName:"vercel-relay"}),de(!0)},le=()=>{p||de(!1)},He=()=>{_({accountId:"",apiToken:"",projectName:"cloudflare-relay"}),xe(!0)},ae=()=>{p||xe(!1)},Ge=()=>{q({denoToken:"",orgDomain:"",projectName:""}),me(!0)},ne=()=>{p||me(!1)},Ye=async()=>{if(F.vercelToken.trim()){S(!0);try{const t=await fetch("/api/proxy-pools/vercel-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),s=await t.json();t.ok?(await f(),le(),n.success(`Deployed: ${s.deployUrl}`)):n.error(s.error||"Deploy failed")}catch(t){console.log("Error deploying Vercel relay:",t),n.error("Deploy failed")}finally{S(!1)}}},Ke=async()=>{if(!(!j.accountId.trim()||!j.apiToken.trim())){S(!0);try{const t=await fetch("/api/proxy-pools/cloudflare-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)}),s=await t.json();t.ok?(await f(),ae(),n.success(`Deployed: ${s.deployUrl}`)):n.error(s.error||"Deploy failed")}catch(t){console.log("Error deploying Cloudflare relay:",t),n.error("Deploy failed")}finally{S(!1)}}},Qe=async()=>{if(N.denoToken.trim()){S(!0);try{const t=await fetch("/api/proxy-pools/deno-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),s=await t.json();t.ok?(await f(),ne(),n.success(`Deployed: ${s.deployUrl}`)):n.error(s.error||"Deploy failed")}catch(t){console.log("Error deploying Deno relay:",t),n.error("Deploy failed")}finally{S(!1)}}},Xe=t=>{const s=t.trim();if(!s)return null;if(s.includes("://")){const o=new URL(s),a=o.port?`${o.hostname}:${o.port}`:o.hostname;return{proxyUrl:o.toString(),name:`Imported ${a}`}}const r=s.split(":");if(r.length===4){const[o,a,m,P]=r;if(!o||!a||!m||!P)throw new Error("Invalid host:port:user:pass format");const d=`http://${encodeURIComponent(m)}:${encodeURIComponent(P)}@${o}:${a}`;return{proxyUrl:new URL(d).toString(),name:`Imported ${o}:${a}`}}throw new Error("Unsupported format")},Ze=async()=>{const t=X.split(/\r?\n/).map(o=>o.trim()).filter(Boolean);if(t.length===0){n.warning("Please paste at least one proxy line.");return}const s=[],r=[];if(t.forEach((o,a)=>{try{const m=Xe(o);m&&s.push({...m,lineNumber:a+1})}catch(m){r.push(`Line ${a+1}: ${m.message}`)}}),r.length>0){n.error(`Invalid proxy format:
4
+ ${r.join(`
5
+ `)}`);return}fe(!0);try{const o=new Set(c.map(d=>`${(d.proxyUrl||"").trim()}|||${(d.noProxy||"").trim()}`));let a=0,m=0,P=0;for(const d of s){const T=`${d.proxyUrl}|||`;if(o.has(T)){m+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,proxyUrl:d.proxyUrl,noProxy:"",isActive:!0})})).ok?(a+=1,o.add(T)):P+=1}await f(),Q(!1),n.success(`Batch import completed: Created ${a}, Skipped ${m}, Failed ${P}`)}catch(o){console.log("Error batch importing proxies:",o),n.error("Batch import failed")}finally{fe(!1)}},et=l.useMemo(()=>c.filter(t=>t.isActive===!0).length,[c]);if(Te)return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[e.jsx(Se,{}),e.jsx(Se,{})]});const tt=async()=>{if(!$.trim()||b.length===0)return;const t=E?"PUT":"POST",s=E?{id:E.id,name:$,poolIds:b}:{name:$,poolIds:b};await fetch("/api/proxy-combos",{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),A(!1),B(""),L([]),Y(null),G()},st=async t=>{await fetch("/api/proxy-combos",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})}),G()},rt=t=>{var s;return((s=c.find(r=>r.id===t))==null?void 0:s.name)||t.slice(0,8)};return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"text-xl font-semibold sm:text-2xl",children:"Proxy Pools"})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[e.jsxs("div",{className:"relative",ref:se,children:[e.jsxs(i,{size:"sm",variant:"secondary",icon:"rocket_launch",onClick:()=>M(!O),children:["Deploy Relay",e.jsx("span",{className:"material-symbols-outlined ml-1 text-[18px]",children:O?"expand_less":"expand_more"})]}),O&&e.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-48 rounded-xl border border-black/10 bg-white p-1 shadow-xl dark:border-white/10 dark:bg-zinc-900 sm:left-auto sm:right-0",children:[e.jsxs("button",{onClick:()=>{He(),M(!1)},className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-main transition-colors hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-orange-500",children:"cloud"}),"Cloudflare Relay"]}),e.jsxs("button",{onClick:()=>{Je(),M(!1)},className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-main transition-colors hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-blue-500",children:"cloud_upload"}),"Vercel Relay"]}),e.jsxs("button",{onClick:()=>{Ge(),M(!1)},className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-main transition-colors hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-green-500",children:"terminal"}),"Deno Relay"]})]})]}),e.jsx(i,{size:"sm",variant:"secondary",icon:"upload",onClick:qe,children:"Batch Import"}),e.jsx(i,{size:"sm",icon:"add",onClick:ve,children:"Add Proxy Pool"})]})]}),e.jsxs(Pe,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[c.length>0&&e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:oe,onChange:Le,className:"size-4 rounded border-black/20 dark:border-white/20"}),oe?"Unselect all":"Select all"]}),e.jsxs(k,{variant:"default",children:["Total: ",c.length]}),e.jsxs(k,{variant:"success",children:["Active: ",et]})]}),(h.length>0||v)&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"checklist"}),e.jsx("span",{className:"text-xs font-medium text-primary",children:h.length>0?`${h.length} selected`:"All pools"}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsx(i,{size:"sm",icon:v?"progress_activity":"health_and_safety",onClick:_e,disabled:v||z||c.length===0,children:v?`Checking ${be.current}/${be.total}`:"Health Check"}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(i,{size:"sm",variant:"secondary",icon:"toggle_on",onClick:()=>Ce(!0),disabled:z||v,children:"Activate"}),e.jsx(i,{size:"sm",variant:"secondary",icon:"toggle_off",onClick:()=>Ce(!1),disabled:z||v,children:"Deactivate"}),e.jsx(i,{size:"sm",variant:"secondary",icon:"delete",onClick:Ve,disabled:z||v,children:"Delete"}),e.jsx(i,{size:"sm",variant:"ghost",onClick:ke,disabled:z||v,children:"Clear"})]})]})]}),c.length===0?e.jsxs("div",{className:"text-center py-10",children:[e.jsx("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),e.jsx(i,{icon:"add",onClick:ve,children:"Add Proxy Pool"})]}):e.jsx("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:c.map(t=>e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[e.jsx("input",{type:"checkbox",checked:h.includes(t.id),onChange:()=>Be(t.id),className:"mt-1 size-4 shrink-0 rounded border-black/20 dark:border-white/20"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"min-w-0 max-w-full truncate text-sm font-medium sm:max-w-[18rem]",children:t.name}),e.jsx(k,{variant:at(t.testStatus),size:"sm",dot:!0,children:t.testStatus||"unknown"}),e.jsx(k,{variant:t.isActive?"success":"default",size:"sm",children:t.isActive?"active":"inactive"}),t.type==="vercel"&&e.jsx(k,{variant:"default",size:"sm",children:"vercel relay"}),t.type==="cloudflare"&&e.jsx(k,{variant:"default",size:"sm",children:"cloudflare relay"}),e.jsxs(k,{variant:"default",size:"sm",children:[t.boundConnectionCount||0," bound"]})]}),e.jsx("p",{className:"text-xs text-text-muted truncate mt-1",children:t.proxyUrl}),t.noProxy?e.jsxs("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",t.noProxy]}):null,e.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",nt(t.lastTestedAt),t.lastError?` · ${t.lastError}`:""]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(ie,{size:"sm",checked:t.isActive===!0,onChange:()=>We(t),title:t.isActive?"Disable":"Enable"}),e.jsx("button",{onClick:()=>ze(t.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:ee===t.id,children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",style:ee===t.id?{animation:"spin 1s linear infinite"}:void 0,children:ee===t.id?"progress_activity":"science"})}),e.jsx("button",{onClick:()=>Me(t),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),e.jsx("button",{onClick:()=>Re(t),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},t.id))})]}),e.jsx(I,{isOpen:$e,title:"Batch Import Proxies",onClose:Ne,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),e.jsx("textarea",{value:X,onChange:t=>ue(t.target.value),placeholder:`http://user:pass@127.0.0.1:7897
6
+ 127.0.0.1:7897:user:pass`,className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Ze,disabled:!X.trim()||J,children:J?"Importing...":"Import"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:Ne,disabled:J,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Ee,title:"Deploy Vercel Relay",onClose:le,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-blue-500/5 border border-blue-500/10 p-3 flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-sm text-text-main font-medium",children:"What is Vercel Relay?"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deploys an edge relay function to Vercel. All AI provider requests will be forwarded through Vercel's edge network, masking your real IP from providers."}),e.jsxs("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[e.jsx("li",{children:"Your IP is replaced by Vercel's dynamic edge IPs (hundreds of IPs across 20+ global regions)"}),e.jsx("li",{children:"Vercel serves millions of apps — providers can't block Vercel IPs without affecting legitimate traffic"}),e.jsx("li",{children:"Free tier: 100GB bandwidth/month, 500K edge invocations"}),e.jsx("li",{children:"Deploy multiple relays on different accounts for more IP diversity"})]})]}),e.jsx(y,{label:"Vercel API Token",value:F.vercelToken,onChange:t=>Z(s=>({...s,vercelToken:t.target.value})),placeholder:"your-vercel-api-token",hint:e.jsxs(e.Fragment,{children:["Token is used once for deployment and not stored. ",e.jsx("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),e.jsx(y,{label:"Project Name",value:F.projectName,onChange:t=>Z(s=>({...s,projectName:t.target.value})),placeholder:"my-relay",hint:"Unique name for your Vercel project. Leave empty for auto-generated name."}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Ye,disabled:!F.vercelToken.trim()||p,children:p?"Deploying... (may take ~1 min)":"Deploy"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:le,disabled:p,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Ue,title:"Deploy Cloudflare Relay",onClose:ae,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-orange-500/5 border border-orange-500/10 p-3 flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-sm text-text-main font-medium",children:"What is Cloudflare Relay?"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deploys a Cloudflare Worker as a proxy relay. All AI provider requests will be forwarded through Cloudflare's global edge network."}),e.jsxs("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[e.jsx("li",{children:"High performance global routing and IP masking via Cloudflare Workers"}),e.jsx("li",{children:"Free tier: 100,000 requests per day"}),e.jsx("li",{children:"Requires Cloudflare Account ID and a Workers API Token (Edit Workers permission)"})]}),e.jsxs("div",{className:"mt-2 pt-2 border-t border-orange-500/10 text-xs text-text-muted",children:[e.jsx("p",{className:"font-medium text-text-main mb-1",children:"How to generate your API Token:"}),e.jsxs("ol",{className:"list-decimal pl-4 space-y-0.5",children:[e.jsxs("li",{children:["Go to ",e.jsx("b",{children:"My Profile"})," → ",e.jsx("b",{children:"API Tokens"})," → ",e.jsx("b",{children:"Create Token"})]}),e.jsxs("li",{children:["Scroll down to ",e.jsx("b",{children:"Custom Token"})," and click ",e.jsx("b",{children:"Get started"})]}),e.jsxs("li",{children:["Under ",e.jsx("b",{children:"Permissions"}),": Account | Workers Scripts | Edit"]}),e.jsxs("li",{children:["Under ",e.jsx("b",{children:"Account Resources"}),": Include | Account | ",e.jsx("i",{children:"Your Account Name"})]}),e.jsxs("li",{children:["Click ",e.jsx("b",{children:"Continue to summary"})," → ",e.jsx("b",{children:"Create Token"})]})]})]})]}),e.jsx(y,{label:"Account ID",value:j.accountId,onChange:t=>_(s=>({...s,accountId:t.target.value})),placeholder:"your-cloudflare-account-id",hint:e.jsx(e.Fragment,{children:"Found on the right side of the Cloudflare dashboard overview page."})}),e.jsx(y,{label:"API Token",value:j.apiToken,onChange:t=>_(s=>({...s,apiToken:t.target.value})),placeholder:"your-cloudflare-api-token",hint:e.jsxs(e.Fragment,{children:['Requires "Workers Scripts: Edit" permission. ',e.jsx("a",{href:"https://dash.cloudflare.com/profile/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),e.jsx(y,{label:"Worker Name",value:j.projectName,onChange:t=>_(s=>({...s,projectName:t.target.value})),placeholder:"my-relay",hint:"Unique name for your Cloudflare Worker. Leave empty for auto-generated name."}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Ke,disabled:!j.accountId.trim()||!j.apiToken.trim()||p,children:p?"Deploying...":"Deploy Worker"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:ae,disabled:p,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Oe,title:"Deploy Deno Relay",onClose:ne,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 p-3 flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-sm text-text-main font-medium",children:"What is Deno Relay?"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deploys a relay worker to Deno Deploy's global edge network. All AI provider requests are forwarded through Deno's edge, masking your real IP."}),e.jsxs("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[e.jsx("li",{children:"Deno Deploy v2 runs on a high-performance global edge network"}),e.jsx("li",{children:"Free tier: 1M requests & 100GiB outbound traffic per month"}),e.jsx("li",{children:"No per-request CPU time limits (unlike Vercel/Cloudflare)"}),e.jsx("li",{children:"Support up to 20 active apps & 50 custom domains"}),e.jsx("li",{children:"Deploy multiple relays for maximum IP diversity"})]}),e.jsxs("div",{className:"mt-2 pt-2 border-t border-black/10 dark:border-white/10 text-xs text-text-muted",children:[e.jsx("p",{className:"font-medium text-text-main mb-1",children:"How to generate API token:"}),e.jsxs("ol",{className:"list-decimal pl-4 space-y-0.5",children:[e.jsxs("li",{children:["Go to ",e.jsx("b",{children:"console.deno.com"})]}),e.jsxs("li",{children:["Select your ",e.jsx("b",{children:"Organization"})," → ",e.jsx("b",{children:"Settings"})," → ",e.jsx("b",{children:"Organization Tokens"})]}),e.jsxs("li",{children:["Create a ",e.jsx("b",{children:"Organization Token"})," (prefix ",e.jsx("b",{children:"ddo_"}),")"]})]})]})]}),e.jsx(y,{label:"Deno Deploy API Token",value:N.denoToken,onChange:t=>q(s=>({...s,denoToken:t.target.value})),placeholder:"ddo_xxxxxxxxxxxxxxxx",hint:e.jsx(e.Fragment,{children:"Token is used once for deployment, not stored. Found in Organization Settings."}),type:"password"}),e.jsx(y,{label:"Organization Domain",value:N.orgDomain,onChange:t=>q(s=>({...s,orgDomain:t.target.value})),placeholder:"your-org.deno.net",hint:"Organization's default domain. Your relay URL will be in the format: https://my-relay.your-org.deno.net"}),e.jsx(y,{label:"App Name",value:N.projectName,onChange:t=>q(s=>({...s,projectName:t.target.value})),placeholder:"deno-relay",hint:"Unique app name. Leave empty for auto-generated name."}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Qe,disabled:!N.denoToken.trim()||!N.orgDomain.trim()||p,children:p?"Deploying...":"Deploy Relay"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:ne,disabled:p,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Ae,title:V?"Edit Proxy Pool":"Add Proxy Pool",onClose:re,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(y,{label:"Name",value:u.name,onChange:t=>C(s=>({...s,name:t.target.value})),placeholder:"Office Proxy"}),e.jsx(y,{label:"Proxy URL",value:u.proxyUrl,onChange:t=>C(s=>({...s,proxyUrl:t.target.value})),placeholder:"http://127.0.0.1:7897"}),e.jsx(y,{label:"No Proxy",value:u.noProxy,onChange:t=>C(s=>({...s,noProxy:t.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Active"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),e.jsx(ie,{checked:u.isActive===!0,onChange:()=>C(t=>({...t,isActive:!t.isActive})),disabled:R})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Strict Proxy"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),e.jsx(ie,{checked:u.strictProxy===!0,onChange:()=>C(t=>({...t,strictProxy:!t.strictProxy})),disabled:R})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Fe,disabled:!u.name.trim()||!u.proxyUrl.trim()||R,children:R?"Saving...":"Save"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:re,disabled:R,children:"Cancel"})]})]})}),e.jsxs(Pe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Proxy Combos"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Round-robin rotation across multiple pools"})]}),e.jsx(i,{size:"sm",icon:"add",onClick:()=>{Y(null),B(""),L([]),A(!0)},children:"Add Combo"})]}),x.length===0?e.jsx("p",{className:"text-sm text-text-muted py-4 text-center",children:"No combos yet. Create one to rotate proxies automatically."}):e.jsx("div",{className:"space-y-2",children:x.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border-subtle bg-surface hover:bg-surface/50",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm text-text-main",children:t.name}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:(t.poolIds||[]).map((s,r)=>e.jsxs("span",{children:[r>0?" → ":"",rt(s)]},s))})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-3",children:[e.jsxs(k,{variant:"success",size:"sm",children:[(t.poolIds||[]).length," pools"]}),e.jsx("button",{onClick:()=>{Y(t),B(t.name),L(t.poolIds||[]),A(!0)},className:"text-xs text-brand-400 hover:text-brand-300 cursor-pointer",children:"Edit"}),e.jsx("button",{onClick:()=>st(t.id),className:"text-xs text-red-400 hover:text-red-300 cursor-pointer",children:"Delete"})]})]},t.id))})]}),e.jsx(I,{isOpen:De,onClose:()=>A(!1),title:E?"Edit Combo":"Create Proxy Combo",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-text-muted block mb-1",children:"Combo Name"}),e.jsx(y,{value:$,onChange:t=>B(t.target.value),placeholder:"e.g. Free Proxy Round Robin"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-text-muted block mb-2",children:"Select Pools (click to toggle)"}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1 rounded-lg border border-border-subtle p-2",children:c.map(t=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer text-sm transition-colors ${b.includes(t.id)?"bg-primary/10 text-primary":"hover:bg-surface-2 text-text-main"}`,children:[e.jsx("input",{type:"checkbox",checked:b.includes(t.id),onChange:s=>{L(s.target.checked?[...b,t.id]:b.filter(r=>r!==t.id))},className:"rounded"}),t.name]},t.id))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{fullWidth:!0,onClick:tt,disabled:!$.trim()||b.length===0,children:E?"Save Changes":"Create Combo"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:()=>A(!1),children:"Cancel"})]})]})}),e.jsx(lt,{isOpen:!!g,onClose:()=>w(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"})]})}export{ht as default};
@@ -0,0 +1 @@
1
+ import{u as Re,r as ce,v as Ue,j as t,M as Ie,B as b,C as Oe}from"./index.C5VWu_q7.js";import{b as s}from"./router.Cjj1--8t.js";import{C as Be,T as y,I as Me}from"./NoAuthProxyCard.DMCykSRG.js";import"./zustand.akaTi5uX.js";const $e=["zh-CN","zh-TW"],S=[{id:"lite",label:"Lite",desc:"Drop filler, keep grammar"},{id:"full",label:"Full",desc:"Drop articles, fragments OK"},{id:"ultra",label:"Ultra",desc:"Telegraphic, max compression"},{id:"wenyan-lite",label:"文 Lite",desc:"Classical Chinese, light compression",wenyan:!0},{id:"wenyan",label:"文 Full",desc:"Maximum 文言文, 80-90% reduction",wenyan:!0},{id:"wenyan-ultra",label:"文 Ultra",desc:"Extreme classical compression",wenyan:!0}],de=[{id:"lite",label:"Lite",desc:"Build asked, name lazier option"},{id:"full",label:"Full",desc:"Ladder enforced: stdlib/native first"},{id:"ultra",label:"Ultra",desc:"YAGNI extremist, deletion first"}];function Ke(){var le,ie;const[M,$]=s.useState(!0),[D,J]=s.useState(!1),[L,j]=s.useState("http://localhost:8787"),[l,T]=s.useState({installed:!1,running:!1,python:null,loading:!0}),[me,A]=s.useState(!1),[v,w]=s.useState(!1),[_,G]=s.useState(""),[N,h]=s.useState({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),[c,x]=s.useState([]),[P,K]=s.useState(!1),[W,p]=s.useState(""),[H,z]=s.useState(null),[F,Y]=s.useState(""),[n,C]=s.useState(null),[he,V]=s.useState(!1),[xe,q]=s.useState(!0),[Q,X]=s.useState(!1),u=s.useRef(null),[R,Z]=s.useState(!1),[k,U]=s.useState("full"),[I,ee]=s.useState(!1),[te,ae]=s.useState("full"),[pe,se]=s.useState("en"),{copied:ue,copy:fe}=Re();s.useEffect(()=>(se(ce()),Ue(()=>se(ce()))),[]);const O=$e.includes(pe),ge=O?S:S.filter(e=>!e.wenyan);s.useEffect(()=>{const e=S.find(a=>a.id===k);e!=null&&e.wenyan&&!O&&(U("ultra"),m({cavemanLevel:"ultra"}))},[O,k]);const m=async e=>{try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(a){console.log("Error updating setting:",a)}},be=async e=>{try{(await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rtkEnabled:e})})).ok&&$(e)}catch(a){console.log("Error updating rtkEnabled:",a)}},ye=e=>{Z(e),m({cavemanEnabled:e})},je=e=>{U(e),m({cavemanLevel:e})},ve=e=>{const a=L.trim()||"http://localhost:8787";j(a),J(e),m({headroomEnabled:e,headroomUrl:a})},we=async()=>{const e=L.trim()||"http://localhost:8787";j(e),await m({headroomUrl:e}),i()},i=s.useCallback(async()=>{T(e=>({...e,loading:!0}));try{const a=await(await fetch("/api/headroom/status",{headers:{"Cache-Control":"no-store"}})).json();if(T({...a,loading:!1}),!(a!=null&&a.installed)){h({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),x([]);return}try{const r=await fetch("/api/headroom/extras",{headers:{"Cache-Control":"no-store"}});if(!r.ok)throw new Error("extras status failed");const o=await r.json();h(g=>({...g,version:o.version??null,extras:o.extras||{code:!1,ml:!1},available:o.available||["code","ml"],loading:!1})),x([])}catch{h({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),x([])}}catch{T({installed:!1,running:!1,python:null,loading:!1}),h({version:null,extras:{code:!1,ml:!1},available:["code","ml"],loading:!1}),x([])}},[]),Ne=s.useCallback(async()=>{G(""),w(!0);try{const e=await fetch("/api/headroom/start",{method:"POST"}),a=await e.json().catch(()=>({}));if(!e.ok)throw new Error(a.error||"Failed to start proxy");await i()}catch(e){G(e.message)}finally{w(!1)}},[i]),Ce=s.useCallback(async()=>{w(!0);try{await fetch("/api/headroom/stop",{method:"POST"}),await i()}finally{w(!1)}},[i]),ke=e=>{x(a=>a.includes(e)?a.filter(r=>r!==e):[...a,e])},E=s.useCallback(()=>{Y(""),u.current&&clearInterval(u.current);const e=async()=>{try{const r=await(await fetch("/api/headroom/extras?log=1",{headers:{"Cache-Control":"no-store"}})).json().catch(()=>({}));typeof r.log=="string"&&Y(r.log)}catch{}};e(),u.current=setInterval(e,1500)},[]),f=s.useCallback(()=>{u.current&&(clearInterval(u.current),u.current=null)},[]);s.useEffect(()=>()=>f(),[f]);const B=s.useCallback(async()=>{if(c.length!==0){K(!0),p(""),E();try{const e=await fetch("/api/headroom/extras",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:c})}),a=await e.json().catch(()=>({}));if(!e.ok)throw new Error(a.error||"Install failed");h(r=>({...r,version:a.version??r.version,extras:a.extras||r.extras})),x([])}catch(e){p(e.message)}finally{f(),K(!1)}}},[c,E,f]),re=s.useCallback(async e=>{z(e),p(""),E();try{const a=await fetch("/api/headroom/extras",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({extras:[e]})}),r=await a.json().catch(()=>({}));if(!a.ok)throw new Error(r.error||"Remove failed");h(o=>({...o,version:r.version??o.version,extras:r.extras||o.extras}))}catch(a){p(a.message)}finally{f(),z(null)}},[E,f]),Ee=s.useCallback(()=>{if(c.length!==0){if(c.includes("ml")){C({title:"Install [ml]",message:"[ml] downloads ~1 GB (torch + huggingface-hub). Continue?",confirmText:"Install",variant:"primary",onConfirm:B});return}B()}},[c,B]),Se=s.useCallback(e=>{C({title:`Remove [${e}]`,message:`Remove [${e}] and its packages?`,confirmText:"Remove",variant:"danger",onConfirm:()=>re(e)})},[re]),Le=s.useCallback(async(e,a)=>{if(p(""),e==="code"&&V(a),e==="ml"&&q(a),await m({[e==="code"?"headroomCodeAware":"headroomKompress"]:a}),!!l.running){X(!0);try{const o=await fetch("/api/headroom/restart",{method:"POST"}),g=await o.json().catch(()=>({}));if(!o.ok)throw new Error(g.error||"Restart failed");await i()}catch(o){p(o.message)}finally{X(!1)}}},[l.running,i]),Te=e=>{ee(e),m({ponytailEnabled:e})},Ae=e=>{ae(e),m({ponytailLevel:e})};s.useEffect(()=>{(async()=>{try{const a=await fetch("/api/settings");if(!a.ok)return;const r=await a.json();$(r.rtkEnabled!==!1),J(!!r.headroomEnabled),j(r.headroomUrl||"http://localhost:8787"),V(r.headroomCodeAware===!0),q(r.headroomKompress!==!1),Z(!!r.cavemanEnabled),U(r.cavemanLevel||"full"),ee(!!r.ponytailEnabled),ae(r.ponytailLevel||"full"),i()}catch{}})()},[i]);const d=!!l.running,ne=l.loading?"Checking…":d?"Running":l.localUrl!==!1&&!l.installed?"Not installed":l.localUrl!==!1?"Stopped":"External",oe=l.localUrl!==!1,Pe=!!l.canStart,He=oe&&!!l.managedPid;return t.jsxs("div",{className:"space-y-6 p-6",children:[t.jsxs(Be,{id:"rtk",children:[t.jsx("div",{className:"flex items-center justify-between mb-2",children:t.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[t.jsx("span",{className:"material-symbols-outlined text-primary",children:"bolt"}),"Token Saver"]})}),t.jsxs("div",{className:"flex items-center justify-between pt-2 pb-4 border-b border-border gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"font-medium",children:["Compress tool output"," ",t.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(RTK)"})]}),t.jsx("p",{className:"text-sm text-text-muted",children:"git/grep/ls/tree/logs → 60-90% fewer input tokens"})]}),t.jsx(y,{checked:M,onChange:()=>be(!M)})]}),t.jsxs("div",{className:"flex items-center justify-between py-4 gap-4 flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[t.jsxs("p",{className:"font-medium",children:["Compress context"," ",t.jsx("a",{href:"https://github.com/chopratejas/headroom",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Headroom)"})]}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${d?"bg-success/15 text-success":"bg-warning/15 text-warning"}`,children:ne}),t.jsx("button",{type:"button",onClick:()=>A(!0),className:"text-xs text-primary underline hover:opacity-80",children:d?"Manage":"Setup"})]}),t.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Compress prompts via /v1/compress before routing to the model"})]}),t.jsx(y,{checked:D&&d,disabled:!d,onChange:()=>ve(!D)})]}),l.installed&&t.jsxs("div",{className:"mb-3 ml-1 pl-3 pb-4 border-l-2 border-border",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"text-xs text-text-muted",children:["Compression extras",N.version?` · v${N.version}`:"",":"]}),N.available.map(e=>{const a=!!N.extras[e],r=c.includes(e),o=e==="code"?"tree-sitter AST compression for code responses":"Kompress-v2 HF model for prose/agentic traces (~+1GB)";if(a){const g=e==="code"?he:xe;return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs px-2 py-1 rounded border border-success/40 bg-success/5 text-text",title:o,children:[t.jsx(y,{size:"sm",checked:g,disabled:Q,onChange:()=>Le(e,!g)}),t.jsxs("span",{className:"font-medium",children:["[",e,"]"]}),t.jsx("button",{type:"button",onClick:()=>Se(e),disabled:H===e,className:"ml-1 text-error underline hover:opacity-80 disabled:opacity-50",title:`Uninstall [${e}]`,children:H===e?"Uninstalling…":"Uninstall"})]},e)}return t.jsxs("label",{className:`flex items-center gap-1.5 text-xs px-2 py-1 rounded border cursor-pointer transition-colors ${r?"border-primary bg-primary/10 text-primary":"border-border text-text-muted hover:bg-surface-2"}`,title:o,children:[t.jsx("input",{type:"checkbox",className:"w-3 h-3",checked:r,onChange:()=>ke(e)}),t.jsxs("span",{className:"font-medium",children:["[",e,"]"]}),t.jsx("span",{className:"opacity-70",children:"not installed"})]},e)}),c.length>0&&t.jsx("button",{onClick:Ee,disabled:P,className:"text-xs px-2.5 py-1 rounded bg-primary text-white hover:opacity-90 disabled:opacity-50",children:P?"Installing…":`Install [proxy,${c.join(",")}]`})]}),W&&t.jsx("p",{className:"text-xs text-error mt-1",children:W}),Q&&t.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Restarting proxy…"}),(P||H)&&F&&t.jsx("pre",{className:"mt-2 max-h-32 overflow-auto rounded bg-surface-2 p-2 text-[10px] leading-tight text-text-muted whitespace-pre-wrap",children:F}),t.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Installing adds the package; use ",t.jsx("code",{children:"on"}),"/",t.jsx("code",{children:"off"})," ","to activate it (restarts the proxy). Default install is"," ",t.jsx("code",{children:"[proxy]"})," only (SmartCrusher for JSON). Adding"," ",t.jsx("code",{children:"[code]"})," enables AST compression (Python/JS/TS/Go/Rust/Java/C/C++/Perl). Adding ",t.jsx("code",{children:"[ml]"})," ","enables the Kompress-v2 HF model for prose/agentic traces but adds ~1 GB (torch + huggingface-hub)."]})]}),t.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-border gap-4 flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"font-medium",children:["Compress LLM output"," ",t.jsx("a",{href:"https://github.com/JuliusBrussee/caveman",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Caveman)"})]}),t.jsx("p",{className:"text-sm text-text-muted",children:"Terse-style system prompt → ~65% fewer output tokens (up to 87%)"})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[R&&t.jsxs("div",{className:"flex flex-col items-end gap-1",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:ge.map(e=>t.jsx("button",{onClick:()=>je(e.id),className:`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${k===e.id?"bg-primary text-white border-primary":"bg-transparent border-border text-text-muted hover:bg-surface-2"}`,title:e.desc,children:e.label},e.id))}),t.jsx("p",{className:"text-xs text-primary",children:(le=S.find(e=>e.id===k))==null?void 0:le.desc})]}),t.jsx(y,{checked:R,onChange:()=>ye(!R)})]})]}),t.jsxs("div",{className:"flex items-center justify-between pt-4 mt-4 border-t border-border gap-4 flex-wrap",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"font-medium",children:["Lazy senior dev"," ",t.jsx("a",{href:"https://github.com/DietrichGebert/ponytail",target:"_blank",rel:"noreferrer",className:"text-xs font-normal text-primary underline hover:opacity-80",children:"(Ponytail)"})]}),t.jsx("p",{className:"text-sm text-text-muted",children:"Bias the model toward minimal code: YAGNI, reuse stdlib, deletion over addition"})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[I&&t.jsxs("div",{className:"flex flex-col items-end gap-1",children:[t.jsx("div",{className:"flex items-center gap-1.5",children:de.map(e=>t.jsx("button",{onClick:()=>Ae(e.id),className:`px-3 py-1.5 rounded text-xs font-medium border transition-colors ${te===e.id?"bg-primary text-white border-primary":"bg-transparent border-border text-text-muted hover:bg-surface-2"}`,title:e.desc,children:e.label},e.id))}),t.jsx("p",{className:"text-xs text-primary",children:(ie=de.find(e=>e.id===te))==null?void 0:ie.desc})]}),t.jsx(y,{checked:I,onChange:()=>Te(!I)})]})]})]}),t.jsx(Ie,{isOpen:me,title:d?"Headroom":"Setup Headroom",onClose:()=>A(!1),children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{children:"Status"}),t.jsx("span",{className:d?"text-success":"text-warning",children:ne})]}),d&&t.jsx("a",{href:"/api/headroom/proxy/dashboard",target:"_blank",rel:"noreferrer",className:"w-full rounded border border-border px-4 py-2 text-center text-sm hover:bg-surface-2",children:"Open Headroom Dashboard"}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Proxy URL"}),t.jsx(Me,{value:L,onChange:e=>j(e.target.value),onBlur:we,placeholder:"http://localhost:8787",className:"font-mono text-sm"}),t.jsx("p",{className:"text-xs text-text-muted",children:"Use a local proxy for Start/Stop, or an external Docker sidecar like http://headroom:8787."})]}),He?t.jsx(b,{onClick:Ce,variant:"ghost",fullWidth:!0,disabled:v,children:v?"Stopping…":"Stop Headroom"}):d?t.jsx("p",{className:"text-sm text-success",children:"Headroom proxy is reachable. You can enable the token saver."}):Pe?t.jsx(b,{onClick:Ne,fullWidth:!0,disabled:v,children:v?"Starting…":"Start Headroom"}):oe?l.python?t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Install then click Start:"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("pre",{className:"flex-1 rounded bg-black/5 dark:bg-white/5 p-2 text-xs font-mono overflow-x-auto",children:'pip install "headroom-ai[proxy]"'}),t.jsx(b,{size:"sm",variant:"ghost",onClick:()=>fe('pip install "headroom-ai[proxy]"'),children:ue?"Copied":"Copy"})]})]}):t.jsx("p",{className:"text-sm text-warning",children:"Python ≥ 3.10 required for local managed mode. Install Python first, or use an external proxy URL."}):t.jsx("p",{className:"text-sm text-warning",children:"Start Headroom separately at the configured URL, then recheck."}),_&&t.jsx("p",{className:"text-sm text-warning",children:_}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(b,{onClick:()=>i(),variant:"ghost",fullWidth:!0,children:"Recheck"}),t.jsx(b,{onClick:()=>A(!1),fullWidth:!0,children:"Done"})]})]})}),t.jsx(Oe,{isOpen:!!n,onClose:()=>C(null),onConfirm:()=>{const e=n==null?void 0:n.onConfirm;C(null),e==null||e()},title:n==null?void 0:n.title,message:n==null?void 0:n.message,confirmText:n==null?void 0:n.confirmText,variant:n==null?void 0:n.variant})]})}export{Ke as default};
@@ -0,0 +1,5 @@
1
+ import{u as On,j as f,B as Je,C as Ln,p as Jt,s as Qt,q as Zt,P as en,M as zn}from"./index.C5VWu_q7.js";import{b as l,W as U,c as Te}from"./router.Cjj1--8t.js";import{C as tn,I as Pn,M as Bn}from"./NoAuthProxyCard.DMCykSRG.js";import{C as Lt}from"./Loading.D9qCFX3R.js";import"./zustand.akaTi5uX.js";function $n(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function De(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function bt(e){return"nodeType"in e}function X(e){var t,n;return e?De(e)?e:bt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function xt(e){const{Document:t}=X(e);return e instanceof t}function Ue(e){return De(e)?!1:e instanceof X(e).HTMLElement}function nn(e){return e instanceof X(e).SVGElement}function Re(e){return e?De(e)?e.document:bt(e)?xt(e)?e:Ue(e)||nn(e)?e.ownerDocument:document:document:document}const re=nt?l.useLayoutEffect:l.useEffect;function yt(e){const t=l.useRef(e);return re(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Fn(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Pe(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return re(()=>{n.current!==e&&(n.current=e)},t),n}function Xe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Qe(e){const t=yt(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function ht(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let ct={};function We(e,t){return l.useMemo(()=>{if(t)return t;const n=ct[e]==null?0:ct[e]+1;return ct[e]=n,e+"-"+n},[e,t])}function rn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((s,i)=>{const a=Object.entries(i);for(const[c,d]of a){const h=s[c];h!=null&&(s[c]=h+e*d)}return s},{...t})}}const Se=rn(1),Be=rn(-1);function Un(e){return"clientX"in e&&"clientY"in e}function wt(e){if(!e)return!1;const{KeyboardEvent:t}=X(e.target);return t&&e instanceof t}function Xn(e){if(!e)return!1;const{TouchEvent:t}=X(e.target);return t&&e instanceof t}function gt(e){if(Xn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Un(e)?{x:e.clientX,y:e.clientY}:null}const $e=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[$e.Translate.toString(e),$e.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),zt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Wn(e){return e.matches(zt)?e:e.querySelector(zt)}const Yn={display:"none"};function Vn(e){let{id:t,value:n}=e;return U.createElement("div",{id:t,style:Yn},n)}function Hn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return U.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Kn(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const on=l.createContext(null);function _n(e){const t=l.useContext(on);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function qn(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:s}=r;e.forEach(i=>{var a;return(a=i[o])==null?void 0:a.call(i,s)})},[e]),t]}const Gn={draggable:`
2
+ 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
+ `},Jn={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 Qn(e){let{announcements:t=Jn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Gn}=e;const{announce:s,announcement:i}=Kn(),a=We("DndLiveRegion"),[c,d]=l.useState(!1);if(l.useEffect(()=>{d(!0)},[]),_n(l.useMemo(()=>({onDragStart(u){let{active:g}=u;s(t.onDragStart({active:g}))},onDragMove(u){let{active:g,over:p}=u;t.onDragMove&&s(t.onDragMove({active:g,over:p}))},onDragOver(u){let{active:g,over:p}=u;s(t.onDragOver({active:g,over:p}))},onDragEnd(u){let{active:g,over:p}=u;s(t.onDragEnd({active:g,over:p}))},onDragCancel(u){let{active:g,over:p}=u;s(t.onDragCancel({active:g,over:p}))}}),[s,t])),!c)return null;const h=U.createElement(U.Fragment,null,U.createElement(Vn,{id:r,value:o.draggable}),U.createElement(Hn,{id:a,announcement:i}));return n?Te.createPortal(h,n):h}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 l.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Zn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Z=Object.freeze({x:0,y:0});function sn(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function an(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function er(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 ln(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function $t(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 tr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=$t(t,t.left,t.top),s=[];for(const i of r){const{id:a}=i,c=n.get(a);if(c){const d=sn($t(c),o);s.push({id:a,data:{droppableContainer:i,value:d}})}}return s.sort(an)},nr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Bt(t),s=[];for(const i of r){const{id:a}=i,c=n.get(a);if(c){const d=Bt(c),h=o.reduce((g,p,R)=>g+sn(d[R],p),0),u=Number((h/4).toFixed(4));s.push({id:a,data:{droppableContainer:i,value:u}})}}return s.sort(an)};function rr(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,a=s-n;if(r<o&&n<s){const c=t.width*t.height,d=e.width*e.height,h=i*a,u=h/(c+d-h);return Number(u.toFixed(4))}return 0}const or=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,a=n.get(i);if(a){const c=rr(a,t);c>0&&o.push({id:i,data:{droppableContainer:s,value:c}})}}return o.sort(er)};function sr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function cn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Z}function ir(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,a)=>({...i,top:i.top+e*a.y,bottom:i.bottom+e*a.y,left:i.left+e*a.x,right:i.right+e*a.x}),{...n})}}const ar=ir(1);function lr(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 cr(e,t,n){const r=lr(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,c=e.left-i-(1-o)*parseFloat(n),d=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),h=o?e.width/o:e.width,u=s?e.height/s:e.height;return{width:h,height:u,top:d,right:c+h,bottom:d+u,left:c}}const dr={ignoreTransform:!1};function Ee(e,t){t===void 0&&(t=dr);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:d,transformOrigin:h}=X(e).getComputedStyle(e);d&&(n=cr(n,d,h))}const{top:r,left:o,width:s,height:i,bottom:a,right:c}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:c}}function Ft(e){return Ee(e,{ignoreTransform:!0})}function ur(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function fr(e,t){return t===void 0&&(t=X(e).getComputedStyle(e)),t.position==="fixed"}function hr(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)||nn(o)||n.includes(o))return n;const s=X(e).getComputedStyle(o);return o!==e&&hr(o,s)&&n.push(o),fr(o,s)?n:r(o.parentNode)}return e?r(e):n}function dn(e){const[t]=rt(e,1);return t??null}function dt(e){return!nt||!e?null:De(e)?e:bt(e)?xt(e)||e===Re(e).scrollingElement?window:Ue(e)?e:null:null}function un(e){return De(e)?e.scrollX:e.scrollLeft}function fn(e){return De(e)?e.scrollY:e.scrollTop}function pt(e){return{x:un(e),y:fn(e)}}var z;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(z||(z={}));function hn(e){return!nt||!e?!1:e===document.scrollingElement}function gn(e){const t={x:0,y:0},n=hn(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,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:a,maxScroll:r,minScroll:t}}const gr={x:.2,y:.2};function pr(e,t,n,r,o){let{top:s,left:i,right:a,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=gr);const{isTop:d,isBottom:h,isLeft:u,isRight:g}=gn(e),p={x:0,y:0},R={x:0,y:0},b={height:t.height*o.y,width:t.width*o.x};return!d&&s<=t.top+b.height?(p.y=z.Backward,R.y=r*Math.abs((t.top+b.height-s)/b.height)):!h&&c>=t.bottom-b.height&&(p.y=z.Forward,R.y=r*Math.abs((t.bottom-b.height-c)/b.height)),!g&&a>=t.right-b.width?(p.x=z.Forward,R.x=r*Math.abs((t.right-b.width-a)/b.width)):!u&&i<=t.left+b.width&&(p.x=z.Backward,R.x=r*Math.abs((t.left+b.width-i)/b.width)),{direction:p,speed:R}}function vr(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 pn(e){return e.reduce((t,n)=>Se(t,pt(n)),Z)}function mr(e){return e.reduce((t,n)=>t+un(n),0)}function br(e){return e.reduce((t,n)=>t+fn(n),0)}function xr(e,t){if(t===void 0&&(t=Ee),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);dn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const yr=[["x",["left","right"],mr],["y",["top","bottom"],br]];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=pn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,a]of yr)for(const c of i)Object.defineProperty(this,c,{get:()=>{const d=a(r),h=o[s]-d;return this.rect[c]+h},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 wr(e){const{EventTarget:t}=X(e);return e instanceof t?e:Re(e)}function ut(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 Cr(e){e.stopPropagation()}var k;(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"})(k||(k={}));const vn={start:[k.Space,k.Enter],cancel:[k.Esc],end:[k.Space,k.Enter,k.Tab]},Sr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case k.Right:return{...n,x:n.x+25};case k.Left:return{...n,x:n.x-25};case k.Down:return{...n,y:n.y+25};case k.Up:return{...n,y:n.y-25}}};class St{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&&xr(r),n(Z)}handleKeyDown(t){if(wt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=vn,coordinateGetter:i=Sr,scrollBehavior:a="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:d}=r.current,h=d?{x:d.left,y:d.top}:Z;this.referenceCoordinates||(this.referenceCoordinates=h);const u=i(t,{active:n,context:r.current,currentCoordinates:h});if(u){const g=Be(u,h),p={x:0,y:0},{scrollableAncestors:R}=r.current;for(const b of R){const y=t.code,{isTop:D,isRight:S,isLeft:w,isBottom:N,maxScroll:v,minScroll:x}=gn(b),m=vr(b),E={x:Math.min(y===k.Right?m.right-m.width/2:m.right,Math.max(y===k.Right?m.left:m.left+m.width/2,u.x)),y:Math.min(y===k.Down?m.bottom-m.height/2:m.bottom,Math.max(y===k.Down?m.top:m.top+m.height/2,u.y))},T=y===k.Right&&!S||y===k.Left&&!w,O=y===k.Down&&!N||y===k.Up&&!D;if(T&&E.x!==u.x){const j=b.scrollLeft+g.x,W=y===k.Right&&j<=v.x||y===k.Left&&j>=x.x;if(W&&!g.y){b.scrollTo({left:j,behavior:a});return}W?p.x=b.scrollLeft-j:p.x=y===k.Right?b.scrollLeft-v.x:b.scrollLeft-x.x,p.x&&b.scrollBy({left:-p.x,behavior:a});break}else if(O&&E.y!==u.y){const j=b.scrollTop+g.y,W=y===k.Down&&j<=v.y||y===k.Up&&j>=x.y;if(W&&!g.x){b.scrollTo({top:j,behavior:a});return}W?p.y=b.scrollTop-j:p.y=y===k.Down?b.scrollTop-v.y:b.scrollTop-x.y,p.y&&b.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(t,Se(Be(u,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()}}St.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=vn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const a=s.activatorNode.current;return a&&e.target!==a?!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 Dt{constructor(t,n,r){var o;r===void 0&&(r=wr(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,Cr,{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:a}}=s;if(!o)return;const c=(n=gt(t))!=null?n:Z,d=Be(o,c);if(!r&&a){if(Xt(a)){if(a.tolerance!=null&&ut(d,a.tolerance))return this.handleCancel();if(ut(d,a.distance))return this.handleStart()}if(Wt(a)&&ut(d,a.tolerance))return this.handleCancel();this.handlePending(a,d);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===k.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Dr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Rt extends Dt{constructor(t){const{event:n}=t,r=Re(n.target);super(t,Dr,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 Rr={move:{name:"mousemove"},end:{name:"mouseup"}};var vt;(function(e){e[e.RightClick=2]="RightClick"})(vt||(vt={}));class Er extends Dt{constructor(t){super(t,Rr,Re(t.event.target))}}Er.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 Nr extends Dt{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(){}}}Nr.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 kr(e){let{acceleration:t,activator:n=Le.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=et.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:h,delta:u,threshold:g}=e;const p=jr({delta:u,disabled:!s}),[R,b]=Fn(),y=l.useRef({x:0,y:0}),D=l.useRef({x:0,y:0}),S=l.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]),w=l.useRef(null),N=l.useCallback(()=>{const x=w.current;if(!x)return;const m=y.current.x*D.current.x,E=y.current.y*D.current.y;x.scrollBy(m,E)},[]),v=l.useMemo(()=>a===et.TreeOrder?[...d].reverse():d,[a,d]);l.useEffect(()=>{if(!s||!d.length||!S){b();return}for(const x of v){if((r==null?void 0:r(x))===!1)continue;const m=d.indexOf(x),E=h[m];if(!E)continue;const{direction:T,speed:O}=pr(x,E,S,t,g);for(const j of["x","y"])p[j][T[j]]||(O[j]=0,T[j]=0);if(O.x>0||O.y>0){b(),w.current=x,R(N,i),y.current=O,D.current=T;return}}y.current={x:0,y:0},D.current={x:0,y:0},b()},[t,N,r,b,s,i,JSON.stringify(S),JSON.stringify(p),R,d,v,h,JSON.stringify(g)])}const Mr={x:{[z.Backward]:!1,[z.Forward]:!1},y:{[z.Backward]:!1,[z.Forward]:!1}};function jr(e){let{delta:t,disabled:n}=e;const r=ht(t);return Xe(o=>{if(n||!r||!o)return Mr;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 Ir(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 Ar(e,t){return l.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 Fe;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Fe||(Fe={}));var mt;(function(e){e.Optimized="optimized"})(mt||(mt={}));const Yt=new Map;function Tr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=l.useState(null),{frequency:a,measure:c,strategy:d}=o,h=l.useRef(e),u=y(),g=Pe(u),p=l.useCallback(function(D){D===void 0&&(D=[]),!g.current&&i(S=>S===null?D:S.concat(D.filter(w=>!S.includes(w))))},[g]),R=l.useRef(null),b=Xe(D=>{if(u&&!n)return Yt;if(!D||D===Yt||h.current!==e||s!=null){const S=new Map;for(let w of e){if(!w)continue;if(s&&s.length>0&&!s.includes(w.id)&&w.rect.current){S.set(w.id,w.rect.current);continue}const N=w.node.current,v=N?new Ct(c(N),N):null;w.rect.current=v,v&&S.set(w.id,v)}return S}return D},[e,s,n,u,c]);return l.useEffect(()=>{h.current=e},[e]),l.useEffect(()=>{u||p()},[n,u]),l.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),l.useEffect(()=>{u||typeof a!="number"||R.current!==null||(R.current=setTimeout(()=>{p(),R.current=null},a))},[a,u,p,...r]),{droppableRects:b,measureDroppableContainers:p,measuringScheduled:s!=null};function y(){switch(d){case Fe.Always:return!1;case Fe.BeforeDragging:return n;default:return!n}}}function mn(e,t){return Xe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Or(e,t){return mn(e,t)}function Lr(e){let{callback:t,disabled:n}=e;const r=yt(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return l.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function ot(e){let{callback:t,disabled:n}=e;const r=yt(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return l.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function zr(e){return new Ct(Ee(e),e)}function Vt(e,t,n){t===void 0&&(t=zr);const[r,o]=l.useState(null);function s(){o(c=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=c??n)!=null?d:null}const h=t(e);return JSON.stringify(c)===JSON.stringify(h)?c:h})}const i=Lr({callback(c){if(e)for(const d of c){const{type:h,target:u}=d;if(h==="childList"&&u instanceof HTMLElement&&u.contains(e)){s();break}}}}),a=ot({callback:s});return re(()=>{s(),e?(a==null||a.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),i==null||i.disconnect())},[e]),r}function Pr(e){const t=mn(e);return cn(e,t)}const Ht=[];function Br(e){const t=l.useRef(e),n=Xe(r=>e?r&&r!==Ht&&e&&t.current&&e.parentNode===t.current.parentNode?r:rt(e):Ht,[e]);return l.useEffect(()=>{t.current=e},[e]),n}function $r(e){const[t,n]=l.useState(null),r=l.useRef(e),o=l.useCallback(s=>{const i=dt(s.target);i&&n(a=>a?(a.set(i,pt(i)),new Map(a)):null)},[]);return l.useEffect(()=>{const s=r.current;if(e!==s){i(s);const a=e.map(c=>{const d=dt(c);return d?(d.addEventListener("scroll",o,{passive:!0}),[d,pt(d)]):null}).filter(c=>c!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(s)};function i(a){a.forEach(c=>{const d=dt(c);d==null||d.removeEventListener("scroll",o)})}},[o,e]),l.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>Se(s,i),Z):pn(e):Z,[e,t])}function Kt(e,t){t===void 0&&(t=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},t),l.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 Fr(e){l.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 Ur(e,t){return l.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function bn(e){return l.useMemo(()=>e?ur(e):null,[e])}const _t=[];function Xr(e,t){t===void 0&&(t=Ee);const[n]=e,r=bn(n?X(n):null),[o,s]=l.useState(_t);function i(){s(()=>e.length?e.map(c=>hn(c)?r:new Ct(t(c),c)):_t)}const a=ot({callback:i});return re(()=>{a==null||a.disconnect(),i(),e.forEach(c=>a==null?void 0:a.observe(c))},[e]),o}function Wr(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ue(t)?t:e}function Yr(e){let{measure:t}=e;const[n,r]=l.useState(null),o=l.useCallback(d=>{for(const{target:h}of d)if(Ue(h)){r(u=>{const g=t(h);return u?{...u,width:g.width,height:g.height}:g});break}},[t]),s=ot({callback:o}),i=l.useCallback(d=>{const h=Wr(d);s==null||s.disconnect(),h&&(s==null||s.observe(h)),r(h?t(h):null)},[t,s]),[a,c]=Qe(i);return l.useMemo(()=>({nodeRef:a,rect:n,setRef:c}),[n,a,c])}const Vr=[{sensor:Rt,options:{}},{sensor:St,options:{}}],Hr={current:{}},Ge={draggable:{measure:Ft},droppable:{measure:Ft,strategy:Fe.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 Kr={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},_r={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Ze,draggableNodes:new Map,over:null,measureDroppableContainers:Ze},st=l.createContext(_r),xn=l.createContext(Kr);function qr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ze}}}function Gr(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 Jr(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=l.useContext(st),s=ht(r),i=ht(n==null?void 0:n.id);return l.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!wt(s)||document.activeElement===s.target)return;const a=o.get(i);if(!a)return;const{activatorNode:c,node:d}=a;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[c.current,d.current]){if(!h)continue;const u=Wn(h);if(u){u.focus();break}}})}},[r,t,o,i,s]),null}function Qr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function Zr(e){return l.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 eo(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=l.useRef(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;re(()=>{if(!i&&!a||!t){s.current=!1;return}if(s.current||!r)return;const d=t==null?void 0:t.node.current;if(!d||d.isConnected===!1)return;const h=n(d),u=cn(h,r);if(i||(u.x=0),a||(u.y=0),s.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const g=dn(d);g&&g.scrollBy({top:u.y,left:u.x})}},[t,i,a,r,n])}const yn=l.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 to=l.memo(function(t){var n,r,o,s;let{id:i,accessibility:a,autoScroll:c=!0,children:d,sensors:h=Vr,collisionDetection:u=or,measuring:g,modifiers:p,...R}=t;const b=l.useReducer(Gr,void 0,qr),[y,D]=b,[S,w]=qn(),[N,v]=l.useState(pe.Uninitialized),x=N===pe.Initialized,{draggable:{active:m,nodes:E,translate:T},droppable:{containers:O}}=y,j=m!=null?E.get(m):null,W=l.useRef({initial:null,translated:null}),Y=l.useMemo(()=>{var B;return m!=null?{id:m,data:(B=j==null?void 0:j.data)!=null?B:Hr,rect:W}:null},[m,j]),V=l.useRef(null),[C,M]=l.useState(null),[A,oe]=l.useState(null),$=Pe(R,Object.values(R)),Q=We("DndDescribedBy",i),Ye=l.useMemo(()=>O.getEnabled(),[O]),F=Zr(g),{droppableRects:se,measureDroppableContainers:ve,measuringScheduled:Ne}=Tr(Ye,{dragging:x,dependencies:[T.x,T.y],config:F.droppable}),q=Ir(E,m),Ve=l.useMemo(()=>A?gt(A):null,[A]),ce=Tn(),ie=Or(q,F.draggable.measure);eo({activeNode:m!=null?E.get(m):null,config:ce.layoutShiftCompensation,initialRect:ie,measure:F.draggable.measure});const I=Vt(q,F.draggable.measure,ie),ke=Vt(q?q.parentElement:null),ee=l.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=Yr({measure:F.dragOverlay.measure}),be=(r=ae.nodeRef.current)!=null?r:q,xe=x?(o=ae.rect)!=null?o:I:null,Nt=!!(ae.nodeRef.current&&ae.rect),kt=Pr(Nt?null:I),it=bn(be?X(be):null),de=Br(x?me??q:null),He=Xr(de),Ke=Qr(p,{transform:{x:T.x-kt.x,y:T.y-kt.y,scaleX:1,scaleY:1},activatorEvent:A,active:Y,activeNodeRect:I,containerNodeRect:ke,draggingNodeRect:xe,over:ee.current.over,overlayNodeRect:ae.rect,scrollableAncestors:de,scrollableAncestorRects:He,windowRect:it}),Mt=Ve?Se(Ve,T):null,jt=$r(de),En=Kt(jt),Nn=Kt(jt,[I]),ye=Se(Ke,En),we=xe?ar(xe,Ke):null,Me=Y&&we?u({active:Y,collisionRect:we,droppableRects:se,droppableContainers:Ye,pointerCoordinates:Mt}):null,It=ln(Me,"id"),[ue,At]=l.useState(null),kn=Nt?Ke:Se(Ke,Nn),Mn=sr(kn,(s=ue==null?void 0:ue.rect)!=null?s:null,I),at=l.useRef(null),Tt=l.useCallback((B,H)=>{let{sensor:K,options:fe}=H;if(V.current==null)return;const G=E.get(V.current);if(!G)return;const _=B.nativeEvent,te=new K({active:V.current,activeNode:G,event:_,options:fe,context:ee,onAbort(P){if(!E.get(P))return;const{onDragAbort:ne}=$.current,le={id:P};ne==null||ne(le),S({type:"onDragAbort",event:le})},onPending(P,he,ne,le){if(!E.get(P))return;const{onDragPending:Ie}=$.current,ge={id:P,constraint:he,initialCoordinates:ne,offset:le};Ie==null||Ie(ge),S({type:"onDragPending",event:ge})},onStart(P){const he=V.current;if(he==null)return;const ne=E.get(he);if(!ne)return;const{onDragStart:le}=$.current,je={activatorEvent:_,active:{id:he,data:ne.data,rect:W}};Te.unstable_batchedUpdates(()=>{le==null||le(je),v(pe.Initializing),D({type:L.DragStart,initialCoordinates:P,active:he}),S({type:"onDragStart",event:je}),M(at.current),oe(_)})},onMove(P){D({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:je,scrollAdjustedTranslate:Ie}=ee.current;let ge=null;if(ne&&Ie){const{cancelDrop:Ae}=$.current;ge={activatorEvent:_,active:ne,collisions:le,delta:Ie,over:je},P===L.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(ge))&&(P=L.DragCancel)}V.current=null,Te.unstable_batchedUpdates(()=>{D({type:P}),v(pe.Uninitialized),At(null),M(null),oe(null),at.current=null;const Ae=P===L.DragEnd?"onDragEnd":"onDragCancel";if(ge){const lt=$.current[Ae];lt==null||lt(ge),S({type:Ae,event:ge})}})}}},[E]),jn=l.useCallback((B,H)=>(K,fe)=>{const G=K.nativeEvent,_=E.get(fe);if(V.current!==null||!_||G.dndKit||G.defaultPrevented)return;const te={active:_};B(K,H.options,te)===!0&&(G.dndKit={capturedBy:H.sensor},V.current=fe,Tt(K,H))},[E,Tt]),Ot=Ar(h,jn);Fr(h),re(()=>{I&&N===pe.Initializing&&v(pe.Initialized)},[I,N]),l.useEffect(()=>{const{onDragMove:B}=$.current,{active:H,activatorEvent:K,collisions:fe,over:G}=ee.current;if(!H||!K)return;const _={active:H,activatorEvent:K,collisions:fe,delta:{x:ye.x,y:ye.y},over:G};Te.unstable_batchedUpdates(()=>{B==null||B(_),S({type:"onDragMove",event:_})})},[ye.x,ye.y]),l.useEffect(()=>{const{active:B,activatorEvent:H,collisions:K,droppableContainers:fe,scrollAdjustedTranslate:G}=ee.current;if(!B||V.current==null||!H||!G)return;const{onDragOver:_}=$.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:H,collisions:K,delta:{x:G.x,y:G.y},over:Ce};Te.unstable_batchedUpdates(()=>{At(Ce),_==null||_(P),S({type:"onDragOver",event:P})})},[It]),re(()=>{ee.current={activatorEvent:A,active:Y,activeNode:q,collisionRect:we,collisions:Me,droppableRects:se,draggableNodes:E,draggingNode:be,draggingNodeRect:xe,droppableContainers:O,over:ue,scrollableAncestors:de,scrollAdjustedTranslate:ye},W.current={initial:xe,translated:we}},[Y,q,Me,we,E,be,xe,se,O,ue,de,ye]),kr({...ce,delta:T,draggingRect:we,pointerCoordinates:Mt,scrollableAncestors:de,scrollableAncestorRects:He});const In=l.useMemo(()=>({active:Y,activeNode:q,activeNodeRect:I,activatorEvent:A,collisions:Me,containerNodeRect:ke,dragOverlay:ae,draggableNodes:E,droppableContainers:O,droppableRects:se,over:ue,measureDroppableContainers:ve,scrollableAncestors:de,scrollableAncestorRects:He,measuringConfiguration:F,measuringScheduled:Ne,windowRect:it}),[Y,q,I,A,Me,ke,ae,E,O,se,ue,ve,de,He,F,Ne,it]),An=l.useMemo(()=>({activatorEvent:A,activators:Ot,active:Y,activeNodeRect:I,ariaDescribedById:{draggable:Q},dispatch:D,draggableNodes:E,over:ue,measureDroppableContainers:ve}),[A,Ot,Y,I,D,Q,E,ue,ve]);return U.createElement(on.Provider,{value:w},U.createElement(st.Provider,{value:An},U.createElement(xn.Provider,{value:In},U.createElement(yn.Provider,{value:Mn},d)),U.createElement(Jr,{disabled:(a==null?void 0:a.restoreFocus)===!1})),U.createElement(Qn,{...a,hiddenTextDescribedById:Q}));function Tn(){const B=(C==null?void 0:C.autoScrollEnabled)===!1,H=typeof c=="object"?c.enabled===!1:c===!1,K=x&&!B&&!H;return typeof c=="object"?{...c,enabled:K}:{enabled:K}}}),no=l.createContext(null),qt="button",ro="Draggable";function oo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=We(ro),{activators:i,activatorEvent:a,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:u,over:g}=l.useContext(st),{role:p=qt,roleDescription:R="draggable",tabIndex:b=0}=o??{},y=(c==null?void 0:c.id)===t,D=l.useContext(y?yn:no),[S,w]=Qe(),[N,v]=Qe(),x=Ur(i,t),m=Pe(n);re(()=>(u.set(t,{id:t,key:s,node:S,activatorNode:N,data:m}),()=>{const T=u.get(t);T&&T.key===s&&u.delete(t)}),[u,t]);const E=l.useMemo(()=>({role:p,tabIndex:b,"aria-disabled":r,"aria-pressed":y&&p===qt?!0:void 0,"aria-roledescription":R,"aria-describedby":h.draggable}),[r,p,b,y,R,h.draggable]);return{active:c,activatorEvent:a,activeNodeRect:d,attributes:E,isDragging:y,listeners:r?void 0:x,node:S,over:g,setNodeRef:w,setActivatorNodeRef:v,transform:D}}function so(){return l.useContext(xn)}const io="Droppable",ao={timeout:25};function lo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=We(io),{active:i,dispatch:a,over:c,measureDroppableContainers:d}=l.useContext(st),h=l.useRef({disabled:n}),u=l.useRef(!1),g=l.useRef(null),p=l.useRef(null),{disabled:R,updateMeasurementsFor:b,timeout:y}={...ao,...o},D=Pe(b??r),S=l.useCallback(()=>{if(!u.current){u.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(D.current)?D.current:[D.current]),p.current=null},y)},[y]),w=ot({callback:S,disabled:R||!i}),N=l.useCallback((E,T)=>{w&&(T&&(w.unobserve(T),u.current=!1),E&&w.observe(E))},[w]),[v,x]=Qe(N),m=Pe(t);return l.useEffect(()=>{!w||!v.current||(w.disconnect(),u.current=!1,w.observe(v.current))},[v,w]),l.useEffect(()=>(a({type:L.RegisterDroppable,element:{id:r,key:s,disabled:n,node:v,rect:g,data:m}}),()=>a({type:L.UnregisterDroppable,key:s,id:r})),[r]),l.useEffect(()=>{n!==h.current.disabled&&(a({type:L.SetDroppableDisabled,id:r,key:s,disabled:n}),h.current.disabled=n)},[r,s,n,a]),{active:i,rect:g,isOver:(c==null?void 0:c.id)===r,node:v,over:c,setNodeRef:x}}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 co(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 uo(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 fo(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const wn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=Et(t,r,n),i=t[o],a=s[o];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},qe={scaleX:1,scaleY:1},ho=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=(t=s[n])!=null?t:r;if(!a)return null;if(o===n){const d=s[i];return d?{x:0,y:n<i?d.top+d.height-(a.top+a.height):d.top-a.top,...qe}:null}const c=go(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-c,...qe}:o<n&&o>=i?{x:0,y:a.height+c,...qe}:{x:0,y:0,...qe}};function go(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 Cn="Sortable",Sn=U.createContext({activeIndex:-1,containerId:Cn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:wn,disabled:{draggable:!1,droppable:!1}});function po(e){let{children:t,id:n,items:r,strategy:o=wn,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:c,over:d,measureDroppableContainers:h}=so(),u=We(Cn,n),g=a.rect!==null,p=l.useMemo(()=>r.map(x=>typeof x=="object"&&"id"in x?x.id:x),[r]),R=i!=null,b=i?p.indexOf(i.id):-1,y=d?p.indexOf(d.id):-1,D=l.useRef(p),S=!uo(p,D.current),w=y!==-1&&b===-1||S,N=fo(s);re(()=>{S&&R&&h(p)},[S,p,R,h]),l.useEffect(()=>{D.current=p},[p]);const v=l.useMemo(()=>({activeIndex:b,containerId:u,disabled:N,disableTransforms:w,items:p,overIndex:y,useDragOverlay:g,sortedRects:co(p,c),strategy:o}),[b,u,N.draggable,N.droppable,w,p,y,c,g,o]);return U.createElement(Sn.Provider,{value:v},t)}const vo=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Et(n,r,o).indexOf(t)},mo=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:c,transition:d}=e;return!d||!r||a!==s&&o===i?!1:n?!0:i!==o&&t===c},bo={duration:200,easing:"ease"},Dn="transform",xo=$e.Transition.toString({property:Dn,duration:0,easing:"linear"}),yo={roleDescription:"sortable"};function wo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=l.useState(null),a=l.useRef(n);return re(()=>{if(!t&&n!==a.current&&r.current){const c=o.current;if(c){const d=Ee(r.current,{ignoreTransform:!0}),h={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(h.x||h.y)&&i(h)}}n!==a.current&&(a.current=n)},[t,n,r,o]),l.useEffect(()=>{s&&i(null)},[s]),s}function Co(e){let{animateLayoutChanges:t=mo,attributes:n,disabled:r,data:o,getNewIndex:s=vo,id:i,strategy:a,resizeObserverConfig:c,transition:d=bo}=e;const{items:h,containerId:u,activeIndex:g,disabled:p,disableTransforms:R,sortedRects:b,overIndex:y,useDragOverlay:D,strategy:S}=l.useContext(Sn),w=So(r,p),N=h.indexOf(i),v=l.useMemo(()=>({sortable:{containerId:u,index:N,items:h},...o}),[u,o,N,h]),x=l.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:m,node:E,isOver:T,setNodeRef:O}=lo({id:i,data:v,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:x,...c}}),{active:j,activatorEvent:W,activeNodeRect:Y,attributes:V,setNodeRef:C,listeners:M,isDragging:A,over:oe,setActivatorNodeRef:$,transform:Q}=oo({id:i,data:v,attributes:{...yo,...n},disabled:w.draggable}),Ye=$n(O,C),F=!!j,se=F&&!R&&_e(g)&&_e(y),ve=!D&&A,Ne=ve&&se?Q:null,Ve=se?Ne??(a??S)({rects:b,activeNodeRect:Y,activeIndex:g,overIndex:y,index:N}):null,ce=_e(g)&&_e(y)?s({id:i,items:h,activeIndex:g,overIndex:y}):N,ie=j==null?void 0:j.id,I=l.useRef({activeId:ie,items:h,newIndex:ce,containerId:u}),ke=h!==I.current.items,ee=t({active:j,containerId:u,isDragging:A,isSorting:F,id:i,index:N,items:h,newIndex:I.current.newIndex,previousItems:I.current.items,previousContainerId:I.current.containerId,transition:d,wasDragging:I.current.activeId!=null}),me=wo({disabled:!ee,index:N,node:E,rect:m});return l.useEffect(()=>{F&&I.current.newIndex!==ce&&(I.current.newIndex=ce),u!==I.current.containerId&&(I.current.containerId=u),h!==I.current.items&&(I.current.items=h)},[F,ce,u,h]),l.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:j,activeIndex:g,attributes:V,data:v,rect:m,index:N,newIndex:ce,items:h,isOver:T,isSorting:F,isDragging:A,listeners:M,node:E,overIndex:y,over:oe,setNodeRef:Ye,setActivatorNodeRef:$,setDroppableNodeRef:O,setDraggableNodeRef:C,transform:me??Ve,transition:ae()};function ae(){if(me||ke&&I.current.newIndex===N)return xo;if(!(ve&&!wt(W)||!d)&&(F||ee))return $e.Transition.toString({...d,property:Dn})}}function So(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 Do=[k.Down,k.Right,k.Up,k.Left],Ro=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:a}}=t;if(Do.includes(e.code)){if(e.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(u=>{if(!u||u!=null&&u.disabled)return;const g=o.get(u.id);if(g)switch(e.code){case k.Down:r.top<g.top&&c.push(u);break;case k.Up:r.top>g.top&&c.push(u);break;case k.Left:r.left>g.left&&c.push(u);break;case k.Right:r.left<g.left&&c.push(u);break}});const d=nr({collisionRect:r,droppableRects:o,droppableContainers:c});let h=ln(d,"id");if(h===(i==null?void 0:i.id)&&d.length>1&&(h=d[1].id),h!=null){const u=s.get(n.id),g=s.get(h),p=g?o.get(g.id):null,R=g==null?void 0:g.node.current;if(R&&p&&u&&g){const y=rt(R).some((x,m)=>a[m]!==x),D=Rn(u,g),S=Eo(u,g),w=y||!D?{x:0,y:0}:{x:S?r.width-p.width:0,y:S?r.height-p.height:0},N={x:p.left,y:p.top};return w.x&&w.y?N:Be(N,w)}}}};function Rn(e,t){return!tt(e)||!tt(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Eo(e,t){return!tt(e)||!tt(t)||!Rn(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function No(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 ko=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return!n||!t?r:No(r,n,t)},Mo=e=>{let{transform:t}=e;return{...t,x:0}},jo=/^[a-zA-Z0-9_.\-]+$/;function Bo(){const[e,t]=l.useState([]),[n,r]=l.useState(!0),[o,s]=l.useState(!1),[i,a]=l.useState(null),[c,d]=l.useState([]),[h,u]=l.useState({}),[g,p]=l.useState(null),{copied:R,copy:b}=On();l.useEffect(()=>{y()},[]);const y=async()=>{try{const[v,x,m]=await Promise.all([fetch("/api/combos"),fetch("/api/providers"),fetch("/api/settings")]),E=await v.json(),T=await x.json(),O=m.ok?await m.json():{};v.ok&&t((E.combos||[]).filter(j=>!j.kind)),x.ok&&d(T.connections||[]),u(O.comboStrategies||{})}catch(v){console.log("Error fetching data:",v)}finally{r(!1)}},D=async v=>{try{const x=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});if(x.ok)await y(),s(!1);else{const m=await x.json();alert(m.error||"Failed to create combo")}}catch(x){console.log("Error creating combo:",x)}},S=async(v,x)=>{try{const m=await fetch(`/api/combos/${v}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(m.ok)await y(),a(null);else{const E=await m.json();alert(E.error||"Failed to update combo")}}catch(m){console.log("Error updating combo:",m)}},w=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(m=>m.id!==v))}catch(x){console.log("Error deleting combo:",x)}}})},N=async(v,x)=>{try{const m={...h};x&&x!=="fallback"?m[v]={fallbackStrategy:x}:delete m[v],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({comboStrategies:m})}),u(m)}catch(m){console.log("Error updating combo strategy:",m)}};return n?f.jsxs("div",{className:"flex flex-col gap-6",children:[f.jsx(Lt,{}),f.jsx(Lt,{})]}):f.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[f.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("h1",{className:"text-2xl font-semibold",children:"Combos"}),f.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with fallback support"})]}),f.jsx(Je,{icon:"add",onClick:()=>s(!0),className:"w-full sm:w-auto",children:"Create Combo"})]}),e.length===0?f.jsx(tn,{children:f.jsxs("div",{className:"text-center py-12",children:[f.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/10 text-primary mb-4",children:f.jsx("span",{className:"material-symbols-outlined text-[32px]",children:"layers"})}),f.jsx("p",{className:"text-text-main font-medium mb-1",children:"No combos yet"}),f.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Create model combos with fallback support"}),f.jsx(Je,{icon:"add",onClick:()=>s(!0),className:"w-full sm:w-auto",children:"Create Combo"})]})}):f.jsx("div",{className:"flex flex-col gap-4",children:e.map(v=>{var x;return f.jsx(Io,{combo:v,copied:R,onCopy:b,onEdit:()=>a(v),onDelete:()=>w(v.id),currentStrategy:((x=h[v.name])==null?void 0:x.fallbackStrategy)||"fallback",onUpdateStrategy:m=>N(v.name,m)},v.id)})}),f.jsx(Gt,{isOpen:o,onClose:()=>s(!1),onSave:D,activeProviders:c},"create"),f.jsx(Gt,{isOpen:!!i,combo:i,onClose:()=>a(null),onSave:v=>S(i.id,v),activeProviders:c},(i==null?void 0:i.id)||"new"),f.jsx(Ln,{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 Io({combo:e,copied:t,onCopy:n,onEdit:r,onDelete:o,currentStrategy:s,onUpdateStrategy:i}){return f.jsx(tn,{padding:"sm",className:"group",children:f.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[f.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3 sm:items-center",children:[f.jsx("div",{className:"size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:f.jsx("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"layers"})}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("code",{className:"block truncate font-mono text-sm font-medium",children:e.name}),f.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1",children:[e.models.length===0?f.jsx("span",{className:"text-xs text-text-muted italic",children:"No models"}):e.models.slice(0,3).map((a,c)=>{const d=Jt(a),h=Qt(a),u=Zt(a);return f.jsxs("code",{className:"max-w-full inline-flex items-center gap-1 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:[d&&f.jsx(en,{src:d==="codebuddy"||d==="cb"?"/providers/codebuddy.svg":`/providers/${d}.png`,alt:d,size:10,className:"shrink-0 rounded-sm",fallbackText:d.slice(0,2).toUpperCase()}),f.jsx("span",{className:"truncate",children:a}),h&&f.jsx("span",{className:"material-symbols-outlined shrink-0 text-blue-500",style:{fontSize:"10px"},title:"Vision",children:"visibility"}),u&&f.jsx("span",{className:"material-symbols-outlined shrink-0 text-orange-500",style:{fontSize:"10px"},title:"Thinking",children:"memory"})]},c)}),e.models.length>3&&f.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.models.length-3," more"]})]})]})]}),f.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:[f.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:[f.jsx("span",{className:"text-xs text-text-muted font-medium mr-1",children:"Strategy:"}),f.jsxs("select",{value:s,onChange:a=>i(a.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:[f.jsx("option",{value:"fallback",className:"dark:bg-zinc-900",children:"Fallback (Priority)"}),f.jsx("option",{value:"round-robin",className:"dark:bg-zinc-900",children:"Round Robin"}),f.jsx("option",{value:"fusion",className:"dark:bg-zinc-900",children:"Fusion (Synthesis)"})]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-1 sm:flex",children:[f.jsxs("button",{onClick:a=>{a.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:[f.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t===`combo-${e.id}`?"check":"content_copy"}),f.jsx("span",{className:"text-[10px] leading-tight",children:"Copy"})]}),f.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:[f.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),f.jsx("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),f.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:[f.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),f.jsx("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]})]})]})})}function Ao({id:e,index:t,model:n,isFirst:r,isLast:o,onEdit:s,onMoveUp:i,onMoveDown:a,onRemove:c}){const{attributes:d,listeners:h,setNodeRef:u,transform:g,isDragging:p}=Co({id:e}),R={transform:$e.Transform.toString(g),opacity:p?.4:1,zIndex:p?999:void 0},[b,y]=l.useState(!1),[D,S]=l.useState(n),w=()=>{const v=D.trim();v&&v!==n?s(v):S(n),y(!1)},N=v=>{v.key==="Enter"&&w(),v.key==="Escape"&&(S(n),y(!1))};return f.jsxs("div",{ref:u,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:[f.jsx("button",{...d,...h,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:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("circle",{cx:"9",cy:"4",r:"2"}),f.jsx("circle",{cx:"15",cy:"4",r:"2"}),f.jsx("circle",{cx:"9",cy:"12",r:"2"}),f.jsx("circle",{cx:"15",cy:"12",r:"2"}),f.jsx("circle",{cx:"9",cy:"20",r:"2"}),f.jsx("circle",{cx:"15",cy:"20",r:"2"})]})}),f.jsx("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:t+1}),b?f.jsx("input",{autoFocus:!0,value:D,onChange:v=>S(v.target.value),onBlur:w,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"}):(()=>{const v=Jt(n),x=Qt(n),m=Zt(n);return f.jsxs("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 flex items-center gap-1.5",onClick:()=>y(!0),title:"Click to edit",children:[v&&f.jsx(en,{src:v==="codebuddy"||v==="cb"?"/providers/codebuddy.svg":`/providers/${v}.png`,alt:v,size:12,className:"shrink-0 rounded-sm",fallbackText:v.slice(0,2).toUpperCase()}),f.jsx("span",{className:"truncate",children:n}),x&&f.jsx("span",{className:"material-symbols-outlined shrink-0 text-blue-500",style:{fontSize:"12px"},title:"Vision",children:"visibility"}),m&&f.jsx("span",{className:"material-symbols-outlined shrink-0 text-orange-500",style:{fontSize:"12px"},title:"Thinking",children:"memory"})]})})(),f.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[f.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:f.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),f.jsx("button",{onClick:a,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:f.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),f.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:f.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,a]=l.useState((t==null?void 0:t.name)||""),[c,d]=l.useState((t==null?void 0:t.models)||[]),[h,u]=l.useState(!1),[g,p]=l.useState(!1),[R,b]=l.useState(""),[y,D]=l.useState({}),S=Zn(Pt(Rt,{activationConstraint:{distance:5}}),Pt(St,{coordinateGetter:Ro})),w=c.map((C,M)=>({uid:`item-${M}`,model:C})),N=C=>{const{active:M,over:A}=C;if(A&&M.id!==A.id){const oe=w.findIndex(Q=>Q.uid===M.id),$=w.findIndex(Q=>Q.uid===A.id);oe!==-1&&$!==-1&&d(Q=>Et(Q,oe,$))}},v=async()=>{try{const C=await fetch("/api/models/alias");if(!C.ok)return;const M=await C.json();D(M.aliases||{})}catch(C){console.error("Error fetching modal data:",C)}};l.useEffect(()=>{e&&v()},[e]);const x=C=>C.trim()?jo.test(C)?(b(""),!0):(b("Only letters, numbers, -, _ and . allowed"),!1):(b("Name is required"),!1),m=C=>{const M=C.target.value;a(M),M?x(M):b("")},E=C=>{c.includes(C.value)||d([...c,C.value])},T=C=>{d(c.filter(M=>M!==C.value))},O=C=>{d(c.filter((M,A)=>A!==C))},j=C=>{if(C===0)return;const M=[...c];[M[C-1],M[C]]=[M[C],M[C-1]],d(M)},W=C=>{if(C===c.length-1)return;const M=[...c];[M[C],M[C+1]]=[M[C+1],M[C]],d(M)},Y=async()=>{x(i)&&(p(!0),await r({name:i.trim(),models:c}),p(!1))},V=!!t;return f.jsxs(f.Fragment,{children:[f.jsx(zn,{isOpen:e,onClose:n,title:V?"Edit Combo":"Create Combo",children:f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{children:[f.jsx(Pn,{label:"Combo Name",value:i,onChange:m,placeholder:"my-combo",error:R}),f.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"Only letters, numbers, -, _ and . allowed"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),c.length===0?f.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:[f.jsx("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),f.jsx("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):f.jsx(to,{sensors:S,collisionDetection:tr,onDragEnd:N,modifiers:[Mo,ko],children:f.jsx(po,{items:w.map(C=>C.uid),strategy:ho,children:f.jsx("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:w.map(({uid:C,model:M},A)=>f.jsx(Ao,{id:C,index:A,model:M,isFirst:A===0,isLast:A===w.length-1,onEdit:oe=>{const $=[...c];$[A]=oe,d($)},onMoveUp:()=>j(A),onMoveDown:()=>W(A),onRemove:()=>O(A)},C))})})}),f.jsxs("button",{onClick:()=>u(!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:[f.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),f.jsxs("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[f.jsx(Je,{onClick:n,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),f.jsx(Je,{onClick:Y,fullWidth:!0,size:"sm",disabled:!i.trim()||!!R||g,children:g?"Saving...":V?"Save":"Create"})]})]})}),f.jsx(Bn,{isOpen:h,onClose:()=>u(!1),onSelect:E,onDeselect:T,activeProviders:o,modelAliases:y,title:"Add Model to Combo",kindFilter:s,addedModelValues:c,closeOnSelect:!1})]})}export{Bo as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.C5VWu_q7.js";import{b as s}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[a,o]=s.useState(""),[l,r]=s.useState(null),[n,c]=s.useState(!1),i=async()=>{c(!0);try{const t=await fetch("/api/web/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a})});r(await t.json())}catch(t){r({error:t.message})}c(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Web Fetch"}),e.jsx("p",{className:"text-text-muted",children:"Fetch web content via Firecrawl, Jina, Tavily, or TinyFish"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 p-3 rounded-lg border",placeholder:"https://example.com",value:a,onChange:t=>o(t.target.value)}),e.jsx("button",{onClick:i,disabled:n,className:"px-4 py-2 bg-primary text-white rounded-lg",children:n?"Fetching...":"Fetch"})]}),l&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto max-h-96",children:JSON.stringify(l,null,2)})]})}export{u as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index.1VBQU7rF.js","assets/router.Cjj1--8t.js"])))=>i.map(i=>d[i]);
2
+ import{u as z,j as t,B as c,_ as F}from"./index.C5VWu_q7.js";import{b as x}from"./router.Cjj1--8t.js";import{C as $}from"./NoAuthProxyCard.DMCykSRG.js";import"./zustand.akaTi5uX.js";const B=x.lazy(()=>F(()=>import("./index.1VBQU7rF.js"),__vite__mapDeps([0,1]))),v=[{id:1,label:"Client Request",file:"1_req_client.json",lang:"json",desc:"Raw request from client"},{id:2,label:"Source Body",file:"2_req_source.json",lang:"json",desc:"After initial conversion"},{id:3,label:"OpenAI Intermediate",file:"3_req_openai.json",lang:"json",desc:"source → openai"},{id:4,label:"Target Request",file:"4_req_target.json",lang:"json",desc:"openai → target + URL + headers"},{id:5,label:"Provider Response",file:"5_res_provider.txt",lang:"text",desc:"Raw SSE from provider"},{id:6,label:"OpenAI Response",file:"6_res_openai.txt",lang:"text",desc:"target → openai (response)"},{id:7,label:"Client Response",file:"7_res_client.txt",lang:"text",desc:"Final response to client"}],I={minimap:{enabled:!1},fontSize:12,lineNumbers:"on",scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0};function W(){const[i,h]=x.useState({}),[g,u]=x.useState({1:!0}),[p,S]=x.useState({}),[o,w]=x.useState(null),l=(e,s)=>S(a=>({...a,[e]:s})),d=(e,s)=>h(a=>({...a,[e]:s})),O=e=>u(s=>({...s,[e]:!s[e]})),j=e=>u(s=>{const a={};return v.forEach(n=>{a[n.id]=!1}),a[e]=!0,a}),_=async e=>{const s=v.find(a=>a.id===e);l(`load-${e}`,!0);try{const n=await(await fetch(`/api/translator/load?file=${s.file}`)).json();n.success?(d(e,n.content),e===1&&await N(n.content)):alert(n.error||"File not found")}catch(a){alert(a.message)}l(`load-${e}`,!1)},N=async e=>{try{const s=typeof e=="string"?JSON.parse(e):e,n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:1,body:s})})).json();n.success&&w(n.result)}catch{}},f=(e,s)=>fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:e,content:s})}).catch(()=>{}),T=async()=>{l("toOpenAI",!0);try{const e=i[1],s=JSON.parse(e);f("1_req_client.json",e),f("2_req_source.json",JSON.stringify({timestamp:new Date().toISOString(),headers:{},body:s.body||s},null,2));const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:2,body:s})})).json();if(!n.success){alert(n.error);return}const r=JSON.stringify(n.result.body,null,2);d(3,r),j(3)}catch(e){alert(e.message)}l("toOpenAI",!1)},C=async()=>{l("toTarget",!0);try{const e=i[3],s=JSON.parse(e);f("3_req_openai.json",e);const n=await(await fetch("/api/translator/translate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({step:3,body:{...s,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model}})})).json();if(!n.success){alert(n.error);return}const r={...n.result,provider:o==null?void 0:o.provider,model:o==null?void 0:o.model};d(4,JSON.stringify(r,null,2)),j(4)}catch(e){alert(e.message)}l("toTarget",!1)},J=async()=>{l("send",!0);try{const e=i[4],s=JSON.parse(e);f("4_req_target.json",e);const a=s.provider||(o==null?void 0:o.provider),n=s.model||(o==null?void 0:o.model);if(!a||!n){alert("Missing provider or model. Please run step 1 first to detect them.");return}const r=await fetch("/api/translator/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,model:n,body:s.body||s})});if(!r.ok){const b=await r.json().catch(()=>({error:r.statusText}));alert(b.error||"Send failed");return}const E=r.body.getReader(),A=new TextDecoder;let y="";for(;;){const{done:b,value:L}=await E.read();if(b)break;y+=A.decode(L,{stream:!0})}d(5,y),j(5),await fetch("/api/translator/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:"5_res_provider.txt",content:y})})}catch(e){alert(e.message)}finally{l("send",!1)}},{copy:P}=z(),R=async e=>{i[e]&&P(i[e],`translator-step-${e}`)},k=e=>{try{const s=JSON.parse(i[e]);d(e,JSON.stringify(s,null,2))}catch{}},q=e=>e===1?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toOpenAI,onClick:T,children:"→ OpenAI"}):e===3?t.jsx(c,{size:"sm",icon:"arrow_forward",loading:p.toTarget,onClick:C,children:"→ Target"}):e===4?t.jsx(c,{size:"sm",icon:"send",loading:p.send,onClick:J,children:"Send"}):null;return t.jsxs("div",{className:"p-8 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold text-text-main",children:"Translator Debug"}),t.jsx("p",{className:"text-sm text-text-muted mt-1",children:"Replay request flow — matches log files"})]}),o&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[t.jsx(m,{label:"src",value:o.sourceFormat,color:"blue"}),t.jsx("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),t.jsx(m,{label:"dst",value:o.targetFormat,color:"orange"}),t.jsx(m,{label:"provider",value:o.provider,color:"green"}),t.jsx(m,{label:"model",value:o.model,color:"purple"})]})]}),v.map(e=>{const s=q(e.id),a=!!g[e.id],n=i[e.id]||"";return t.jsx($,{children:t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("button",{onClick:()=>O(e.id),className:"flex items-center gap-2 flex-1 text-left group",children:[t.jsx("span",{className:"material-symbols-outlined text-[20px] text-text-muted group-hover:text-primary transition-colors",children:a?"expand_more":"chevron_right"}),t.jsx("span",{className:"text-xs font-mono text-text-muted/60 w-4",children:e.id}),t.jsx("h3",{className:"text-sm font-semibold text-text-main",children:e.label}),t.jsx("span",{className:"text-xs text-text-muted/60 font-mono",children:e.file}),n&&t.jsxs("span",{className:"text-xs text-green-500",children:["(",n.length," chars)"]})]}),!a&&t.jsxs("div",{className:"flex gap-1 shrink-0",children:[t.jsx(c,{size:"sm",variant:"ghost",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id)}),s]})]}),a&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border border-border rounded-lg overflow-hidden",children:t.jsx(B,{height:"400px",defaultLanguage:e.lang==="text"?"plaintext":"json",value:n,onChange:r=>{d(e.id,r||""),e.id===1&&N(r||"")},theme:"vs-dark",options:I})}),t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsx(c,{size:"sm",variant:"outline",icon:"folder_open",loading:p[`load-${e.id}`],onClick:()=>_(e.id),children:"Load"}),t.jsx(c,{size:"sm",variant:"outline",icon:"data_object",onClick:()=>k(e.id),children:"Format"}),t.jsx(c,{size:"sm",variant:"outline",icon:"content_copy",onClick:()=>R(e.id),children:"Copy"}),s]})]})]})},e.id)})]})}function m({label:i,value:h,color:g}){const u={blue:"bg-blue-500/10 text-blue-500",orange:"bg-orange-500/10 text-orange-500",green:"bg-green-500/10 text-green-500",purple:"bg-purple-500/10 text-purple-500"};return t.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono ${u[g]}`,children:[t.jsxs("span",{className:"text-text-muted/70 font-sans text-[10px]",children:[i,":"]}),h]})}export{W as default};
@@ -0,0 +1 @@
1
+ import{g as v,j as e,B as c,m as j}from"./index.C5VWu_q7.js";import{d as N,b as u,L as h}from"./router.Cjj1--8t.js";import{C as p,S as k,I as x,T as A}from"./NoAuthProxyCard.DMCykSRG.js";import"./zustand.akaTi5uX.js";const P=Object.values(v).map(a=>({value:a.id,label:a.name})),S=Object.values(j).map(a=>({value:a.id,label:a.name}));function E(){const a=N(),[b,m]=u.useState(!1),[t,y]=u.useState({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[s,n]=u.useState({}),i=(r,o)=>{y(l=>({...l,[r]:o})),s[r]&&n(l=>({...l,[r]:null}))},f=()=>{const r={};return t.provider||(r.provider="Please select a provider"),t.authMethod==="api_key"&&!t.apiKey&&(r.apiKey="API Key is required"),n(r),Object.keys(r).length===0},g=async r=>{if(r.preventDefault(),!!f()){m(!0);try{const o=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(o.ok)a("/dashboard/providers");else{const l=await o.json();n({submit:l.error||"Failed to create provider"})}}catch{n({submit:"An error occurred. Please try again."})}finally{m(!1)}}},d=v[t.provider];return e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs(h,{to:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[e.jsx("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),e.jsx("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),e.jsx(p,{children:e.jsxs("form",{onSubmit:g,className:"flex flex-col gap-6",children:[e.jsx(k,{label:"Provider",options:P,value:t.provider,onChange:r=>i("provider",r.target.value),placeholder:"Select a provider",error:s.provider,required:!0}),d&&e.jsxs(p.Section,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:e.jsx("span",{className:"material-symbols-outlined text-xl",style:{color:d.color},children:d.icon})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:d.name}),e.jsx("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"text-sm font-medium",children:["Authentication Method ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex gap-3",children:S.map(r=>e.jsxs("button",{type:"button",onClick:()=>i("authMethod",r.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${t.authMethod===r.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[e.jsx("span",{className:"material-symbols-outlined",children:r.value==="api_key"?"key":"lock"}),e.jsx("span",{className:"font-medium",children:r.label})]},r.value))})]}),t.authMethod==="api_key"&&e.jsx(x,{label:"API Key",type:"password",placeholder:"Enter your API key",value:t.apiKey,onChange:r=>i("apiKey",r.target.value),error:s.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),t.authMethod==="oauth2"&&e.jsxs(p.Section,{children:[e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),e.jsx(c,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),e.jsx(x,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:t.displayName,onChange:r=>i("displayName",r.target.value),hint:"Optional. A friendly name to identify this configuration."}),e.jsx(A,{checked:t.isActive,onChange:r=>i("isActive",r),label:"Active",description:"Enable this provider for use in your applications"}),s.submit&&e.jsx("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:s.submit}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-border",children:[e.jsx(h,{to:"/dashboard/providers",className:"flex-1",children:e.jsx(c,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),e.jsx(c,{type:"submit",loading:b,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}export{E as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.C5VWu_q7.js";import{L as m,b as i}from"./router.Cjj1--8t.js";import{g as u}from"./machine.CagOtseJ.js";import{C as d}from"./NoAuthProxyCard.DMCykSRG.js";import{C as r}from"./Loading.D9qCFX3R.js";import{C as p,M as h}from"./cliTools.CsdwAybi.js";import"./zustand.akaTi5uX.js";function f({tool:s}){return e.jsx(m,{to:"/dashboard/mitm",className:"block",children:e.jsx(d,{padding:"sm",className:"overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:s.image,alt:s.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:t=>{t.target.style.display="none"}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium text-sm",children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-medium bg-purple-500/10 text-purple-600 dark:text-purple-400 rounded-full",children:"MITM"})]}),e.jsx("p",{className:"text-xs text-text-muted truncate",children:s.description})]})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[20px]",children:"chevron_right"})]})})})}function j(s){return s?s.installed?s.hasFSRouter?{label:"Connected",cls:"bg-green-500/10 text-green-600 dark:text-green-400"}:{label:"Not configured",cls:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400"}:{label:"Not installed",cls:"bg-gray-500/10 text-gray-500"}:{label:"Unknown",cls:"bg-gray-500/10 text-gray-500"}}function N({toolId:s,tool:t,status:c}){const n=j(c);return e.jsx(m,{to:`/dashboard/cli-tools/${s}`,className:"block",children:e.jsx(d,{padding:"sm",className:"h-full overflow-hidden hover:border-primary/50 transition-colors cursor-pointer",children:e.jsx("div",{className:"flex h-full flex-col gap-2",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-8 flex items-center justify-center shrink-0",children:t.image?e.jsx("img",{src:t.image,alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",sizes:"32px",onError:o=>{o.target.style.display="none"}}):t.icon?e.jsx("span",{className:"material-symbols-outlined text-[28px]",style:{color:t.color},children:t.icon}):null}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:t.name}),e.jsx("span",{className:`inline-block mt-1 px-1.5 py-0.5 text-[10px] font-medium rounded-full ${n.cls}`,children:n.label})]}),e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[18px] shrink-0",children:"chevron_right"})]})})})})}const b="/api/cli-tools/all-statuses";function y({machineId:s}){const[t,c]=i.useState(!0),[n,o]=i.useState({});if(i.useEffect(()=>{let a=!0;return(async()=>{try{const l=await fetch(b);l.ok&&a&&o(await l.json())}catch(l){console.log("Error fetching tool statuses:",l)}finally{a&&c(!1)}})(),()=>{a=!1}},[]),t)return e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{}),e.jsx(r,{})]});const x=Object.entries(p),g=Object.entries(h);return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-6 px-1 sm:px-0",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:x.map(([a,l])=>e.jsx(N,{toolId:a,tool:l,status:n[a]},a))}),e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"security"}),e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"MITM Tools"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:g.map(([a,l])=>e.jsx(f,{tool:l},a))})]})]})}function M(){const[s,t]=i.useState("");return i.useEffect(()=>{u().then(t)},[]),s?e.jsx(y,{machineId:s}):null}export{M as default};