mapigate 0.5.162 → 0.5.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/tools/definitions/amp/definition.js +1 -1
- package/dist/cli/tools/definitions/claude/configurator.js +1 -1
- package/dist/cli/tools/definitions/claude/definition.js +5 -2
- package/dist/cli/tools/definitions/cline/definition.js +1 -1
- package/dist/cli/tools/definitions/codewhale/definition.js +1 -1
- package/dist/cli/tools/definitions/codex/definition.js +1 -1
- package/dist/cli/tools/definitions/continue/definition.js +1 -1
- package/dist/cli/tools/definitions/copilot/definition.js +1 -1
- package/dist/cli/tools/definitions/cowork/definition.js +1 -1
- package/dist/cli/tools/definitions/crush/definition.js +1 -1
- package/dist/cli/tools/definitions/deepseek-tui/definition.js +1 -1
- package/dist/cli/tools/definitions/droid/definition.js +1 -1
- package/dist/cli/tools/definitions/forge/definition.js +1 -1
- package/dist/cli/tools/definitions/grok-build/definition.js +1 -1
- package/dist/cli/tools/definitions/hermes/definition.js +1 -1
- package/dist/cli/tools/definitions/jcode/definition.js +1 -1
- package/dist/cli/tools/definitions/kilo/definition.js +1 -1
- package/dist/cli/tools/definitions/omp/definition.js +1 -1
- package/dist/cli/tools/definitions/openclaw/definition.js +1 -1
- package/dist/cli/tools/definitions/opencode/definition.js +1 -1
- package/dist/cli/tools/definitions/pi/definition.js +1 -1
- package/dist/cli/tools/definitions/qwen/definition.js +1 -1
- package/dist/cli/tools/definitions/roo/definition.js +1 -1
- package/dist/cli/tools/definitions/smelt/definition.js +1 -1
- package/dist/core/adapters/anthropic/requestAnthropicToOpenAi.js +3 -3
- package/dist/core/adapters/anthropic/requestOpenAiToAnthropic.js +2 -2
- package/dist/core/adapters/anthropic/responseConverters.js +3 -3
- package/dist/core/adapters/anthropic/streamOpenAiToAnthropic.js +29 -29
- package/dist/core/adapters/anthropic/types.js +1 -1
- package/dist/core/adapters/anthropicAdapter.js +1 -1
- package/dist/core/adapters/helpers/index.js +1 -1
- package/dist/core/adapters/helpers/streamToolCallTracker.js +1 -0
- package/dist/core/adapters/helpers/toolCallRescue.js +1 -1
- package/dist/core/adapters/helpers/toolSchemaNormalize.js +1 -1
- package/dist/core/adapters/helpers/zeroContentCheck.js +1 -1
- package/dist/core/adapters/responsesAdapter.js +2 -2
- package/dist/core/caching/promptCacheAffinity.js +3 -3
- package/dist/core/capabilities/index.js +1 -1
- package/dist/core/capabilities/patterns.js +1 -1
- package/dist/mitm/handlers/base.js +2 -2
- package/dist/providers/catalog/cerebras/metadata.js +1 -1
- package/dist/providers/catalog/coarena/metadata.js +1 -1
- package/dist/providers/catalog/groq/metadata.js +1 -1
- package/dist/providers/catalog/iteracompute/metadata.js +1 -1
- package/dist/providers/catalog/jan/metadata.js +1 -1
- package/dist/providers/catalog/kilo-gateway/metadata.js +1 -1
- package/dist/providers/catalog/lm-studio/metadata.js +1 -1
- package/dist/providers/catalog/mistral/metadata.js +1 -1
- package/dist/providers/catalog/nvidia/metadata.js +1 -1
- package/dist/providers/catalog/ollama-local/metadata.js +1 -1
- package/dist/providers/catalog/onomeo/metadata.js +1 -1
- package/dist/providers/catalog/opencode-go/responses.js +5 -5
- package/dist/providers/catalog/opencode-zen/metadata.js +1 -1
- package/dist/providers/catalog/openrouter/metadata.js +1 -1
- package/dist/providers/catalog/sail/metadata.js +1 -1
- package/dist/providers/catalog/sambanova/metadata.js +1 -1
- package/dist/providers/runtime/antigravity/executor.js +8 -8
- package/dist/providers/runtime/antigravity/metadata.js +1 -1
- package/dist/providers/runtime/antigravity/provider.js +1 -1
- package/dist/providers/runtime/antigravity/quota.js +1 -1
- package/dist/providers/runtime/antigravity/routes.js +1 -1
- package/dist/providers/runtime/antigravity/types.js +1 -1
- package/dist/providers/runtime/antigravity/weekly.js +1 -1
- package/dist/providers/runtime/cloudflare/metadata.js +1 -1
- package/dist/providers/runtime/gemini/metadata.js +1 -1
- package/dist/providers/runtime/gemini/provider.js +1 -1
- package/dist/providers/runtime/gemini-cli/provider.js +1 -1
- package/dist/providers/runtime/gemini-cli/quota.js +1 -1
- package/dist/providers/runtime/gemini-cli/routes.js +1 -1
- package/dist/providers/runtime/kiro/constants.js +1 -0
- package/dist/providers/runtime/kiro/createResponseStream.js +4 -4
- package/dist/providers/runtime/kiro/executor.js +6 -6
- package/dist/providers/runtime/kiro/index.js +1 -1
- package/dist/providers/runtime/kiro/metadata.js +1 -1
- package/dist/providers/runtime/kiro/provider.js +1 -1
- package/dist/providers/runtime/kiro/quota.js +1 -1
- package/dist/providers/runtime/ollama/metadata.js +1 -1
- package/dist/providers/runtime/opencode/metadata.js +1 -1
- package/dist/server/index.js +3 -3
- package/dist/server/middlewares/doubledV1Middleware.js +1 -0
- package/dist/server/proxy/executorHelpers.js +1 -1
- package/dist/server/proxy/pipeline.js +5 -5
- package/dist/server/proxy/responseHandlers.js +1 -1
- package/dist/server/proxy/routeSimulator.js +1 -0
- package/dist/server/proxy/singleModelExecutor.js +5 -5
- package/dist/server/proxy/streaming/sseStreamer.js +18 -18
- package/dist/server/routes/apiCliTools.js +1 -1
- package/dist/server/routes/apiModels.js +1 -1
- package/dist/storage/repositories/settingsRepo.js +2 -2
- package/dist/storage/repositories/toolMappingRepo.js +5 -4
- package/dist/web/assets/CliToolsTab-AP4tHWEj.js +171 -0
- package/dist/web/assets/ComboDetailPage-8ZPxPl5N.js +1 -0
- package/dist/web/assets/CombosTab-D0T91znw.js +1 -0
- package/dist/web/assets/{ConfirmModal-Co5OXd_g.js → ConfirmModal-gmHKbGNe.js} +1 -1
- package/dist/web/assets/{ConsoleLogTab-BTGaJpcD.js → ConsoleLogTab-Bpvxqa2f.js} +1 -1
- package/dist/web/assets/{EditAccountModal-DLyP9VNQ.js → EditAccountModal-PEltZRS8.js} +1 -1
- package/dist/web/assets/{EndpointTab-DbjjVT7s.js → EndpointTab-CYnFpxjA.js} +1 -1
- package/dist/web/assets/MitmTab-De7zsN2f.js +14 -0
- package/dist/web/assets/ModelAutocompleteInput-BH4gr6Dr.js +1 -0
- package/dist/web/assets/ModelSelectModal-B7-jAYUU.js +1 -0
- package/dist/web/assets/{ProviderDetailPage-CeOUazix.js → ProviderDetailPage-DvqxjQHh.js} +1 -1
- package/dist/web/assets/{ProvidersTab-Dd-prffr.js → ProvidersTab-DyeFqcx4.js} +1 -1
- package/dist/web/assets/{QuotaTab-zPkj0Rwo.js → QuotaTab-DrNRwUP6.js} +1 -1
- package/dist/web/assets/{SettingsTab-DUlhyz1z.js → SettingsTab-DS6HQKrg.js} +1 -1
- package/dist/web/assets/{ToolIcon-Cp4gSgFt.js → ToolIcon-BZE0Fv7L.js} +1 -1
- package/dist/web/assets/{UsageTab-Da7c7zwV.js → UsageTab-Du6U3MIb.js} +1 -1
- package/dist/web/assets/index-9wZva5_f.css +1 -0
- package/dist/web/assets/index-BvY11iVv.js +2 -0
- package/dist/web/assets/metadataRegistry-4BIaQVmV.js +1 -0
- package/dist/web/assets/{providersData-HX0E7hDv.js → providersData-C-7jZmPi.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/CliToolsTab-iJozQAQx.js +0 -168
- package/dist/web/assets/CombosTab-DdsJ2ova.js +0 -1
- package/dist/web/assets/MitmTab-DMRg64by.js +0 -14
- package/dist/web/assets/ModelAutocompleteInput-D0L1aj3-.js +0 -1
- package/dist/web/assets/index-CtfMJ11V.js +0 -2
- package/dist/web/assets/index-DXsZmXJg.css +0 -1
- package/dist/web/assets/metadataRegistry-CGDAkFU1.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-BcOI2aZ9.js";import{S as Ne}from"./Select-BNRH8LIG.js";import{C as we}from"./ConfirmModal-Co5OXd_g.js";import{u as ee,D as m,d as te,P as ve}from"./index-CtfMJ11V.js";import"./lucide-Cc35htxl.js";const u="10.*, 172.16-31.*, 192.168.*, 169.254.*, *.local",Ce={host:te,port:m,requireApiKey:!1,proxyUrl:"",customHeaders:{},allowedHosts:u},De=({onRestartClick:K})=>{const o=ee(t=>t.info),w=ee(t=>t.fetchSystemInfo),se=!!(o!=null&&o.isRestartRequired),[r,c]=l.useState(Ce),[ae,T]=l.useState(!0),[P,H]=l.useState(!1),[L,f]=l.useState(null),[R,I]=l.useState(null),[y,g]=l.useState([]),[v,j]=l.useState([]),[le,_]=l.useState(!0),[re,ne]=l.useState(new Set),[p,U]=l.useState(null),[oe,F]=l.useState(null),[q,h]=l.useState(!1),[G,O]=l.useState(""),[$,M]=l.useState(!1),[N,b]=l.useState(null),[x,C]=l.useState(null),[J,k]=l.useState(null),[A,V]=l.useState(!1),W=l.useCallback(async()=>{try{T(!0);const[t]=await Promise.all([fetch("/api/settings/endpoint"),w()]);if(t.ok){const s=await t.json();c({host:s.host||te,port:s.port||m,requireApiKey:!!s.requireApiKey,proxyUrl:s.proxyUrl||"",customHeaders:s.customHeaders||{},allowedHosts:s.allowedHosts||u});const a=Object.entries(s.customHeaders||{}).map(([i,n],d)=>({id:`header-${d}-${Date.now()}`,key:i,value:String(n)}));g(a)}}catch(t){console.error("Failed to load endpoint settings:",t)}finally{T(!1)}},[w]),z=l.useCallback(async()=>{try{_(!0);const t=await fetch("/api/settings/endpoint/keys");if(t.ok){const s=await t.json();Array.isArray(s)&&j(s)}}catch(t){console.error("Failed to load gateway API keys:",t)}finally{_(!1)}},[]);l.useEffect(()=>{W(),z()},[W,z]);const ie=async t=>{var a,i;t&&t.preventDefault(),H(!0),f(null),I(null);const s={};for(const n of y){const d=n.key.trim();d&&(s[d]=n.value.trim())}try{const n={host:r.host,port:Number(r.port)||m,requireApiKey:r.requireApiKey,proxyUrl:((a=r.proxyUrl)==null?void 0:a.trim())||"",customHeaders:s,allowedHosts:((i=r.allowedHosts)==null?void 0:i.trim())||u},d=await fetch("/api/settings/endpoint",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!d.ok){const je=await d.json();throw new Error(je.error||"Failed to update endpoint settings")}const ye=await d.json();c(ye);const D=await w(),ge=!!(D!=null&&D.isRestartRequired);f(ge?"Configuration saved! Server restart is required to rebind the network interface.":"Settings saved successfully!"),setTimeout(()=>f(null),5e3)}catch(n){I((n==null?void 0:n.message)||"Failed to save settings")}finally{H(!1)}},ce=async t=>{t.preventDefault();try{M(!0);const s=await fetch("/api/settings/endpoint/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.trim()||void 0})});if(s.ok){const a=await s.json();j(i=>[a,...i]),b(a),O("")}else{const a=await s.json();alert(a.error||"Failed to create API key")}}catch(s){console.error("Error creating key:",s)}finally{M(!1)}},de=async t=>{try{const s=await fetch(`/api/settings/endpoint/keys/${t.id}/toggle`,{method:"PATCH"});if(s.ok){const a=await s.json();j(i=>i.map(n=>n.id===t.id?a:n))}}catch(s){console.error("Error toggling API key:",s)}},xe=async()=>{if(x)try{(await fetch(`/api/settings/endpoint/keys/${x.id}`,{method:"DELETE"})).ok&&j(s=>s.filter(a=>a.id!==x.id))}catch(t){console.error("Error deleting API key:",t)}finally{C(null)}},pe=t=>{ne(s=>{const a=new Set(s);return a.has(t)?a.delete(t):a.add(t),a})},S=(t,s)=>{navigator.clipboard.writeText(t),U(s),setTimeout(()=>U(null),2e3)},me=(t,s)=>{navigator.clipboard.writeText(t),F(s),setTimeout(()=>F(null),2e3)},ue=()=>{g([...y,{id:`header-${Date.now()}`,key:"",value:""}])},X=(t,s,a)=>{g(i=>i.map(n=>n.id===t?{...n,[s]:a}:n))},he=t=>{g(s=>s.filter(a=>a.id!==t))},Y=r.host==="0.0.0.0"?"127.0.0.1":r.host||"127.0.0.1",be=(o==null?void 0:o.port)||(typeof window<"u"&&window.location.port&&window.location.port!=="5173"?Number(window.location.port):m),E=r.port||be,Q=`http://${Y}:${E}/v1`,B=`http://${Y}:${E}`,fe=async()=>{V(!0),k(null);try{const s=await(await fetch("/health")).json();k(JSON.stringify(s,null,2))}catch{k(JSON.stringify({error:"Failed to connect to gateway"},null,2))}finally{V(!1)}},Z=t=>{if(t.length<=10)return"••••••••";const s=t.slice(0,6),a=t.slice(-4);return`${s}••••••••${a}`};return e.jsxs("div",{className:"space-y-8 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-blue-400",children:"api"}),"Local Gateway Endpoints"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Universal endpoints accepting OpenAI Chat Completions and Anthropic Messages protocols"})]}),e.jsxs("div",{className:"space-y-3.5 text-xs font-mono",children:[e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"OpenAI-Compatible Base URL (Cursor, Cline, OpenCode, Codex)"}),e.jsx("span",{className:"text-blue-400 font-bold text-sm",children:Q})]}),e.jsxs("button",{type:"button",onClick:()=>S(Q,"openai"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="openai"?"check":"content_copy"}),p==="openai"?"Copied":"Copy"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"Anthropic Base URL (Claude Code CLI: ANTHROPIC_BASE_URL)"}),e.jsx("span",{className:"text-cyan-400 font-bold text-sm",children:B})]}),e.jsxs("button",{type:"button",onClick:()=>S(B,"anthropic"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="anthropic"?"check":"content_copy"}),p==="anthropic"?"Copied":"Copy"]})]})]}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold text-slate-200 block font-sans",children:"Test Gateway Connectivity:"}),e.jsxs("button",{type:"button",onClick:fe,disabled:A,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer font-sans",children:[e.jsx("span",{className:`material-symbols-outlined text-[15px] ${A?"animate-spin":""}`,children:A?"sync":"play_arrow"}),"Execute Test Ping"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-3 rounded-xl border border-[#1E293B] text-xs font-mono text-slate-300 overflow-x-auto",children:["curl ",B,"/health"]}),J&&e.jsx("pre",{className:"bg-[#080B10] p-4 rounded-xl border border-blue-500/30 text-emerald-400 text-xs font-mono overflow-x-auto animate-rt-scale-in",children:J})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-cyan-400",children:"tune"}),"Gateway & Connection Configuration"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Configure server listening network interface, listening port, security enforcement, and global upstream proxy."})]}),L&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs font-medium flex items-center gap-1.5 animate-rt-fade-in self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),L]}),R&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-rose-500/10 border border-rose-500/30 text-rose-400 text-xs font-medium flex items-center gap-1.5 self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"error"}),R]})]}),se&&e.jsxs("div",{className:"p-4 rounded-xl bg-amber-500/10 border border-amber-500/30 flex flex-col sm:flex-row sm:items-center justify-between gap-3 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400 shrink-0",children:"restart_alt"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-amber-300",children:"Restart Required to Apply Network Configuration"}),e.jsxs("p",{className:"text-[11px] text-amber-200/70 mt-0.5",children:["Listening host is configured as ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.configuredHost}),", but the gateway socket is still bound to ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.host}),"."]})]})]}),K&&e.jsxs("button",{type:"button",onClick:K,className:"px-3.5 py-1.5 rounded-lg bg-amber-500 hover:bg-amber-400 text-slate-950 font-semibold text-xs transition-colors flex items-center gap-1.5 shrink-0 self-start sm:self-center cursor-pointer shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"restart_alt"}),"Restart Gateway Now"]})]}),ae?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading configuration..."})]}):e.jsxs("form",{onSubmit:ie,className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Listening Host Interface"}),e.jsx(Ne,{value:r.host,onChange:t=>c({...r,host:t}),options:[{value:"127.0.0.1",label:"127.0.0.1 — Localhost only (Recommended, Private)"},{value:"0.0.0.0",label:"0.0.0.0 — All Interfaces (LAN / Network Access)"},{value:"localhost",label:"localhost — Standard local loopback"}],className:"w-full"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Bind to 127.0.0.1 to isolate Mapigate to this machine, or 0.0.0.0 to expose on your local network."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Gateway Port"}),e.jsx("input",{type:"number",min:1024,max:65535,value:r.port,onChange:t=>c({...r,port:parseInt(t.target.value,10)||m}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Active server listening on port ",e.jsx("span",{className:"text-blue-400 font-mono font-semibold",children:E}),". Default port is ",m,". Change requires restarting Mapigate server."]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-2.5",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-200 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-cyan-400",children:"lan"}),"Trusted LAN Host Patterns / IP Ranges"]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Host header patterns allowed when accessing Mapigate over LAN (comma-separated)."})]}),e.jsxs("button",{type:"button",onClick:()=>c({...r,allowedHosts:u}),className:"px-2.5 py-1 rounded-lg bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-[11px] font-medium text-slate-300 hover:text-white flex items-center gap-1 transition-all cursor-pointer self-start sm:self-center shrink-0",title:"Reset to default private network ranges",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px] text-slate-400",children:"restart_alt"}),"Reset to Default"]})]}),e.jsx("input",{type:"text",placeholder:u,value:r.allowedHosts||"",onChange:t=>c({...r,allowedHosts:t.target.value}),className:"w-full bg-[#080B10] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 text-[10.5px] text-slate-500",children:[e.jsxs("span",{children:["Default: ",e.jsx("code",{className:"text-slate-400 font-mono",children:u})]}),e.jsx("span",{children:"Supports wildcards (e.g. 192.168.*, 10.*, *.local)"})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"text-xs font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400",children:"key"}),"Require API Key Authentication"]}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:["When enabled, all incoming proxy requests to ",e.jsx("code",{className:"font-mono text-slate-300",children:"/v1/*"})," must supply an Authorization header matching an active Gateway Key below."]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:r.requireApiKey,onChange:t=>c({...r,requireApiKey:t.target.checked}),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4.5 after:w-4.5 after:transition-all peer-checked:bg-blue-600"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-purple-400",children:"router"}),"Global Upstream Proxy URL (Optional)"]}),e.jsx("input",{type:"text",placeholder:"e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:1080",value:r.proxyUrl||"",onChange:t=>c({...r,proxyUrl:t.target.value}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Egress proxy used for routing outgoing requests to upstream AI model providers. Leave blank for direct connection."})]}),e.jsxs("div",{className:"space-y-2.5 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200",children:"Custom Outbound Headers"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Appended to all outgoing requests to upstream providers"})]}),e.jsxs("button",{type:"button",onClick:ue,className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium flex items-center gap-1 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Header"]})]}),y.length===0?e.jsx("div",{className:"p-3 text-center rounded-xl bg-[#0A0D14] border border-[#1E293B] text-slate-500 text-xs",children:"No custom headers configured. Click “Add Header” to add custom headers."}):e.jsx("div",{className:"space-y-2",children:y.map(t=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("input",{type:"text",placeholder:"Header Name (e.g. X-Org-ID)",value:t.key,onChange:s=>X(t.id,"key",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("span",{className:"text-slate-600 font-mono text-xs",children:":"}),e.jsx("input",{type:"text",placeholder:"Header Value",value:t.value,onChange:s=>X(t.id,"value",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("button",{type:"button",onClick:()=>he(t.id),className:"p-1 text-slate-500 hover:text-rose-400 cursor-pointer transition-colors",title:"Remove header",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},t.id))})]}),e.jsx("div",{className:"flex items-center justify-end pt-3 border-t border-[#1E293B]",children:e.jsx("button",{type:"submit",disabled:P,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:P?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving Configuration..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),"Save Configuration"]})})})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400",children:"vpn_key"}),"Client Gateway API Keys (",v.length,")"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Authentication tokens used by Claude Code CLI, Cursor, and Cline to access Mapigate gateway securely."})]}),e.jsxs("button",{type:"button",onClick:()=>{b(null),h(!0)},className:"px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 text-xs font-semibold text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Generate New Key"]})]}),le?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading API keys..."})]}):v.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center justify-center gap-2.5 bg-[#0A0D14] rounded-xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600",children:"key_off"}),e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:"No Gateway API Keys Generated"}),e.jsx("p",{className:"text-[11px] text-slate-500 max-w-sm",children:"Generate a client API key to authenticate requests from external developer tools when “Require API Key” is enabled."})]}):e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs text-slate-300 border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] text-[11px] text-slate-400 uppercase font-semibold",children:[e.jsx("th",{className:"py-3 px-3",children:"Name / Label"}),e.jsx("th",{className:"py-3 px-3",children:"API Token"}),e.jsx("th",{className:"py-3 px-3",children:"Created"}),e.jsx("th",{className:"py-3 px-3",children:"Last Used"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"Status"}),e.jsx("th",{className:"py-3 px-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]/60",children:v.map(t=>{const s=re.has(t.id),a=oe===t.id;return e.jsxs("tr",{className:"hover:bg-[#141B2D]/40 transition-colors",children:[e.jsx("td",{className:"py-3.5 px-3 font-semibold text-white",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:t.name}),t.isSystem&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-400 border border-blue-500/30 font-medium",children:"System"})]})}),e.jsx("td",{className:"py-3.5 px-3",children:e.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-lg border ${s?"bg-[#0A0D14] border-blue-500/30 text-blue-300 select-all":"bg-[#0A0D14] border-[#1E293B] text-slate-400 select-none"}`,children:s?t.key:Z(t.key)}),e.jsx("button",{type:"button",onClick:()=>pe(t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:s?"Hide token":"Reveal token",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:s?"visibility_off":"visibility"})}),e.jsx("button",{type:"button",onClick:()=>me(t.key,t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:"Copy API key",children:e.jsx("span",{className:`material-symbols-outlined text-[15px] ${a?"text-emerald-400":""}`,children:a?"check":"content_copy"})})]})}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px] font-mono",children:t.lastUsedAt?new Date(t.lastUsedAt).toLocaleString():"Never"}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:e.jsxs("label",{className:`relative inline-flex items-center ${t.isSystem?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[e.jsx("input",{type:"checkbox",checked:t.isActive,disabled:t.isSystem,onChange:()=>de(t),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-3.5 after:w-3.5 after:transition-all peer-checked:bg-emerald-500"})]})}),e.jsx("td",{className:"py-3.5 px-3 text-right",children:t.isSystem?e.jsx("span",{className:"text-[11px] text-slate-500 italic pr-2",children:"Protected"}):e.jsx("button",{type:"button",onClick:()=>C(t),className:"p-1.5 text-slate-400 hover:text-rose-400 hover:bg-rose-500/10 rounded-lg transition-colors cursor-pointer",title:"Delete API key",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})})]},t.id)})})]})})]}),q&&e.jsx(ve,{isOpen:q,onClose:()=>{h(!1),b(null)},maxWidthClass:"max-w-xl",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400",children:"vpn_key"}),"Generate Gateway API Key"]}),e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"p-1 rounded text-slate-400 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),N?e.jsxs("div",{className:"space-y-4 py-2 animate-rt-scale-in",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"check_circle"}),e.jsxs("span",{children:["API Key “",N.name,"” generated successfully!"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 block",children:"Your Gateway Secret Token:"}),e.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("span",{className:"font-mono text-xs text-white break-all flex-1 select-all",children:N.key}),e.jsxs("button",{type:"button",onClick:()=>S(N.key,"newlyCreated"),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white text-xs font-semibold flex items-center gap-1 transition-all cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="newlyCreated"?"check":"content_copy"}),p==="newlyCreated"?"Copied":"Copy"]})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"px-4 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] text-xs font-semibold text-white hover:border-slate-600 cursor-pointer",children:"Done"})})]}):e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1",children:"Key Label / Client Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Claude Code CLI, Cursor MacBook, Cline",value:G,onChange:t=>O(t.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3 py-2 text-xs text-white placeholder-slate-500 focus:outline-none",autoFocus:!0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"A friendly label to identify which coding tool is using this key."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:$,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:$?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] animate-spin",children:"progress_activity"}),"Generating..."]}):"Generate Key"})]})]})]})}),x&&e.jsx(we,{isOpen:x!==null,title:"Delete Gateway API Key",message:`Are you sure you want to permanently delete API key "${x.name}" (${Z(x.key)})? Any client tool configured with this key will no longer be authorized.`,confirmText:"Delete Key",variant:"danger",onConfirm:xe,onCancel:()=>C(null)})]})};export{De as EndpointTab};
|
|
1
|
+
import{r as l,j as e}from"./vendor-BcOI2aZ9.js";import{S as Ne}from"./Select-BNRH8LIG.js";import{C as we}from"./ConfirmModal-gmHKbGNe.js";import{u as ee,D as m,d as te,P as ve}from"./index-BvY11iVv.js";import"./lucide-Cc35htxl.js";const u="10.*, 172.16-31.*, 192.168.*, 169.254.*, *.local",Ce={host:te,port:m,requireApiKey:!1,proxyUrl:"",customHeaders:{},allowedHosts:u},De=({onRestartClick:K})=>{const o=ee(t=>t.info),w=ee(t=>t.fetchSystemInfo),se=!!(o!=null&&o.isRestartRequired),[r,c]=l.useState(Ce),[ae,T]=l.useState(!0),[P,H]=l.useState(!1),[L,f]=l.useState(null),[R,I]=l.useState(null),[y,g]=l.useState([]),[v,j]=l.useState([]),[le,_]=l.useState(!0),[re,ne]=l.useState(new Set),[p,U]=l.useState(null),[oe,F]=l.useState(null),[q,h]=l.useState(!1),[G,O]=l.useState(""),[$,M]=l.useState(!1),[N,b]=l.useState(null),[x,C]=l.useState(null),[J,k]=l.useState(null),[A,V]=l.useState(!1),W=l.useCallback(async()=>{try{T(!0);const[t]=await Promise.all([fetch("/api/settings/endpoint"),w()]);if(t.ok){const s=await t.json();c({host:s.host||te,port:s.port||m,requireApiKey:!!s.requireApiKey,proxyUrl:s.proxyUrl||"",customHeaders:s.customHeaders||{},allowedHosts:s.allowedHosts||u});const a=Object.entries(s.customHeaders||{}).map(([i,n],d)=>({id:`header-${d}-${Date.now()}`,key:i,value:String(n)}));g(a)}}catch(t){console.error("Failed to load endpoint settings:",t)}finally{T(!1)}},[w]),z=l.useCallback(async()=>{try{_(!0);const t=await fetch("/api/settings/endpoint/keys");if(t.ok){const s=await t.json();Array.isArray(s)&&j(s)}}catch(t){console.error("Failed to load gateway API keys:",t)}finally{_(!1)}},[]);l.useEffect(()=>{W(),z()},[W,z]);const ie=async t=>{var a,i;t&&t.preventDefault(),H(!0),f(null),I(null);const s={};for(const n of y){const d=n.key.trim();d&&(s[d]=n.value.trim())}try{const n={host:r.host,port:Number(r.port)||m,requireApiKey:r.requireApiKey,proxyUrl:((a=r.proxyUrl)==null?void 0:a.trim())||"",customHeaders:s,allowedHosts:((i=r.allowedHosts)==null?void 0:i.trim())||u},d=await fetch("/api/settings/endpoint",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!d.ok){const je=await d.json();throw new Error(je.error||"Failed to update endpoint settings")}const ye=await d.json();c(ye);const D=await w(),ge=!!(D!=null&&D.isRestartRequired);f(ge?"Configuration saved! Server restart is required to rebind the network interface.":"Settings saved successfully!"),setTimeout(()=>f(null),5e3)}catch(n){I((n==null?void 0:n.message)||"Failed to save settings")}finally{H(!1)}},ce=async t=>{t.preventDefault();try{M(!0);const s=await fetch("/api/settings/endpoint/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.trim()||void 0})});if(s.ok){const a=await s.json();j(i=>[a,...i]),b(a),O("")}else{const a=await s.json();alert(a.error||"Failed to create API key")}}catch(s){console.error("Error creating key:",s)}finally{M(!1)}},de=async t=>{try{const s=await fetch(`/api/settings/endpoint/keys/${t.id}/toggle`,{method:"PATCH"});if(s.ok){const a=await s.json();j(i=>i.map(n=>n.id===t.id?a:n))}}catch(s){console.error("Error toggling API key:",s)}},xe=async()=>{if(x)try{(await fetch(`/api/settings/endpoint/keys/${x.id}`,{method:"DELETE"})).ok&&j(s=>s.filter(a=>a.id!==x.id))}catch(t){console.error("Error deleting API key:",t)}finally{C(null)}},pe=t=>{ne(s=>{const a=new Set(s);return a.has(t)?a.delete(t):a.add(t),a})},S=(t,s)=>{navigator.clipboard.writeText(t),U(s),setTimeout(()=>U(null),2e3)},me=(t,s)=>{navigator.clipboard.writeText(t),F(s),setTimeout(()=>F(null),2e3)},ue=()=>{g([...y,{id:`header-${Date.now()}`,key:"",value:""}])},X=(t,s,a)=>{g(i=>i.map(n=>n.id===t?{...n,[s]:a}:n))},he=t=>{g(s=>s.filter(a=>a.id!==t))},Y=r.host==="0.0.0.0"?"127.0.0.1":r.host||"127.0.0.1",be=(o==null?void 0:o.port)||(typeof window<"u"&&window.location.port&&window.location.port!=="5173"?Number(window.location.port):m),E=r.port||be,Q=`http://${Y}:${E}/v1`,B=`http://${Y}:${E}`,fe=async()=>{V(!0),k(null);try{const s=await(await fetch("/health")).json();k(JSON.stringify(s,null,2))}catch{k(JSON.stringify({error:"Failed to connect to gateway"},null,2))}finally{V(!1)}},Z=t=>{if(t.length<=10)return"••••••••";const s=t.slice(0,6),a=t.slice(-4);return`${s}••••••••${a}`};return e.jsxs("div",{className:"space-y-8 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-blue-400",children:"api"}),"Local Gateway Endpoints"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Universal endpoints accepting OpenAI Chat Completions and Anthropic Messages protocols"})]}),e.jsxs("div",{className:"space-y-3.5 text-xs font-mono",children:[e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"OpenAI-Compatible Base URL (Cursor, Cline, OpenCode, Codex)"}),e.jsx("span",{className:"text-blue-400 font-bold text-sm",children:Q})]}),e.jsxs("button",{type:"button",onClick:()=>S(Q,"openai"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="openai"?"check":"content_copy"}),p==="openai"?"Copied":"Copy"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-4 rounded-xl border border-[#1E293B] flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-500 block text-[10px] uppercase font-sans font-semibold",children:"Anthropic Base URL (Claude Code CLI: ANTHROPIC_BASE_URL)"}),e.jsx("span",{className:"text-cyan-400 font-bold text-sm",children:B})]}),e.jsxs("button",{type:"button",onClick:()=>S(B,"anthropic"),className:"px-3.5 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-xs font-semibold text-slate-300 hover:text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="anthropic"?"check":"content_copy"}),p==="anthropic"?"Copied":"Copy"]})]})]}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold text-slate-200 block font-sans",children:"Test Gateway Connectivity:"}),e.jsxs("button",{type:"button",onClick:fe,disabled:A,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer font-sans",children:[e.jsx("span",{className:`material-symbols-outlined text-[15px] ${A?"animate-spin":""}`,children:A?"sync":"play_arrow"}),"Execute Test Ping"]})]}),e.jsxs("div",{className:"bg-[#0A0D14] p-3 rounded-xl border border-[#1E293B] text-xs font-mono text-slate-300 overflow-x-auto",children:["curl ",B,"/health"]}),J&&e.jsx("pre",{className:"bg-[#080B10] p-4 rounded-xl border border-blue-500/30 text-emerald-400 text-xs font-mono overflow-x-auto animate-rt-scale-in",children:J})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-cyan-400",children:"tune"}),"Gateway & Connection Configuration"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Configure server listening network interface, listening port, security enforcement, and global upstream proxy."})]}),L&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs font-medium flex items-center gap-1.5 animate-rt-fade-in self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),L]}),R&&e.jsxs("span",{className:"px-3 py-1 rounded-lg bg-rose-500/10 border border-rose-500/30 text-rose-400 text-xs font-medium flex items-center gap-1.5 self-start sm:self-center",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"error"}),R]})]}),se&&e.jsxs("div",{className:"p-4 rounded-xl bg-amber-500/10 border border-amber-500/30 flex flex-col sm:flex-row sm:items-center justify-between gap-3 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400 shrink-0",children:"restart_alt"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-amber-300",children:"Restart Required to Apply Network Configuration"}),e.jsxs("p",{className:"text-[11px] text-amber-200/70 mt-0.5",children:["Listening host is configured as ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.configuredHost}),", but the gateway socket is still bound to ",e.jsx("span",{className:"font-mono font-semibold text-white",children:o==null?void 0:o.host}),"."]})]})]}),K&&e.jsxs("button",{type:"button",onClick:K,className:"px-3.5 py-1.5 rounded-lg bg-amber-500 hover:bg-amber-400 text-slate-950 font-semibold text-xs transition-colors flex items-center gap-1.5 shrink-0 self-start sm:self-center cursor-pointer shadow-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"restart_alt"}),"Restart Gateway Now"]})]}),ae?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading configuration..."})]}):e.jsxs("form",{onSubmit:ie,className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Listening Host Interface"}),e.jsx(Ne,{value:r.host,onChange:t=>c({...r,host:t}),options:[{value:"127.0.0.1",label:"127.0.0.1 — Localhost only (Recommended, Private)"},{value:"0.0.0.0",label:"0.0.0.0 — All Interfaces (LAN / Network Access)"},{value:"localhost",label:"localhost — Standard local loopback"}],className:"w-full"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Bind to 127.0.0.1 to isolate Mapigate to this machine, or 0.0.0.0 to expose on your local network."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5",children:"Gateway Port"}),e.jsx("input",{type:"number",min:1024,max:65535,value:r.port,onChange:t=>c({...r,port:parseInt(t.target.value,10)||m}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("p",{className:"text-[11px] text-slate-500 mt-1",children:["Active server listening on port ",e.jsx("span",{className:"text-blue-400 font-mono font-semibold",children:E}),". Default port is ",m,". Change requires restarting Mapigate server."]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-2.5",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("label",{className:"text-xs font-semibold text-slate-200 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-cyan-400",children:"lan"}),"Trusted LAN Host Patterns / IP Ranges"]}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"Host header patterns allowed when accessing Mapigate over LAN (comma-separated)."})]}),e.jsxs("button",{type:"button",onClick:()=>c({...r,allowedHosts:u}),className:"px-2.5 py-1 rounded-lg bg-[#141B2D] border border-[#1E293B] hover:border-slate-600 text-[11px] font-medium text-slate-300 hover:text-white flex items-center gap-1 transition-all cursor-pointer self-start sm:self-center shrink-0",title:"Reset to default private network ranges",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px] text-slate-400",children:"restart_alt"}),"Reset to Default"]})]}),e.jsx("input",{type:"text",placeholder:u,value:r.allowedHosts||"",onChange:t=>c({...r,allowedHosts:t.target.value}),className:"w-full bg-[#080B10] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 text-[10.5px] text-slate-500",children:[e.jsxs("span",{children:["Default: ",e.jsx("code",{className:"text-slate-400 font-mono",children:u})]}),e.jsx("span",{children:"Supports wildcards (e.g. 192.168.*, 10.*, *.local)"})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B] flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"text-xs font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400",children:"key"}),"Require API Key Authentication"]}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:["When enabled, all incoming proxy requests to ",e.jsx("code",{className:"font-mono text-slate-300",children:"/v1/*"})," must supply an Authorization header matching an active Gateway Key below."]})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer shrink-0",children:[e.jsx("input",{type:"checkbox",checked:r.requireApiKey,onChange:t=>c({...r,requireApiKey:t.target.checked}),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4.5 after:w-4.5 after:transition-all peer-checked:bg-blue-600"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-slate-200 mb-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-purple-400",children:"router"}),"Global Upstream Proxy URL (Optional)"]}),e.jsx("input",{type:"text",placeholder:"e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:1080",value:r.proxyUrl||"",onChange:t=>c({...r,proxyUrl:t.target.value}),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3.5 py-2 text-xs font-mono text-white placeholder-slate-500 focus:outline-none transition-colors"}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Egress proxy used for routing outgoing requests to upstream AI model providers. Leave blank for direct connection."})]}),e.jsxs("div",{className:"space-y-2.5 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200",children:"Custom Outbound Headers"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Appended to all outgoing requests to upstream providers"})]}),e.jsxs("button",{type:"button",onClick:ue,className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium flex items-center gap-1 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Header"]})]}),y.length===0?e.jsx("div",{className:"p-3 text-center rounded-xl bg-[#0A0D14] border border-[#1E293B] text-slate-500 text-xs",children:"No custom headers configured. Click “Add Header” to add custom headers."}):e.jsx("div",{className:"space-y-2",children:y.map(t=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("input",{type:"text",placeholder:"Header Name (e.g. X-Org-ID)",value:t.key,onChange:s=>X(t.id,"key",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("span",{className:"text-slate-600 font-mono text-xs",children:":"}),e.jsx("input",{type:"text",placeholder:"Header Value",value:t.value,onChange:s=>X(t.id,"value",s.target.value),className:"flex-1 bg-transparent border-0 px-2 py-1 text-xs font-mono text-white placeholder-slate-600 focus:outline-none"}),e.jsx("button",{type:"button",onClick:()=>he(t.id),className:"p-1 text-slate-500 hover:text-rose-400 cursor-pointer transition-colors",title:"Remove header",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]},t.id))})]}),e.jsx("div",{className:"flex items-center justify-end pt-3 border-t border-[#1E293B]",children:e.jsx("button",{type:"submit",disabled:P,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:P?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] animate-spin",children:"progress_activity"}),"Saving Configuration..."]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),"Save Configuration"]})})})]})]}),e.jsxs("div",{className:"w-full p-6 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-amber-400",children:"vpn_key"}),"Client Gateway API Keys (",v.length,")"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Authentication tokens used by Claude Code CLI, Cursor, and Cline to access Mapigate gateway securely."})]}),e.jsxs("button",{type:"button",onClick:()=>{b(null),h(!0)},className:"px-4 py-2 rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 text-xs font-semibold text-white flex items-center gap-1.5 transition-all cursor-pointer self-start sm:self-center shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Generate New Key"]})]}),le?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-2xl text-blue-400 animate-spin",children:"progress_activity"}),e.jsx("span",{className:"text-xs",children:"Loading API keys..."})]}):v.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-400 flex flex-col items-center justify-center gap-2.5 bg-[#0A0D14] rounded-xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600",children:"key_off"}),e.jsx("p",{className:"text-xs font-semibold text-slate-300",children:"No Gateway API Keys Generated"}),e.jsx("p",{className:"text-[11px] text-slate-500 max-w-sm",children:"Generate a client API key to authenticate requests from external developer tools when “Require API Key” is enabled."})]}):e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs text-slate-300 border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] text-[11px] text-slate-400 uppercase font-semibold",children:[e.jsx("th",{className:"py-3 px-3",children:"Name / Label"}),e.jsx("th",{className:"py-3 px-3",children:"API Token"}),e.jsx("th",{className:"py-3 px-3",children:"Created"}),e.jsx("th",{className:"py-3 px-3",children:"Last Used"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"Status"}),e.jsx("th",{className:"py-3 px-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]/60",children:v.map(t=>{const s=re.has(t.id),a=oe===t.id;return e.jsxs("tr",{className:"hover:bg-[#141B2D]/40 transition-colors",children:[e.jsx("td",{className:"py-3.5 px-3 font-semibold text-white",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:t.name}),t.isSystem&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-blue-500/15 text-blue-400 border border-blue-500/30 font-medium",children:"System"})]})}),e.jsx("td",{className:"py-3.5 px-3",children:e.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-lg border ${s?"bg-[#0A0D14] border-blue-500/30 text-blue-300 select-all":"bg-[#0A0D14] border-[#1E293B] text-slate-400 select-none"}`,children:s?t.key:Z(t.key)}),e.jsx("button",{type:"button",onClick:()=>pe(t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:s?"Hide token":"Reveal token",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:s?"visibility_off":"visibility"})}),e.jsx("button",{type:"button",onClick:()=>me(t.key,t.id),className:"p-1 text-slate-400 hover:text-white transition-colors cursor-pointer",title:"Copy API key",children:e.jsx("span",{className:`material-symbols-outlined text-[15px] ${a?"text-emerald-400":""}`,children:a?"check":"content_copy"})})]})}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-3.5 px-3 text-slate-400 text-[11px] font-mono",children:t.lastUsedAt?new Date(t.lastUsedAt).toLocaleString():"Never"}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:e.jsxs("label",{className:`relative inline-flex items-center ${t.isSystem?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[e.jsx("input",{type:"checkbox",checked:t.isActive,disabled:t.isSystem,onChange:()=>de(t),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4.5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-3.5 after:w-3.5 after:transition-all peer-checked:bg-emerald-500"})]})}),e.jsx("td",{className:"py-3.5 px-3 text-right",children:t.isSystem?e.jsx("span",{className:"text-[11px] text-slate-500 italic pr-2",children:"Protected"}):e.jsx("button",{type:"button",onClick:()=>C(t),className:"p-1.5 text-slate-400 hover:text-rose-400 hover:bg-rose-500/10 rounded-lg transition-colors cursor-pointer",title:"Delete API key",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})})]},t.id)})})]})})]}),q&&e.jsx(ve,{isOpen:q,onClose:()=>{h(!1),b(null)},maxWidthClass:"max-w-xl",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400",children:"vpn_key"}),"Generate Gateway API Key"]}),e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"p-1 rounded text-slate-400 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),N?e.jsxs("div",{className:"space-y-4 py-2 animate-rt-scale-in",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-400 text-xs flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"check_circle"}),e.jsxs("span",{children:["API Key “",N.name,"” generated successfully!"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 block",children:"Your Gateway Secret Token:"}),e.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsx("span",{className:"font-mono text-xs text-white break-all flex-1 select-all",children:N.key}),e.jsxs("button",{type:"button",onClick:()=>S(N.key,"newlyCreated"),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white text-xs font-semibold flex items-center gap-1 transition-all cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:p==="newlyCreated"?"check":"content_copy"}),p==="newlyCreated"?"Copied":"Copy"]})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{type:"button",onClick:()=>{h(!1),b(null)},className:"px-4 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] text-xs font-semibold text-white hover:border-slate-600 cursor-pointer",children:"Done"})})]}):e.jsxs("form",{onSubmit:ce,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-200 mb-1",children:"Key Label / Client Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Claude Code CLI, Cursor MacBook, Cline",value:G,onChange:t=>O(t.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] focus:border-blue-500 rounded-xl px-3 py-2 text-xs text-white placeholder-slate-500 focus:outline-none",autoFocus:!0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"A friendly label to identify which coding tool is using this key."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"px-4 py-2 text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] rounded-xl transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:$,className:"px-4 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 disabled:opacity-50 transition-all flex items-center gap-1.5 cursor-pointer",children:$?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] animate-spin",children:"progress_activity"}),"Generating..."]}):"Generate Key"})]})]})]})}),x&&e.jsx(we,{isOpen:x!==null,title:"Delete Gateway API Key",message:`Are you sure you want to permanently delete API key "${x.name}" (${Z(x.key)})? Any client tool configured with this key will no longer be authorized.`,confirmText:"Delete Key",variant:"danger",onConfirm:xe,onCancel:()=>C(null)})]})};export{De as EndpointTab};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as Bt,D as Et,d as At,P as Xe,e as Dt}from"./index-BvY11iVv.js";import{M as Ze}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{r as ue}from"./metadataRegistry-4BIaQVmV.js";import{T as It}from"./ToolIcon-BZE0Fv7L.js";import"./lucide-Cc35htxl.js";const Se={},Pt=({toolId:m="kiro",value:r,onChange:u,onEnter:b,placeholder:w="Select or type source model ID...",className:v="",autoFocus:x=!1,disabled:C=!1})=>{const f=(m||"kiro").toLowerCase(),[N,c]=n.useState([]),[g,j]=n.useState(!1),[S,D]=n.useState(-1),[pe,P]=n.useState("bottom"),M=n.useRef(null),R=n.useRef(null);n.useEffect(()=>{if(g&&M.current){const l=M.current.getBoundingClientRect(),p=240,T=window.innerHeight-l.bottom,O=l.top;T<p&&O>T?P("top"):P("bottom")}},[g]),n.useEffect(()=>{let l=!0;if(Se[f]){c(Se[f]);return}return fetch(`/api/mitm/mappings/source-models/${encodeURIComponent(f)}`).then(p=>{if(!p.ok)throw new Error("Failed to load source models");return p.json()}).then(p=>{l&&Array.isArray(p)&&(Se[f]=p,c(p))}).catch(()=>{}),()=>{l=!1}},[f]),n.useEffect(()=>{const l=p=>{M.current&&!M.current.contains(p.target)&&j(!1)};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[]);const h=n.useMemo(()=>{const l=(r||"").trim().toLowerCase();return l?N.filter(p=>p.id.toLowerCase().includes(l)||p.name.toLowerCase().includes(l)):N},[N,r]);n.useEffect(()=>{D(h.length>0?0:-1)},[h]),n.useEffect(()=>{if(g&&S>=0&&R.current){const l=R.current.children[S];l&&l.scrollIntoView({block:"nearest"})}},[S,g]);const Q=l=>{u(l),j(!1)},xe=l=>{l.key==="ArrowDown"?(l.preventDefault(),g?h.length>0&&D(p=>(p+1)%h.length):j(!0)):l.key==="ArrowUp"?(l.preventDefault(),g&&h.length>0&&D(p=>(p-1+h.length)%h.length)):l.key==="Enter"?g&&S>=0&&S<h.length?(l.preventDefault(),Q(h[S].id)):b&&(l.preventDefault(),b()):l.key==="Escape"&&j(!1)};return e.jsxs("div",{ref:M,className:"relative w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{type:"text",value:r,onChange:l=>{u(l.target.value),g||j(!0)},onFocus:()=>j(!0),onKeyDown:xe,placeholder:w,disabled:C,autoFocus:x,className:v||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500 placeholder:text-slate-600"}),e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>j(l=>!l),className:"absolute right-2 text-slate-500 hover:text-slate-300 p-0.5 rounded cursor-pointer",title:"Toggle model suggestions",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:g?"arrow_drop_up":"arrow_drop_down"})})]}),g&&h.length>0&&e.jsx("div",{ref:R,className:`absolute left-0 right-0 z-50 max-h-56 overflow-y-auto rounded-xl border border-[#1E293B] bg-[#0A0D14] shadow-2xl py-1 ${pe==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:h.map((l,p)=>{const T=p===S,O=l.category==="native";return e.jsxs("div",{onClick:()=>Q(l.id),onMouseEnter:()=>D(p),className:`px-3 py-2 flex items-center justify-between text-xs cursor-pointer transition-colors ${T?"bg-blue-600/20 text-white":"text-slate-300 hover:bg-white/5"}`,children:[e.jsxs("div",{className:"flex flex-col min-w-0 pr-2",children:[e.jsx("span",{className:"font-mono font-medium text-slate-100 truncate",children:l.id}),l.name&&l.name!==l.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:l.name})]}),e.jsx("div",{className:"flex-shrink-0",children:O?e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-cyan-500/15 border border-cyan-500/30 text-[9.5px] font-mono text-cyan-300 uppercase tracking-wider font-semibold",children:[f," native"]}):e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-500/15 border border-purple-500/30 text-[9.5px] font-mono text-purple-300 uppercase tracking-wider font-semibold",children:"Standard"})})]},`${l.category}-${l.id}`)})})]})},Rt={id:"antigravity",name:"Antigravity IDE",image:"/assets/providers/antigravity/icon.png",desc:"Intercept Google Antigravity IDE requests via MITM proxy",hosts:["daily-cloudcode-pa.googleapis.com","cloudcode-pa.googleapis.com"],urlPatterns:[":generateContent",":streamGenerateContent",":fetchAvailableModels","/v1internal:fetchAvailableModels"],defaultHost:`127.0.0.1 daily-cloudcode-pa.googleapis.com
|
|
2
|
+
127.0.0.1 cloudcode-pa.googleapis.com`,hostRewrite:{"cloudcode-pa.googleapis.com":"daily-cloudcode-pa.googleapis.com"},matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com"].some(u=>r===u||r.endsWith("."+u))},isModelListRequest:m=>(m.url||"").toLowerCase().includes("fetchavailablemodels"),modelSynonyms:{"gemini-default":"gemini-3.8-flash-medium","gemini-3.5-flash-high":"gemini-3.8-flash-high","gemini-3.5-flash-medium":"gemini-3.8-flash-medium","gemini-3.5-flash-low":"gemini-3.8-flash-low","gemini-3.5-flash-extra-low":"gemini-3.8-flash-low","gemini-3.8-flash":"gemini-3.8-flash-medium","gemini-3.8-flash-high":"gemini-3.8-flash-high","gemini-3.8-flash-medium":"gemini-3.8-flash-medium","gemini-3.8-flash-low":"gemini-3.8-flash-low","gemini-3.1-pro-high":"gemini-pro-agent","gemini-3-pro-high":"gemini-pro-agent","gemini-3-pro-low":"gemini-3.1-pro-low","claude-sonnet-5-5-max":"claude-sonnet-5-5-max","claude-sonnet-5-5-high":"claude-sonnet-5-5-high","claude-sonnet-5-5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5-5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5":"claude-sonnet-5-5","claude-sonnet-5.5":"claude-sonnet-5-5","claude-sonnet-5.5-max":"claude-sonnet-5-5-max","claude-sonnet-5.5-high":"claude-sonnet-5-5-high","claude-sonnet-5.5-medium":"claude-sonnet-5-5-medium","claude-sonnet-5.5-low":"claude-sonnet-5-5-low","claude-sonnet-5-5-thinking":"claude-sonnet-5-5","claude-sonnet-5.5-thinking":"claude-sonnet-5-5","claude-opus-5-5-max":"claude-opus-5-5-max","claude-opus-5-5-high":"claude-opus-5-5-high","claude-opus-5-5-medium":"claude-opus-5-5-medium","claude-opus-5-5-low":"claude-opus-5-5-low","claude-opus-5-5":"claude-opus-5-5","claude-opus-5.5":"claude-opus-5-5","claude-opus-5.5-max":"claude-opus-5-5-max","claude-opus-5.5-high":"claude-opus-5-5-high","claude-opus-5.5-medium":"claude-opus-5-5-medium","claude-opus-5.5-low":"claude-opus-5-5-low","claude-opus-5-5-thinking":"claude-opus-5-5","claude-opus-5.5-thinking":"claude-opus-5-5","claude-sonnet-4.6":"claude-sonnet-4-6","claude-opus-4.6":"claude-opus-4-6-thinking","claude-opus-4.6-thinking":"claude-opus-4-6-thinking","gemini-4-argon":"gemini-4-argon-medium","gemini-4-argon-high":"gemini-4-argon-high","gemini-4-argon-medium":"gemini-4-argon-medium","gemini-4-argon-low":"gemini-4-argon-low","gemini-4-carbon":"gemini-4-carbon-medium","gemini-4-carbon-high":"gemini-4-carbon-high","gemini-4-carbon-medium":"gemini-4-carbon-medium","gemini-4-carbon-low":"gemini-4-carbon-low","gemini-4-hydrogen":"gemini-4-hydrogen-medium","gemini-4-hydrogen-xhigh":"gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high":"gemini-4-hydrogen-high","gemini-4-hydrogen-medium":"gemini-4-hydrogen-medium","gemini-4-hydrogen-low":"gemini-4-hydrogen-low","gemini-4-neon":"gemini-4-neon-medium","gemini-4-neon-xhigh":"gemini-4-neon-xhigh","gemini-4-neon-high":"gemini-4-neon-high","gemini-4-neon-medium":"gemini-4-neon-medium","gemini-4-neon-low":"gemini-4-neon-low"},modelPatterns:[{match:/flash.*extra.*low|extra.*low.*flash|flash.*low|low.*flash/i,alias:"gemini-3.8-flash-low"},{match:/flash.*medium|medium.*flash/i,alias:"gemini-3.8-flash-medium"},{match:/flash.*agent|agent.*flash|flash/i,alias:"gemini-3.8-flash-high"},{match:/pro.*low|low.*pro/i,alias:"gemini-3.1-pro-low"},{match:/gemini.*pro|pro.*gemini/i,alias:"gemini-pro-agent"},{match:/opus.*5[.-]5.*max|5[.-]5.*opus.*max/i,alias:"claude-opus-5-5-max"},{match:/opus.*5[.-]5.*high|5[.-]5.*opus.*high/i,alias:"claude-opus-5-5-high"},{match:/opus.*5[.-]5.*medium|5[.-]5.*opus.*medium/i,alias:"claude-opus-5-5-medium"},{match:/opus.*5[.-]5.*low|5[.-]5.*opus.*low/i,alias:"claude-opus-5-5-low"},{match:/sonnet.*5[.-]5.*max|5[.-]5.*sonnet.*max/i,alias:"claude-sonnet-5-5-max"},{match:/sonnet.*5[.-]5.*high|5[.-]5.*sonnet.*high/i,alias:"claude-sonnet-5-5-high"},{match:/sonnet.*5[.-]5.*medium|5[.-]5.*sonnet.*medium/i,alias:"claude-sonnet-5-5-medium"},{match:/sonnet.*5[.-]5.*low|5[.-]5.*sonnet.*low/i,alias:"claude-sonnet-5-5-low"},{match:/opus.*5[.-]5|5[.-]5.*opus/i,alias:"claude-opus-5-5"},{match:/sonnet.*5[.-]5|5[.-]5.*sonnet/i,alias:"claude-sonnet-5-5"},{match:/opus/i,alias:"claude-opus-4-6-thinking"},{match:/sonnet|claude/i,alias:"claude-sonnet-4-6"},{match:/gpt.*oss|oss/i,alias:"gpt-oss-120b-medium"},{match:/carbon.*high/i,alias:"gemini-4-carbon-high"},{match:/carbon.*low/i,alias:"gemini-4-carbon-low"},{match:/carbon/i,alias:"gemini-4-carbon-medium"},{match:/hydrogen.*xhigh/i,alias:"gemini-4-hydrogen-xhigh"},{match:/hydrogen.*high/i,alias:"gemini-4-hydrogen-high"},{match:/hydrogen.*low/i,alias:"gemini-4-hydrogen-low"},{match:/hydrogen/i,alias:"gemini-4-hydrogen-medium"},{match:/neon.*xhigh/i,alias:"gemini-4-neon-xhigh"},{match:/neon.*high/i,alias:"gemini-4-neon-high"},{match:/neon.*low/i,alias:"gemini-4-neon-low"},{match:/neon/i,alias:"gemini-4-neon-medium"},{match:/argon.*high|gemini.*4.*high/i,alias:"gemini-4-argon-high"},{match:/argon.*low|gemini.*4.*low/i,alias:"gemini-4-argon-low"},{match:/argon|gemini.*4/i,alias:"gemini-4-argon-medium"}],modelNoMap:[/^tab[_-]/i],defaultModels:["gemini-4-argon","gemini-4-argon-high","gemini-4-argon-medium","gemini-4-argon-low","gemini-4-carbon","gemini-4-carbon-high","gemini-4-carbon-medium","gemini-4-carbon-low","gemini-4-hydrogen","gemini-4-hydrogen-xhigh","gemini-4-hydrogen-high","gemini-4-hydrogen-medium","gemini-4-hydrogen-low","gemini-4-neon","gemini-4-neon-xhigh","gemini-4-neon-high","gemini-4-neon-medium","gemini-4-neon-low","gemini-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","claude-sonnet-5.5-thinking","claude-sonnet-5.5-high","claude-sonnet-5.5-medium","claude-sonnet-5.5-low","claude-opus-5.5-thinking","claude-opus-5.5-high","claude-opus-5.5-medium","claude-opus-5.5-low","claude-sonnet-4.6-thinking","claude-opus-4.6-thinking","gpt-oss-120b-medium"]},Lt={id:"copilot",name:"GitHub Copilot",image:"/assets/providers/github/icon.png",desc:"Intercept GitHub Copilot requests in VS Code via MITM proxy",hosts:["api.githubcopilot.com","copilot-proxy.githubusercontent.com","api.individual.githubcopilot.com","api.business.githubcopilot.com","api.enterprise.githubcopilot.com"],urlPatterns:["/chat/completions","/v1/messages","/responses","/models"],defaultHost:`127.0.0.1 api.githubcopilot.com
|
|
3
|
+
127.0.0.1 copilot-proxy.githubusercontent.com
|
|
4
|
+
127.0.0.1 api.individual.githubcopilot.com
|
|
5
|
+
127.0.0.1 api.business.githubcopilot.com
|
|
6
|
+
127.0.0.1 api.enterprise.githubcopilot.com`,matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["githubcopilot.com","copilot-proxy.githubusercontent.com"].some(u=>r===u||r.endsWith("."+u))},isModelListRequest:m=>{const r=(m.url||"").toLowerCase().split("?")[0];return r==="/models"||r==="/v1/models"||r.endsWith("/models")},defaultModels:["auto","claude-haiku-4.5","claude-haiku-5.5","claude-sonnet-4","claude-sonnet-4.6","claude-sonnet-5","claude-sonnet-5.5","claude-opus-4.8","claude-opus-5","claude-opus-5.5","claude-fable-5","claude-fable-5.1","claude-fable-5.2","copilot-search-a","copilot-search-b","gpt-3.5-turbo","gpt-4","gpt-4.1","gpt-4o","gpt-4o-mini","gpt-5-mini","gpt-5.2","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4","gpt-5.4-nano","gpt-5.6-terra","gpt-5.6-luna","gpt-5.6-sol","gpt-6-astra","gpt-6-luna","gpt-6-sol","gpt-6.1-terra","gpt-6.1-sol","mai-code-1.1-flash","mai-code-2-flash","mai-code-2","gemini-3.7-flash","gemini-3.8-flash","gemini-4-argon","grok-4.5","grok-4.6","grok-4.7","kimi-k3"]},_t={id:"kiro",name:"Kiro IDE",image:"/assets/providers/kiro/icon.png",desc:"Intercept Amazon Kiro IDE requests via MITM proxy",iconBg:"#9046ff",hosts:["management.us-east-1.kiro.dev","runtime.us-east-1.kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"],urlPatterns:["/generateAssistantResponse","/responses","/List-Available-Models","/list-available-models","/ListAvailableModels","/listavailablemodels"],defaultHost:`127.0.0.1 management.us-east-1.kiro.dev
|
|
7
|
+
127.0.0.1 runtime.us-east-1.kiro.dev
|
|
8
|
+
127.0.0.1 q.us-east-1.amazonaws.com
|
|
9
|
+
127.0.0.1 codewhisperer.us-east-1.amazonaws.com`,matchesHost:m=>{const r=(m||"").split(":")[0].trim().toLowerCase();return["kiro.dev","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com"].some(u=>r===u||r.endsWith("."+u))},isChatRequest:m=>{var b;const r=(b=m.headers)==null?void 0:b["x-amz-target"],u=Array.isArray(r)?r[0]:String(r||"");return u.includes("GenerateAssistantResponse")||u.includes("CreateResponse")},isModelListRequest:m=>{var v;const r=(m.url||"").toLowerCase(),u=r.replace(/[-_]/g,"");if(u.includes("listavailablemodels")||u.includes("listmodels")||r.includes("list-available-models")||r.includes("listavailablemodels"))return!0;const b=(v=m.headers)==null?void 0:v["x-amz-target"],w=Array.isArray(b)?b[0]:String(b||"");return w.includes("ListAvailableModels")||w.includes("ListModels")},modelSynonyms:{"auto (kiro agent)":"auto","auto-(kiro-agent)":"auto","kiro-auto":"auto","claude-sonnet-4-5":"claude-sonnet-4.5","claude-haiku-4-5":"claude-haiku-4.5","claude-sonnet-5-5":"claude-sonnet-5.5","deepseek-3-2":"deepseek-3.2","minimax-m2-5":"minimax-m2.5","minimax-m2-1":"minimax-m2.1",glm5:"glm-5","qwen-3-coder-next":"qwen3-coder-next","qwen3-coder":"qwen3-coder-next"},modelPatterns:[{match:/auto.*kiro|kiro.*auto/i,alias:"auto"},{match:/claude.*sonnet.*4[.-]5/i,alias:"claude-sonnet-4.5"},{match:/claude.*haiku.*4[.-]5/i,alias:"claude-haiku-4.5"},{match:/claude.*sonnet.*4/i,alias:"claude-sonnet-4"},{match:/claude.*sonnet.*5[.-]5/i,alias:"claude-sonnet-5.5"},{match:/claude.*sonnet.*5/i,alias:"claude-sonnet-5"},{match:/deepseek.*3[.-]2/i,alias:"deepseek-3.2"},{match:/minimax.*2[.-]5/i,alias:"minimax-m2.5"},{match:/minimax.*2[.-]1/i,alias:"minimax-m2.1"},{match:/glm.*5/i,alias:"glm-5"},{match:/sol/i,alias:"gpt-5.6-sol"},{match:/terra/i,alias:"gpt-5.6-terra"},{match:/luna/i,alias:"gpt-5.6-luna"},{match:/qwen.*3.*coder/i,alias:"qwen3-coder-next"}],defaultModels:["auto","claude-opus-5.5","claude-opus-5","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-opus-4.5","claude-sonnet-5.5","claude-sonnet-5","claude-sonnet-4.6","claude-sonnet-4.5","claude-sonnet-4","claude-haiku-5.5","claude-haiku-4.5","deepseek-3.2","minimax-m2.5","minimax-m2.1","kimi-k3","glm-5","simple-task","permission-classifier","gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","qwen3-coder-next"]},et=[Rt,Lt,_t];function Ot(m,r="source",u="asc"){return[...m].sort((b,w)=>{if(r==="target"){const f=b.targetModel||"",N=w.targetModel||"";if(!f&&N)return 1;if(f&&!N)return-1;const c=f.localeCompare(N,void 0,{numeric:!0,sensitivity:"base"});if(c!==0)return u==="asc"?c:-c}const v=b.sourceModel.toLowerCase()==="auto",x=w.sourceModel.toLowerCase()==="auto";if(v&&!x)return u==="asc"?-1:1;if(!v&&x)return u==="asc"?1:-1;const C=b.sourceModel.localeCompare(w.sourceModel,void 0,{numeric:!0,sensitivity:"base"});return u==="asc"?C:-C})}const zt=()=>{const m=Bt(t=>t.info),r=(m==null?void 0:m.port)||Et,u=(m==null?void 0:m.host)||At,[b,w]=n.useState(""),v=b||`http://${u}:${r}`,[x,C]=n.useState(!0),[f,N]=n.useState(443),[c,g]=n.useState(null),[j,S]=n.useState(""),[D,pe]=n.useState(!1),[P,M]=n.useState(!1),[R,h]=n.useState(null),[Q,xe]=n.useState(!0),[l,p]=n.useState(!1),[T,O]=n.useState(""),[he,tt]=n.useState(""),[X,st]=n.useState({windows:'certutil -addstore -user "Root" "%USERPROFILE%\\.mapigate\\mitm\\rootCA.crt"',mac:"sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.mapigate/mitm/rootCA.crt",linux:"sudo cp ~/.mapigate/mitm/rootCA.crt /usr/local/share/ca-certificates/mapigate-rootCA.crt && sudo update-ca-certificates"}),[B,ke]=n.useState(null),[Me,Te]=n.useState(!1),[Be,Ee]=n.useState(!1),[Z,k]=n.useState(null),[Ae,$]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[L,ee]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[at,nt]=n.useState(null),ot=n.useMemo(()=>[...et].sort((t,s)=>t.name.localeCompare(s.name)),[]),[De,te]=n.useState({antigravity:`127.0.0.1 daily-cloudcode-pa.googleapis.com
|
|
10
|
+
127.0.0.1 cloudcode-pa.googleapis.com`,kiro:`127.0.0.1 management.us-east-1.kiro.dev
|
|
11
|
+
127.0.0.1 runtime.us-east-1.kiro.dev
|
|
12
|
+
127.0.0.1 q.us-east-1.amazonaws.com
|
|
13
|
+
127.0.0.1 codewhisperer.us-east-1.amazonaws.com`,copilot:"127.0.0.1 api.individual.githubcopilot.com"}),[it,ge]=n.useState({}),[Ie,lt]=n.useState({}),[rt,se]=n.useState({}),[ct,U]=n.useState({antigravity:[],kiro:[],copilot:[]}),[dt,mt]=n.useState({}),[ut,Pe]=n.useState({}),[H,Re]=n.useState({}),[pt,ae]=n.useState(null),[ne,oe]=n.useState(null),[be,q]=n.useState(""),[_,F]=n.useState(null),[fe,ye]=n.useState(""),[je,Ne]=n.useState(""),[Le,xt]=n.useState(new Set),[K,_e]=n.useState(""),[z,Oe]=n.useState(""),[$e,Ue]=n.useState(!1),[He,qe]=n.useState(!1),[Fe,Ke]=n.useState(!1),[ie,we]=n.useState(null),[le,W]=n.useState(null),[re,ht]=n.useState([]),G=n.useMemo(()=>{const t=K.trim().toLowerCase();return t?!t.includes("127.0.0.1")&&!t.includes("localhost")&&!t.includes("0.0.0.0"):!1},[K]);n.useEffect(()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const s=Array.isArray(t)?t:t.combos||[];xt(new Set(s.map(o=>(o.name||"").toLowerCase())))}).catch(()=>{})},[]);const E=(t,s)=>{navigator.clipboard.writeText(s),ke(t),setTimeout(()=>ke(null),2e3)},I=()=>{fetch("/api/mitm/status").then(t=>t.json()).then(t=>{C(!!t.running),t.port&&N(t.port),xe(!!t.certExists),p(!!t.certTrusted),t.certPath&&O(t.certPath),t.fingerprint&&tt(t.fingerprint),t.routerBaseUrl&&w(t.routerBaseUrl),t.installCommands&&st(t.installCommands),t.dnsStatus&&$(s=>{var o,a,d;return{...s,antigravity:!!((o=t.dnsStatus)!=null&&o.antigravity),kiro:!!((a=t.dnsStatus)!=null&&a.kiro),copilot:!!((d=t.dnsStatus)!=null&&d.copilot)}}),t.augmentModels&&ee(s=>({...s,...t.augmentModels})),Dt.getState().fetchStatus()}).catch(()=>{}),fetch("/api/mitm/router-target").then(t=>t.ok?t.json():null).then(t=>{t&&(_e(t.baseUrl||""),Ue(!!t.hasApiKey),t.isRemote&&t.baseUrl&&ze())}).catch(()=>{})},ze=()=>{fetch("/api/mitm/router-target/models").then(t=>t.ok?t.json():{models:[]}).then(t=>{const s=(t.models||[]).map(o=>({id:o.id,value:o.id,name:o.name||o.id,providerId:o.provider||"remote",providerName:o.provider||"Remote Gateway",hasConnectedAccount:!0,accountsCount:1,caps:{vision:!0,reasoning:!0,audio:!1},contextLength:128e3}));ht(s)}).catch(()=>{})},gt=async()=>{qe(!0),we(null);try{const s=await(await fetch("/api/mitm/router-target/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:K.trim(),apiKey:z.trim()||void 0})})).json();we({success:!!s.success,message:s.message||(s.success?"Connection successful":"Connection failed")}),s.success&&G&&ze()}catch(t){we({success:!1,message:(t==null?void 0:t.message)||"Test request failed"})}finally{qe(!1)}},bt=async()=>{if(!x){Ke(!0),W(null);try{const s=await(await fetch("/api/mitm/router-target",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:K.trim(),apiKey:z!==""?z.trim():void 0})})).json();s.success?(W({success:!0,message:"Target configuration saved!"}),Ue(!!s.hasApiKey),Oe(""),I()):W({success:!1,message:s.error||"Failed to save target"})}catch(t){W({success:!1,message:(t==null?void 0:t.message)||"Failed to save target"})}finally{Ke(!1),setTimeout(()=>W(null),3e3)}}},ft=()=>{et.forEach(t=>{fetch(`/api/mitm/hosts/${t.id}`).then(s=>s.json()).then(s=>{s.entries&&te(o=>({...o,[t.id]:s.entries}))}).catch(()=>{}),fetch(`/api/mitm/mappings/${t.id}`).then(s=>s.json()).then(s=>{Array.isArray(s)&&U(o=>({...o,[t.id]:s}))}).catch(()=>{})})};n.useEffect(()=>{I(),ft()},[]);const ce=async(t=!1,s)=>{h(null);let o;if(s!==void 0)o=s;else if(j.trim()){const a=Number(j.trim());if(isNaN(a)||!Number.isInteger(a)||a<1||a>65535){h("Port must be an integer between 1 and 65535.");return}o=a}if(x&&!t){C(!1);try{const d=await(await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!1})})).json();C(!!d.running),d.port&&N(d.port),d.dnsStatus&&$({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),I()}catch(a){h((a==null?void 0:a.message)||"Failed to stop server")}return}t&&M(!0);try{const a=await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!0,port:o,forceKill:t})});if(a.status===409){const A=await a.json();g(A.portOwner||{port:o||443,inUse:!0}),C(!1);return}if(!a.ok){const A=await a.json().catch(()=>({}));throw new Error(A.error||`Failed to start server (${a.status})`)}const d=await a.json();C(!!d.running),d.port&&N(d.port),d.dnsStatus&&$({antigravity:!!d.dnsStatus.antigravity,kiro:!!d.dnsStatus.kiro,copilot:!!d.dnsStatus.copilot}),d.warning&&h(d.warning),g(null),I()}catch(a){h((a==null?void 0:a.message)||"Failed to start server")}finally{M(!1)}},yt=async()=>{Te(!0),k(null);try{const s=await(await fetch("/api/mitm/install-cert",{method:"POST"})).json();s.success?(k({type:"success",text:s.message||"Root CA installed successfully!"}),I()):k({type:"error",text:s.message||"Installation failed"})}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to install certificate"})}finally{Te(!1)}},jt=async()=>{Ee(!0),k(null);try{const s=await(await fetch("/api/mitm/uninstall-cert",{method:"POST"})).json();s.success?(k({type:"success",text:s.message||"Root CA uninstalled successfully!"}),I()):k({type:"error",text:s.message||"Uninstallation failed"})}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to uninstall certificate"})}finally{Ee(!1)}},Nt=async t=>{const s=!Ae[t];$(o=>({...o,[t]:s}));try{const a=await(await fetch("/api/mitm/toggle-dns",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,active:s})})).json();a.dnsStatus&&$(d=>({...d,antigravity:!!a.dnsStatus.antigravity,kiro:!!a.dnsStatus.kiro,copilot:!!a.dnsStatus.copilot})),a.warning&&h(a.warning),I()}catch{}},wt=async t=>{const s=!L[t];ee(o=>({...o,[t]:s}));try{const a=await(await fetch("/api/mitm/augment-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,enabled:s})})).json();a.augmentModels&&ee(d=>({...d,...a.augmentModels}))}catch{ee(o=>({...o,[t]:!s}))}},vt=async t=>{const s=De[t]||"";try{(await fetch(`/api/mitm/hosts/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:s})})).ok&&(se(a=>({...a,[t]:"Saved hosts successfully."})),ge(a=>({...a,[t]:!1})),setTimeout(()=>{se(a=>({...a,[t]:null}))},3e3))}catch{}},Ct=async t=>{try{const o=await(await fetch(`/api/mitm/hosts/${t}/reset`,{method:"POST"})).json();o.entries&&(te(a=>({...a,[t]:o.entries})),se(a=>({...a,[t]:"Hosts reset to default."})),setTimeout(()=>{se(a=>({...a,[t]:null}))},3e3))}catch{}},St=async t=>{try{const o=await(await fetch("/api/mitm/mappings/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t})})).json();Array.isArray(o.mappings)&&U(a=>({...a,[t]:o.mappings}))}catch{}},kt=async()=>{if(!_||!fe.trim()||!je.trim())return;const t=_,s={sourceModel:fe.trim(),targetModel:je.trim()};U(o=>({...o,[t]:[...o[t]||[],s]}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:s.sourceModel,targetModel:s.targetModel})})}catch{}finally{ye(""),Ne(""),F(null)}},We=async t=>{if(!ne||!be.trim())return;let s=be.trim();Le.has(s.toLowerCase())&&!s.startsWith("combo/")&&(s=`combo/${s}`),U(o=>({...o,[t]:(o[t]||[]).map(a=>a.sourceModel===ne?{...a,targetModel:s}:a)}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:ne,targetModel:s})})}catch{}finally{oe(null),ae(null),q("")}},Mt=(t,s)=>{U(o=>({...o,[t]:(o[t]||[]).filter(a=>a.sourceModel!==s)})),fetch(`/api/mitm/mappings/${t}?sourceModel=${encodeURIComponent(s)}`,{method:"DELETE"}).catch(()=>{})};return e.jsxs("div",{className:"space-y-6 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl bg-amber-500/10 border border-amber-500/20 text-xs text-amber-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-amber-400 shrink-0",children:"warning"}),e.jsxs("p",{children:[e.jsx("strong",{children:"MITM Interceptor:"})," Intercepts HTTPS traffic of closed IDE tools (Antigravity, Kiro, GitHub Copilot) via a local Root CA to redirect requests to your chosen providers and models. DNS is controlled independently per tool."]})]}),e.jsxs("div",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl bg-blue-500/10 border border-blue-500/20 text-xs text-blue-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-400 shrink-0",children:"info"}),e.jsx("p",{className:"font-mono text-[11px] sm:text-xs text-blue-200",children:"How it works: Antigravity/Kiro IDE request → DNS redirect to localhost:443 → MITM proxy intercepts → Mapigate → response to Antigravity/Kiro"})]}),e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-cyan-500/10 border border-cyan-500/20 text-cyan-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"alt_route"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"MITM HTTPS Proxy Server"}),e.jsx("span",{className:`rt-badge ${x?"rt-badge--success":"rt-badge--muted"}`,children:x?`● Running (Port :${f})`:"Stopped"})]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-0.5",children:["Intercepts inbound IDE requests via SNI certificate emulation on port ",f,"."]})]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("button",{onClick:()=>ce(),className:`rt-btn text-xs py-1.5 px-3.5 ${x?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:x?"stop":"play_arrow"}),x?"Stop Server":"Start Server"]})})]}),R&&e.jsxs("div",{className:"p-3 rounded-xl bg-rose-500/10 border border-rose-500/30 text-xs text-rose-300 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-rose-400",children:"error"}),e.jsx("span",{children:R})]}),e.jsx("button",{type:"button",onClick:()=>h(null),className:"text-rose-400 hover:text-white",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 pt-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-semibold text-slate-300",children:"Active Gateway Endpoint:"}),e.jsx("code",{className:"text-blue-400 font-mono bg-[#0A0D14] px-3 py-1.5 rounded-lg border border-[#1E293B]",children:v})]}),e.jsx("span",{className:"text-[11px] text-slate-400 italic",children:"Enable DNS per tool below to activate redirection"})]}),e.jsx("div",{className:"pt-3 border-t border-[#1E293B]",children:e.jsxs("div",{className:"p-3.5 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-cyan-400",children:"hub"}),e.jsx("span",{className:"text-xs font-bold text-white",children:"Target Gateway"}),G?e.jsx("span",{className:"rt-badge rt-badge--info",children:"Remote Machine"}):e.jsx("span",{className:"rt-badge rt-badge--success",children:"Local Machine"})]}),x&&e.jsxs("span",{className:"text-[11px] text-amber-400/90 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"lock"}),"Stop server to edit target configuration"]})]}),e.jsx("p",{className:"text-[11.5px] text-slate-400 leading-relaxed",children:"Specify where intercepted prompts are forwarded. Leave URL blank to route to this machine's local Mapigate Gateway, or enter another IP/URL to delegate requests to a remote machine."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-semibold text-slate-300 block mb-1",children:"Gateway Base URL"}),e.jsx("input",{type:"text",placeholder:`Leave blank for local (${v})`,value:K,disabled:x,onChange:t=>_e(t.target.value),className:"w-full bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] font-semibold text-slate-300 block mb-1",children:["Gateway API Key ",$e&&!z&&"(Configured ✓)"]}),e.jsx("input",{type:"password",disabled:x,placeholder:$e?"•••••••••••• (Leave blank to keep)":G?"Optional (Required if Target requires key)":"Optional (Dedicated MITM key used by default)",value:z,onChange:t=>Oe(t.target.value),className:"w-full bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"text-xs",children:[ie&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${ie.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:ie.success?"check_circle":"cancel"}),ie.message]}),le&&e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11.5px] ${le.success?"text-emerald-400":"text-rose-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:le.success?"check":"error"}),le.message]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:He,onClick:gt,className:"rt-btn rt-btn--secondary text-xs py-1 px-3 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"network_check"}),He?"Testing...":"Test Connection"]}),e.jsxs("button",{type:"button",disabled:Fe||x,title:x?"Stop MITM server before editing target configuration":void 0,onClick:bt,className:"rt-btn rt-btn--primary text-xs py-1 px-3.5 flex items-center gap-1 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"save"}),Fe?"Saving...":"Save Target"]})]})]})]})}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B]/60",children:[e.jsxs("button",{type:"button",onClick:()=>pe(t=>!t),className:"flex items-center gap-1.5 text-xs text-slate-400 hover:text-slate-200 transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:D?"expand_less":"tune"}),e.jsx("span",{children:"Advanced / Custom Port Configuration"})]}),D&&e.jsxs("div",{className:"mt-3 p-3.5 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3 justify-between",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-slate-300 block",children:"Custom MITM Listen Port"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default is port 443. Custom ports are for manual developer testing only."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"1",max:"65535",placeholder:"443",value:j,onChange:t=>S(t.target.value),disabled:x,className:"w-24 bg-[#141B2D] border border-[#1E293B] rounded-lg px-2.5 py-1.5 text-xs font-mono text-white text-center focus:outline-none focus:border-blue-500 disabled:opacity-50"}),!x&&j&&e.jsx("button",{type:"button",onClick:()=>S(""),className:"text-xs text-slate-400 hover:text-white px-1.5 py-1 rounded",title:"Reset to default 443",children:"Reset"})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg bg-amber-500/10 border border-amber-500/20 text-[11.5px] text-amber-300 leading-relaxed",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400 shrink-0 mt-0.5",children:"warning"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Notice:"})," OS ",e.jsx("code",{children:"hosts"})," file redirection maps domain names to IP addresses without port numbers. AI coding tools (Antigravity, Kiro, Copilot) connect to port 443 by default. Running on custom ports will ",e.jsx("strong",{children:"not"})," intercept standard IDE traffic."]})]})]})]})]}),e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"verified_user"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:"SSL Root CA Certificate"}),l?e.jsxs("span",{className:"rt-badge rt-badge--success",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"check"})," Trusted in System"]}):e.jsxs("span",{className:"rt-badge rt-badge--warning",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"info"})," Not Yet Trusted"]}),Q&&e.jsx("span",{className:"rt-badge rt-badge--info",children:"Generated"})]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Required for IDEs to accept MITM proxy SSL handshakes without security warnings."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:async()=>{try{const t=await fetch("/api/mitm/cert");if(!t.ok)throw new Error(`HTTP ${t.status}`);const s=await t.blob(),o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download="mapigate-rootCA.crt",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o)}catch(t){k({type:"error",text:(t==null?void 0:t.message)||"Failed to download Root CA certificate."})}},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"download"}),"Download CA"]}),l?e.jsxs("button",{disabled:Be,onClick:jt,className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3.5 flex items-center gap-1.5 text-rose-400 hover:text-rose-300 border-rose-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"}),Be?"Uninstalling...":"Uninstall from System"]}):e.jsxs("button",{disabled:Me,onClick:yt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_task"}),Me?"Installing...":"Install to System Store"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"p-3 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"SHA1 Fingerprint:"}),he&&e.jsxs("button",{onClick:()=>E("fp",he),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),B==="fp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-purple-300 font-mono text-[11px] block break-all",children:he||"Generating upon first start..."})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] rounded-xl border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"CA File Path:"}),T&&e.jsxs("button",{onClick:()=>E("cp",T),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),B==="cp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-slate-300 font-mono text-[11px] block truncate",children:T||"~/.mapigate/mitm/rootCA.crt"})]})]}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsx("span",{className:"font-semibold text-slate-300 block",children:"Manual Installation Commands:"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-2.5",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"Windows (PowerShell / cmd):"}),e.jsxs("button",{onClick:()=>E("winCmd",X.windows),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),B==="winCmd"?"Copied!":"Copy"]})]}),e.jsx("code",{className:"text-emerald-400 font-mono text-[11px] block break-all bg-[#05070B] p-2 rounded-lg border border-[#1E293B]",children:X.windows})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#0A0D14] border border-[#1E293B] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:"macOS (Terminal):"}),e.jsxs("button",{onClick:()=>E("macCmd",X.mac),className:"text-blue-400 hover:text-blue-300 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"content_copy"}),B==="macCmd"?"Copied!":"Copy"]})]}),e.jsx("code",{className:"text-emerald-400 font-mono text-[11px] block break-all bg-[#05070B] p-2 rounded-lg border border-[#1E293B]",children:X.mac})]})]})]}),Z&&e.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-center gap-2 ${Z.type==="success"?"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:Z.type==="success"?"check_circle":"error"}),Z.text]})]}),e.jsx("div",{className:"space-y-4",children:ot.map(t=>{const s=at===t.id,o=!!Ae[t.id],a=!!it[t.id],d=De[t.id]||t.defaultHost,A=dt[t.id]||"source",de=ut[t.id]||"asc",Ge=Ot(ct[t.id]||[],A,de),J=(H[t.id]||"").trim().toLowerCase(),Je=J?Ge.filter(i=>{const y=i.sourceModel.toLowerCase(),V=(i.targetModel||"").toLowerCase(),Y=(ue(i.sourceModel)||"").toLowerCase(),ve=(ue(i.targetModel)||"").toLowerCase();return y.includes(J)||V.includes(J)||Y.includes(J)||ve.includes(J)}):Ge,Ve=rt[t.id],Ye=i=>{A===i?Pe(y=>({...y,[t.id]:de==="asc"?"desc":"asc"})):(mt(y=>({...y,[t.id]:i})),Pe(y=>({...y,[t.id]:"asc"})))};return e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{onClick:()=>nt(s?null:t.id),className:"flex items-center justify-between cursor-pointer select-none",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx(It,{src:t.image,name:t.name,iconBg:t.iconBg,size:"md"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-sm font-bold text-white",children:t.name}),e.jsx("span",{className:`rt-badge ${o?"rt-badge--success":"rt-badge--muted"}`,children:o?"DNS on":"DNS off"})]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:t.desc})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:i=>{i.stopPropagation(),Nt(t.id)},className:`rt-btn text-xs py-1.5 px-3 ${o?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:o?"stop":"play_arrow"}),o?"Stop DNS":"Start DNS"]}),e.jsx("span",{className:"material-symbols-outlined text-[20px] text-slate-500",children:s?"expand_less":"expand_more"})]})]}),s&&e.jsxs("div",{className:"pt-4 border-t border-[#1E293B] space-y-5 text-xs animate-rt-fade-in",children:[e.jsxs("div",{className:"space-y-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"font-bold text-white flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[16px]",children:"dns"}),"Hosts File Entries (",t.name,")"]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Domain mappings added to your system hosts file when DNS redirection is enabled."})]}),e.jsx("div",{className:"flex items-center gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{Ie[t.id]!==void 0&&te(i=>({...i,[t.id]:Ie[t.id]})),ge(i=>({...i,[t.id]:!1}))},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"}),"Cancel"]}),e.jsxs("button",{onClick:()=>vt(t.id),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"save"}),"Save Hosts"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>Ct(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",title:"Reset hosts entries to tool default",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset"]}),e.jsxs("button",{onClick:()=>{lt(i=>({...i,[t.id]:d})),ge(i=>({...i,[t.id]:!0}))},className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"edit"}),"Edit"]})]})})]}),e.jsx("textarea",{readOnly:!a,rows:Math.max(2,d.split(`
|
|
14
|
+
`).length+1),value:d,onChange:i=>te(y=>({...y,[t.id]:i.target.value})),className:`w-full border rounded-xl p-3 text-xs font-mono leading-relaxed transition-colors ${a?"bg-[#05070B] border-blue-500/60 text-emerald-400 cursor-text focus:outline-none focus:border-blue-500":"bg-[#07090E] border-[#1E293B] text-emerald-400/80 cursor-default focus:outline-none"}`,placeholder:"127.0.0.1 domain"}),Ve&&e.jsxs("div",{className:"text-[11px] text-emerald-400 font-mono flex items-center gap-1.5 animate-rt-scale-in",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"check_circle"}),Ve]})]}),(t.id==="kiro"||!!t.isModelListRequest)&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4 rounded-xl bg-[#0A0D14] border border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-3",children:[e.jsx("div",{className:"size-8 rounded-lg bg-purple-500/10 border border-purple-500/20 text-purple-400 flex items-center justify-center shrink-0 mt-0.5 sm:mt-0",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"auto_awesome"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-white text-xs",children:"Augment Models in IDE"}),e.jsx("span",{className:`rt-badge ${L[t.id]?"rt-badge--success":"rt-badge--muted"}`,children:L[t.id]?"Enabled":"Disabled"})]}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["Injects Mapigate's rich model catalog into ",t.name," so you can select from all models in the IDE regardless of your account's tier."]})]})]}),e.jsxs("button",{type:"button",onClick:()=>wt(t.id),className:`rt-btn text-xs py-1.5 px-3.5 shrink-0 flex items-center gap-1.5 cursor-pointer ${L[t.id]?"rt-btn--primary":"rt-btn--secondary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:L[t.id]?"toggle_on":"toggle_off"}),L[t.id]?"Enabled":"Enable"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[20px]",children:"alt_route"}),"Model Redirection Mappings (",t.name,")"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Map requested models to your chosen Mapigate providers and upstream model IDs (slashes / supported)."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>St(t.id),className:"px-3 py-1.5 text-xs font-medium rounded-xl bg-slate-800/80 hover:bg-slate-700/80 border border-[#1E293B] hover:border-slate-600 text-slate-200 flex items-center gap-1.5 transition-all cursor-pointer",title:"Reset to default mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-slate-400",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{type:"button",onClick:()=>{F(t.id),ye(""),Ne("")},className:"px-3.5 py-1.5 text-xs font-semibold rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/30 text-white flex items-center gap-1.5 transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_circle"}),"Add Mapping"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 text-[18px]",children:"search"}),e.jsx("input",{type:"text",value:H[t.id]||"",onChange:i=>Re(y=>({...y,[t.id]:i.target.value})),placeholder:"Search model alias or destination...",className:"w-full bg-[#0F1420]/80 border border-[#1E293B] focus:border-blue-500 rounded-xl pl-9 pr-4 py-2 text-xs text-slate-200 focus:outline-none"})]}),(H[t.id]||"")&&e.jsx("button",{type:"button",onClick:()=>Re(i=>({...i,[t.id]:""})),className:"text-xs text-slate-400 hover:text-white cursor-pointer",children:"Clear"})]}),e.jsx("div",{className:"rounded-2xl border border-[#1E293B] overflow-hidden bg-[#0F1420]/80",children:Je.length===0?e.jsxs("div",{className:"py-14 text-center text-xs text-slate-400 space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600 block",children:"alt_route"}),e.jsx("p",{className:"font-semibold text-slate-300",children:H[t.id]?`No mappings match "${H[t.id]}"`:`No model mappings configured for ${t.name}`}),e.jsxs("p",{className:"text-slate-500 max-w-md mx-auto text-[11.5px] leading-relaxed",children:["Click ",e.jsx("strong",{className:"text-blue-400",children:"“+ Add Mapping”"})," to add a custom mapping or"," ",e.jsx("strong",{className:"text-slate-300",children:"“Reset to Default”"})," to restore defaults."]})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] bg-[#0A0D14] text-slate-400 font-semibold",children:[e.jsx("th",{onClick:()=>Ye("source"),className:"p-3 pl-4 cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Source Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Source Model (IDE)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:A==="source"?de==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>Ye("target"),className:"p-3 cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Destination",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Destination (Model or Combo)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:A==="target"?de==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 pr-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:Je.map((i,y)=>{const V=pt===t.id&&ne===i.sourceModel,Y=ue(i.sourceModel),ve=!!(Y&&Y!==i.sourceModel),Ce=i.targetModel?ue(i.targetModel):"",Qe=!!(i.targetModel&&(i.targetModel.startsWith("combo/")||Le.has(i.targetModel.toLowerCase()))),me=Qe&&!i.targetModel.startsWith("combo/")?`combo/${i.targetModel}`:i.targetModel,Tt=!!(me&&Ce&&Ce!==me);return e.jsxs("tr",{className:`transition-colors ${V?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3 pl-4 font-mono text-slate-200",children:e.jsx("div",{className:"flex items-center gap-2",children:ve?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-slate-100 font-sans font-semibold text-xs leading-snug",children:Y}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"px-2 py-0.5 rounded-lg bg-slate-800/80 border border-slate-700/60 font-mono text-[11px] text-slate-400",children:i.sourceModel}),e.jsx("button",{type:"button",onClick:()=>E(`src-${t.id}-${i.sourceModel}`,i.sourceModel),className:"text-slate-500 hover:text-slate-300 p-0.5 cursor-pointer",title:"Copy source model ID",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:B===`src-${t.id}-${i.sourceModel}`?"done":"content_copy"})})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-slate-800/80 border border-slate-700/60 text-slate-100 font-medium",children:i.sourceModel}),e.jsx("button",{type:"button",onClick:()=>E(`src-${t.id}-${i.sourceModel}`,i.sourceModel),className:"text-slate-500 hover:text-slate-300 p-0.5 cursor-pointer",title:"Copy source model ID",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:B===`src-${t.id}-${i.sourceModel}`?"done":"content_copy"})})]})})}),e.jsx("td",{className:"p-3",children:V?e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-md",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(Ze,{value:be,onChange:q,onEnter:()=>We(t.id),placeholder:"Search model or combo...",fetchCustomModels:G&&re.length>0?()=>Promise.resolve(re):void 0,className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-xl px-3 py-1.5 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):i.targetModel?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),Qe&&e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 text-[9.5px] font-mono text-cyan-300 font-semibold tracking-wide",children:"COMBO"}),e.jsx("span",{className:"text-emerald-300 font-mono font-medium text-xs",children:Ce||me})]}),Tt&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400 pl-4",children:me})]}):e.jsxs("button",{type:"button",onClick:()=>{ae(t.id),oe(i.sourceModel),q("")},className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-dashed border-amber-500/40 bg-amber-500/10 text-amber-300 hover:border-amber-400 hover:text-amber-200 text-xs font-medium transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Click to select target model or combo"]})}),e.jsx("td",{className:"p-3 pr-4 text-right space-x-2 whitespace-nowrap",children:V?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>We(t.id),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white font-sans text-xs font-semibold transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>{oe(null),ae(null),q("")},className:"px-2.5 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 font-sans text-xs transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>{ae(t.id),oe(i.sourceModel),q(i.targetModel||"")},className:"p-1 rounded-lg text-slate-400 hover:text-blue-400 hover:bg-blue-500/10 transition-colors cursor-pointer",title:"Edit target model",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),e.jsx("button",{type:"button",onClick:()=>Mt(t.id,i.sourceModel),className:"p-1 rounded-lg text-slate-400 hover:text-red-400 hover:bg-red-500/10 transition-colors cursor-pointer",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})})]},y)})})]})})})]})]})]},t.id)})}),e.jsx(Xe,{isOpen:!!_,onClose:()=>F(null),maxWidthClass:"max-w-xl",children:_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"add_circle"}),"Add Model Mapping (",_.toUpperCase(),")"]}),e.jsx("button",{onClick:()=>F(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Source Model ID (Sent by IDE)"}),e.jsx(Pt,{toolId:_,value:fe,onChange:ye,placeholder:"Select or type model ID (e.g. auto, claude-sonnet-4.5)..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Target Upstream Model ID (Mapigate Provider Model)"}),e.jsx(Ze,{value:je,onChange:Ne,placeholder:"Search model or type ID...",fetchCustomModels:G&&re.length>0?()=>Promise.resolve(re):void 0}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Supports slash / formats, e.g. provider/model-name."})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-[#1E293B]",children:[e.jsx("button",{onClick:()=>F(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsx("button",{onClick:kt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-4",children:"Add Mapping"})]})]})}),e.jsx(Xe,{isOpen:!!c,onClose:()=>g(null),maxWidthClass:"max-w-xl",children:c&&(()=>{var s;const t=!!c.isTransient||c.pid===0||!!((s=c.processName)!=null&&s.toLowerCase().includes("idle"));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`material-symbols-outlined text-[20px] ${t?"text-blue-400":c.isSystemProcess?"text-rose-400":"text-amber-400"}`,children:t?"hourglass_top":c.isSystemProcess?"gpp_bad":"warning"}),e.jsxs("h4",{className:"text-sm font-bold text-white",children:["Port ",c.port," ",t?"Socket Releasing":c.isSystemProcess?"System Conflict":"Already In Use"]})]}),e.jsx("button",{onClick:()=>g(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),t?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-blue-500/10 border border-blue-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"hourglass_top"}),e.jsx("span",{children:"Socket Releasing (TIME_WAIT)"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently releasing from a recent restart (",e.jsx("strong",{className:"text-white",children:"TCP TIME_WAIT"}),"). The operating system will free this socket in a few seconds. Click ",e.jsx("strong",{children:"Retry"})," to start the MITM server."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ce(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):c.isSystemProcess?e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-rose-500/10 border border-rose-500/30 rounded-xl space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-rose-300 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"admin_panel_settings"}),e.jsx("span",{children:"Windows Kernel / System Service Conflict"})]}),e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is occupied by"," ",e.jsx("strong",{children:c.processName||"System"})," (PID ",c.pid??4,"). This is a Windows system kernel service (e.g. ",e.jsx("code",{children:"HTTP.sys"}),", IIS, or Web Publishing Service) and cannot be killed directly."]})]}),e.jsxs("div",{className:"p-3 bg-[#0A0D14] border border-[#1E293B] rounded-xl space-y-2",children:[e.jsx("span",{className:"text-slate-400 text-[11px] font-semibold block",children:"Run these commands as Administrator to release the port:"}),e.jsxs("div",{className:"space-y-1.5 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"iisreset /stop"}),e.jsx("button",{type:"button",onClick:()=>E("iisreset","iisreset /stop"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:B==="iisreset"?"check":"content_copy"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-[#141B2D] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-cyan-300",children:"net stop w3svc"}),e.jsx("button",{type:"button",onClick:()=>E("w3svc","net stop w3svc"),className:"text-slate-400 hover:text-white ml-2 shrink-0",title:"Copy command",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:B==="w3svc"?"check":"content_copy"})})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>ce(!1,c.port),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"}),"Retry"]})]})]}):e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{className:"p-3.5 bg-amber-500/10 border border-amber-500/30 rounded-xl space-y-2",children:[e.jsxs("p",{className:"text-slate-300 text-[11.5px] leading-relaxed",children:["Port ",c.port," is currently used by another process:"]}),e.jsxs("div",{className:"p-2.5 bg-[#0A0D14] rounded-lg border border-[#1E293B] font-mono text-xs text-amber-200",children:[e.jsxs("div",{children:["Process: ",e.jsx("strong",{className:"text-white",children:c.processName||"Unknown"})]}),e.jsxs("div",{children:["PID: ",e.jsx("strong",{className:"text-white",children:c.pid??"Unknown"})]})]}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["Kill this process to start MITM Proxy on port ",c.port,"?"]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-[#1E293B]",children:[e.jsx("button",{type:"button",onClick:()=>g(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:P,onClick:()=>ce(!0,c.port),className:"rt-btn rt-btn--danger text-xs py-1.5 px-3.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:P?"hourglass_empty":"power_settings_new"}),P?"Terminating...":"Kill & Start"]})]})]})]})})()})]})};export{zt as MitmTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as r,r as f}from"./vendor-BcOI2aZ9.js";import{n as E,g as te,a as ne}from"./metadataRegistry-4BIaQVmV.js";const k={vision:!1,pdf:!1,audioInput:!1,videoInput:!1,imageOutput:!1,audioOutput:!1,search:!1,tools:!0,reasoning:!1,thinkingFormat:null,thinkingCanDisable:!0,thinkingRange:null,thinkingEffortSupported:!1,contextWindow:2e5,maxOutput:64e3},y="[-_/:.]",ie=new RegExp([`(^|${y})(image|img)(${y}|$)`,"stable-image","gen[0-9]_image","nanobanana","imagine","t2v","i2v","flux","dall","sdxl","diffusion","embed","rerank","guard","moderation","tts","stt","whisper","voice","speech","audio"].join("|"),"i"),ae=new RegExp([`(^|${y})(vision|vl|vlm|multimodal|omni|visual)(${y}|$)`,`[0-9]\\.[0-9]+v(${y}|$)`,`(^|${y})glm-[0-9]+v(${y}|$)`,"(^|[-_/:.])(llava|pixtral|internvl|cogvlm|minicpm-v|moondream|idefics|fuyu)"].join("|"),"i"),H={nvidia:{"minimaxai/minimax-m2.7":{reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:2e5,maxOutput:131072},"minimaxai/minimax-m3":{vision:!0,reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:512e3,maxOutput:131072},"deepseek-ai/deepseek-v4-pro":{reasoning:!0,thinkingFormat:"openai",contextWindow:1e6,maxOutput:65536}},"opencode-go":{"glm-5.3-flash":{vision:!0,videoInput:!0,pdf:!0,reasoning:!0,thinkingFormat:"openai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072}}},$={"claude-fable-5-1":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:128e3},"claude-opus-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1},"claude-opus-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1},"claude-opus-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1},"claude-sonnet-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1},"claude-haiku-5.5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-haiku-5-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-5":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4.8":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4-8":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4.6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-opus-4-6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-4.6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-sonnet-4-6":{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3},"claude-3-7-sonnet":{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3},"claude-3.7-sonnet":{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3},"claude-3-5-sonnet":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3.5-sonnet":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3-5-haiku":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3.5-haiku":{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192},"claude-3-opus":{vision:!0,contextWindow:2e5,maxOutput:4096},"claude-3-haiku":{vision:!0,contextWindow:2e5,maxOutput:4096},"glm-5.3-flash":{vision:!0,videoInput:!0,pdf:!0,reasoning:!0,thinkingFormat:"zai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072},"glm-4.6v":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"zai",contextWindow:128e3,maxOutput:32768},"glm-4.5v":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"zai",contextWindow:64e3,maxOutput:16384},"glm-5.2":{reasoning:!0,thinkingFormat:"zai",thinkingCanDisable:!1,contextWindow:1e6,maxOutput:131072},"deepseek-chat":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3,maxOutput:64e3},"deepseek-reasoner":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3,maxOutput:64e3},"deepseek-r1":{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3,maxOutput:64e3},"deepseek-v4.1-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-v4-1-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-v4-flash-vision-exp":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:1e6,maxOutput:384e3},"deepseek-flash":{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3,maxOutput:64e3},"kimi-k3":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072},"kimi-for-coding":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536},"kimi-k2.7-code":{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536},"gpt-image-1":{imageOutput:!0,tools:!1}};function D(n){if(!n)return!1;const t=String(n).toLowerCase();return ie.test(t)?!1:ae.test(t)}const K=new Map;function oe(n){let t=K.get(n);return t||(t=new RegExp("^"+n.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i"),K.set(n,t)),t}function G(n,t){return!n||!t?!1:oe(n).test(t)}const re=[{pattern:"*claude*opus-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1}},{pattern:"*claude*opus-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingCanDisable:!1,forcedToolChoice:!1}},{pattern:"*claude*sonnet-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1}},{pattern:"*claude*sonnet-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3,thinkingOffType:"between_tools",forcedToolChoice:!1}},{pattern:"*claude*haiku-5.5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-5-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*opus-4-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4-7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*sonnet-4-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-5*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*haiku-4*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive",contextWindow:1e6,maxOutput:128e3}},{pattern:"*claude*3.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*3-7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*3.5*sonnet*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3-5*sonnet*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3.5*haiku*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3-5*haiku*",caps:{vision:!0,search:!0,contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*3*opus*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*3*sonnet*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*3*haiku*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude-3*",caps:{vision:!0,contextWindow:2e5,maxOutput:4096}},{pattern:"*claude*haiku*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:8192}},{pattern:"*claude*opus*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*sonnet*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*claude*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget",contextWindow:2e5,maxOutput:64e3}},{pattern:"*gemini*image*",caps:{vision:!0,imageOutput:!0,contextWindow:1048576}},{pattern:"*gemini-4*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-3.8*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-3.7*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-level",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-2.5*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,search:!0,thinkingFormat:"gemini-budget",thinkingRange:{min:0,max:24576},contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini-2*",caps:{vision:!0,audioInput:!0,videoInput:!0,search:!0,contextWindow:1048576,maxOutput:65536}},{pattern:"*gemini*",caps:{vision:!0,search:!0,contextWindow:1048576}},{pattern:"*gemma*",caps:{vision:!0,contextWindow:128e3}},{pattern:"*gpt-6.1-terra*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:128e3}},{pattern:"*gpt-6.1-sol*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:272e3,maxOutput:128e3}},{pattern:"*gpt-6*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:105e4,maxOutput:128e3}},{pattern:"*gpt-5*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:4e5,maxOutput:128e3}},{pattern:"*gpt-4o*",caps:{vision:!0,search:!0,contextWindow:128e3,maxOutput:16384}},{pattern:"*gpt-4.1*",caps:{vision:!0,contextWindow:1e6,maxOutput:32768}},{pattern:"*gpt-4-turbo*",caps:{vision:!0,contextWindow:128e3}},{pattern:"*gpt-4*",caps:{contextWindow:128e3}},{pattern:"*gpt-3.5*",caps:{contextWindow:16385,maxOutput:4096}},{pattern:"*o1-mini*",caps:{reasoning:!0,thinkingFormat:"openai",contextWindow:128e3}},{pattern:"*o1*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*o3*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*o4*",caps:{vision:!0,reasoning:!0,thinkingFormat:"openai",contextWindow:2e5,maxOutput:1e5}},{pattern:"*grok*image*",caps:{imageOutput:!0}},{pattern:"*grok-code*",caps:{reasoning:!0,thinkingFormat:"openai",contextWindow:256e3}},{pattern:"*grok-4.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:5e5}},{pattern:"*grok-4.6*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:5e5}},{pattern:"*grok-4.5*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:5e5,maxOutput:64e3}},{pattern:"*grok-4*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:256e3}},{pattern:"*grok*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"openai",contextWindow:128e3}},{pattern:"*deepseek*v4.1*flash*free*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",contextWindow:33e4,maxOutput:128e3}},{pattern:"*deepseek-v4.*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingEffortSupported:!0,contextWindow:1e6,maxOutput:128e3}},{pattern:"*deepseek-v4*",caps:{reasoning:!0,thinkingFormat:"deepseek",thinkingEffortSupported:!0,contextWindow:1e6,maxOutput:384e3}},{pattern:"*reasoner*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3}},{pattern:"*deepseek-r*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:128e3}},{pattern:"*deepseek-chat*",caps:{vision:!1,reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3}},{pattern:"*deepseek*",caps:{reasoning:!0,thinkingFormat:"deepseek",contextWindow:128e3}},{pattern:"*qwen*vl*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:262144}},{pattern:"*qwen*omni*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:262144,maxOutput:65536}},{pattern:"*qwen*coder*",caps:{reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6}},{pattern:"*qwen*max*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.5*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.6*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen3.7*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwen*plus*",caps:{vision:!0,reasoning:!0,thinkingFormat:"qwen",contextWindow:1e6,maxOutput:65536}},{pattern:"*qwq*",caps:{reasoning:!0,thinkingFormat:"qwen",thinkingCanDisable:!1,contextWindow:131072}},{pattern:"*qwen*",caps:{reasoning:!0,thinkingFormat:"qwen",contextWindow:262144}},{pattern:"*kimi*k3.1*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*kimi*k3*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*k3.1*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*k3*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*kimi*coding*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536}},{pattern:"*kimi*k2*",caps:{vision:!0,videoInput:!0,reasoning:!0,thinkingFormat:"kimi",thinkingCanDisable:!1,contextWindow:262144,maxOutput:65536}},{pattern:"*kimi*",caps:{vision:!0,reasoning:!0,thinkingFormat:"kimi",contextWindow:262144}},{pattern:"*mimo*v2.6*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*mimo*v2.5*",caps:{vision:!0,audioInput:!0,videoInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:1048576,maxOutput:131072}},{pattern:"*mimo*omni*",caps:{vision:!0,audioInput:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:262144,maxOutput:131072}},{pattern:"*mimo*",caps:{vision:!0,reasoning:!0,thinkingFormat:"deepseek",thinkingCanDisable:!1,contextWindow:262144,maxOutput:131072}},{pattern:"*llama-4*",caps:{vision:!0,contextWindow:1e6}},{pattern:"*llama*",caps:{contextWindow:128e3}},{pattern:"*mistral-large*",caps:{vision:!0,contextWindow:256e3}},{pattern:"*codestral*",caps:{contextWindow:256e3}},{pattern:"*mistral*",caps:{contextWindow:128e3}}];function U(n){if(n){if(Array.isArray(n)){const t={};for(const a of n)typeof a=="string"&&(t[a]=!0);return t}return n}}const Q=new Map;function Y(n,t){if(!t)return{...k};const a=`${n||""}|${t}`,c=Q.get(a);if(c)return c;const p=se(n,t);return Q.set(a,p),p}function se(n,t){const a=t.includes("/")?t.split("/").pop():t,c=!n&&t.includes("/")?t.split("/")[0]:n,p=c?c.replace(/\[.*?\]$/,""):null,i=E(a);if(p){const s=te(p);if(s!=null&&s.models){const l=s.models.find(o=>o.id===t||o.id===a||o.upstreamModelId&&(o.upstreamModelId===t||o.upstreamModelId===a)||E(o.id)===i||o.upstreamModelId&&E(o.upstreamModelId)===i);if(l!=null&&l.capabilities){const o=U(l.capabilities);if(o){const g={...k,...o};return!g.vision&&D(t)&&(g.vision=!0),g}}}}else for(const s of ne()){if(!s.models)continue;const l=s.models.find(o=>o.id===t||o.id===a||o.upstreamModelId&&(o.upstreamModelId===t||o.upstreamModelId===a)||E(o.id)===i||o.upstreamModelId&&E(o.upstreamModelId)===i);if(l!=null&&l.capabilities){const o=U(l.capabilities);if(o){const g={...k,...o};return!g.vision&&D(t)&&(g.vision=!0),g}}}if(p&&H[p]){const s=H[p];if(s[t])return{...k,...s[t]};if(s[a])return{...k,...s[a]}}if($[a]){const s={...k,...$[a]};return!s.vision&&D(t)&&(s.vision=!0),s}if($[t]){const s={...k,...$[t]};return!s.vision&&D(t)&&(s.vision=!0),s}for(const{pattern:s,caps:l}of re)if(G(s,a)||G(s,t)){const o={...k,...l};return!o.vision&&D(t)&&(o.vision=!0),o}const m={...k};return!m.vision&&D(t)&&(m.vision=!0),m}function me(n,t,a=0){if(!n||n.length===0||a>6)return null;const c=n.map(i=>{!i.includes("/")&&(t!=null&&t[i]);const m=i.indexOf("/"),s=m===-1?null:i.slice(0,m),l=m===-1?i:i.slice(m+1);return Y(s,l)}),p=c[0];return{vision:c.some(i=>i.vision),pdf:c.some(i=>i.pdf),audioInput:c.some(i=>i.audioInput),videoInput:c.some(i=>i.videoInput),imageOutput:c.some(i=>i.imageOutput),audioOutput:c.some(i=>i.audioOutput),search:c.some(i=>i.search),tools:c.every(i=>i.tools),reasoning:p.reasoning,thinkingFormat:p.thinkingFormat,thinkingCanDisable:p.thinkingCanDisable,thinkingRange:p.thinkingRange,thinkingEffortSupported:p.thinkingEffortSupported,contextWindow:Math.min(...c.map(i=>i.contextWindow)),maxOutput:Math.max(...c.map(i=>i.maxOutput))}}const S={vision:{key:"vision",label:"Vision",icon:"visibility",desc:"Supports image inputs (png, jpg, webp, base64)",colorClass:"text-cyan-400",bgClass:"bg-cyan-500/10",borderClass:"border-cyan-500/20"},pdf:{key:"pdf",label:"PDF",icon:"picture_as_pdf",desc:"Supports PDF and document parsing",colorClass:"text-orange-400",bgClass:"bg-orange-500/10",borderClass:"border-orange-500/20"},audio:{key:"audio",label:"Audio",icon:"graphic_eq",desc:"Supports raw voice and audio speech input",colorClass:"text-purple-400",bgClass:"bg-purple-500/10",borderClass:"border-purple-500/20"},thinking:{key:"thinking",label:"Thinking",icon:"psychology",desc:"Supports reasoning and thinking trace",colorClass:"text-emerald-400",bgClass:"bg-emerald-500/10",borderClass:"border-emerald-500/20"}};function ue(n){if(!n)return null;const t=n.indexOf("/"),a=t===-1?null:n.slice(0,t),c=t===-1?n:n.slice(t+1);return Y(a,c)}const ce=({caps:n,model:t,className:a="",showLabels:c=!1,size:p="sm"})=>{const i=n||(t?ue(t):null);if(!i)return null;const m=!!i.vision,s=!!i.pdf,l=!!(i.audioInput||i.audio),o=!!(i.reasoning||i.thinking||i.thinkingFormat&&i.thinkingFormat!==null),g=[];if(m&&g.push(S.vision),s&&g.push(S.pdf),l&&g.push(S.audio),o&&g.push(S.thinking),g.length===0)return null;const W={xs:"text-[12px]",sm:"text-[14px]",md:"text-[16px]"},N={xs:"text-[9.5px]",sm:"text-[10.5px]",md:"text-xs"};return r.jsx("div",{className:`inline-flex items-center gap-1.5 flex-wrap ${a}`,children:g.map(x=>r.jsxs("span",{title:`${x.label}: ${x.desc}`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md border font-medium transition-all ${x.colorClass} ${x.bgClass} ${x.borderClass} ${N[p]}`,children:[r.jsx("span",{className:`material-symbols-outlined leading-none ${W[p]}`,children:x.icon}),c&&r.jsx("span",{children:x.label})]},x.key))})};function pe(n,t){if(!t.trim())return!0;const a=t.toLowerCase().trim(),c=n.toLowerCase();if(c.includes(a))return!0;const p=a.split(/\s+/).filter(Boolean);if(p.length===0)return!0;const i=c.replace(/[-_./]/g," ");return p.every(m=>c.includes(m)||i.includes(m))}let M=null,A=null;const R=new Set;function de(n){return R.add(n),()=>{R.delete(n)}}function xe(){M=null,A=null;for(const n of R)try{n()}catch(t){console.error("Error in model cache invalidation listener:",t)}}function X(){return A?Promise.resolve(A):(M||(M=fetch("/api/models/available").then(n=>{if(!n.ok)throw new Error("Failed to load models");return n.json()}).then(n=>(A=n,n)).catch(n=>{throw M=null,n})),M)}const he=({value:n,onChange:t,onEnter:a,placeholder:c="Search model (e.g. openai/gpt-4o)...",className:p="",autoFocus:i=!1,connectedOnly:m=!0,disabled:s=!1,excludeValues:l,allowCombos:o=!0,fetchCustomModels:g})=>{const[W,N]=f.useState([]),[x,v]=f.useState(!1),[O,w]=f.useState(-1),[F,T]=f.useState(m),[J,_]=f.useState("bottom"),j=f.useRef(null),q=f.useRef(null);f.useEffect(()=>{if(x&&j.current){const e=j.current.getBoundingClientRect(),d=280,h=window.innerHeight-e.bottom,I=e.top;h<d&&I>h?_("top"):_("bottom")}},[x]),f.useEffect(()=>{let e=!0;const d=()=>{(g?g():X()).then(u=>{e&&N(u)}).catch(()=>{})};d();const h=de(()=>{e&&d()});return()=>{e=!1,h()}},[g]),f.useEffect(()=>{T(m)},[m]),f.useEffect(()=>{const e=d=>{j.current&&!j.current.contains(d.target)&&v(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const P=f.useMemo(()=>W.some(e=>e.hasConnectedAccount),[W]),C=f.useMemo(()=>{const e=(n||"").trim().toLowerCase(),d=new Set((l||[]).map(u=>u.toLowerCase()));let h=W;if(o===!1&&(h=h.filter(u=>!u.isCombo)),d.size>0&&(h=h.filter(u=>!d.has(u.value.toLowerCase())&&!(u.isCombo&&d.has(u.id.toLowerCase())))),F&&P&&(h=h.filter(u=>u.hasConnectedAccount)),!e)return h.slice(0,50);const I=h.filter(u=>{let b=`${u.name} ${u.id} ${u.value} ${u.providerName} ${u.providerId}`;return u.isCombo&&(u.strategy&&(b+=` ${u.strategy}`),u.models&&(b+=` ${u.models.join(" ")}`)),pe(b,e)});return I.sort((u,b)=>{const B=u.value.toLowerCase(),L=b.value.toLowerCase(),z=u.id.toLowerCase(),V=b.id.toLowerCase();return B===e||z===e?-1:L===e||V===e?1:B.startsWith(e)||z.startsWith(e)?-1:L.startsWith(e)||V.startsWith(e)?1:u.isCombo&&!b.isCombo?-1:!u.isCombo&&b.isCombo?1:0}),I.slice(0,50)},[W,n,F,P,l,o]);f.useEffect(()=>{if(O>=0&&q.current){const e=q.current.children[O];e&&e.scrollIntoView({block:"nearest"})}},[O]);const Z=e=>{if(!s)if(e.key==="ArrowDown")e.preventDefault(),x?w(d=>d<C.length-1?d+1:0):v(!0);else if(e.key==="ArrowUp")e.preventDefault(),x?w(d=>d>0?d-1:C.length-1):v(!0);else if(e.key==="Enter")if(x&&O>=0&&C[O]){e.preventDefault();const d=C[O];t(d.value),v(!1),w(-1),a&&a(d.value)}else v(!1),a&&(e.preventDefault(),a(n));else e.key==="Escape"&&(e.preventDefault(),v(!1),w(-1))},ee=e=>{t(e),v(!1),w(-1)};return r.jsxs("div",{ref:j,className:"relative w-full",children:[r.jsx("input",{type:"text",value:n,onChange:e=>{t(e.target.value),x||v(!0),w(-1)},onFocus:()=>{(W.length===0||!A)&&X().then(e=>N(e)).catch(()=>{}),v(!0)},onKeyDown:Z,placeholder:c,disabled:s,autoFocus:i,className:p||"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl pl-3 pr-8 py-2 text-xs text-white font-mono focus:outline-none focus:border-blue-500"}),n&&!s&&r.jsx("button",{type:"button",onClick:()=>{t(""),w(-1)},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition-colors cursor-pointer flex items-center justify-center",title:"Clear input",children:r.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})}),x&&r.jsxs("div",{className:`absolute left-0 right-0 ${J==="top"?"bottom-full mb-1.5":"top-full mt-1.5"} z-50 rounded-xl bg-[#0A0D14] border border-[#1E293B] shadow-2xl overflow-hidden animate-rt-scale-in min-w-[280px]`,children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#1E293B] bg-[#05070B] text-[11px]",children:[r.jsxs("span",{className:"text-slate-400 font-mono text-[10.5px]",children:[C.length," models ",n.trim()?"found":"available"]}),r.jsxs("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!F)},className:`px-2 py-0.5 rounded-md font-sans text-[10.5px] font-medium flex items-center gap-1 transition-all cursor-pointer ${F?"bg-emerald-500/15 border border-emerald-500/30 text-emerald-400":"bg-slate-800 border border-slate-700 text-slate-400 hover:text-slate-200"}`,title:F?"Showing only models from connected accounts. Click to show all catalog models.":"Showing all catalog models. Click to filter by connected accounts.",children:[r.jsx("span",{className:"material-symbols-outlined text-[12px]",children:F?"check":"filter_alt"}),"Connected only"]})]}),r.jsx("div",{ref:q,className:"max-h-56 overflow-y-auto divide-y divide-[#1E293B]/40",children:C.length===0?r.jsxs("div",{className:"p-3 text-center text-xs text-slate-500 space-y-1",children:[r.jsx("p",{children:"No matching models in catalog."}),r.jsx("p",{className:"text-[10.5px] text-slate-400",children:"Custom IDs are supported. Press Enter or click outside to use your custom model ID."}),F&&!P&&r.jsx("button",{type:"button",onMouseDown:e=>{e.preventDefault(),T(!1)},className:"mt-1 text-[11px] text-blue-400 hover:underline",children:"View all registry models"})]}):C.map((e,d)=>{const h=d===O,I=e.value===n;return r.jsxs("div",{onMouseDown:u=>{u.preventDefault(),ee(e.value)},onMouseEnter:()=>w(d),className:`px-3 py-2 cursor-pointer transition-colors flex items-center justify-between gap-2.5 ${h?"bg-blue-600/20 text-white":I?"bg-[#141B2D] text-slate-100":"hover:bg-white/5 text-slate-300"}`,children:[r.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[r.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.isCombo?r.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 font-mono text-[9.5px] text-cyan-300 font-semibold tracking-wide",children:"COMBO"}):r.jsx("span",{className:"px-1.5 py-0.2 rounded bg-slate-800/80 border border-slate-700/60 font-mono text-[9.5px] text-slate-300",children:e.providerName||e.providerId}),r.jsx("span",{className:"font-medium text-xs text-slate-100 truncate",children:e.name}),e.isCombo&&e.strategy&&r.jsx("span",{className:`px-1.5 py-0.2 rounded font-sans text-[9px] font-medium border ${e.strategy==="round-robin"?"bg-cyan-950/40 text-cyan-300 border-cyan-500/30":e.strategy==="fusion"?"bg-purple-950/40 text-purple-300 border-purple-500/30":"bg-amber-950/40 text-amber-300 border-amber-500/30"}`,children:e.strategy==="round-robin"?"Round Robin":e.strategy==="fusion"?"Fusion":"Fallback"}),e.hasConnectedAccount&&r.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400 shrink-0",title:`Connected account active (${e.accountsCount})`})]}),e.isCombo&&e.models&&e.models.length>0?r.jsxs("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:[r.jsxs("span",{className:"text-cyan-400 font-semibold",children:[e.models.length," model",e.models.length>1?"s":"",":"]})," ",r.jsxs("span",{className:"text-slate-300",children:[e.models.slice(0,3).join(", "),e.models.length>3?` +${e.models.length-3} more`:""]})]}):r.jsx("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:e.value})]}),r.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:r.jsx(ce,{caps:e.caps,size:"xs",showLabels:!1})})]},e.value)})})]})]})};export{ce as C,he as M,me as a,X as b,Y as g,xe as i,pe as m,de as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,j as e,R as ce}from"./vendor-BcOI2aZ9.js";import{u as Te,a as ge,b as Le,D as _e,c as ze,S as Oe,v as We,s as Ge,K as Ke,P as Fe,d as Qe,C as Ve}from"./dnd-kit-DecqzwfZ.js";import{P as Ye}from"./index-BvY11iVv.js";import{o as Ue,g as H,m as qe,a as ve,C as xe,b as Ze}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{T as He}from"./ToolIcon-BZE0Fv7L.js";import{S as Je}from"./Select-BNRH8LIG.js";import{P as de}from"./metadataRegistry-4BIaQVmV.js";const Xe={},X=[],_=50;function et(n){return!n||n<=0?null:n>=1e6?`${(n/1e6).toFixed(n%1e6===0?0:1)}M ctx`:n>=1e3?`${Math.round(n/1e3)}K ctx`:`${n} ctx`}function J(n,x,h,v,y,C,A,j="llm",p=!1){const M=`${h} ${n} ${x} ${y} ${v}`.toLowerCase(),g=M.replace(/[-_./]/g," ");return{id:n,value:x,name:h,providerId:v,providerName:y,caps:C,contextLength:A,kind:j,isCustom:p,searchTarget:M,normalizedSearchTarget:g}}const ye=ce.memo(({id:n,index:x,onRemove:h,onMoveUp:v,onMoveDown:y,isFirst:C,isLast:A})=>{const{attributes:j,listeners:p,setNodeRef:M,transform:g,transition:z,isDragging:E}=Qe({id:n}),F={transform:Ve.Transform.toString(g),transition:z,zIndex:E?50:void 0,opacity:E?.6:1};return e.jsxs("div",{ref:M,style:F,className:`flex items-center justify-between gap-2 px-3 py-2 rounded-xl border bg-[#0A0D14] transition-all ${E?"border-blue-500 shadow-lg shadow-blue-500/10 bg-blue-950/40":"border-[#1E293B] hover:border-slate-700"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[e.jsx("button",{type:"button",...j,...p,className:"cursor-grab active:cursor-grabbing text-slate-500 hover:text-slate-300 p-0.5 rounded touch-none shrink-0",title:"Drag to reorder priority",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"drag_indicator"})}),e.jsx("span",{className:"size-5 rounded-md bg-[#141B2D] border border-[#1E293B] text-[10px] font-mono text-blue-400 font-bold flex items-center justify-center shrink-0",children:x+1}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-mono text-xs text-white truncate block",title:n,children:n}),e.jsx(xe,{model:n,size:"xs",className:"mt-1"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:v,disabled:C,className:"p-1 text-slate-400 hover:text-white disabled:opacity-20 disabled:hover:text-slate-400 cursor-pointer",title:"Move up",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"arrow_upward"})}),e.jsx("button",{type:"button",onClick:y,disabled:A,className:"p-1 text-slate-400 hover:text-white disabled:opacity-20 disabled:hover:text-slate-400 cursor-pointer",title:"Move down",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"arrow_downward"})}),e.jsx("button",{type:"button",onClick:h,className:"p-1 text-slate-400 hover:text-rose-400 cursor-pointer",title:"Remove",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})]})});ye.displayName="SortableModelItem";const je=ce.memo(({item:n,isSelected:x,onToggle:h})=>{const v=et(n.contextLength);return e.jsxs("div",{onClick:()=>h(n),className:`flex items-center justify-between p-2.5 rounded-xl border transition-colors cursor-pointer ${x?"bg-blue-600/10 border-blue-500/40 text-white":"bg-[#0A0D14] border-[#1E293B] hover:border-slate-700 text-slate-300"}`,children:[e.jsxs("div",{className:"min-w-0 pr-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-white truncate",children:n.name}),v&&e.jsx("span",{className:"text-[9.5px] font-mono px-1 py-0.2 rounded bg-slate-800 text-slate-400 border border-slate-700/60 leading-tight",children:v})]}),e.jsx("div",{className:"font-mono text-[11px] text-slate-400 truncate mt-0.5",children:n.value}),e.jsx("div",{className:"mt-1",children:e.jsx(xe,{caps:n.caps,size:"xs"})})]}),e.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),h(n)},className:`size-7 rounded-lg flex items-center justify-center shrink-0 border transition-colors ${x?"bg-blue-600 border-blue-500 text-white":"bg-[#141B2D] border-[#1E293B] text-slate-400 hover:text-white hover:border-slate-600"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:x?"check":"add"})})]})});je.displayName="ModelOptionRow";const Ne=ce.memo(({group:n,isExpanded:x,visibleModelCount:h,selectedSet:v,selectedModel:y,onToggleGroup:C,onToggleModel:A,onShowMore:j,onShowAll:p})=>{const M=x?n.models.slice(0,h):X;return e.jsxs("div",{className:"rounded-xl border border-[#1E293B] bg-[#0A0D14]/70 overflow-hidden transition-colors",children:[e.jsxs("div",{onClick:()=>C(n.providerId),className:`flex items-center justify-between p-2.5 cursor-pointer select-none transition-colors ${x?"bg-[#141B2D]/80 hover:bg-[#141B2D] border-b border-[#1E293B]":"hover:bg-white/[0.03]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(He,{src:n.image,name:n.providerName,color:n.color,iconBg:n.iconBg,size:"sm"}),e.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-white truncate",children:n.providerName}),e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.2 rounded bg-slate-800/80 text-slate-400 border border-slate-700/60 shrink-0",children:[n.models.length," model",n.models.length>1?"s":""]}),n.selectedCount>0&&e.jsxs("span",{className:"text-[10px] font-mono px-1.5 py-0.2 rounded bg-blue-500/20 text-blue-300 border border-blue-500/40 font-semibold shrink-0",children:[n.selectedCount," selected"]})]})]}),e.jsx("span",{className:`material-symbols-outlined text-[18px] text-slate-400 transition-transform duration-200 shrink-0 ${x?"rotate-180 text-blue-400":""}`,children:"expand_more"})]}),x&&e.jsxs("div",{className:"p-2 space-y-1.5 bg-[#080B12]/60",children:[M.map(g=>{const z=v.has(g.value)||y===g.value;return e.jsx(je,{item:g,isSelected:z,onToggle:A},g.value)}),n.models.length>h&&e.jsxs("div",{className:"pt-2 pb-1 text-center flex items-center justify-center gap-2",children:[e.jsxs("button",{type:"button",onClick:g=>{g.stopPropagation(),j()},className:"px-3 py-1.5 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium cursor-pointer transition-colors",children:["Show 50 more (",n.models.length-h," remaining)"]}),n.models.length-h>50&&e.jsxs("button",{type:"button",onClick:g=>{g.stopPropagation(),p()},className:"px-3 py-1.5 rounded-lg bg-[#141B2D] border border-[#1E293B] text-slate-400 hover:text-white text-xs font-medium cursor-pointer transition-colors",children:["Show all (",n.models.length,")"]})]})]})]})});Ne.displayName="ProviderAccordionItem";const it=({isOpen:n,onClose:x,title:h="Select & Reorder Models",initialSelectedModels:v=X,onConfirm:y,multiSelect:C=!0,filterModality:A=null,onSelect:j,onDeselect:p,selectedModel:M,activeProviders:g=X,modelAliases:z=Xe,kindFilter:E=null,capFilter:F=null,addedModelValues:me,closeOnSelect:U=!1,excludeModelIds:ue=X,allowCombos:P=!0})=>{const[N,b]=l.useState([]),[ee,te]=l.useState(""),$=l.useDeferredValue(ee),[f,se]=l.useState("all"),[w,Q]=l.useState(F||A||"all"),[re,oe]=l.useState(""),[O,pe]=l.useState([]),[q,Ce]=l.useState([]),[k,ne]=l.useState(!0),[he,W]=l.useState(null),[we,R]=l.useState(_),be=l.useRef(null),ke=Te(ge(Fe,{activationConstraint:{distance:4}}),ge(Ke,{coordinateGetter:Ge}));l.useEffect(()=>{if(n){b([...me||v||[]]),te(""),se("all"),Q(F||A||"all"),oe(""),W(null),R(_);const s=setTimeout(()=>{var o;(o=be.current)==null||o.focus()},50);return()=>clearTimeout(s)}},[n,v,me,A,F]),l.useEffect(()=>{if(!n)return;let t=!1;return fetch("/api/combos").then(s=>s.ok?s.json():[]).then(s=>{if(!t){const o=Array.isArray(s)?s:s.combos||[];pe(o)}}).catch(()=>{t||pe([])}),()=>{t=!0}},[n]),l.useEffect(()=>{if(!n)return;let t=!1;const s=(r=!1)=>{Ze().then(a=>{if(!t&&(Ce(a),r)){const d=a.some(i=>i.hasConnectedAccount);ne(P===!1?!1:d)}}).catch(()=>{})};s(!0);const o=Ue(()=>{t||s(!1)});return()=>{t=!0,o()}},[n,P]);const B=l.useMemo(()=>{const t=new Set;for(const s of q)s.hasConnectedAccount&&t.add(s.providerId);return t},[q]),G=l.useMemo(()=>B.size>0,[B]),I=l.useMemo(()=>new Set(N),[N]),K=l.useMemo(()=>{var r,a,d,m;const t=[],s=new Set,o=new Set;for(const i of q){if(i.isCombo||s.has(i.value))continue;s.add(i.value),o.add(i.providerId);const c=H(i.providerId,i.id);t.push(J(i.id,i.value,i.name||i.id,i.providerId,i.providerName||i.providerId,{...c,vision:!!((r=i.caps)!=null&&r.vision||c.vision),reasoning:!!((a=i.caps)!=null&&a.reasoning||c.reasoning),audioInput:!!((d=i.caps)!=null&&d.audio||c.audioInput),audioOutput:!!((m=i.caps)!=null&&m.audio||c.audioOutput)},i.contextLength||c.contextWindow,"llm",!1))}for(const[i,c]of Object.entries(de)){if(!c||!c.models)continue;const D=c.alias||c.id||i;if(!(o.has(i)||o.has(D)||c.aliases&&c.aliases.some(u=>o.has(u))))for(const u of c.models){const L=u.id.startsWith(`${D}/`)||u.id.startsWith(`${i}/`)||c.uiAlias&&u.id.startsWith(`${c.uiAlias}/`)?u.id:`${D}/${u.id}`;if(s.has(L))continue;s.add(L);const ie=H(i,u.id);t.push(J(u.id,L,u.name||u.id,i,c.name||i,ie,u.contextLength,u.kind||"llm",!1))}}for(const[i,c]of Object.entries(z))if(!s.has(c)){s.add(c);const D=c.indexOf("/"),Y=D===-1?"custom":c.slice(0,D),u=D===-1?c:c.slice(D+1),L=de[Y],ie=H(Y,u);t.push(J(u,c,i,Y,(L==null?void 0:L.name)||Y,ie,void 0,"llm",!0))}return t},[q,z]),T=l.useMemo(()=>new Set((ue||[]).map(t=>t.toLowerCase())),[ue]),ae=l.useMemo(()=>$.toLowerCase().trim().split(/\s+/).filter(Boolean),[$]),fe=l.useMemo(()=>{const t=new Map,s=P!==!1&&O.length>0;for(const a of K)k&&G&&!B.has(a.providerId)||t.has(a.providerId)||t.set(a.providerId,a.providerName);const o=new Intl.Collator(void 0,{sensitivity:"base"}),r=Array.from(t.entries()).map(([a,d])=>({id:a,name:d})).sort((a,d)=>o.compare(a.name,d.name));return s?[{id:"combo",name:"Combos"},...r]:r},[K,k,G,B,P,O]),V=l.useMemo(()=>{if(P===!1)return[];if(w!=="all"||E)return[];const t=$.trim().toLowerCase(),o=[...O.filter(r=>!T.has(r.id.toLowerCase())&&!T.has(r.name.toLowerCase())&&!T.has(`combo/${r.name}`.toLowerCase()))].sort((r,a)=>r.name.localeCompare(a.name,void 0,{sensitivity:"base"}));return t?o.filter(r=>{const a=`${r.name} ${r.id} ${r.strategy||""} ${r.models.join(" ")}`;return qe(a,t)}):o},[O,$,w,E,P,T]),Z=l.useMemo(()=>f==="combo"?[]:K.filter(t=>!(t.providerId==="combo"&&T.has(t.id.toLowerCase())||T.has(t.value.toLowerCase())||k&&G&&!B.has(t.providerId)||E&&t.kind&&t.kind!==E||f!=="all"&&t.providerId!==f||w==="vision"&&!t.caps.vision||w==="pdf"&&!t.caps.pdf||w==="audio"&&!t.caps.audioInput&&!t.caps.audio||w==="thinking"&&!t.caps.reasoning&&!t.caps.thinking&&!t.caps.thinkingFormat||ae.length>0&&!ae.every(o=>t.searchTarget.includes(o)||t.normalizedSearchTarget.includes(o)))),[K,f,w,E,ae,k,G,B,T]),S=l.useMemo(()=>{const t=new Map;for(const r of Z){const a=r.providerId;let d=t.get(a);if(!d){const m=de[a];d={providerId:a,providerName:r.providerName||(m==null?void 0:m.name)||a,color:m==null?void 0:m.color,iconBg:m==null?void 0:m.iconBg,image:m==null?void 0:m.image,models:[],selectedCount:0},t.set(a,d)}d.models.push(r),(I.has(r.value)||M===r.value)&&d.selectedCount++}const s=new Intl.Collator(void 0,{sensitivity:"base"});return Array.from(t.values()).map(r=>({...r,models:[...r.models].sort((a,d)=>s.compare(a.name||a.id,d.name||d.id))})).sort((r,a)=>{if(r.selectedCount>0&&a.selectedCount===0)return-1;if(a.selectedCount>0&&r.selectedCount===0)return 1;const d=B.has(r.providerId)?1:0,m=B.has(a.providerId)?1:0;return d!==m?m-d:s.compare(r.providerName,a.providerName)})},[Z,I,M,B]);l.useEffect(()=>{$.trim()?(W(t=>{var s;return t&&S.some(o=>o.providerId===t)?t:((s=S[0])==null?void 0:s.providerId)||null}),R(_)):f!=="all"&&(W(f),R(_))},[$,f,S]),l.useEffect(()=>{n&&!$.trim()&&f==="all"&&S.length>0&&(W(t=>{var o;if(t&&S.some(r=>r.providerId===t))return t;const s=S.find(r=>r.selectedCount>0);return s?s.providerId:((o=S[0])==null?void 0:o.providerId)||null}),R(_))},[n,S,$,f]);const Se=l.useCallback(t=>{W(s=>s===t?null:t),R(_)},[]),Me=l.useCallback(()=>{W(null)},[]),Be=l.useCallback(()=>{R(t=>t+_)},[]),Ie=l.useCallback(t=>{const s=t.value;I.has(s)?(p&&p(t),b(r=>r.filter(a=>a!==s))):(j&&j(t),b(C?r=>[...r,s]:[s])),U&&x()},[I,p,j,C,U,x]),le=l.useCallback(t=>{const s=t.name,o=I.has(s),r=ve(t.models),a=J(t.name,t.name,t.name,"combo","Combos",r||H(null,t.name),void 0,"combo",!1);o?(p&&p(a),b(d=>d.filter(m=>m!==s))):(j&&j(a),b(C?d=>[...d,s]:[s])),U&&x()},[I,p,j,C,U,x]),Ae=l.useCallback(t=>{b(o=>o.filter(r=>r!==t));const s=K.find(o=>o.value===t);s&&p&&p(s)},[K,p]),Ee=l.useCallback(t=>{t!==0&&b(s=>{const o=[...s],r=o[t-1];return o[t-1]=o[t],o[t]=r,o})},[]),$e=l.useCallback(t=>{b(s=>{if(t===s.length-1)return s;const o=[...s],r=o[t+1];return o[t+1]=o[t],o[t]=r,o})},[]),De=l.useCallback(t=>{const{active:s,over:o}=t;o&&s.id!==o.id&&b(r=>{const a=r.indexOf(String(s.id)),d=r.indexOf(String(o.id));return a!==-1&&d!==-1?Le(r,a,d):r})},[]),Pe=t=>{t.preventDefault();const s=re.trim();s&&(I.has(s)||b(C?o=>[...o,s]:[s]),oe(""))},Re=()=>{y&&y(N),x()};return e.jsx(Ye,{isOpen:n,onClose:x,maxWidthClass:"w-full max-w-[72rem]",children:e.jsxs("div",{className:"flex flex-col h-[85vh] max-h-[780px] -m-2 sm:-m-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-5 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-9 rounded-xl bg-blue-500/10 border border-blue-500/20 text-blue-400 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"tune"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm sm:text-base font-bold text-white",children:h}),e.jsx("p",{className:"text-xs text-slate-400",children:"Pick models and drag & drop in the right panel to set priority order"})]})]}),e.jsx("button",{type:"button",onClick:x,className:"p-1.5 rounded-lg text-slate-400 hover:text-white hover:bg-white/10 cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 flex-1 min-h-0 overflow-hidden divide-y lg:divide-y-0 lg:divide-x divide-[#1E293B]",children:[e.jsxs("div",{className:"lg:col-span-7 flex flex-col min-h-0 p-4 space-y-3.5 overflow-hidden",children:[e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-[18px] text-slate-500",children:"search"}),e.jsx("input",{ref:be,type:"text",placeholder:"Search models by name, provider, or ID...",value:ee,onChange:t=>te(t.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl pl-9 pr-8 py-2 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 font-mono"}),ee&&e.jsx("button",{type:"button",onClick:()=>te(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Je,{value:f,onChange:se,options:[{value:"all",label:`All Providers (${fe.length})`},...fe.map(t=>({value:t.id,label:t.name}))],className:"shrink-0 min-w-[150px]"}),P!==!1&&O.length>0&&e.jsxs("button",{type:"button",onClick:()=>se(f==="combo"?"all":"combo"),className:`px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1.5 ${f==="combo"?"bg-cyan-500/20 text-cyan-300 border-cyan-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-cyan-300"}`,title:"Filter by Smart Combos",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"layers"}),"Combos",e.jsx("span",{className:"text-[9.5px] px-1 rounded bg-cyan-500/30 text-cyan-300 font-mono",children:O.length})]}),e.jsxs("button",{type:"button",onClick:()=>ne(!k),className:`px-2.5 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1.5 ${k?"bg-emerald-500/20 text-emerald-300 border-emerald-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-white"}`,title:k?"Showing only models from connected accounts. Click to show all models.":"Showing all catalog models. Click to filter by connected accounts.",children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:k?"check_circle":"tune"}),"Connected Only",G&&e.jsx("span",{className:"text-[9.5px] px-1 rounded bg-emerald-500/30 text-emerald-300 font-mono",children:B.size})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>Q("all"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer ${w==="all"?"bg-blue-600 text-white border-blue-500":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-white"}`,children:"All"}),e.jsxs("button",{type:"button",onClick:()=>Q("vision"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1 ${w==="vision"?"bg-cyan-500/20 text-cyan-300 border-cyan-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-cyan-300"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"visibility"}),"Vision"]}),e.jsxs("button",{type:"button",onClick:()=>Q("audio"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1 ${w==="audio"?"bg-purple-500/20 text-purple-300 border-purple-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-purple-300"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"graphic_eq"}),"Audio"]}),e.jsxs("button",{type:"button",onClick:()=>Q("thinking"),className:`px-2 py-1 rounded-lg text-[11px] font-medium border transition-colors cursor-pointer flex items-center gap-1 ${w==="thinking"?"bg-emerald-500/20 text-emerald-300 border-emerald-500/40":"bg-[#0A0D14] text-slate-400 border-[#1E293B] hover:text-emerald-300"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:"psychology"}),"Reasoning"]})]})]}),f!=="combo"&&V.length>0&&e.jsxs("div",{className:"p-2.5 rounded-xl border border-cyan-500/20 bg-cyan-950/20 space-y-1.5 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-cyan-400 font-semibold",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"layers"}),e.jsxs("span",{children:["Smart Combos (",V.length,")"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.map(t=>{const s=I.has(t.name);return e.jsxs("button",{type:"button",onClick:()=>le(t),className:`inline-flex items-center gap-1 px-2 py-1 rounded-lg text-xs font-mono font-medium border transition-colors cursor-pointer ${s?"bg-cyan-600 text-white border-cyan-500":"bg-[#0A0D14] text-slate-300 border-[#1E293B] hover:border-cyan-500/40 hover:text-white"}`,children:[s&&e.jsx("span",{className:"material-symbols-outlined text-[12px] text-cyan-200",children:"check"}),e.jsx("span",{children:t.name}),e.jsxs("span",{className:"text-[10px] opacity-60",children:["(",t.models.length,")"]})]},t.id)})})]}),f==="combo"?e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:V.length===0?e.jsxs("div",{className:"py-10 text-center text-slate-500 text-xs space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[26px] text-slate-600 block mx-auto",children:"layers_clear"}),e.jsx("p",{className:"max-w-xs mx-auto",children:"No combos found matching your search or filters."})]}):e.jsx("div",{className:"space-y-2",children:V.map(t=>{const s=I.has(t.name),o=ve(t.models);return e.jsxs("div",{onClick:()=>le(t),className:`flex items-center justify-between p-3 rounded-xl border transition-colors cursor-pointer ${s?"bg-cyan-950/30 border-cyan-500/50 text-white":"bg-[#0A0D14]/70 border-[#1E293B] hover:border-slate-700 text-slate-300"}`,children:[e.jsxs("div",{className:"min-w-0 pr-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 font-mono text-[9.5px] text-cyan-300 font-semibold tracking-wide",children:"COMBO"}),e.jsx("span",{className:"text-xs font-semibold text-white truncate",children:t.name}),t.strategy&&e.jsx("span",{className:`px-1.5 py-0.2 rounded font-sans text-[9px] font-medium border ${t.strategy==="round-robin"?"bg-cyan-950/40 text-cyan-300 border-cyan-500/30":t.strategy==="fusion"?"bg-purple-950/40 text-purple-300 border-purple-500/30":t.strategy==="lkgp"?"bg-emerald-950/40 text-emerald-300 border-emerald-500/30":t.strategy==="p2c"?"bg-indigo-950/40 text-indigo-300 border-indigo-500/30":"bg-amber-950/40 text-amber-300 border-amber-500/30"}`,children:t.strategy==="round-robin"?"Round Robin":t.strategy==="fusion"?"Fusion":t.strategy==="lkgp"?"LKGP":t.strategy==="p2c"?"P2C":"Fallback"})]}),e.jsxs("div",{className:"font-mono text-[11px] text-slate-400 truncate",children:[e.jsxs("span",{className:"text-cyan-400 font-semibold",children:[t.models.length," model",t.models.length>1?"s":"",":"]})," ",e.jsx("span",{className:"text-slate-300",children:t.models.join(", ")})]}),o&&e.jsx("div",{className:"pt-0.5",children:e.jsx(xe,{caps:o,size:"xs"})})]}),e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),le(t)},className:`size-7 rounded-lg flex items-center justify-center shrink-0 border transition-colors ${s?"bg-cyan-600 border-cyan-500 text-white":"bg-[#141B2D] border-[#1E293B] text-slate-400 hover:text-white hover:border-slate-600"}`,children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:s?"check":"add"})})]},t.id)})})}):Z.length===0?e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:e.jsxs("div",{className:"py-10 text-center text-slate-500 text-xs space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[26px] text-slate-600 block mx-auto",children:"search_off"}),e.jsx("p",{className:"max-w-xs mx-auto",children:k&&!G?"No accounts connected yet. All models are currently hidden by 'Connected Only'.":k?"No models found from connected accounts matching your search/filters.":"No models matched your filter. Try clearing filters or enter a custom model below."}),k&&e.jsx("button",{type:"button",onClick:()=>ne(!1),className:"px-3 py-1 rounded-lg bg-blue-600/10 border border-blue-500/30 text-blue-400 hover:bg-blue-600/20 text-xs font-medium cursor-pointer transition-colors",children:"Show All Registry Models"})]})}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400 px-1 shrink-0",children:[e.jsxs("span",{className:"font-medium text-slate-300",children:[S.length," provider",S.length>1?"s":""," •"," ",Z.length," models"]}),e.jsx("div",{className:"flex items-center gap-2",children:he&&e.jsx("button",{type:"button",onClick:Me,className:"text-[11px] text-slate-400 hover:text-slate-300 font-medium cursor-pointer hover:underline",children:"Collapse"})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:S.map(t=>{const s=he===t.providerId;return e.jsx(Ne,{group:t,isExpanded:s,visibleModelCount:we,selectedSet:I,selectedModel:M,onToggleGroup:Se,onToggleModel:Ie,onShowMore:Be,onShowAll:()=>R(t.models.length)},t.providerId)})})]}),e.jsxs("form",{onSubmit:Pe,className:"flex gap-2 pt-1 border-t border-[#1E293B]",children:[e.jsx("input",{type:"text",placeholder:"Or enter custom model ID (e.g. provider/model)...",value:re,onChange:t=>oe(t.target.value),className:"flex-1 bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-1.5 text-xs text-white font-mono placeholder-slate-500 focus:outline-none focus:border-blue-500"}),e.jsx("button",{type:"submit",disabled:!re.trim(),className:"px-3 py-1.5 rounded-xl bg-[#141B2D] border border-[#1E293B] hover:border-blue-500/50 hover:bg-blue-600/10 text-xs text-slate-300 hover:text-white disabled:opacity-40 cursor-pointer",children:"Add Custom"})]})]}),e.jsxs("div",{className:"lg:col-span-5 flex flex-col min-h-0 p-4 space-y-3 bg-[#0A0D14]/40",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[18px]",children:"format_list_numbered"}),e.jsxs("span",{className:"text-xs font-bold text-white",children:["Selected Models (",N.length,")"]})]}),N.length>0&&e.jsx("button",{type:"button",onClick:()=>b([]),className:"text-[11px] text-slate-500 hover:text-rose-400 transition-colors cursor-pointer",children:"Clear all"})]}),e.jsx("p",{className:"text-[11px] text-slate-400 leading-normal",children:"Order determines execution priority (1 = primary, 2+ = backup fallbacks). Drag handles to reorder."}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto space-y-2 pr-1",children:N.length===0?e.jsx("div",{className:"py-16 text-center text-slate-500 text-xs border border-dashed border-[#1E293B] rounded-2xl p-4",children:"No models selected yet. Click any model on the left to add it to this priority list."}):e.jsx(_e,{sensors:ke,collisionDetection:ze,onDragEnd:De,children:e.jsx(Oe,{items:N,strategy:We,children:e.jsx("div",{className:"space-y-1.5",children:N.map((t,s)=>e.jsx(ye,{id:t,index:s,onRemove:()=>Ae(t),onMoveUp:()=>Ee(s),onMoveDown:()=>$e(s),isFirst:s===0,isLast:s===N.length-1},t))})})})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 sm:p-5 border-t border-[#1E293B] bg-[#0A0D14]/60",children:[e.jsx("div",{className:"text-xs text-slate-400",children:N.length===0?e.jsx("span",{children:"No models selected"}):e.jsxs("span",{children:[e.jsx("strong",{className:"text-white font-mono",children:N.length})," model",N.length>1?"s":""," in priority order"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 rounded-xl text-xs font-medium text-slate-400 hover:text-white bg-[#141B2D] border border-[#1E293B] hover:border-slate-700 transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{type:"button",onClick:Re,className:"px-5 py-2 rounded-xl text-xs font-semibold text-white bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/20 transition-all cursor-pointer",children:y?"Confirm Selection":"Done"})]})]})]})})};export{it as M};
|