@fudrouter/fsrouter 0.6.82 → 0.6.83

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/package.json +1 -1
  2. package/public/.vite/manifest.json +89 -89
  3. package/public/assets/EndpointPageClient.B1Pk_WAK.js +6 -0
  4. package/public/assets/Loading.CYS14nGq.js +1 -0
  5. package/public/assets/NoAuthProxyCard.CbdAR_EJ.js +89 -0
  6. package/public/assets/index.WEEOI9Yd.js +89 -0
  7. package/public/assets/page.0V4YzdlE.js +1 -0
  8. package/public/assets/page.4HQp0W96.js +1 -0
  9. package/public/assets/page.6WqoW7rJ.js +6 -0
  10. package/public/assets/page.8wawKT_1.js +31 -0
  11. package/public/assets/page.B3i_xr2T.js +64 -0
  12. package/public/assets/page.B5WRSQGC.js +1 -0
  13. package/public/assets/page.B7FGH_5K.js +1 -0
  14. package/public/assets/page.B9P9zKv3.js +5 -0
  15. package/public/assets/page.BKP0wYIK.js +23 -0
  16. package/public/assets/page.BYBO0NtL.js +1 -0
  17. package/public/assets/page.Bg89P00k.js +1 -0
  18. package/public/assets/page.BqAhnX2u.js +1 -0
  19. package/public/assets/page.BrFtZdnn.js +2 -0
  20. package/public/assets/page.BuWdnu7k.js +1 -0
  21. package/public/assets/page.CDv8_as_.js +1 -0
  22. package/public/assets/page.CKjbKM6f.js +1 -0
  23. package/public/assets/page.CWfxstdC.js +5 -0
  24. package/public/assets/page.Cc2BUz5h.js +1 -0
  25. package/public/assets/page.Ce_8sge3.js +4 -0
  26. package/public/assets/page.CfVZCsMm.js +1 -0
  27. package/public/assets/page.ClOh42sE.js +1 -0
  28. package/public/assets/page.CuA_DfQG.js +1 -0
  29. package/public/assets/page.DCPWvJU4.js +1 -0
  30. package/public/assets/page.DP-BfKv8.js +1 -0
  31. package/public/assets/page.DQ0jp0G1.js +1 -0
  32. package/public/assets/page.DYd0ZEzM.js +1 -0
  33. package/public/assets/page.D_05_f-z.js +1 -0
  34. package/public/assets/page.Dc_ARSSS.js +1 -0
  35. package/public/assets/page.DjkxfoPR.js +1 -0
  36. package/public/assets/page.FrFOYEwa.js +1 -0
  37. package/public/assets/page.PTAgP9hn.js +1 -0
  38. package/public/assets/page.SS6G2WdS.js +1 -0
  39. package/public/assets/page.W9wqy988.js +1 -0
  40. package/public/assets/page.f_n3mtFq.js +1 -0
  41. package/public/assets/page.mc94aTsQ.js +1 -0
  42. package/public/assets/page.q9bsf4tq.js +2 -0
  43. package/public/assets/page.y4Bfqvc0.js +6 -0
  44. package/public/index.html +1 -1
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.WEEOI9Yd.js";import{b as r}from"./router.Cjj1--8t.js";import{C as j}from"./Loading.CYS14nGq.js";import"./zustand.akaTi5uX.js";function P(){return e.jsx(r.Suspense,{fallback:e.jsx(j,{}),children:e.jsx(v,{})})}function v(){const[o,u]=r.useState([]),[p,b]=r.useState(!0),[s,f]=r.useState(""),[a,n]=r.useState(null),[i,d]=r.useState(!1),[l,x]=r.useState(""),[c,m]=r.useState(null);r.useEffect(()=>{fetch("/api/media-providers/moderation").then(t=>t.json()).then(t=>{u(Array.isArray(t)?t:[]),t.length>0&&x(t[0].id)}).catch(()=>{}).finally(()=>b(!1))},[]);const h=async()=>{if(s.trim()){d(!0),m(null),n(null);try{const t=await fetch("/api/media/moderation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:s,providerId:l||void 0})});if(!t.ok)throw new Error(`HTTP ${t.status}`);const g=await t.json();n(g)}catch(t){m(t.message)}finally{d(!1)}}};return e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:px-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"shield"}),e.jsx("h1",{className:"text-xl font-semibold text-text-main",children:"Moderations"})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Moderation Providers"}),p?e.jsx("p",{className:"text-xs text-text-muted",children:"Loading providers..."}):o.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:"No moderation providers configured. Add one in Media Providers."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(t=>e.jsx("button",{onClick:()=>x(t.id),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors cursor-pointer ${l===t.id?"bg-primary/10 text-primary border border-primary/30":"bg-surface-2 text-text-muted hover:text-text-main border border-transparent"}`,children:t.name||t.id},t.id))})]}),e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Test Moderation"}),e.jsx("textarea",{value:s,onChange:t=>f(t.target.value),placeholder:"Enter text to moderate...",rows:4,className:"w-full rounded-lg border border-border-subtle bg-surface-2 px-3 py-2 text-sm text-text-main placeholder:text-text-muted/50 focus:outline-none focus:ring-1 focus:ring-primary/50 resize-none mb-3"}),e.jsx("button",{onClick:h,disabled:i||!s.trim(),className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-medium hover:bg-primary/90 disabled:opacity-50 transition-colors cursor-pointer",children:i?"Testing...":"Run Moderation"})]}),c&&e.jsx("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 p-4",children:e.jsx("p",{className:"text-sm text-red-400",children:c})}),a&&e.jsxs("div",{className:"rounded-xl border border-border-subtle bg-surface p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main mb-3",children:"Result"}),e.jsx("pre",{className:"text-xs text-text-muted overflow-auto max-h-96 bg-surface-2 rounded-lg p-3 font-mono whitespace-pre-wrap",children:JSON.stringify(a,null,2)})]})]})}export{P as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.WEEOI9Yd.js";import"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function i(){return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center justify-center size-8 rounded-lg bg-primary/10",children:e.jsx("span",{className:"material-symbols-outlined text-primary text-[18px]",children:"menu_book"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-sm font-semibold text-text-main",children:"API Reference"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Image & Video Generation — all providers, models, and parameters"})]})]}),e.jsxs("a",{href:"/image-video-docs.html",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-text-muted hover:text-text-main hover:bg-surface-2 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"open_in_new"}),"Open in new tab"]})]}),e.jsx("iframe",{src:"/image-video-docs.html",className:"flex-1 w-full border-0 min-h-0",title:"Image & Video API Reference"})]})}export{i as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.WEEOI9Yd.js";import{b as t,d as H}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function z(){const[x,N]=t.useState(""),[m,c]=t.useState(""),[W,b]=t.useState(""),[r,f]=t.useState(0),[g,w]=t.useState(!1),[y,u]=t.useState(null),[n,k]=t.useState("password"),[i,L]=t.useState(!1),[S,C]=t.useState("Sign in with OIDC"),[h,M]=t.useState(!1),l=H();t.useEffect(()=>{if(r<=0)return;const a=setInterval(()=>f(s=>s>0?s-1:0),1e3);return()=>clearInterval(a)},[r]),t.useEffect(()=>{async function a(){const s=new AbortController,o=setTimeout(()=>s.abort(),5e3),R=typeof window<"u"?window.location.origin:"";try{const v=await fetch(`${R}/api/auth/status`,{signal:s.signal});if(clearTimeout(o),v.ok){const d=await v.json(),j=new URLSearchParams(window.location.search),E=j.get("force")==="true"||j.get("force")==="1";if(d.requireLogin===!1&&!E){localStorage.setItem("9r_authed","1"),l("/dashboard"),l(0);return}u(!!d.hasPassword),k(d.authMode||"password"),L(d.oidcConfigured===!0),C(d.oidcLoginLabel||"Sign in with OIDC")}else u(!0)}catch{clearTimeout(o),u(!0)}}a()},[l]);const P=async a=>{a.preventDefault(),w(!0),c(""),b("");try{const s=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:x})});if(s.ok)localStorage.setItem("9r_authed","1"),l("/dashboard"),l(0);else{const o=await s.json();c(o.error||"Invalid password"),o.resetHint&&b(o.resetHint),o.retryAfter&&f(Number(o.retryAfter))}}catch{c("An error occurred. Please try again.")}finally{w(!1)}},I=()=>{window.location.href="/api/auth/oidc/start"},A=i&&["oidc","both"].includes(n),p=n!=="oidc"||!i,O=n==="oidc"&&!i||n==="both"&&!i,D=n==="both"&&i;return y===null?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-slate-400"})}):e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-slate-100 p-4",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute -top-40 -right-40 w-80 h-80 bg-violet-200/30 rounded-full blur-3xl"}),e.jsx("div",{className:"absolute -bottom-40 -left-40 w-80 h-80 bg-blue-200/30 rounded-full blur-3xl"})]}),e.jsxs("div",{className:"relative w-full max-w-sm",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-200/60 p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-violet-500 to-blue-500 mb-4 shadow-lg shadow-violet-500/25",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 tracking-tight",children:"FSRouter"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:n==="oidc"&&i?"Sign in with your OIDC provider":"Enter your password to continue"})]}),O&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-amber-50 border border-amber-200 text-xs text-amber-700",children:"OIDC not configured yet. Password login is available."}),D&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-violet-50 border border-violet-200 text-xs text-violet-700 text-center",children:"Password and OIDC login are both enabled."}),p&&e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-slate-600 block mb-1.5",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{name:"password",type:h?"text":"password",placeholder:"••••••••",value:x,onChange:a=>N(a.target.value),required:!0,autoFocus:!0,className:"w-full bg-slate-50 border border-slate-200 text-slate-900 text-sm p-3 pr-10 rounded-xl focus:outline-none focus:border-violet-400 focus:ring-2 focus:ring-violet-100 placeholder-slate-400 transition-all"}),e.jsx("button",{type:"button",onClick:()=>M(!h),className:"absolute inset-y-0 right-3 flex items-center text-slate-400 hover:text-slate-600",children:h?e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878l4.242 4.242M21 21l-3.122-3.122"})}):e.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]}),m&&e.jsx("p",{className:"text-xs text-red-500 mt-1.5",children:m}),r>0&&e.jsxs("p",{className:"text-xs text-amber-600 mt-1.5",children:["Locked. Retry in ",r,"s."]})]}),e.jsx("button",{type:"submit",disabled:g||r>0,className:"w-full bg-gradient-to-r from-violet-500 to-blue-500 hover:from-violet-600 hover:to-blue-600 text-white font-medium text-sm py-3 rounded-xl transition-all shadow-lg shadow-violet-500/25 disabled:opacity-50 cursor-pointer",children:g?"Logging in...":r>0?`Wait ${r}s`:"Login"}),e.jsxs("p",{className:"text-center text-xs text-slate-400",children:["Default password is ",e.jsx("code",{className:"bg-slate-100 px-1.5 py-0.5 rounded text-slate-500 font-mono",children:"123456"})]})]}),A&&e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{className:"relative flex items-center justify-center py-4",children:[e.jsx("span",{className:"w-full border-t border-slate-200"}),e.jsx("span",{className:"px-3 text-xs text-slate-400 bg-white absolute",children:"or"})]}),e.jsxs("button",{onClick:I,type:"button",className:"w-full flex items-center justify-center gap-2 border border-slate-200 rounded-xl py-3 hover:bg-slate-50 transition-colors text-slate-600 text-sm cursor-pointer",children:[e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4M10 17l5-5-5-5M15 12H3"})}),S]})]})]}),e.jsx("p",{className:"text-center text-xs text-slate-400 mt-6",children:"Powered by FSRouter"})]})]})}export{z as default};
@@ -0,0 +1,2 @@
1
+ import{j as t}from"./index.WEEOI9Yd.js";import{b as a}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function g(){const[s,u]=a.useState(""),[n,i]=a.useState(""),[r,l]=a.useState(null),[o,c]=a.useState(!1),d=async()=>{c(!0);try{const e=await fetch("/api/rerank",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:s,documents:n.split(`
2
+ `).filter(Boolean)})});l(await e.json())}catch(e){l({error:e.message})}c(!1)};return t.jsxs("div",{className:"space-y-6 p-6",children:[t.jsx("h1",{className:"text-2xl font-bold",children:"Rerank"}),t.jsx("p",{className:"text-text-muted",children:"Rerank documents by relevance using Cohere-compatible API"}),t.jsx("input",{className:"w-full p-3 rounded-lg border",placeholder:"Query",value:s,onChange:e=>u(e.target.value)}),t.jsx("textarea",{className:"w-full p-3 rounded-lg border h-40",placeholder:"Documents (one per line)",value:n,onChange:e=>i(e.target.value)}),t.jsx("button",{onClick:d,disabled:o,className:"px-4 py-2 bg-primary text-white rounded-lg",children:o?"Reranking...":"Rerank"}),r&&t.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm overflow-auto",children:JSON.stringify(r,null,2)})]})}export{g as default};
@@ -0,0 +1 @@
1
+ import{J as m,j as e,B as p}from"./index.WEEOI9Yd.js";import{b as l}from"./router.Cjj1--8t.js";import{C as f}from"./NoAuthProxyCard.CbdAR_EJ.js";import"./zustand.akaTi5uX.js";const g={LOG:"text-green-400",INFO:"text-blue-400",WARN:"text-yellow-400",ERROR:"text-red-400",DEBUG:"text-purple-400"};function h(n){var s;const o=n.match(/\[(\w+)\]/g),u=o?(s=o[1])==null?void 0:s.replace(/\[|\]/g,""):null,c=g[u]||"text-green-400";return e.jsx("span",{className:c,children:n})}function j(){const[n,o]=l.useState([]),[u,c]=l.useState(!1),s=l.useRef(null),d=async()=>{try{await fetch("/api/translator/console-logs",{method:"DELETE"})}catch(t){console.error("Failed to clear console logs:",t)}};return l.useEffect(()=>{const t=new EventSource("/api/translator/console-logs/stream");return t.onopen=()=>c(!0),t.onmessage=a=>{const r=JSON.parse(a.data);r.type==="init"?o(r.logs.slice(-200)):r.type==="line"?o(x=>{const i=[...x,r.line];return i.length>m.maxLines?i.slice(-200):i}):r.type==="clear"&&o([])},t.onerror=()=>c(!1),()=>t.close()},[]),l.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[n]),e.jsx("div",{className:"",children:e.jsxs(f,{children:[e.jsx("div",{className:"flex items-center justify-end px-4 pt-3 pb-2",children:e.jsx(p,{size:"sm",variant:"outline",icon:"delete",onClick:d,children:"Clear"})}),e.jsx("div",{ref:s,className:"bg-black rounded-b-lg p-4 text-xs font-mono h-[calc(100vh-220px)] overflow-y-auto",children:n.length===0?e.jsx("span",{className:"text-text-muted",children:"No console logs yet."}):e.jsx("div",{className:"space-y-0.5",children:n.map((t,a)=>e.jsx("div",{children:h(t)},a))})})]})})}const N="force-dynamic";function O(){return e.jsx(j,{})}export{O as default,N as dynamic};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.WEEOI9Yd.js";import{b as n,f as h}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function u(){const[s]=h(),[a,l]=n.useState("processing");return n.useEffect(()=>{const r=s.get("code"),i=s.get("state"),o=s.get("error"),d=s.get("error_description"),c={code:r,state:i,error:o,errorDescription:d,fullUrl:window.location.href},m=[window.location.origin,"http://localhost:1455","http://localhost:51121"];if(window.opener)for(const t of m)try{window.opener.postMessage({type:"oauth_callback",data:c},t)}catch(x){console.log("postMessage failed:",x)}try{const t=new BroadcastChannel("oauth_callback");t.postMessage(c),t.close()}catch(t){console.log("BroadcastChannel failed:",t)}try{localStorage.setItem("oauth_callback",JSON.stringify({...c,timestamp:Date.now()}))}catch(t){console.log("localStorage failed:",t)}if(!(r||o)){setTimeout(()=>l("manual"),0);return}l("success"),setTimeout(()=>{window.close(),setTimeout(()=>l("done"),500)},1500)},[s]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[a==="processing"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Processing..."}),e.jsx("p",{className:"text-text-muted",children:"Please wait while we complete the authorization."})]}),(a==="success"||a==="done")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Authorization Successful!"}),e.jsx("p",{className:"text-text-muted",children:a==="success"?"This window will close automatically...":"You can close this tab now."})]}),a==="manual"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-100 dark:bg-yellow-900/30 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-yellow-600",children:"info"})}),e.jsx("h1",{className:"text-xl font-semibold mb-2",children:"Copy This URL"}),e.jsx("p",{className:"text-text-muted mb-4",children:"Please copy the URL from the address bar and paste it in the application."}),e.jsx("div",{className:"bg-surface border border-border rounded-lg p-3 text-left",children:e.jsx("code",{className:"text-xs break-all",children:typeof window<"u"?window.location.href:""})})]})]})})}function b(){return e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bg",children:e.jsxs("div",{className:"text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),e.jsx("p",{className:"text-text-muted",children:"Loading..."})]})}),children:e.jsx(u,{})})}export{b as default};
@@ -0,0 +1 @@
1
+ import{j as e,u}from"./index.WEEOI9Yd.js";import{C as l,B as d}from"./NoAuthProxyCard.CbdAR_EJ.js";import"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";const c="nexusrouters/fsrouter",m="main",x="skills",h=`https://github.com/${c}`,f=`https://raw.githubusercontent.com/${c}/refs/heads/${m}/${x}`,b=`https://github.com/${c}/blob/${m}/${x}`,n=[{id:"fsrouter",name:"FSRouter (Entry)",description:"Setup + index of all capabilities. Start here — covers base URL, auth, model discovery, and links to every capability skill.",endpoint:null,icon:"hub",isEntry:!0},{id:"fsrouter-chat",name:"Chat",description:"Chat / code-gen via OpenAI or Anthropic format with streaming.",endpoint:"/v1/chat/completions",icon:"chat"},{id:"fsrouter-image",name:"Image Generation",description:"Text-to-image via DALL-E, Imagen, FLUX, MiniMax, SDWebUI…",endpoint:"/v1/images/generations",icon:"image"},{id:"fsrouter-tts",name:"Text-to-Speech",description:"OpenAI / ElevenLabs / Edge / Google / Deepgram voices.",endpoint:"/v1/audio/speech",icon:"record_voice_over"},{id:"fsrouter-stt",name:"Speech-to-Text",description:"Transcribe audio via OpenAI Whisper, Groq, Gemini, Deepgram, AssemblyAI…",endpoint:"/v1/audio/transcriptions",icon:"mic"},{id:"fsrouter-embeddings",name:"Embeddings",description:"Vectors for RAG / semantic search via OpenAI, Gemini, Mistral…",endpoint:"/v1/embeddings",icon:"scatter_plot"},{id:"fsrouter-web-search",name:"Web Search",description:"Tavily / Exa / Brave / Serper / SearXNG / Google PSE / You.com.",endpoint:"/v1/search",icon:"search"},{id:"fsrouter-web-fetch",name:"Web Fetch",description:"URL → markdown / text / HTML via Firecrawl, Jina, Tavily, Exa.",endpoint:"/v1/web/fetch",icon:"language"},{id:"using-superpowers",name:"Using Superpowers",description:"Use when starting any conversation — establishes how to find and use skills before ANY response.",endpoint:null,icon:"bolt"},{id:"multi-brain",name:"Multi-Brain Memory",description:"Share work and memory across Claude Code, OpenCode, Codex, and other agents via a two-level memory index.",endpoint:null,icon:"memory"}];function o(t){return`${f}/${t}/SKILL.md`}function g(t){return`${b}/${t}/SKILL.md`}function p({value:t,label:i="Copy link"}){const{copied:r,copy:s}=u(2e3);return e.jsxs("button",{onClick:()=>s(t),className:"px-2 py-1 rounded-md bg-primary text-white text-[11px] font-medium hover:bg-primary/90 transition-colors cursor-pointer shrink-0 inline-flex items-center gap-1",title:t,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:r?"check":"content_copy"}),r?"Copied!":i]})}function a({skill:t}){const i=o(t.id);return e.jsxs("div",{className:`flex items-start gap-3 p-4 rounded-[14px] border shadow-[var(--shadow-soft)] transition-colors ${t.isEntry?"border-primary/40 bg-primary/5":"border-border-subtle bg-surface hover:bg-surface-2"}`,children:[e.jsx("div",{className:`size-9 rounded-lg flex items-center justify-center shrink-0 ${t.isEntry?"bg-primary text-white":"bg-primary/10 text-primary"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t.icon})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-sm text-text-main",children:t.name}),t.isEntry&&e.jsx(d,{variant:"primary",size:"sm",children:"START HERE"}),t.endpoint&&e.jsx(d,{variant:"default",size:"sm",children:e.jsx("code",{className:"text-[10px]",children:t.endpoint})})]}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:t.description}),e.jsxs("a",{href:g(t.id),target:"_blank",rel:"noreferrer",className:"text-[11px] text-text-muted hover:text-primary mt-1 inline-flex items-center gap-1 break-all",children:[i,e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"open_in_new"})]})]}),e.jsx(p,{value:i})]})}const y=["fsrouter-chat","fsrouter-image","fsrouter-tts","fsrouter-stt","fsrouter-embeddings","fsrouter-web-search","fsrouter-web-fetch"],j=["using-superpowers","multi-brain"];function L(){const t=n.find(s=>s.isEntry),i=n.filter(s=>y.includes(s.id)),r=n.filter(s=>j.includes(s.id));return e.jsxs("div",{className:"max-w-4xl mx-auto space-y-8",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"size-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"extension"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-text-main",children:"Agent Skills"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Raw SKILL.md URLs to paste into any AI agent or coding assistant."})]})]})}),e.jsxs(l,{padding:"md",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"rocket_launch"}),e.jsx("span",{className:"text-xs font-semibold text-text-main uppercase tracking-wide",children:"Quick Start — Paste this to your AI"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex-1 px-3 py-2 rounded-lg bg-surface-2 font-mono text-[12px] text-text-main border border-border-subtle min-w-0 break-all",children:["Read this skill and use it: ",o("fsrouter")]}),e.jsx(p,{value:`Read this skill and use it: ${o("fsrouter")}`,label:"Copy prompt"})]}),e.jsx("p",{className:"text-[11px] text-text-muted mt-2",children:"This entry skill covers setup, authentication, model discovery, and links to all capability skills below."})]}),t&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider px-1",children:"Entry Point"}),e.jsx(a,{skill:t})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider px-1",children:"API Capabilities"}),e.jsx("div",{className:"space-y-2",children:i.map(s=>e.jsx(a,{skill:s},s.id))})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider px-1",children:"Agent Workflow"}),e.jsx("div",{className:"space-y-2",children:r.map(s=>e.jsx(a,{skill:s},s.id))})]}),e.jsx(l,{padding:"md",children:e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"Browse on GitHub"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"View source, README, and full skill documentation."})]}),e.jsxs("a",{href:`${h}/tree/master/skills`,target:"_blank",rel:"noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1 shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"open_in_new"}),"View on GitHub"]})]})})]})}export{L 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.WEEOI9Yd.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.CbdAR_EJ.js";import{C as Lt}from"./Loading.CYS14nGq.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.WEEOI9Yd.js";import{b as s}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function A(){const[a,y]=s.useState({currentVersion:"",latestVersion:"",hasUpdate:!1}),[k,b]=s.useState(!0),[f,i]=s.useState(!1),[c,g]=s.useState(0),[S,o]=s.useState(""),[m,h]=s.useState([]),[j,r]=s.useState(""),x=s.useRef(null),v=async()=>{try{b(!0);const n=await(await fetch("/api/version")).json();y(n)}catch(t){console.error(t),r("Gagal memuat informasi versi.")}finally{b(!1)}};s.useEffect(()=>{v()},[]),s.useEffect(()=>{x.current&&x.current.scrollIntoView({behavior:"smooth"})},[m]);const w=async()=>{if(window.confirm("Apakah Anda yakin ingin memulai update otomatis?")){i(!0),g(0),h([]),o("Menghubungi server untuk memulai update..."),r("");try{const n=await(await fetch("/api/version/update",{method:"POST"})).json();if(n.success){const d=new EventSource("/api/version/update");d.onmessage=u=>{const l=JSON.parse(u.data);if(g(l.progress||0),h(l.logs||[]),l.status==="updating")o(`Sedang memproses update... (${l.progress}%)`);else if(l.status==="done"||l.progress===100){d.close(),o("Update berhasil diselesaikan! Server sedang merestart...");let p=0;const N=setInterval(async()=>{p++,o(`Menunggu server online kembali... (Mencoba menghubungkan: ${p}s)`);try{(await fetch("/api/health")).ok&&(clearInterval(N),o("Update Selesai! Halaman akan dimuat ulang..."),setTimeout(()=>{window.location.reload()},1500))}catch{}p>90&&(clearInterval(N),i(!1),r("Server memakan waktu terlalu lama untuk online kembali. Silakan periksa status PM2 Anda secara manual."))},2e3)}},d.onerror=u=>{console.error("EventSource error:",u),c>80?d.close():(d.close(),r("Koneksi ke server terputus saat proses update berjalan."),i(!1))}}else r(n.message||"Gagal memulai update otomatis."),i(!1)}catch(t){console.error(t),r("Koneksi gagal saat memulai update."),i(!1)}}};return e.jsxs("div",{className:"max-w-4xl mx-auto p-4 space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("h1",{className:"text-2xl font-bold text-text-main flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[28px] text-primary",children:"system_update"}),"FSRouter System Update"]}),e.jsx("p",{className:"text-xs text-text-muted",children:"Kelola dan perbarui versi FSRouter Anda langsung dari repositori GitHub atau NPM registry."})]}),k?e.jsx("div",{className:"flex items-center justify-center p-12 border border-border-subtle rounded-[14px] bg-surface",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("span",{className:"material-symbols-outlined text-4xl animate-spin text-primary",children:"sync"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Memuat informasi versi..."})]})}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col gap-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"Detail Versi"}),e.jsxs("div",{className:"flex items-center justify-between border-b border-border-subtle pb-3",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Versi Saat Ini"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-text-main",children:["v",a.currentVersion||"0.0.0"]})]}),e.jsxs("div",{className:"flex items-center justify-between border-b border-border-subtle pb-3",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Versi Terbaru di GitHub"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-text-main",children:["v",a.latestVersion||"0.0.0"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Status"}),a.hasUpdate?e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-semibold bg-amber-500/10 text-amber-500 border border-amber-500/20",children:"Update Tersedia"}):e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-semibold bg-green-500/10 text-green-500 border border-green-500/20",children:"Versi Terbaru"})]})]}),e.jsxs("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface flex flex-col justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-text-main",children:"Aksi Pembaruan"}),e.jsx("p",{className:"text-xs text-text-muted leading-relaxed",children:a.hasUpdate?"Versi baru tersedia! Update otomatis akan menginstal versi terbaru, memperbarui dependensi, membangun ulang kode, dan me-restart server FSRouter Anda secara mulus.":"FSRouter Anda sudah menggunakan versi terbaru. Tidak ada pembaruan yang diperlukan saat ini."})]}),f?e.jsxs("div",{className:"p-4 rounded-lg bg-primary/5 border border-primary/20 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-primary",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] animate-spin",children:"sync"}),"Proses Update Sedang Berjalan: ",c,"%"]}),e.jsx("div",{className:"w-full bg-border-subtle rounded-full h-2.5 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-2.5 rounded-full transition-all duration-500",style:{width:`${c}%`}})}),e.jsx("p",{className:"text-[11px] text-text-muted leading-relaxed",children:S})]}):e.jsxs("div",{className:"space-y-2",children:[j&&e.jsx("p",{className:"text-xs text-red-500 font-semibold bg-red-500/10 border border-red-500/20 p-3 rounded-lg",children:j}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{disabled:!a.hasUpdate,onClick:w,className:`flex-1 py-2 px-4 rounded-lg text-xs font-semibold text-white transition-colors flex items-center justify-center gap-2 ${a.hasUpdate?"bg-primary hover:bg-primary/90 cursor-pointer":"bg-border-subtle text-text-muted cursor-not-allowed"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"download"}),"Otomatis Update Sekarang"]}),e.jsx("button",{onClick:v,className:"py-2 px-3 rounded-lg border border-border-subtle text-text-main text-xs hover:bg-surface-2 transition-colors cursor-pointer",title:"Periksa Ulang",children:e.jsx("span",{className:"material-symbols-outlined text-[16px] block",children:"refresh"})})]})]})]})]}),f&&m.length>0&&e.jsxs("div",{className:"p-4 rounded-[14px] border border-border-subtle bg-black text-green-400 font-mono text-xs overflow-hidden flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-green-900/50",children:[e.jsxs("span",{className:"text-green-500 font-semibold flex items-center gap-1.5",children:[e.jsx("span",{className:"size-2 rounded-full bg-green-500 animate-pulse"}),"Logs Konsol Pembaruan"]}),e.jsx("span",{className:"text-[10px] text-green-600",children:"FSRouter Updater"})]}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto space-y-1 custom-scrollbar",children:[m.map((t,n)=>e.jsx("pre",{className:"whitespace-pre-wrap leading-relaxed break-all font-mono",children:t},n)),e.jsx("div",{ref:x})]})]})]})}export{A as default};
@@ -0,0 +1,4 @@
1
+ import{j as e,f as l,B as N,g as Ve,M as tt,u as _s,O as gt,A as bt,F as et,c as Ht,W as Fs,h as Ks,i as zs,k as qs,l as Vs,T as Bs,C as Qt,t as Ee}from"./index.WEEOI9Yd.js";import{b as i,h as Gs,d as Js,L as Yt}from"./router.Cjj1--8t.js";import{B as Ue,T as st,I as ce,S as yt,C as Ne,N as Ws,K as Hs,a as Qs,G as Ys,O as Xs,b as Zs,E as ea}from"./NoAuthProxyCard.CbdAR_EJ.js";import{L as ta,C as Xt}from"./Loading.CYS14nGq.js";import"./zustand.akaTi5uX.js";const sa=600*1e3,Zt=new Map;async function aa(n){if(!(n!=null&&n.url)||!(n!=null&&n.type))return[];const c=Zt.get(n.url);if(c&&Date.now()<c.expiresAt)return c.data;try{const a=new URLSearchParams({url:n.url,type:n.type}),d=await fetch(`/api/providers/suggested-models?${a}`);if(!d.ok)return[];const u=(await d.json()).data??[];return Zt.set(n.url,{data:u,expiresAt:Date.now()+sa}),u}catch{return[]}}function vt({model:n,fullModel:c,alias:a,copied:d,onCopy:x,testStatus:u,isCustom:f,isFree:h,onDeleteAlias:o,onTest:b,isTesting:S,onDisable:C}){const R=u==="ok"?"border-green-500/40":u==="error"?"border-red-500/40":"border-border",L=u==="ok"?"#22c55e":u==="error"?"#ef4444":void 0;return e.jsx("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${R} hover:bg-sidebar/50`,children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[e.jsx("span",{className:"material-symbols-outlined shrink-0 text-base",style:L?{color:L}:void 0,children:u==="ok"?"check_circle":u==="error"?"cancel":"smart_toy"}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[e.jsx("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:c}),n.name&&e.jsx("span",{className:"truncate pl-1 text-[9px] italic text-text-muted/70",children:n.name})]}),b&&e.jsxs("div",{className:"relative shrink-0 group/btn",children:[e.jsx("button",{onClick:b,disabled:S,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${S?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:e.jsx("span",{className:"material-symbols-outlined text-sm",style:S?{animation:"spin 1s linear infinite"}:void 0,children:S?"progress_activity":"science"})}),e.jsx("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:S?"Testing...":"Test"})]}),e.jsxs("div",{className:"relative shrink-0 group/btn",children:[e.jsx("button",{onClick:()=>x(c,`model-${n.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:d===`model-${n.id}`?"check":"content_copy"})}),e.jsx("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:d===`model-${n.id}`?"Copied!":"Copy"})]}),f?e.jsx("button",{onClick:o,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"close"})}):C?e.jsx("button",{onClick:C,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}vt.propTypes={model:l.shape({id:l.string.isRequired}).isRequired,fullModel:l.string.isRequired,alias:l.string,copied:l.string,onCopy:l.func.isRequired,testStatus:l.oneOf(["ok","error"]),isCustom:l.bool,isFree:l.bool,onDeleteAlias:l.func,onTest:l.func,isTesting:l.bool,onDisable:l.func};l.string.isRequired,l.string.isRequired,l.string,l.func.isRequired,l.func.isRequired,l.func,l.oneOf(["ok","error"]),l.bool;l.string.isRequired,l.object.isRequired,l.string,l.func.isRequired,l.func.isRequired,l.func.isRequired;function la({modelId:n,fullModel:c,copied:a,onCopy:d,onDeleteAlias:x,onTest:u,testStatus:f,isTesting:h}){const o=f==="ok"?"border-green-500/40":f==="error"?"border-red-500/40":"border-border",b=f==="ok"?"#22c55e":f==="error"?"#ef4444":void 0;return e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${o} hover:bg-sidebar/50`,children:[e.jsx("span",{className:"material-symbols-outlined text-base text-text-muted",style:b?{color:b}:void 0,children:f==="ok"?"check_circle":f==="error"?"cancel":"smart_toy"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:n}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:c}),e.jsxs("div",{className:"relative group/btn",children:[e.jsx("button",{onClick:()=>d(c,`model-${n}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:a===`model-${n}`?"check":"content_copy"})}),e.jsx("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:a===`model-${n}`?"Copied!":"Copy"})]}),u&&e.jsxs("div",{className:"relative group/btn",children:[e.jsx("button",{onClick:u,disabled:h,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-sm",style:h?{animation:"spin 1s linear infinite"}:void 0,children:h?"progress_activity":"science"})}),e.jsx("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:h?"Testing...":"Test"})]})]})]}),e.jsx("button",{onClick:x,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function ls({providerStorageAlias:n,providerDisplayAlias:c,modelAliases:a,copied:d,onCopy:x,onSetAlias:u,onDeleteAlias:f,connections:h,isAnthropic:o}){const[b,S]=i.useState(""),[C,R]=i.useState(!1),[L,U]=i.useState(!1),[F,J]=i.useState(null),[X,E]=i.useState({}),Z=async y=>{if(!F){J(y);try{const B=await(await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${n}/${y}`})})).json();E(te=>({...te,[y]:B.ok?"ok":"error"}))}catch{E($=>({...$,[y]:"error"}))}finally{J(null)}}},O=Object.entries(a).filter(([,y])=>y.startsWith(`${n}/`)).map(([y,$])=>({modelId:$.replace(`${n}/`,""),fullModel:$,alias:y})),P=y=>{const $=y.split("/");return $[$.length-1]},g=y=>{const $=`${n}/${y}`;if(Object.values(a).includes($))return null;const B=P(y);if(!a[B])return B;const te=`${c}-${B}`;return a[te]?null:te},_=async()=>{if(!b.trim()||C)return;const y=b.trim(),$=g(y);if(!$){alert("All suggested aliases already exist. Please choose a different model or remove conflicting aliases.");return}R(!0);try{await u(y,$,n),S("")}catch(B){console.log("Error adding model:",B)}finally{R(!1)}},z=async()=>{if(L)return;const y=h.find($=>$.isActive!==!1);if(y){U(!0);try{const $=await fetch(`/api/providers/${y.id}/models`),B=await $.json();if(!$.ok){alert(B.error||"Failed to import models");return}const te=B.models||[];if(te.length===0){alert("No models returned from /models.");return}let ie=0;for(const ne of te){const se=ne.id||ne.name||ne.model;if(!se)continue;const K=g(se);K&&(await u(se,K,n),ie+=1)}ie===0&&alert("No new models were added.")}catch($){console.log("Error importing models:",$)}finally{U(!1)}}},ee=h.some(y=>y.isActive!==!1);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("p",{className:"text-sm text-text-muted",children:["Add ",o?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),e.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex-1 min-w-[240px]",children:[e.jsx("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),e.jsx("input",{id:"new-compatible-model-input",type:"text",value:b,onChange:y=>S(y.target.value),onKeyDown:y=>y.key==="Enter"&&_(),placeholder:o?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),e.jsx(N,{size:"sm",icon:"add",onClick:_,disabled:!b.trim()||C,children:C?"Adding...":"Add"}),e.jsx(N,{size:"sm",variant:"secondary",icon:"download",onClick:z,disabled:!ee||L,children:L?"Importing...":"Import from /models"})]}),!ee&&e.jsx("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),O.length>0&&e.jsx("div",{className:"flex flex-col gap-3",children:O.map(({modelId:y,fullModel:$,alias:B})=>e.jsx(la,{modelId:y,fullModel:`${c}/${y}`,copied:d,onCopy:x,onDeleteAlias:()=>f(B),onTest:h.length>0?()=>Z(y):void 0,testStatus:X[y],isTesting:F===y},$))})]})}ls.propTypes={providerStorageAlias:l.string.isRequired,providerDisplayAlias:l.string.isRequired,modelAliases:l.object.isRequired,copied:l.string,onCopy:l.func.isRequired,onSetAlias:l.func.isRequired,onDeleteAlias:l.func.isRequired,connections:l.arrayOf(l.shape({id:l.string,isActive:l.bool})).isRequired,isAnthropic:l.bool};function rs({until:n}){const[c,a]=i.useState("");return i.useEffect(()=>{const d=()=>{const u=new Date(n).getTime()-Date.now();if(u<=0){a("");return}const f=Math.floor(u/1e3);if(f<60)a(`${f}s`);else if(f<3600)a(`${Math.floor(f/60)}m ${f%60}s`);else{const h=Math.floor(f/3600),o=Math.floor(f%3600/60);a(`${h}h ${o}m`)}};d();const x=setInterval(d,1e3);return()=>clearInterval(x)},[n]),c?e.jsxs("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",c]}):null}rs.propTypes={until:l.string.isRequired};function is({connection:n,proxyPools:c,isOAuth:a,isFirst:d,isLast:x,onMoveUp:u,onMoveDown:f,onToggleActive:h,onUpdateProxy:o,onEdit:b,onDelete:S,oneByOneStatus:C=null,isSelected:R,onSelect:L}){var pe,we,Ae,Me,ge,me,Ce;const[U,F]=i.useState(!1),[J,X]=i.useState(!1),E=i.useRef(null),Z=new Map((c||[]).map(T=>[T.id,T])),A=((pe=n.providerSpecificData)==null?void 0:pe.proxyPoolId)||null,O=A?Z.get(A):null,P=((we=n.providerSpecificData)==null?void 0:we.connectionProxyEnabled)===!0&&!!((Ae=n.providerSpecificData)!=null&&Ae.connectionProxyUrl),g=!!A||P,_=O?`Pool: ${O.name}`:A?`Pool: ${A} (inactive/missing)`:P?`Legacy: ${(Me=n.providerSpecificData)==null?void 0:Me.connectionProxyUrl}`:"";let z="";if(O!=null&&O.proxyUrl||(ge=n.providerSpecificData)!=null&&ge.connectionProxyUrl){const T=(O==null?void 0:O.proxyUrl)||((me=n.providerSpecificData)==null?void 0:me.connectionProxyUrl);try{const le=new URL(T);z=`${le.protocol}//${le.hostname}${le.port?`:${le.port}`:""}`}catch{z=T}}const ee=(O==null?void 0:O.noProxy)||((Ce=n.providerSpecificData)==null?void 0:Ce.connectionNoProxy)||"";let y="default";(O==null?void 0:O.isActive)===!0?y="success":(A||P)&&(y="error"),i.useEffect(()=>{if(!U)return;const T=le=>{E.current&&!E.current.contains(le.target)&&F(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[U]);const $=async T=>{X(!0);try{await o(T==="__none__"?null:T)}finally{X(!1),F(!1)}},B=n.authType||(a?"oauth":"apikey"),te=B==="oauth",ie=B==="cookie",ne=ie?"cookie":te?"lock":"key",se=te?"OAuth":ie?"Cookie":"API Key",K=T=>typeof T=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(T),Q=te?K(n.email)?n.email:K(n.name)?n.name:n.name||n.email||n.displayName||"OAuth Account":n.name||n.email||n.displayName||"API Key",[oe,ue]=i.useState(!1),fe=Object.entries(n).filter(([T])=>T.startsWith("modelLock_")).map(([,T])=>T).filter(T=>!!T).sort()[0]||null;i.useEffect(()=>{const T=()=>{const v=Object.entries(n).filter(([Y])=>Y.startsWith("modelLock_")).map(([,Y])=>Y).filter(Y=>Y&&new Date(Y).getTime()>Date.now()).sort()[0]||null;ue(!!v)};T();const le=fe?setInterval(T,1e3):null;return()=>{le&&clearInterval(le)}},[fe]);const W=n.testStatus==="unavailable"&&!oe?"active":n.testStatus,be=()=>n.isActive===!1?"default":W==="active"||W==="success"?"success":W==="error"||W==="expired"||W==="unavailable"?"error":"default",ke=()=>C?C.state==="success"?"success":C.state==="failed"?"error":C.state==="testing"?"primary":"default":"default",ye=()=>C?C.state==="queued"?"queued":C.state==="testing"?"testing":C.state==="success"?"success":C.state==="failed"?C.error?`failed: ${C.error}`:"failed":null:null;return e.jsxs("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${n.isActive===!1?"opacity-60":""}`,children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[L&&e.jsx("input",{type:"checkbox",checked:R,onChange:L,className:"mt-1 sm:mt-0 h-4 w-4 shrink-0 rounded border-black/20 text-primary focus:ring-primary dark:border-white/20 dark:bg-black"}),e.jsxs("div",{className:"flex shrink-0 flex-col",children:[e.jsx("button",{onClick:u,disabled:d,className:`p-0.5 rounded ${d?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),e.jsx("button",{onClick:f,disabled:x,className:`p-0.5 rounded ${x?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),e.jsx("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:ne}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:Q}),e.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[e.jsx(Ue,{variant:be(),size:"sm",dot:!0,children:n.isActive===!1?"disabled":W||"Unknown"}),e.jsx(Ue,{variant:"default",size:"sm",children:se}),g&&e.jsx(Ue,{variant:y,size:"sm",children:"Proxy"}),oe&&n.isActive!==!1&&e.jsx(rs,{until:fe}),n.lastError&&n.isActive!==!1&&e.jsx("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:n.lastError,children:n.lastError}),e.jsxs("span",{className:"text-xs text-text-muted",children:["#",n.priority]}),n.globalPriority&&e.jsxs("span",{className:"text-xs text-text-muted",children:["Auto: ",n.globalPriority]}),ye()&&e.jsx(Ue,{variant:ke(),size:"sm",children:ye()})]}),g&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:_,children:_}),z&&e.jsx("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:z}),ee&&e.jsxs("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:ee,children:["no_proxy: ",ee]})]})]})]}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[e.jsxs("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[(c||[]).length>0&&e.jsxs("div",{className:"relative",ref:E,children:[e.jsxs("button",{onClick:()=>F(T=>!T),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${g?"text-primary":"text-text-muted hover:text-primary"}`,disabled:J,children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:J?"progress_activity":"lan"}),e.jsx("span",{className:"text-[10px] leading-tight",children:"Proxy"})]}),U&&e.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 max-w-[78vw] min-w-[160px] rounded-lg border border-border bg-bg py-1 shadow-lg",children:[e.jsx("button",{onClick:()=>$("__none__"),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${A?"text-text-main":"text-primary font-medium"}`,children:"None"}),(c||[]).map(T=>e.jsx("button",{onClick:()=>$(T.id),className:`w-full text-left px-3 py-1.5 text-sm hover:bg-black/5 dark:hover:bg-white/5 ${A===T.id?"text-primary font-medium":"text-text-main"}`,children:T.name},T.id))]})]}),e.jsxs("button",{onClick:b,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),e.jsx("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),e.jsxs("button",{onClick:S,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),e.jsx("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),e.jsx(st,{size:"sm",checked:n.isActive??!0,onChange:h,title:n.isActive??!0?"Disable connection":"Enable connection"})]})]})}is.propTypes={connection:l.shape({id:l.string,name:l.string,email:l.string,displayName:l.string,modelLockUntil:l.string,testStatus:l.string,isActive:l.bool,lastError:l.string,priority:l.number,globalPriority:l.number}).isRequired,proxyPools:l.arrayOf(l.shape({id:l.string,name:l.string,proxyUrl:l.string,noProxy:l.string,isActive:l.bool})),isOAuth:l.bool.isRequired,isFirst:l.bool.isRequired,isLast:l.bool.isRequired,onMoveUp:l.func.isRequired,onMoveDown:l.func.isRequired,onToggleActive:l.func.isRequired,onUpdateProxy:l.func,onEdit:l.func.isRequired,onDelete:l.func.isRequired,oneByOneStatus:l.shape({state:l.string,error:l.string}),isSelected:l.bool,onSelect:l.func};const ra=`name1|sk-key1
2
+ name2|sk-key2
3
+ sk-key-only-auto-named`;function ns({isOpen:n,provider:c,providerName:a,isCompatible:d,isAnthropic:x,authType:u,authHint:f,website:h,proxyPools:o,error:b,onSave:S,onBulkDone:C,onClose:R}){var ge,me,Ce,T,le;const L="__none__",U=c==="ollama-local",F=u==="cookie",J=c==="xai"&&!F,X=F?"Cookie Value":"API Key",E=F?c==="grok-web"?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":J?"xai-...":"",Z=c==="azure",A=c==="cloudflare-ai",O=((me=(ge=Ve)==null?void 0:ge[c])==null?void 0:me.regions)||null,P=((T=(Ce=Ve)==null?void 0:Ce[c])==null?void 0:T.defaultRegion)||((le=O==null?void 0:O[0])==null?void 0:le.id)||"",[g,_]=i.useState({name:"",apiKey:"",email:"",defaultModel:"",priority:1,proxyPoolId:L,ollamaHostUrl:""}),[z,ee]=i.useState({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[y,$]=i.useState({accountId:""}),[B,te]=i.useState(P),[ie,ne]=i.useState(!1),[se,K]=i.useState(null),[Q,oe]=i.useState(!1),[ue,fe]=i.useState("single"),[W,be]=i.useState(""),[ke,ye]=i.useState(null),pe=()=>{if(U&&g.ollamaHostUrl.trim())return{baseUrl:g.ollamaHostUrl.trim()};if(Z)return{azureEndpoint:z.azureEndpoint,apiVersion:z.apiVersion,deployment:z.deployment,organization:z.organization};if(A)return{accountId:y.accountId};if(O&&B)return{region:B}},we=async()=>{ne(!0);try{const Y=await(await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c,apiKey:g.apiKey,providerSpecificData:pe()})})).json();K(Y.valid?"success":"failed")}catch{K("failed")}finally{ne(!1)}},Ae=async()=>{if(c&&!(!U&&!g.apiKey)&&!(!U&&!g.name)&&!(d&&!g.defaultModel.trim())){oe(!0);try{let v=!1;try{ne(!0),K(null),v=!!(await(await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c,apiKey:g.apiKey,providerSpecificData:pe()})})).json()).valid,K(v?"success":"failed")}catch{K("failed")}finally{ne(!1)}await S({name:g.name||(U?"Ollama Local":""),apiKey:g.apiKey,email:c==="codebuddy"?g.email:void 0,defaultModel:d?g.defaultModel.trim():void 0,priority:g.priority,proxyPoolId:g.proxyPoolId===L?null:g.proxyPoolId,testStatus:v?"active":"unknown",providerSpecificData:pe()})}finally{oe(!1)}}},Me=async()=>{const v=W.split(`
4
+ `).map(s=>s.trim()).filter(Boolean);if(!v.length)return;oe(!0),ye(null);let Y=0,Re=0;for(let s=0;s<v.length;s++){const m=v[s];let k="",G="",xe="";if(c==="codebuddy"){const q=m.includes("|")?m.split("|"):m.split(":");q.length>=2?q.length===3?(xe=q[0].trim(),G=q[1].trim(),k=q[2].trim()):(G=q[0].trim(),k=q[1].trim(),xe=G):(k=q[0].trim(),xe=`Key ${s+1}`)}else{const q=m.split("|");k=q.length>=2?q.slice(1).join("|").trim():q[0].trim(),xe=`${q.length>=2?q[0].trim():"Key"} ${s+1}`}try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:c,apiKey:k,email:G||void 0,name:xe,priority:1,testStatus:"unknown"})})).ok?Y++:Re++}catch{Re++}}oe(!1),ye({success:Y,failed:Re}),Y>0&&C&&C()};return c?e.jsx(tt,{isOpen:n,title:`Add ${a||c} ${X}`,onClose:R,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{size:"sm",variant:ue==="single"?"primary":"ghost",onClick:()=>{fe("single"),ye(null)},children:"Single"}),e.jsx(N,{size:"sm",variant:ue==="bulk"?"primary":"ghost",onClick:()=>{fe("bulk"),ye(null)},children:"Bulk Add"})]}),ue==="bulk"&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:c==="codebuddy"?e.jsxs(e.Fragment,{children:["One key per line. Format: ",e.jsx("code",{children:"email:apiKey"})," or ",e.jsx("code",{children:"name|email|apiKey"}),"."]}):e.jsxs(e.Fragment,{children:["One key per line. Format: ",e.jsx("code",{children:"name|apiKey"})," or just ",e.jsx("code",{children:"apiKey"})," (auto-named by index)."]})}),e.jsx("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:ra,value:W,onChange:v=>be(v.target.value)}),ke&&e.jsxs("div",{className:`text-sm font-medium ${ke.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",ke.success," added",ke.failed>0?`, ✗ ${ke.failed} failed`:""]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{onClick:Me,fullWidth:!0,disabled:Q||!W.trim(),children:Q?"Adding...":"Add All Keys"}),e.jsx(N,{onClick:R,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),ue==="single"&&e.jsxs(e.Fragment,{children:[c==="codebuddy"&&e.jsx(ce,{label:"Email / Account ID",value:g.email,onChange:v=>_({...g,email:v.target.value}),placeholder:"your-codebuddy-email@example.com"}),e.jsx(ce,{label:"Name",value:g.name,onChange:v=>_({...g,name:v.target.value}),placeholder:U?"Ollama Local":"Production Key"}),U&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{label:"Ollama Host URL",value:g.ollamaHostUrl,onChange:v=>_({...g,ollamaHostUrl:v.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),e.jsx("div",{className:"pt-6",children:e.jsx(N,{onClick:we,disabled:ie||Q,variant:"secondary",children:ie?"Checking...":"Check"})})]}),!U&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{label:X,type:F?"text":"password",value:g.apiKey,onChange:v=>_({...g,apiKey:v.target.value}),placeholder:E,className:"flex-1"}),e.jsx("div",{className:"pt-6",children:e.jsx(N,{onClick:we,disabled:!g.apiKey||ie||Q,variant:"secondary",children:ie?"Checking...":"Check"})})]}),J&&e.jsx("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),F&&f&&e.jsxs("p",{className:"text-xs text-text-muted",children:[f,h&&e.jsxs(e.Fragment,{children:[" ",e.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",h.replace(/^https?:\/\//,"")]})]})]}),O&&e.jsx(yt,{label:"Region",value:B,onChange:v=>te(v.target.value),options:O.map(v=>({value:v.id,label:v.label}))}),d&&e.jsx(ce,{label:"Default Model",value:g.defaultModel,onChange:v=>_({...g,defaultModel:v.target.value}),placeholder:x?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),U&&e.jsxs("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",e.jsx("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",e.jsx("code",{children:"http://192.168.1.10:11434"}),")."]}),se&&e.jsx(Ue,{variant:se==="success"?"success":"error",children:se==="success"?"Valid":"Invalid"}),b&&e.jsx("p",{className:"text-xs text-red-500 break-words",children:b}),d&&e.jsx("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),A&&e.jsxs("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[e.jsx("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),e.jsx(ce,{label:"Account ID",value:y.accountId,onChange:v=>$({...y,accountId:v.target.value}),placeholder:"abc123def456..."}),e.jsxs("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",e.jsx("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),Z&&e.jsxs("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[e.jsx("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ce,{label:"Azure Endpoint",value:z.azureEndpoint,onChange:v=>ee({...z,azureEndpoint:v.target.value}),placeholder:"https://your-resource.openai.azure.com"}),e.jsx(ce,{label:"Deployment Name",value:z.deployment,onChange:v=>ee({...z,deployment:v.target.value}),placeholder:"gpt-4"}),e.jsx(ce,{label:"API Version",value:z.apiVersion,onChange:v=>ee({...z,apiVersion:v.target.value}),placeholder:"2024-10-01-preview"}),e.jsx(ce,{label:"Organization",value:z.organization,onChange:v=>ee({...z,organization:v.target.value}),placeholder:"Organization ID"})]})]}),e.jsx(ce,{label:"Priority",type:"number",value:g.priority,onChange:v=>_({...g,priority:Number.parseInt(v.target.value)||1})}),e.jsx(yt,{label:"Proxy Pool",value:g.proxyPoolId,onChange:v=>_({...g,proxyPoolId:v.target.value}),options:[{value:L,label:"None"},...(o||[]).map(v=>({value:v.id,label:v.name}))],placeholder:"None"}),(o||[]).length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"No active proxy pools available. Create one in Proxy Pools page first."}),e.jsx("p",{className:"text-xs text-text-muted",children:"Legacy manual proxy fields are still accepted by API for backward compatibility."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{onClick:Ae,fullWidth:!0,disabled:Q||!U&&(!g.name||!g.apiKey)||d&&!g.defaultModel.trim()||Z&&(!z.azureEndpoint||!z.deployment||!z.organization)||A&&!y.accountId,children:Q?"Saving...":"Save"}),e.jsx(N,{onClick:R,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}ns.propTypes={isOpen:l.bool.isRequired,provider:l.string,providerName:l.string,isCompatible:l.bool,isAnthropic:l.bool,authType:l.string,authHint:l.string,website:l.string,proxyPools:l.arrayOf(l.shape({id:l.string,name:l.string})),error:l.string,onSave:l.func.isRequired,onBulkDone:l.func,onClose:l.func.isRequired};function os({isOpen:n,node:c,onSave:a,onClose:d,isAnthropic:x}){const[u,f]=i.useState({name:"",prefix:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[h,o]=i.useState(!1),[b,S]=i.useState(""),[C,R]=i.useState(""),[L,U]=i.useState(!1),[F,J]=i.useState(null);i.useEffect(()=>{c&&f({name:c.name||"",prefix:c.prefix||"",apiType:c.apiType||"chat",baseUrl:c.baseUrl||(x?"https://api.anthropic.com/v1":"https://api.openai.com/v1")})},[c,x]);const X=[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],E=async()=>{if(!(!u.name.trim()||!u.prefix.trim()||!u.baseUrl.trim())){o(!0);try{const A={name:u.name,prefix:u.prefix,baseUrl:u.baseUrl};x||(A.apiType=u.apiType),await a(A)}finally{o(!1)}}},Z=async()=>{U(!0);try{const O=await(await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:u.baseUrl,apiKey:b,type:x?"anthropic-compatible":"openai-compatible",modelId:C.trim()||void 0})})).json();J(O.valid?"success":"failed")}catch{J("failed")}finally{U(!1)}};return c?e.jsx(tt,{isOpen:n,title:`Edit ${x?"Anthropic":"OpenAI"} Compatible`,onClose:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ce,{label:"Name",value:u.name,onChange:A=>f({...u,name:A.target.value}),placeholder:`${x?"Anthropic":"OpenAI"} Compatible (Prod)`,hint:"Required. A friendly label for this node."}),e.jsx(ce,{label:"Prefix",value:u.prefix,onChange:A=>f({...u,prefix:A.target.value}),placeholder:x?"ac-prod":"oc-prod",hint:"Required. Used as the provider prefix for model IDs."}),!x&&e.jsx(yt,{label:"API Type",options:X,value:u.apiType,onChange:A=>f({...u,apiType:A.target.value})}),e.jsx(ce,{label:"Base URL",value:u.baseUrl,onChange:A=>f({...u,baseUrl:A.target.value}),placeholder:x?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Use the base URL (ending in /v1) for your ${x?"Anthropic":"OpenAI"}-compatible API.`}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{label:"API Key (for Check)",type:"password",value:b,onChange:A=>S(A.target.value),className:"flex-1"}),e.jsx("div",{className:"pt-6",children:e.jsx(N,{onClick:Z,disabled:!b||L||!u.baseUrl.trim(),variant:"secondary",children:L?"Checking...":"Check"})})]}),e.jsx(ce,{label:"Model ID (optional)",value:C,onChange:A=>R(A.target.value),placeholder:"e.g. my-model-id",hint:"If provider lacks /models endpoint, enter a model ID to validate via chat/completions instead."}),F&&e.jsx(Ue,{variant:F==="success"?"success":"error",children:F==="success"?"Valid":"Invalid"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{onClick:E,fullWidth:!0,disabled:!u.name.trim()||!u.prefix.trim()||!u.baseUrl.trim()||h,children:h?"Saving...":"Save"}),e.jsx(N,{onClick:d,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}os.propTypes={isOpen:l.bool.isRequired,node:l.shape({id:l.string,name:l.string,prefix:l.string,apiType:l.string,baseUrl:l.string}),onSave:l.func.isRequired,onClose:l.func.isRequired,isAnthropic:l.bool};const ia={llm:{label:"LLM / Chat",icon:"smart_toy",color:"text-blue-400"},image:{label:"Image Generation",icon:"brush",color:"text-purple-400"},video:{label:"Video Generation",icon:"movie",color:"text-orange-400"}};function ds({isOpen:n,providerAlias:c,providerDisplayAlias:a,allowedKinds:d,onSave:x,onClose:u}){const f=d!=null&&d.length?d:["llm"],h=f.includes("llm")?"llm":f[0],[o,b]=i.useState(""),[S,C]=i.useState(h),[R,L]=i.useState(null),[U,F]=i.useState(""),[J,X]=i.useState(!1);i.useEffect(()=>{n&&(b(""),L(null),F(""),C(h))},[n,h]);const E=P=>{const g=`${c}/`;return P.startsWith(g)?P.slice(g.length):P},Z=async()=>{const P=E(o.trim());if(P){L("testing"),F("");try{const _=await(await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${c}/${P}`})})).json();L(_.ok?"ok":"error"),F(_.error||"")}catch(g){L("error"),F(g.message)}}},A=async()=>{const P=E(o.trim());if(!(!P||J)){X(!0);try{await x(P,S)}finally{X(!1)}}},O=f.length>1;return e.jsx(tt,{isOpen:n,onClose:u,title:"Add Custom Model",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[O&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Model Type"}),e.jsx("div",{className:"flex gap-2",children:f.map(P=>{const g=ia[P]||{label:P,icon:"category",color:"text-text-muted"},_=S===P;return e.jsxs("button",{onClick:()=>C(P),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-xs font-medium transition-all ${_?"border-primary bg-primary/10 text-primary":"border-border bg-sidebar text-text-muted hover:border-primary/40 hover:text-primary"}`,children:[e.jsx("span",{className:`material-symbols-outlined text-sm ${_?"text-primary":g.color}`,children:g.icon}),g.label]},P)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:o,onChange:P=>{b(P.target.value),L(null),F("")},onKeyDown:P=>P.key==="Enter"&&Z(),placeholder:S==="image"?"e.g. leo-seedream":S==="video"?"e.g. leo-kling-3":"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),S==="llm"&&e.jsx(N,{variant:"secondary",icon:"science",loading:R==="testing",onClick:Z,disabled:!o.trim()||R==="testing",children:R==="testing"?"Testing...":"Test"})]}),e.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Will be registered as:"," ",e.jsxs("code",{className:"font-mono bg-sidebar px-1 rounded",children:[a,"/",E(o.trim())||"model-id"]})]})]}),R==="ok"&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-500",children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),R==="error"&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[e.jsx("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),e.jsx("span",{children:U||"Model not reachable"})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(N,{onClick:u,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),e.jsx(N,{onClick:A,fullWidth:!0,size:"sm",disabled:!o.trim()||J,children:J?"Adding...":"Add Model"})]})]})})}ds.propTypes={isOpen:l.bool.isRequired,providerAlias:l.string.isRequired,providerDisplayAlias:l.string.isRequired,allowedKinds:l.arrayOf(l.string),onSave:l.func.isRequired,onClose:l.func.isRequired};const na=[{pattern:/kling.*o3|kling-o3/,caps:{startFrame:!0,endFrame:!1,imageReference:!0,videoReference:!0,defaultImageReferenceStrength:"MID",durations:[5,10],defaultDuration:5,defaultResolution:"1080p",defaultAspectRatio:"16:9"},label:"Kling O3"},{pattern:/kling.*3\./,caps:{startFrame:!0,endFrame:!1,durations:[5,10,12],defaultDuration:10,defaultResolution:"720p",defaultAspectRatio:"16:9"},label:"Kling 3.x"},{pattern:/kling/,caps:{startFrame:!0,endFrame:!1,durations:[5,10],defaultDuration:5,defaultResolution:"1080p",defaultAspectRatio:"16:9"},label:"Kling 2.x"},{pattern:/seedance.*lite/,caps:{startFrame:!0,endFrame:!1,durations:[4,8],defaultDuration:4,defaultResolution:"480p",defaultAspectRatio:"16:9"},label:"Seedance Lite"},{pattern:/seedance/,caps:{startFrame:!0,endFrame:!0,durations:[4,8,10],defaultDuration:8,defaultResolution:"720p",defaultAspectRatio:"16:9"},label:"Seedance"},{pattern:/veo-3\.1|veo.*3\.1/,caps:{startFrame:!0,endFrame:!1,durations:[4,6,8],defaultDuration:8,defaultResolution:"720p",defaultAspectRatio:"16:9"},label:"Veo 3.1"},{pattern:/veo/,caps:{startFrame:!0,endFrame:!1,durations:[8],defaultDuration:8,defaultResolution:"720p",defaultAspectRatio:"16:9"},label:"Veo 3"},{pattern:/sora/,caps:{startFrame:!1,endFrame:!1,durations:[4,8,12],defaultDuration:8,defaultResolution:"720p",defaultAspectRatio:"16:9"},label:"Sora"},{pattern:/hailuo/,caps:{startFrame:!0,endFrame:!1,durations:[6,10],defaultDuration:6,defaultResolution:"768p",defaultAspectRatio:"16:9"},label:"Hailuo"},{pattern:/ltx/,caps:{startFrame:!0,endFrame:!0,durations:[6,8,10],defaultDuration:6,defaultResolution:"1080p",defaultAspectRatio:"16:9"},label:"LTX"},{pattern:/motion/,caps:{startFrame:!0,endFrame:!1,durations:[5],defaultDuration:5,defaultResolution:"720p",defaultAspectRatio:"16:9"},label:"Motion"}],oa=[{pattern:/seedream.*4\.5/,caps:{apiVersion:"v2",resolutionTiers:{SMALL:null,MEDIUM:{base:2048},LARGE:{base:4096}},defaultTier:"MEDIUM",imageReference:!0,refMethod:"guidances",maxRefs:6,strengthSupported:!0,defaultStrength:"MID",supportsStyleIds:!0},label:"Seedream 4.5"},{pattern:/seedream/,caps:{apiVersion:"v2",resolutionTiers:{SMALL:{base:1024},MEDIUM:{base:2048},LARGE:{base:4096}},defaultTier:"MEDIUM",imageReference:!0,refMethod:"guidances",maxRefs:6,strengthSupported:!0,defaultStrength:"MID",supportsStyleIds:!0},label:"Seedream"},{pattern:/flux-dev/,caps:{apiVersion:"v1",resolutionTiers:{SMALL:null,MEDIUM:null,LARGE:null},defaultTier:null,imageReference:!0,refMethod:"controlnets",maxRefs:1,strengthSupported:!0,defaultStrength:"MID",preprocessorId:233},label:"Flux Dev"},{pattern:/flux/,caps:{apiVersion:"v2",resolutionTiers:{SMALL:null,MEDIUM:{base:1024},LARGE:null},defaultTier:"MEDIUM",imageReference:!0,refMethod:"guidances",maxRefs:4,strengthSupported:!0,defaultStrength:"MID"},label:"Flux"},{pattern:/phoenix/,caps:{apiVersion:"v1",resolutionTiers:{SMALL:null,MEDIUM:null,LARGE:null},defaultTier:null,imageReference:!0,refMethod:"controlnets",maxRefs:1,strengthSupported:!0,defaultStrength:"MID",preprocessorId:364,supportsContrast:!0,supportsUltra:!0},label:"Phoenix"},{pattern:/ideogram/,caps:{apiVersion:"v2",resolutionTiers:{SMALL:null,MEDIUM:{base:1024},LARGE:null},defaultTier:"MEDIUM",qualityOptions:["TURBO","BALANCED","QUALITY"],defaultQuality:"BALANCED",imageReference:!0,refMethod:"guidances",maxRefs:6,strengthSupported:!0,defaultStrength:"MID"},label:"Ideogram"},{pattern:/gpt.image/,caps:{apiVersion:"v2",resolutionTiers:{SMALL:{base:1024},MEDIUM:{base:2048},LARGE:{base:2880}},defaultTier:"MEDIUM",qualityOptions:["LOW","MEDIUM","HIGH"],defaultQuality:"MEDIUM",imageReference:!0,refMethod:"guidances",maxRefs:6,strengthSupported:!1},label:"GPT Image"},{pattern:/recraft/,caps:{apiVersion:"v2",resolutionTiers:{SMALL:null,MEDIUM:{base:2048},LARGE:null},defaultTier:"MEDIUM",imageReference:!0,refMethod:"guidances",maxRefs:6,strengthSupported:!0,defaultStrength:"MID"},label:"Recraft"}];function da(n,c,a,d){const x=[c,a,d].filter(Boolean).join(" ").toLowerCase(),u=n==="video"?na:oa;for(const f of u)if(f.pattern.test(x))return f;return null}const ca=[4,5,6,8,10,12,15,20],ua=["Auto","480p","720p","768p","1080p","4K"],pa=["auto","16:9","9:16","1:1","4:3"],es=["SMALL","MEDIUM","LARGE"],ts={id:"",name:"",uuid:"",type:"image",apiModelName:"",quality:"",isPublic:!0,promptEnhance:"OFF",dimensions:{},capabilities:{apiVersion:"v2",resolutionTiers:{SMALL:null,MEDIUM:{base:1024},LARGE:null},defaultTier:"MEDIUM",qualityOptions:null,defaultQuality:null,imageReference:!0,refMethod:"guidances",maxRefs:6,strengthSupported:!0,defaultStrength:"MID",supportsStyleIds:!1,supportsContrast:!1,supportsUltra:!1,preprocessorId:null,startFrame:!1,endFrame:!1,videoReference:!1,defaultImageReferenceStrength:"MID",durations:[5,10],defaultDuration:5,defaultResolution:"720p",defaultAspectRatio:"16:9"}};function ma(){var Y,Re;const[n,c]=i.useState("models"),[a,d]=i.useState(null),[x,u]=i.useState(!0),[f,h]=i.useState(!1),[o,b]=i.useState(null),[S,C]=i.useState("all"),[R,L]=i.useState(""),[U,F]=i.useState(null),[J,X]=i.useState(!1),[E,Z]=i.useState(JSON.parse(JSON.stringify(ts))),[A,O]=i.useState(!1),[P,g]=i.useState([]),[_,z]=i.useState("leonardo"),[ee,y]=i.useState(""),[$,B]=i.useState(""),[te,ie]=i.useState(!1),[ne,se]=i.useState(""),K=(s,m)=>{b({type:s,text:m}),setTimeout(()=>b(null),4e3)},Q=async()=>{try{const m=await(await fetch("/api/automation/leonardo")).json();m.ok&&d(m.config)}catch(s){K("error","Gagal memuat config: "+s.message)}finally{u(!1)}},oe=async()=>{try{const s=await fetch("/api/providers"),m=await s.json();s.ok&&g(m.connections||[])}catch(s){console.error(s)}};i.useEffect(()=>{Q(),oe()},[]),i.useEffect(()=>{if(A||!E.id)return;const s=da(E.type,E.id,E.name,E.apiModelName);s&&Z(m=>({...m,capabilities:{...m.capabilities,...s.caps}}))},[E.id,E.name,E.apiModelName,E.type,A]);const ue=async(s,m={})=>(await fetch("/api/automation/leonardo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:s,...m})})).json(),fe=async()=>{h(!0);try{const s=await ue("import-defaults");s.ok?(K("success",`✓ ${s.added} model diimport (${s.imageAdded} image, ${s.videoAdded} video)`),await Q()):K("error",s.error)}finally{h(!1)}},W=async()=>{if(confirm("Hapus SEMUA model dari config? Tindakan ini tidak bisa di-undo.")){h(!0);try{const s=await ue("delete-all-models");s.ok?(K("success",`${s.deleted} model dihapus`),await Q()):K("error",s.error)}finally{h(!1)}}},be=async s=>{if(!confirm(`Hapus model "${s}"?`))return;const m=await ue("delete-model",{id:s});m.ok?(K("success",`Model "${s}" dihapus`),await Q()):K("error",m.error)},ke=async()=>{var m,k;const s={...E};if(!((m=s.id)!=null&&m.trim())||!((k=s.name)!=null&&k.trim()))return K("error","Model ID dan Name wajib diisi");s.id.startsWith("leo-")||(s.id=`leo-${s.id}`),h(!0);try{const G=await ue("add-model",{model:s});G.ok?(K("success",`Model "${s.id}" berhasil ditambahkan`),Z(JSON.parse(JSON.stringify(ts))),O(!1),X(!1),await Q()):K("error",G.error)}finally{h(!1)}},ye=async(s,m)=>{const k=await ue("update-model",{id:s,model:m});k.ok?(K("success","Model diperbarui"),F(null),await Q()):K("error",k.error)},pe=async()=>{h(!0);try{const{failThreshold:s,coolingMinutes:m,autoDisableThreshold:k,imageTimeoutMs:G,videoTimeoutMs:xe}=a,q=await ue("save-settings",{failThreshold:s,coolingMinutes:m,autoDisableThreshold:k,imageTimeoutMs:G,videoTimeoutMs:xe});q.ok?K("success","Settings disimpan"):K("error",q.error)}finally{h(!1)}},we=async s=>{if(s.preventDefault(),!ee.trim()||!$.trim())return alert("Label dan Cookie wajib diisi");ie(!0);try{const m=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:_,apiKey:$.trim(),name:ee.trim(),email:ee.trim(),priority:1})}),k=await m.json();m.ok?(y(""),B(""),se("Cookie ditambahkan!"),await oe(),setTimeout(()=>se(""),3e3)):alert(k.error||"Gagal menambahkan")}finally{ie(!1)}},Ae=async s=>{confirm("Hapus connection ini?")&&(await fetch(`/api/providers/${s}`,{method:"DELETE"}),await oe())},Me=async s=>{await fetch(`/api/providers/${s.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!s.isActive})}),await oe()},ge=async s=>{se("Testing...");const k=await(await fetch(`/api/providers/${s}/test`,{method:"POST"})).json();se(k.valid?"✓ Valid":`⚠ ${k.error||"Test gagal"}`),await oe(),setTimeout(()=>se(""),5e3)},me=P.filter(s=>s.provider===_),Ce=((a==null?void 0:a.models)||[]).filter(s=>!(S!=="all"&&s.type!==S||R&&![s.id,s.name,s.apiModelName].join(" ").toLowerCase().includes(R.toLowerCase()))),T=Ce.filter(s=>s.type==="image"),le=Ce.filter(s=>s.type==="video"),v=(s,m,k)=>e.jsxs("button",{onClick:()=>c(s),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${n===s?"bg-primary/15 text-primary":"text-text-muted hover:text-text-main hover:bg-surface"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:m}),k]});return x?e.jsx(Ne,{children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(ta,{})})}):e.jsx(Ne,{children:e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx("img",{src:"/providers/leonardo.png",alt:"Leonardo",className:"size-5 rounded object-contain"}),"Leonardo Admin"]})}),o&&e.jsxs("div",{className:`px-4 py-2.5 rounded-lg text-sm font-medium flex items-center gap-2 ${o.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:o.type==="success"?"check_circle":"cancel"}),o.text]}),e.jsxs("div",{className:"flex items-center gap-2",children:[v("models","category",`Models (${((Y=a==null?void 0:a.models)==null?void 0:Y.length)||0})`),v("cookies","cookie",`Cookies (${me.length})`),v("config","tune","Settings")]}),n==="models"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ne,{padding:"sm",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"text",placeholder:"Search models...",value:R,onChange:s=>L(s.target.value),className:"flex-1 min-w-[180px] text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),e.jsxs("select",{value:S,onChange:s=>C(s.target.value),className:"text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"all",children:"All Types"}),e.jsx("option",{value:"image",children:"Image"}),e.jsx("option",{value:"video",children:"Video"})]}),e.jsx(N,{size:"sm",variant:"secondary",icon:"download",onClick:fe,disabled:f,children:"Import Defaults"}),e.jsx(N,{size:"sm",variant:"primary",icon:"add",onClick:()=>{X(s=>!s),O(!1)},children:"Add Model"}),e.jsx(N,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:W,disabled:f,children:"Delete All"})]})}),J&&e.jsxs(Ne,{padding:"md",className:"border border-primary/30",children:[e.jsxs("h3",{className:"text-sm font-bold mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-primary",children:"add_circle"}),"Add New Model"]}),e.jsx(as,{model:E,onChange:(s,m)=>{Z(k=>s.includes(".")?ss(k,s,m):{...k,[s]:m})},onCapsTouched:()=>O(!0)}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(N,{size:"sm",variant:"ghost",onClick:()=>X(!1),children:"Cancel"}),e.jsx(N,{size:"sm",variant:"primary",onClick:ke,disabled:f,children:f?"Saving...":"+ Add Model"})]})]}),[{label:"Image Generation",icon:"brush",list:T},{label:"Video Generation",icon:"movie",list:le}].map(s=>s.list.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-sm text-text-muted",children:s.icon}),e.jsx("span",{className:"text-xs font-bold text-text-muted uppercase tracking-wider",children:s.label}),e.jsx("span",{className:"text-[10px] text-text-muted/60 bg-sidebar px-1.5 py-0.5 rounded-full",children:s.list.length}),e.jsx("div",{className:"flex-1 h-px bg-border/40"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-3",children:s.list.map(m=>{var k,G,xe,q;return e.jsxs("div",{className:"group relative rounded-xl border border-border bg-card hover:border-primary/30 transition-all p-3 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-mono text-xs font-bold text-text-main truncate",title:m.id,children:m.id}),e.jsx("p",{className:"text-[11px] text-text-muted truncate",title:m.name,children:m.name})]}),e.jsxs("div",{className:"flex gap-1 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:()=>F(JSON.parse(JSON.stringify(m))),className:"p-1 rounded-lg hover:bg-primary/10 text-text-muted hover:text-primary transition-colors",title:"Edit model",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"edit"})}),e.jsx("button",{onClick:()=>be(m.id),className:"p-1 rounded-lg hover:bg-red-500/10 text-text-muted hover:text-red-400 transition-colors",title:"Delete model",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"delete"})})]})]}),m.apiModelName&&e.jsx("p",{className:"text-[10px] font-mono bg-sidebar px-2 py-0.5 rounded text-text-muted truncate",title:m.apiModelName,children:m.apiModelName}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-auto",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${((k=m.capabilities)==null?void 0:k.apiVersion)==="v1"?"bg-orange-500/10 text-orange-400":"bg-blue-500/10 text-blue-400"}`,children:m.type==="image"?((G=m.capabilities)==null?void 0:G.apiVersion)||"v2":"video"}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${m.isPublic?"bg-green-500/10 text-green-400":"bg-gray-500/10 text-gray-400"}`,children:m.isPublic?"public":"hidden"}),e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-sidebar text-text-muted",children:["✨ ",m.promptEnhance||"OFF"]}),m.type==="video"&&((xe=m.capabilities)==null?void 0:xe.durations)&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-sidebar text-text-muted",children:[m.capabilities.durations.join("/"),"s"]}),m.type==="video"&&((q=m.capabilities)==null?void 0:q.defaultResolution)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-sidebar text-text-muted",children:m.capabilities.defaultResolution})]})]},m.id)})})]},s.label)),Ce.length===0&&e.jsx("div",{className:"rounded-xl border border-border bg-card p-8",children:e.jsx("p",{className:"text-center text-text-muted text-sm",children:((Re=a==null?void 0:a.models)==null?void 0:Re.length)===0?'Belum ada model. Klik "Import Defaults" untuk mengisi dari providerModels.js.':"Tidak ada model yang cocok dengan filter."})})]}),n==="cookies"&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-5",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Ne,{padding:"md",className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"filter_list"}),"Filter Provider"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:`/providers/${_}.png`,alt:_,className:"size-5 rounded object-contain",onError:s=>{s.target.style.display="none"}}),e.jsxs("select",{value:_,onChange:s=>z(s.target.value),className:"flex-1 text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"leonardo",children:"Leonardo AI"}),e.jsx("option",{value:"grok-web",children:"Grok Web"}),e.jsx("option",{value:"perplexity-web",children:"Perplexity Web"})]})]}),e.jsxs("p",{className:"text-xs text-text-muted",children:[me.length," connections untuk ",_]})]}),e.jsxs(Ne,{padding:"md",className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_circle"}),"Add Cookie"]}),e.jsxs("form",{onSubmit:we,className:"space-y-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted block mb-1",children:"Label / Email"}),e.jsx("input",{type:"text",placeholder:"account@gmail.com",value:ee,onChange:s=>y(s.target.value),className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-text-muted block mb-1",children:"Cookie Value"}),e.jsx("textarea",{placeholder:"Paste cookie string...",value:$,onChange:s=>B(s.target.value),rows:4,className:"w-full text-xs font-mono px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary resize-y",required:!0})]}),e.jsx(N,{type:"submit",variant:"primary",size:"sm",fullWidth:!0,disabled:te,children:te?"Adding...":"Add Cookie Connection"})]}),ne&&e.jsx("p",{className:"text-xs text-primary italic",children:ne})]})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(Ne,{padding:"md",className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-bold flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"list_alt"}),"Cookie Pool — ",_]}),e.jsx("div",{className:"border border-border rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-sidebar text-text-muted border-b border-border font-semibold",children:[e.jsx("th",{className:"px-3 py-2.5",children:"Label"}),e.jsx("th",{className:"px-3 py-2.5",children:"Status"}),e.jsx("th",{className:"px-3 py-2.5",children:"Balance"}),e.jsx("th",{className:"px-3 py-2.5",children:"Fails"}),e.jsx("th",{className:"px-3 py-2.5",children:"Active"}),e.jsx("th",{className:"px-3 py-2.5 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:me.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-text-muted",children:"Tidak ada cookie untuk provider ini"})}):me.map(s=>{var m;return e.jsxs("tr",{className:"border-b border-border hover:bg-surface/50 transition-colors",children:[e.jsxs("td",{className:"px-3 py-2.5",children:[e.jsx("div",{className:"font-semibold text-text-main",children:s.name||s.email||"—"}),e.jsxs("div",{className:"text-[10px] text-text-muted font-mono",children:[(m=s.id)==null?void 0:m.slice(0,8),"..."]})]}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx(Ue,{variant:s.testStatus==="active"||s.testStatus==="ok"?"success":s.testStatus==="error"?"danger":"secondary",children:s.testStatus||"unknown"})}),e.jsx("td",{className:"px-3 py-2.5 text-text-main font-semibold",children:s.last_balance!==void 0&&s.last_balance!==null?`${s.last_balance} tok`:"—"}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:s.fail_count>0?"text-red-400":"text-text-muted",children:s.fail_count||0})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx(st,{checked:s.isActive,onChange:()=>Me(s)})}),e.jsx("td",{className:"px-3 py-2.5 text-right",children:e.jsxs("div",{className:"flex gap-1.5 justify-end",children:[e.jsx(N,{size:"xs",variant:"secondary",onClick:()=>ge(s.id),children:"Test"}),e.jsx(N,{size:"xs",variant:"danger",onClick:()=>Ae(s.id),children:"Del"})]})})]},s.id)})})]})})]})})]}),n==="config"&&a&&e.jsxs(Ne,{padding:"md",className:"space-y-4 max-w-xl",children:[e.jsx("h3",{className:"text-sm font-bold",children:"Global Settings"}),[{key:"failThreshold",label:"Fail Threshold",help:"Berapa kali gagal sebelum masuk cooling"},{key:"coolingMinutes",label:"Cooling (menit)",help:"Durasi cooling period setelah fail threshold"},{key:"autoDisableThreshold",label:"Auto-disable Threshold",help:"Total failures sebelum cookie dinonaktifkan"},{key:"imageTimeoutMs",label:"Image Timeout (ms)",help:"Timeout generasi image"},{key:"videoTimeoutMs",label:"Video Timeout (ms)",help:"Timeout generasi video"}].map(({key:s,label:m,help:k})=>e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold block mb-1",children:m}),e.jsx("input",{type:"number",value:a[s]||0,onChange:G=>d(xe=>({...xe,[s]:Number(G.target.value)})),className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),e.jsx("p",{className:"text-[11px] text-text-muted mt-0.5",children:k})]},s)),e.jsx(N,{variant:"primary",size:"sm",onClick:pe,disabled:f,children:f?"Saving...":"Save Settings"})]}),U&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/90 backdrop-blur-sm flex items-center justify-center p-4",onClick:s=>s.target===s.currentTarget&&F(null),children:e.jsxs("div",{className:"bg-background border border-border rounded-2xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-y-auto p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-bold text-base",children:["Edit Model — ",U.id]}),e.jsx("button",{onClick:()=>F(null),className:"text-text-muted hover:text-text-main",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),e.jsx(as,{model:U,onChange:(s,m)=>{F(k=>s.includes(".")?ss(k,s,m):{...k,[s]:m})},onCapsTouched:()=>{}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{size:"sm",variant:"ghost",onClick:()=>F(null),children:"Cancel"}),e.jsx(N,{size:"sm",variant:"primary",onClick:()=>ye(U.id,U),disabled:f,children:f?"Saving...":"Save Changes"})]})]})})]})})}function ss(n,c,a){const d=c.split("."),x={...n};let u=x;for(let f=0;f<d.length-1;f++)u[d[f]]={...u[d[f]]},u=u[d[f]];return u[d[d.length-1]]=a,x}function as({model:n,onChange:c,onCapsTouched:a}){const d=n.type==="video",x=n.capabilities||{},u=(o,b,S)=>e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-text-muted block mb-1",children:o}),S]},b),f=(o,b="")=>e.jsx("input",{type:"text",value:n[o]||"",placeholder:b,onChange:S=>c(o,S.target.value),className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}),h=(o,b)=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!x[o],onChange:S=>{a(),c(`capabilities.${o}`,S.target.checked)},className:"w-3.5 h-3.5 accent-primary"}),e.jsx("span",{className:"text-xs text-text-muted",children:b})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u("Model ID (tanpa prefix leo-)","id",f("id","e.g. kling-3")),u("Display Name","name",f("name","e.g. Kling 3.0")),u("UUID (kosong untuk native v2)","uuid",f("uuid","xxxxxxxx-xxxx-xxxx...")),u("API Model Name","apiModelName",f("apiModelName","e.g. kling-3.0"))]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[u("Type","type",e.jsxs("select",{value:n.type||"image",onChange:o=>c("type",o.target.value),className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"image",children:"Image"}),e.jsx("option",{value:"video",children:"Video"})]})),u("Prompt Enhance","promptEnhance",e.jsxs("select",{value:n.promptEnhance||"OFF",onChange:o=>c("promptEnhance",o.target.value),className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"AUTO",children:"AUTO"}),e.jsx("option",{value:"ON",children:"ON"}),e.jsx("option",{value:"OFF",children:"OFF"})]})),u("Public","isPublic",e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(st,{checked:!!n.isPublic,onChange:o=>c("isPublic",o)}),e.jsx("span",{className:"text-xs text-text-muted",children:n.isPublic?"Visible to users":"Hidden"})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-[11px] font-bold text-text-muted uppercase tracking-wider",children:d?"Video Capabilities":"Image Capabilities"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),d?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u("Default Resolution","capabilities.defaultResolution",e.jsx("select",{value:x.defaultResolution||"720p",onChange:o=>{a(),c("capabilities.defaultResolution",o.target.value)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:ua.map(o=>e.jsx("option",{children:o},o))})),u("Default Aspect Ratio","capabilities.defaultAspectRatio",e.jsx("select",{value:x.defaultAspectRatio||"16:9",onChange:o=>{a(),c("capabilities.defaultAspectRatio",o.target.value)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:pa.map(o=>e.jsx("option",{children:o},o))}))]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-text-muted block mb-2",children:"Supported Durations (seconds)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ca.map(o=>e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:(x.durations||[]).includes(o),onChange:b=>{a();const S=x.durations||[],C=b.target.checked?[...S,o].sort((R,L)=>R-L):S.filter(R=>R!==o);c("capabilities.durations",C),C.includes(x.defaultDuration)||c("capabilities.defaultDuration",C[0])},className:"w-3.5 h-3.5 accent-primary"}),e.jsxs("span",{className:"text-xs",children:[o,"s"]})]},o))})]}),(x.durations||[]).length>0&&u("Default Duration","capabilities.defaultDuration",e.jsx("select",{value:x.defaultDuration||"",onChange:o=>{a(),c("capabilities.defaultDuration",Number(o.target.value))},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:(x.durations||[]).map(o=>e.jsxs("option",{value:o,children:[o,"s"]},o))})),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 mt-1",children:[h("startFrame","Start Frame (first image)"),h("endFrame","End Frame (last image)"),h("imageReference","Image Reference (img2vid)"),h("videoReference","Video Reference")]}),x.imageReference&&u("Image Reference Strength","capabilities.defaultImageReferenceStrength",e.jsx("select",{value:x.defaultImageReferenceStrength||"MID",onChange:o=>{a(),c("capabilities.defaultImageReferenceStrength",o.target.value)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:["LOW","MID","HIGH"].map(o=>e.jsx("option",{children:o},o))}))]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u("API Version","capabilities.apiVersion",e.jsxs("select",{value:x.apiVersion||"v2",onChange:o=>{a(),c("capabilities.apiVersion",o.target.value)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"v2",children:"v2 (native)"}),e.jsx("option",{value:"v1",children:"v1 (legacy UUID)"})]})),u("Ref Method","capabilities.refMethod",e.jsxs("select",{value:x.refMethod||"guidances",onChange:o=>{a(),c("capabilities.refMethod",o.target.value)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"guidances",children:"guidances (v2)"}),e.jsx("option",{value:"controlnets",children:"controlnets (v1)"})]}))]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-text-muted block mb-2",children:"Resolution Tiers"}),e.jsx("div",{className:"space-y-2",children:es.map(o=>{var C;const b=(C=x.resolutionTiers)==null?void 0:C[o],S=!!b;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-1.5 w-20 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:R=>{a();const L=x.resolutionTiers||{};c("capabilities.resolutionTiers",{...L,[o]:R.target.checked?{base:1024}:null})},className:"w-3.5 h-3.5 accent-primary"}),e.jsx("span",{className:"text-xs font-semibold",children:o})]}),S&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11px] text-text-muted",children:"base px:"}),e.jsx("input",{type:"number",value:(b==null?void 0:b.base)||1024,step:256,onChange:R=>{a();const L=x.resolutionTiers||{};c("capabilities.resolutionTiers",{...L,[o]:{base:Number(R.target.value)}})},className:"w-24 text-xs px-2 py-1 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]})]},o)})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[u("Default Tier","capabilities.defaultTier",e.jsx("select",{value:x.defaultTier||"MEDIUM",onChange:o=>{a(),c("capabilities.defaultTier",o.target.value)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary",children:es.map(o=>e.jsx("option",{children:o},o))})),u("Max Refs","capabilities.maxRefs",e.jsx("input",{type:"number",min:1,max:10,value:x.maxRefs||6,onChange:o=>{a(),c("capabilities.maxRefs",Number(o.target.value))},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"}))]}),u("Quality Options (comma-separated, kosong = none)","capabilities.qualityOptions",e.jsx("input",{type:"text",value:(x.qualityOptions||[]).join(","),placeholder:"e.g. TURBO,BALANCED,QUALITY",onChange:o=>{a();const b=o.target.value?o.target.value.split(",").map(S=>S.trim()).filter(Boolean):null;c("capabilities.qualityOptions",b)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})),u("Preprocessor ID (v1 only, kosong = none)","capabilities.preprocessorId",e.jsx("input",{type:"number",value:x.preprocessorId||"",placeholder:"e.g. 364",onChange:o=>{a(),c("capabilities.preprocessorId",o.target.value?Number(o.target.value):null)},className:"w-full text-xs px-3 py-2 border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:[h("imageReference","Image Reference"),h("strengthSupported","Strength Supported"),h("supportsStyleIds","Supports Style IDs"),h("supportsContrast","Supports Contrast (v1)"),h("supportsUltra","Supports Ultra (v1)")]})]})]})}const xa=1e3;function ha(n){return new Promise(c=>setTimeout(c,n))}function ja(){var Lt,Ut,_t,Ft,Kt,zt,qt,Vt,Bt,Gt;const n=Gs(),c=Js(),a=n.id,[d,x]=i.useState([]),[u,f]=i.useState(!0),[h,o]=i.useState(null),[b,S]=i.useState([]),[C,R]=i.useState(!1),[L,U]=i.useState(!1),[F,J]=i.useState(!1),[X,E]=i.useState(""),[Z,A]=i.useState(!1),[O,P]=i.useState(!1),[g,_]=i.useState(!1),[z,ee]=i.useState(null),[y,$]=i.useState({}),[B,te]=i.useState(!1),[ie,ne]=i.useState({}),[se,K]=i.useState(""),[Q,oe]=i.useState(null),[ue,fe]=i.useState(!1),[W,be]=i.useState([]),[ke,ye]=i.useState("__none__"),[pe,we]=i.useState(!1),[Ae,Me]=i.useState(null),[ge,me]=i.useState(""),[Ce,T]=i.useState("auto"),[le,v]=i.useState([]),[Y,Re]=i.useState([]),[s,m]=i.useState([]),[k,G]=i.useState(null),[xe,q]=i.useState(!1),[$e,jt]=i.useState(!1),[Nt,at]=i.useState(!1),[lt,rt]=i.useState(null),[cs,Je]=i.useState({}),[_e,it]=i.useState(null),We=i.useRef(!1),[Be,kt]=i.useState(!1),[nt,us]=i.useState("overview"),{copied:ot,copy:dt}=_s(),wt="ag_risk_confirmed",Ct=()=>{R(!0)},ct=()=>{if(a==="antigravity"&&typeof window<"u"&&!(window.localStorage.getItem(wt)==="true")){q(!0);return}if(Fe){Ct();return}E(""),J(!0)},He=()=>{E(""),J(!0)},St=()=>{if(Fe){ct();return}He()},ps=()=>{if(typeof window<"u"&&window.localStorage.setItem(wt,"true"),q(!1),Fe){Ct();return}He()},j=h?{id:h.id,name:h.name||(h.type==="anthropic-compatible"?"Anthropic Compatible":"OpenAI Compatible"),color:h.type==="anthropic-compatible"?"#D97757":"#10A37F",textIcon:h.type==="anthropic-compatible"?"AC":"OC",apiType:h.apiType,baseUrl:h.baseUrl,type:h.type}:gt[a]||bt[a]||et[a]||Ht[a]||Fs[a],At=(j==null?void 0:j.authModes)||[],Fe=!!gt[a]||!!et[a]||At.includes("oauth"),ms=!!bt[a]||At.includes("apikey"),ut=!!((Lt=et[a])!=null&&Lt.noAuth),Le=Ks(a),pt=zs(a),Mt=qs(a),Te=Vs(a),he=Mt||Te,mt=!he&&Fe&&ms,xt=a==="xai"?"Grok Build OAuth":"OAuth",ht=a==="xai"?"xAI API Key":"API Key";(Ut=Ve[a])!=null&&Ut.thinkingConfig||Bs.extended;const ae=he?a:pt,Qe=he?(h==null?void 0:h.prefix)||a:pt,Ke=i.useCallback(async()=>{try{const t=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(ae)}`,{cache:"no-store"}),r=await t.json();t.ok&&m(r.ids||[])}catch(t){console.log("Error fetching disabled models:",t)}},[ae]),xs=async t=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:ae,ids:[t]})})).ok&&await Ke()}catch(r){console.log("Error disabling model:",r)}},hs=async t=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(ae)}&id=${encodeURIComponent(t)}`,{method:"DELETE"})).ok&&await Ke()}catch(r){console.log("Error enabling model:",r)}},fs=async t=>{t.length&&G({title:"Disable All Models",message:`Disable all ${t.length} model(s)?`,onConfirm:async()=>{G(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:ae,ids:t})})).ok&&await Ke()}catch(r){console.log("Error disabling all models:",r)}}})},gs=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(ae)}`,{method:"DELETE"})).ok&&await Ke()}catch(t){console.log("Error enabling all models:",t)}},Ye=i.useCallback(async()=>{try{const t=await fetch("/api/models/alias"),r=await t.json();t.ok&&$(r.aliases||{})}catch(t){console.log("Error fetching aliases:",t)}},[]);i.useEffect(()=>{a==="kilocode"&&fetch("/api/providers/kilo/free-models").then(t=>t.json()).then(t=>{var r;(r=t.models)!=null&&r.length&&Re(t.models)}).catch(()=>{})},[a]);const Se=i.useCallback(async()=>{try{const[t,r,p,M]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/proxy-pools?isActive=true",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),I=await t.json(),D=await r.json(),H=await p.json(),de=M.ok?await M.json():{};if(t.ok){const Ie=(I.connections||[]).filter(je=>je.provider===a);x(Ie)}p.ok&&S(H.proxyPools||[]);const ve=(de.providerStrategies||{})[a]||{};Me(ve.fallbackStrategy||null),me(ve.stickyRoundRobinLimit!=null?String(ve.stickyRoundRobinLimit):"1");const Oe=(de.providerThinking||{})[a]||{};if(T(Oe.mode||"auto"),r.ok){let Ie=(D.nodes||[]).find(je=>je.id===a)||null;if(!Ie&&he)for(let je=0;je<3;je+=1){await new Promise(qe=>setTimeout(qe,150));const ze=await fetch("/api/provider-nodes",{cache:"no-store"});if(!ze.ok)continue;if(Ie=((await ze.json()).nodes||[]).find(qe=>qe.id===a)||null,Ie)break}o(Ie)}}catch(t){console.log("Error fetching connections:",t)}finally{f(!1)}},[a,he]),bs=async t=>{try{const r=await fetch(`/api/provider-nodes/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),p=await r.json();r.ok&&(o(p.node),await Se(),P(!1))}catch(r){console.log("Error updating provider node:",r)}},Rt=async(t,r)=>{try{const p=await fetch("/api/settings",{cache:"no-store"}),I=(p.ok?await p.json():{}).providerStrategies||{},D={};t&&(D.fallbackStrategy=t),t==="round-robin"&&r!==""&&(D.stickyRoundRobinLimit=Number(r)||3);const H={...I};Object.keys(D).length===0?delete H[a]:H[a]=D,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:H})})}catch(p){console.log("Error saving provider strategy:",p)}},ys=t=>{const r=t?"round-robin":null,p=t?ge||"1":ge;t&&!ge&&me("1"),Me(r),Rt(r,p)},vs=t=>{me(t),Rt("round-robin",t)};i.useEffect(()=>{Se(),Ye(),Ke()},[Se,Ye,Ke]),i.useEffect(()=>{var r;const t=(r=gt[a]||bt[a]||et[a]||Ht[a])==null?void 0:r.modelsFetcher;t&&aa(t).then(v)},[a]);const Ge=async(t,r,p=pt)=>{const M=`${p}/${t}`;try{const I=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:M,alias:r})});if(I.ok)await Ye();else{const D=await I.json();alert(D.error||"Failed to set alias")}}catch(I){console.log("Error setting alias:",I)}},ft=async t=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(t)}`,{method:"DELETE"})).ok&&await Ye()}catch(r){console.log("Error deleting alias:",r)}},js=async()=>{if(Be)return;const t=d.find(r=>r.isActive!==!1);if(!t){alert(Ee("Please add an active Qoder connection first"));return}kt(!0);try{const r=await fetch(`/api/providers/${t.id}/models`),p=await r.json();if(!r.ok){alert(p.error||Ee("Failed to fetch models"));return}const M=p.models||[];if(M.length===0){alert(Ee("No models returned"));return}let I=0;for(const D of M){const H=D.id||D.name;if(!H)continue;const de=H.replace(/^qoder\//,""),ve=`${ae}/${de}`;if(Object.values(y).includes(ve))continue;const Oe=de;y[Oe]||(await Ge(de,Oe,ae),I+=1)}alert(I===0?Ee("All models already exist, no new models added"):Ee("Successfully added")+` ${I} `+Ee("models"))}catch(r){console.log("Error importing Qoder models:",r),alert(Ee("Error fetching models")+": "+r.message)}finally{kt(!1)}},Ns=async()=>{if($e||d.length===0)return;const t=Object.fromEntries(d.map(M=>[M.id,{state:"queued",error:null}]));We.current=!1,jt(!0),at(!1),rt(null),Je(t),it({total:d.length,completed:0,passed:0,failed:0,stopped:!1});let r=0,p=0;try{for(let M=0;M<d.length;M+=1){if(We.current){it({total:d.length,completed:M,passed:r,failed:p,stopped:!0});break}const I=d[M];rt(I.id),Je(D=>({...D,[I.id]:{state:"testing",error:null}}));try{const H=await(await fetch(`/api/providers/${I.id}/test`,{method:"POST"})).json(),de=!!H.valid;de?r+=1:p+=1,Je(ve=>({...ve,[I.id]:{state:de?"success":"failed",error:de?null:H.error||null}}))}catch(D){p+=1,Je(H=>({...H,[I.id]:{state:"failed",error:D.message||"Test failed"}}))}it({total:d.length,completed:M+1,passed:r,failed:p,stopped:!1}),M<d.length-1&&await ha(xa)}}finally{rt(null),jt(!1),at(!1),We.current=!1}},ks=()=>{$e&&(We.current=!0,at(!0))},ws=async t=>{G({title:"Delete Connection",message:"Delete this connection?",onConfirm:async()=>{G(null);try{(await fetch(`/api/providers/${t}`,{method:"DELETE"})).ok&&x(d.filter(p=>p.id!==t))}catch(r){console.log("Error deleting connection:",r)}}})},Xe=()=>{Se(),R(!1)},Cs=()=>{Se(),U(!1)},Ss=async t=>{E("");try{const r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:a,...t})});let p=null;try{p=await r.json()}catch{p=null}if(r.ok){await Se(),J(!1);return}E((p==null?void 0:p.error)||"Failed to save connection")}catch(r){console.log("Error saving connection:",r),E("Failed to save connection")}},As=async t=>{try{(await fetch(`/api/providers/${z.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok&&(await Se(),A(!1))}catch(r){console.log("Error updating connection:",r)}},Ms=async(t,r)=>{try{(await fetch(`/api/providers/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:r})})).ok&&x(M=>M.map(I=>I.id===t?{...I,isActive:r}:I))}catch(p){console.log("Error updating connection status:",p)}},Tt=async(t,r)=>{const p=[...d];[p[t],p[r]]=[p[r],p[t]],x(p);try{await Promise.all([fetch(`/api/providers/${p[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})}),fetch(`/api/providers/${p[r].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:r})})])}catch(M){console.log("Error swapping priority:",M),await Se()}},It=d.filter(t=>W.includes(t.id)),Dt=d.length>0&&W.length===d.length,Rs=t=>{be(r=>r.includes(t)?r.filter(p=>p!==t):[...r,t])},Ts=()=>{if(Dt){be([]);return}be(d.map(t=>t.id))},Is=()=>{be([]),ye("__none__")};i.useEffect(()=>{be(t=>t.filter(r=>d.some(p=>p.id===r)))},[d]),(()=>{if(It.length===0)return"";const t=new Set(It.map(r=>{var p;return((p=r.providerSpecificData)==null?void 0:p.proxyPoolId)||"__none__"}));if(t.size===1){const r=[...t][0];if(r==="__none__")return"All selected currently unbound";const p=b.find(M=>M.id===r);return`All selected currently bound to ${(p==null?void 0:p.name)||r}`}return"Selected connections have mixed proxy bindings"})();const Et=()=>{pe||_(!1)},Ot=async t=>{we(!0);try{let r=0;for(const{connectionId:p,proxyPoolId:M}of t)try{(await fetch(`/api/providers/${p}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:M})})).ok||(r+=1)}catch(I){console.log("Error applying proxy for",p,I),r+=1}r>0&&alert(`Updated with ${r} failed request(s).`),await Se(),_(!1)}finally{we(!1)}},Pt=t=>{const r=d.map(p=>({connectionId:p.id,proxyPoolId:t}));return Ot(r)},Ds=()=>{const t=b.filter(p=>p.isActive===!0);if(t.length===0){alert("No active proxy pools available.");return}const r=d.map((p,M)=>({connectionId:p.id,proxyPoolId:t[M%t.length].id}));return Ot(r)},Es=t=>W.includes(t),Os=e.jsx("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:d.map((t,r)=>e.jsx("div",{className:"flex min-w-0 items-stretch",children:e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(is,{connection:t,proxyPools:b,isOAuth:Fe,isFirst:r===0,isLast:r===d.length-1,onMoveUp:()=>Tt(r,r-1),onMoveDown:()=>Tt(r,r+1),onToggleActive:p=>Ms(t.id,p),onUpdateProxy:async p=>{try{(await fetch(`/api/providers/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({proxyPoolId:p||null})})).ok&&x(I=>I.map(D=>D.id===t.id?{...D,providerSpecificData:{...D.providerSpecificData,proxyPoolId:p||null}}:D))}catch(M){console.log("Error updating proxy:",M)}},onEdit:()=>{ee(t),A(!0)},onDelete:()=>ws(t.id),oneByOneStatus:cs[t.id]||null,isSelected:Es(t.id),onSelect:()=>Rs(t.id)})})},t.id))}),Ps=b.filter(t=>t.isActive===!0),$s=e.jsx(tt,{isOpen:g,onClose:Et,title:`Apply Proxy (${d.length} connections)`,children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("button",{onClick:Ds,disabled:pe||Ps.length===0,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"sync_alt"}),e.jsx("span",{className:"text-sm text-text-main",children:"One-to-one (rotate)"})]}),e.jsxs("button",{onClick:()=>Pt(null),disabled:pe,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"link_off"}),e.jsx("span",{className:"text-sm text-text-main",children:"None (unbind all)"})]}),b.map(t=>e.jsxs("button",{onClick:()=>Pt(t.id),disabled:pe||t.isActive!==!0,className:"flex items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/[0.04] dark:hover:bg-white/[0.04] disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("span",{className:"material-symbols-outlined text-text-muted text-[18px]",children:"lan"}),e.jsx("span",{className:"truncate text-sm text-text-main",children:t.name}),t.isActive!==!0&&e.jsx("span",{className:"text-[10px] text-text-muted",children:"(inactive)"})]},t.id))]}),pe&&e.jsx("p",{className:"text-xs text-text-muted",children:"Applying..."}),e.jsx(N,{onClick:Et,variant:"ghost",fullWidth:!0,disabled:pe,children:"Cancel"})]})}),$t=async t=>{if(!Q){oe(t);try{const p=await(await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${ae}/${t}`})})).json();ne(M=>({...M,[t]:p.ok?"ok":"error"})),K(p.ok?"":p.error||"Model not reachable")}catch{ne(r=>({...r,[t]:"error"})),K("Network error")}finally{oe(null)}}},Ls=()=>{var qe;if(he)return e.jsx(ls,{providerStorageAlias:ae,providerDisplayAlias:Qe,modelAliases:y,copied:ot,onCopy:dt,onSetAlias:Ge,onDeleteAlias:ft,connections:d,isAnthropic:Te});const t=((qe=Ve[a])==null?void 0:qe.serviceKinds)||["llm"],r=t.includes("llm"),p=[...Le,...Y.filter(w=>!Le.some(V=>V.id===w.id))].filter(w=>{const V=w.type||"llm";return r&&(!w.type||w.type==="llm")?!0:t.includes(V)}),M=new Set(s),I=p.filter(w=>!M.has(w.id)),D=p.filter(w=>M.has(w.id)),H=Object.entries(y).filter(([w,V])=>{const De=`${ae}/`;if(!V.startsWith(De))return!1;const re=V.slice(De.length);return j.passthroughModels?!Le.some(Pe=>Pe.id===re):!Le.some(Pe=>Pe.id===re)&&w===re}).map(([w,V])=>({id:V.slice(`${ae}/`.length),alias:w,fullModel:V})),de=t.length>1&&!t.every(w=>w==="llm"),ve=I.filter(w=>w.type==="image"),Oe=I.filter(w=>w.type==="video"),Ie=I.filter(w=>!w.type||w.type==="llm"),je=w=>w.map(V=>{var Wt;const De=`${ae}/${V.id}`,re=`${a}/${V.id}`,Pe=(Wt=Object.entries(y).find(([,Ze])=>Ze===De||Ze===re))==null?void 0:Wt[0];return e.jsx(vt,{model:V,fullModel:`${Qe}/${V.id}`,alias:Pe,copied:ot,onCopy:dt,onSetAlias:Ze=>Ge(V.id,Ze,ae),onDeleteAlias:()=>ft(Pe),testStatus:ie[V.id],onTest:d.length>0||ut?()=>$t(V.id):void 0,isTesting:Q===V.id,isFree:V.isFree,onDisable:()=>xs(V.id)},V.id)}),ze=({icon:w,label:V,count:De})=>e.jsxs("div",{className:"w-full flex items-center gap-2 mt-1 mb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-base text-text-muted",children:w}),e.jsx("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:V}),e.jsx("span",{className:"text-[10px] text-text-muted/60 bg-sidebar px-1.5 py-0.5 rounded-full",children:De}),e.jsx("div",{className:"flex-1 h-px bg-border/40"})]}),Jt=e.jsxs("button",{onClick:()=>fe(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]});return e.jsxs("div",{className:"flex flex-col gap-2",children:[H.length>0&&e.jsxs(e.Fragment,{children:[de&&e.jsx(ze,{icon:"star",label:"Custom",count:H.length}),e.jsx("div",{className:"flex flex-wrap gap-3",children:H.map(w=>e.jsx(vt,{model:{id:w.id},fullModel:`${Qe}/${w.id}`,alias:w.alias,copied:ot,onCopy:dt,onSetAlias:()=>{},onDeleteAlias:()=>ft(w.alias),testStatus:ie[w.id],onTest:d.length>0||ut?()=>$t(w.id):void 0,isTesting:Q===w.id,isCustom:!0,isFree:!1},w.id))})]}),de&&ve.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{icon:"brush",label:"Image Generation",count:ve.length}),e.jsx("div",{className:"flex flex-wrap gap-3",children:je(ve)})]}),de&&Oe.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ze,{icon:"movie",label:"Video Generation",count:Oe.length}),e.jsx("div",{className:"flex flex-wrap gap-3",children:je(Oe)})]}),(de?Ie:I).length>0&&e.jsx("div",{className:"flex flex-wrap gap-3",children:je(de?Ie:I)}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1",children:[Jt,a==="qoder"&&d.some(w=>w.isActive!==!1)&&e.jsxs("button",{onClick:js,disabled:Be,className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-blue-500/40 px-3 py-2 text-xs text-blue-600 dark:text-blue-400 transition-colors hover:border-blue-500 hover:bg-blue-500/5 sm:w-auto disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",style:Be?{animation:"spin 1s linear infinite"}:void 0,children:Be?"progress_activity":"download"}),Be?Ee("Fetching..."):Ee("Fetch Qoder Models")]})]}),le.length>0&&(()=>{const w=new Set(Object.values(y)),V=new Set(Le.map(re=>re.id)),De=le.filter(re=>!w.has(`${ae}/${re.id}`)&&!V.has(re.id));return De.length===0?null:e.jsxs("div",{className:"w-full mt-2",children:[e.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:De.map(re=>e.jsxs("button",{onClick:async()=>{const Pe=re.id.split("/").pop();await Ge(re.id,Pe,ae)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${re.name} · ${(re.contextLength/1e3).toFixed(0)}k ctx`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),re.id.split("/").pop()]},re.id))})]})})(),D.length>0&&e.jsxs("div",{className:"w-full mt-2",children:[e.jsxs("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",D.length,"):"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(w=>e.jsxs("button",{onClick:()=>hs(w.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),w.id]},w.id))})]})]})};if(u)return e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(Xt,{}),e.jsx(Xt,{})]});if(!j)return e.jsxs("div",{className:"text-center py-20",children:[e.jsx("p",{className:"text-text-muted",children:"Provider not found"}),e.jsx(Yt,{to:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]});const Us=()=>a==="codebuddy"||a==="cb"?"/providers/codebuddy.svg":Mt&&j.apiType?j.apiType==="responses"?"/providers/oai-r.png":"/providers/oai-cc.png":Te?"/providers/anthropic-m.png":a==="weavy"?"/providers/weavy.jpeg":`/providers/${j.id}.png`;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(Yt,{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.jsxs("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${j.color}15`},children:B?e.jsx("span",{className:"text-sm font-bold",style:{color:j.color},children:j.textIcon||j.id.slice(0,2).toUpperCase()}):e.jsx("img",{src:Us(),alt:j.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",onError:()=>te(!0)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:j.name}),(((_t=j.notice)==null?void 0:_t.apiKeyUrl)||((Ft=j.notice)==null?void 0:Ft.signupUrl)||j.website)&&e.jsxs("a",{href:((Kt=j.notice)==null?void 0:Kt.apiKeyUrl)||((zt=j.notice)==null?void 0:zt.signupUrl)||j.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),(qt=j.notice)!=null&&qt.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),e.jsxs("p",{className:"text-text-muted",children:[d.length," connection",d.length===1?"":"s"]})]})]})]}),j.deprecated&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),e.jsx("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:j.deprecationNotice})]}),((Vt=j.notice)==null?void 0:Vt.text)&&!j.deprecated&&e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),e.jsx("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:j.notice.text}),j.notice.apiKeyUrl&&e.jsx("a",{href:j.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),a==="leonardo"&&e.jsx("div",{className:"flex border-b border-border-subtle pb-px gap-6",children:[{id:"overview",icon:"dashboard",label:"Overview",useImage:!1},{id:"admin",icon:"tune",label:"Leonardo Admin",useImage:!0}].map(t=>e.jsxs("button",{onClick:()=>us(t.id),className:`flex items-center gap-2 pb-3 text-sm font-semibold transition-all border-b-2 cursor-pointer ${nt===t.id?"border-primary text-primary":"border-transparent text-text-muted hover:text-text-main"}`,children:[t.useImage?e.jsx("img",{src:"/providers/leonardo.png",alt:"Leonardo",className:"size-[18px] rounded object-contain"}):e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:t.icon}),t.label]},t.id))}),a==="leonardo"&&nt==="admin"&&e.jsx(ma,{}),a==="weavy"&&e.jsxs("div",{style:{marginBottom:16,padding:"12px 16px",background:"#0c1a2e",border:"1px solid #1e3a5f",borderRadius:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"#60a5fa"},children:"🪄 Weavy Token Pool"}),e.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:2},children:"Copy firebase_refresh_token, firebase_api_key, dan JWT untuk dipakai di sistem lain (kliperspro, dll.)"})]}),e.jsx("a",{href:"/dashboard/providers/weavy/pool",style:{padding:"7px 16px",borderRadius:6,background:"#1e3a5f",border:"1px solid #2563eb",color:"#93c5fd",fontSize:13,fontWeight:600,textDecoration:"none",whiteSpace:"nowrap"},children:"Buka Token Pool →"})]}),(a!=="leonardo"||nt==="overview")&&e.jsxs(e.Fragment,{children:[he&&h&&e.jsx(Ne,{children:e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-semibold",children:Te?"Anthropic Compatible Details":"OpenAI Compatible Details"}),e.jsxs("p",{className:"break-all text-sm text-text-muted",children:[Te?"Messages API":h.apiType==="responses"?"Responses API":"Chat Completions"," · ",(h.baseUrl||"").replace(/\/$/,""),"/",Te?"messages":h.apiType==="responses"?"responses":"chat/completions"]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[e.jsx(N,{size:"sm",icon:"add",onClick:()=>{E(""),J(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),e.jsx(N,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>P(!0),className:"w-full sm:w-auto",children:"Edit"}),e.jsx(N,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{G({title:"Delete Compatible Node",message:`Delete this ${Te?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{G(null);try{(await fetch(`/api/provider-nodes/${a}`,{method:"DELETE"})).ok&&c("/dashboard/providers")}catch(t){console.log("Error deleting provider node:",t)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),ut?e.jsx(Ws,{providerId:a}):e.jsxs(Ne,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Connections"}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[d.length>0&&b.length>0&&e.jsx(N,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>_(!0),children:"Apply Proxy"}),d.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"sm",variant:"secondary",icon:"sync",onClick:Ns,disabled:$e,children:$e?"Testing Connection One-by-One...":"Test Connection One-by-One"}),$e&&e.jsx(N,{size:"sm",variant:"ghost",icon:"stop",onClick:ks,disabled:Nt,children:Nt?"Stopping...":"Stop"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),e.jsx(st,{checked:Ae==="round-robin",onChange:ys}),Ae==="round-robin"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Sticky:"}),e.jsx("input",{type:"number",min:1,value:ge,onChange:t=>vs(t.target.value),placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),d.length===0?e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:Fe?"lock":"key"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"No connections yet"}),mt&&e.jsxs("p",{className:"text-xs text-text-muted",children:["Choose ",xt," or ",ht,"."]})]})]}),e.jsx("div",{className:"flex gap-2",children:mt?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"sm",icon:"lock",variant:"secondary",onClick:ct,children:xt}),e.jsx(N,{size:"sm",icon:"key",onClick:He,children:ht})]}):e.jsxs(e.Fragment,{children:[!he&&a==="iflow"&&e.jsx(N,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>U(!0),children:"Cookie"}),e.jsx(N,{size:"sm",icon:"add",onClick:St,children:he?"Add API Key":a==="iflow"?"OAuth":"Add Connection"})]})})]}):e.jsxs(e.Fragment,{children:[_e&&e.jsx("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("span",{children:["Total: ",_e.total]}),e.jsxs("span",{children:["Completed: ",_e.completed]}),e.jsxs("span",{children:["Passed: ",_e.passed]}),e.jsxs("span",{children:["Failed: ",_e.failed]}),_e.stopped&&e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),$e&&lt&&e.jsxs("span",{children:["Running: ",((Bt=d.find(t=>t.id===lt))==null?void 0:Bt.name)||lt]})]})}),d.length>0&&e.jsxs("div",{className:"mb-2 flex items-center justify-between rounded-lg border border-black/5 bg-black/[0.02] px-3 py-2 dark:border-white/5 dark:bg-white/[0.02]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:Dt,onChange:Ts,className:"h-4 w-4 rounded border-black/20 text-primary focus:ring-primary dark:border-white/20 dark:bg-black"}),e.jsxs("span",{className:"text-sm font-medium",children:["Select All (",W.length,"/",d.length,")"]})]}),W.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[b.length>0&&e.jsx(N,{size:"sm",variant:"secondary",icon:"lan",onClick:()=>_(!0),children:"Apply Proxy"}),e.jsx(N,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{W.length!==0&&G({title:"Delete Connections",message:`Delete ${W.length} selected connection(s)?`,onConfirm:async()=>{G(null);try{await Promise.all(W.map(t=>fetch(`/api/providers/${t}`,{method:"DELETE"}))),x(d.filter(t=>!W.includes(t.id))),Is()}catch(t){console.log("Error deleting connections:",t)}}})},children:"Delete Selected"})]})]}),Os,!he&&e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:[a==="iflow"&&e.jsx(N,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>U(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),mt?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"sm",icon:"lock",variant:"secondary",onClick:ct,className:"w-full sm:w-auto",children:xt}),e.jsx(N,{size:"sm",icon:"key",onClick:He,className:"w-full sm:w-auto",children:ht})]}):e.jsx(N,{size:"sm",icon:"add",onClick:St,className:"w-full sm:w-auto",children:"Add"})]})]})]}),e.jsxs(Ne,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Available Models"}),!he&&(()=>{var I;const t=((I=Ve[a])==null?void 0:I.serviceKinds)||["llm"],r=t.includes("llm"),M=[...Le,...Y.filter(D=>!Le.some(H=>H.id===D.id))].filter(D=>{const H=D.type||"llm";return r&&(!D.type||D.type==="llm")?!0:t.includes(H)}).map(D=>D.id).filter(D=>!s.includes(D));return e.jsxs("div",{className:"flex gap-2",children:[s.length>0&&e.jsx(N,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:gs,children:"Active All"}),M.length>0&&e.jsx(N,{size:"sm",variant:"secondary",icon:"block",onClick:()=>fs(M),children:"Disable All"})]})})()]}),!!se&&e.jsx("p",{className:"text-xs text-red-500 mb-3 break-words",children:se}),Ls()]}),$s]}),a==="kiro"?e.jsx(Hs,{isOpen:C,providerInfo:j,onSuccess:Xe,onClose:()=>R(!1)}):a==="cursor"?e.jsx(Qs,{isOpen:C,onSuccess:Xe,onClose:()=>R(!1)}):a==="gitlab"?e.jsx(Ys,{isOpen:C,providerInfo:j,onSuccess:Xe,onClose:()=>R(!1)}):e.jsx(Xs,{isOpen:C,provider:a,providerInfo:j,onSuccess:Xe,onClose:()=>R(!1)}),a==="iflow"&&e.jsx(Zs,{isOpen:L,onSuccess:Cs,onClose:()=>U(!1)}),e.jsx(ns,{isOpen:F,provider:a,providerName:j.name,isCompatible:he,isAnthropic:Te,authType:j==null?void 0:j.authType,authHint:j==null?void 0:j.authHint,website:j==null?void 0:j.website,proxyPools:b,error:X,onSave:Ss,onBulkDone:Se,onClose:()=>{E(""),J(!1)}}),e.jsx(ea,{isOpen:Z,connection:z,proxyPools:b,onSave:As,onClose:()=>A(!1)}),he&&e.jsx(os,{isOpen:O,node:h,onSave:bs,onClose:()=>P(!1),isAnthropic:Te}),!he&&e.jsx(ds,{isOpen:ue,providerAlias:ae,providerDisplayAlias:Qe,allowedKinds:((Gt=Ve[a])==null?void 0:Gt.serviceKinds)||["llm"],onSave:async(t,r)=>{const p=j!=null&&j.passthroughModels?t.split("/").pop():t;await Ge(t,p,ae),fe(!1)},onClose:()=>fe(!1)}),e.jsx(Qt,{isOpen:xe,onClose:()=>q(!1),onConfirm:ps,title:"Risk Notice",message:j==null?void 0:j.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),e.jsx(Qt,{isOpen:!!k,onClose:()=>G(null),onConfirm:k==null?void 0:k.onConfirm,title:(k==null?void 0:k.title)||"Confirm",message:k==null?void 0:k.message,variant:"danger"})]})}export{ja as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.WEEOI9Yd.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.CbdAR_EJ.js";import{C as r}from"./Loading.CYS14nGq.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};
@@ -0,0 +1 @@
1
+ import{j as e}from"./index.WEEOI9Yd.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};