mapigate 0.5.120 → 0.5.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/core/adapters/anthropic/requestOpenAiToAnthropic.js +36 -2
  3. package/dist/core/adapters/anthropicAdapter.js +2 -2
  4. package/dist/core/adapters/helpers/toolCallRescue.js +6 -1
  5. package/dist/core/capabilities/constants.js +12 -0
  6. package/dist/core/capabilities/patterns.js +25 -13
  7. package/dist/mitm/handlers/base.js +58 -18
  8. package/dist/mitm/manager.js +6 -2
  9. package/dist/mitm/portConflict.js +38 -19
  10. package/dist/providers/catalog/xiaomi-tokenplan/provider.js +44 -11
  11. package/dist/providers/core/base/anthropicProvider.js +1 -1
  12. package/dist/providers/runtime/bedrock/provider.js +1 -1
  13. package/dist/providers/runtime/mimo/provider.js +43 -10
  14. package/dist/server/proxy/singleModelExecutor.js +7 -1
  15. package/dist/server/routes/apiMitm.js +50 -0
  16. package/dist/server/routes/mitmRouterTargetHelper.js +109 -0
  17. package/dist/storage/repositories/mitmRepo.js +44 -0
  18. package/dist/web/assets/{CliToolsTab-BzhczMaa.js → CliToolsTab--_BDAxpc.js} +1 -1
  19. package/dist/web/assets/{CombosTab-Cz8KYH4M.js → CombosTab-CK0CrOWr.js} +1 -1
  20. package/dist/web/assets/{ConfirmModal-BU1PPpF0.js → ConfirmModal-BkkI8yej.js} +1 -1
  21. package/dist/web/assets/{ConsoleLogTab-CFvXde1l.js → ConsoleLogTab-CuqPUkXq.js} +1 -1
  22. package/dist/web/assets/{EditAccountModal-CS2TR4bt.js → EditAccountModal-CtWFLt1J.js} +1 -1
  23. package/dist/web/assets/{EndpointTab-DZCRpAbh.js → EndpointTab-BpWmu2u2.js} +1 -1
  24. package/dist/web/assets/MitmTab-D8qh-Ng3.js +14 -0
  25. package/dist/web/assets/ModelAutocompleteInput-C5YopybP.js +1 -0
  26. package/dist/web/assets/ProviderDetailPage-DRz6xsUD.js +6 -0
  27. package/dist/web/assets/{ProvidersTab-DwHMHdPu.js → ProvidersTab-B4NLxZtO.js} +1 -1
  28. package/dist/web/assets/{QuotaTab-DS1y9gGp.js → QuotaTab-ByMCdVsx.js} +1 -1
  29. package/dist/web/assets/{SettingsTab-DULcs9O4.js → SettingsTab-Bm4ndn4C.js} +1 -1
  30. package/dist/web/assets/{UsageTab-DKBaBAeT.js → UsageTab-0xMr9ziL.js} +1 -1
  31. package/dist/web/assets/{index-DPdrZakW.js → index-DrTal_uX.js} +2 -2
  32. package/dist/web/index.html +1 -1
  33. package/package.json +1 -1
  34. package/dist/web/assets/MitmTab-CTfwqdey.js +0 -14
  35. package/dist/web/assets/ModelAutocompleteInput-CAi2R2s9.js +0 -1
  36. package/dist/web/assets/ProviderDetailPage-Dv2LpFj_.js +0 -6
@@ -8,7 +8,7 @@
8
8
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>Mapigate - AI Model API Gateway & Token Optimizer</title>
11
- <script type="module" crossorigin src="/assets/index-DPdrZakW.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-DrTal_uX.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/vendor-BcOI2aZ9.js">
13
13
  <link rel="modulepreload" crossorigin href="/assets/lucide-Cc35htxl.js">
14
14
  <link rel="stylesheet" crossorigin href="/assets/index-BisuNW2y.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapigate",
3
- "version": "0.5.120",
3
+ "version": "0.5.127",
4
4
  "description": "AI Model API Gateway & Token Optimizer for coding tools",
5
5
  "author": "Giao Ho",
6
6
  "main": "dist/server/index.js",
@@ -1,14 +0,0 @@
1
- import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{u as it,D as ot,d as lt,P as Ee,e as rt}from"./index-DPdrZakW.js";import{M as Be}from"./ModelAutocompleteInput-CAi2R2s9.js";import{r as Ae}from"./metadataRegistry-7DDoxaR3.js";import{T as ct}from"./ToolIcon-Cp4gSgFt.js";import"./lucide-Cc35htxl.js";const ue={},dt=({toolId:r="kiro",value:p,onChange:h,onEnter:g,placeholder:N="Select or type source model ID...",className:S="",autoFocus:b=!1,disabled:w=!1})=>{const f=(r||"kiro").toLowerCase(),[j,d]=n.useState([]),[x,y]=n.useState(!1),[v,B]=n.useState(-1),[Z,A]=n.useState("bottom"),C=n.useRef(null),D=n.useRef(null);n.useEffect(()=>{if(x&&C.current){const i=C.current.getBoundingClientRect(),m=240,M=window.innerHeight-i.bottom,H=i.top;M<m&&H>M?A("top"):A("bottom")}},[x]),n.useEffect(()=>{let i=!0;if(ue[f]){d(ue[f]);return}return fetch(`/api/mitm/mappings/source-models/${encodeURIComponent(f)}`).then(m=>{if(!m.ok)throw new Error("Failed to load source models");return m.json()}).then(m=>{i&&Array.isArray(m)&&(ue[f]=m,d(m))}).catch(()=>{}),()=>{i=!1}},[f]),n.useEffect(()=>{const i=m=>{C.current&&!C.current.contains(m.target)&&y(!1)};return document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[]);const u=n.useMemo(()=>{const i=(p||"").trim().toLowerCase();return i?j.filter(m=>m.id.toLowerCase().includes(i)||m.name.toLowerCase().includes(i)):j},[j,p]);n.useEffect(()=>{B(u.length>0?0:-1)},[u]),n.useEffect(()=>{if(x&&v>=0&&D.current){const i=D.current.children[v];i&&i.scrollIntoView({block:"nearest"})}},[v,x]);const U=i=>{h(i),y(!1)},ee=i=>{i.key==="ArrowDown"?(i.preventDefault(),x?u.length>0&&B(m=>(m+1)%u.length):y(!0)):i.key==="ArrowUp"?(i.preventDefault(),x&&u.length>0&&B(m=>(m-1+u.length)%u.length)):i.key==="Enter"?x&&v>=0&&v<u.length?(i.preventDefault(),U(u[v].id)):g&&(i.preventDefault(),g()):i.key==="Escape"&&y(!1)};return e.jsxs("div",{ref:C,className:"relative w-full",children:[e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{type:"text",value:p,onChange:i=>{h(i.target.value),x||y(!0)},onFocus:()=>y(!0),onKeyDown:ee,placeholder:N,disabled:w,autoFocus:b,className:S||"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:()=>y(i=>!i),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:x?"arrow_drop_up":"arrow_drop_down"})})]}),x&&u.length>0&&e.jsx("div",{ref:D,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 ${Z==="top"?"bottom-full mb-1":"top-full mt-1"}`,children:u.map((i,m)=>{const M=m===v,H=i.category==="native";return e.jsxs("div",{onClick:()=>U(i.id),onMouseEnter:()=>B(m),className:`px-3 py-2 flex items-center justify-between text-xs cursor-pointer transition-colors ${M?"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:i.id}),i.name&&i.name!==i.id&&e.jsx("span",{className:"text-[10.5px] text-slate-400 font-sans truncate",children:i.name})]}),e.jsx("div",{className:"flex-shrink-0",children:H?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"})})]},`${i.category}-${i.id}`)})})]})},mt={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:r=>r.includes("cloudcode-pa.googleapis.com"),isModelListRequest:r=>(r.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.7-flash-high":"gemini-3.7-flash-high","gemini-3.7-flash-medium":"gemini-3.7-flash-medium","gemini-3.7-flash-low":"gemini-3.7-flash-low","gemini-3.6-flash-high":"gemini-3.6-flash-high","gemini-3.6-flash-medium":"gemini-3.6-flash-medium","gemini-3.6-flash-low":"gemini-3.6-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-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-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-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-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"},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.*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.*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:/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-3.8-flash-high","gemini-3.8-flash-medium","gemini-3.8-flash-low","gemini-3.7-flash-high","gemini-3.7-flash-medium","gemini-3.7-flash-low","gemini-3.6-flash-high","gemini-3.6-flash-medium","gemini-3.6-flash-low","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-3.1-pro-high-legacy","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"]},pt={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:r=>r.includes("githubcopilot.com")||r.includes("copilot-proxy.githubusercontent.com"),isModelListRequest:r=>{const p=(r.url||"").toLowerCase().split("?")[0];return p==="/models"||p==="/v1/models"||p.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","gpt-5-mini","gpt-5.2","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4","gpt-5.6-terra","gpt-5.6-luna","gpt-6-luna","gpt-6.1-terra","mai-code-1.1-flash","gemini-3.7-flash","gemini-3.8-flash","grok-4.5","grok-4.6","grok-4.7","kimi-k3"]},ut={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:r=>r.includes("kiro.dev")||r.includes("q.us-east-1.amazonaws.com")||r.includes("codewhisperer.us-east-1.amazonaws.com"),isChatRequest:r=>{var g;const p=(g=r.headers)==null?void 0:g["x-amz-target"],h=Array.isArray(p)?p[0]:String(p||"");return h.includes("GenerateAssistantResponse")||h.includes("CreateResponse")},isModelListRequest:r=>{var S;const p=(r.url||"").toLowerCase(),h=p.replace(/[-_]/g,"");if(h.includes("listavailablemodels")||h.includes("listmodels")||p.includes("list-available-models")||p.includes("listavailablemodels"))return!0;const g=(S=r.headers)==null?void 0:S["x-amz-target"],N=Array.isArray(g)?g[0]:String(g||"");return N.includes("ListAvailableModels")||N.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","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/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","gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","qwen3-coder-next"]},De=[mt,pt,ut];function xt(r,p="source",h="asc"){return[...r].sort((g,N)=>{if(p==="target"){const f=g.targetModel||"",j=N.targetModel||"";if(!f&&j)return 1;if(f&&!j)return-1;const d=f.localeCompare(j,void 0,{numeric:!0,sensitivity:"base"});if(d!==0)return h==="asc"?d:-d}const S=g.sourceModel.toLowerCase()==="auto",b=N.sourceModel.toLowerCase()==="auto";if(S&&!b)return h==="asc"?-1:1;if(!S&&b)return h==="asc"?1:-1;const w=g.sourceModel.localeCompare(N.sourceModel,void 0,{numeric:!0,sensitivity:"base"});return h==="asc"?w:-w})}const Nt=()=>{const r=it(t=>t.info),p=(r==null?void 0:r.port)||ot,h=(r==null?void 0:r.host)||lt,[g,N]=n.useState(""),S=g||`http://${h}:${p}`,[b,w]=n.useState(!0),[f,j]=n.useState(443),[d,x]=n.useState(null),[y,v]=n.useState(""),[B,Z]=n.useState(!1),[A,C]=n.useState(!1),[D,u]=n.useState(null),[U,ee]=n.useState(!0),[i,m]=n.useState(!1),[M,H]=n.useState(""),[te,Pe]=n.useState(""),[F,Ie]=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"}),[P,xe]=n.useState(null),[he,ge]=n.useState(!1),[be,fe]=n.useState(!1),[z,T]=n.useState(null),[ye,L]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[I,K]=n.useState({antigravity:!1,kiro:!1,copilot:!1}),[Re,_e]=n.useState(null),Oe=n.useMemo(()=>[...De].sort((t,s)=>t.name.localeCompare(s.name)),[]),[je,W]=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"}),[He,se]=n.useState({}),[Ne,Le]=n.useState({}),[$e,G]=n.useState({}),[qe,$]=n.useState({antigravity:[],kiro:[],copilot:[]}),[Ue,Fe]=n.useState({}),[ze,we]=n.useState({}),[Ke,ae]=n.useState(null),[J,ne]=n.useState(null),[ie,V]=n.useState(""),[R,q]=n.useState(null),[oe,le]=n.useState(""),[re,ce]=n.useState(""),[ve,We]=n.useState(new Set);n.useEffect(()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const s=Array.isArray(t)?t:t.combos||[];We(new Set(s.map(o=>(o.name||"").toLowerCase())))}).catch(()=>{})},[]);const _=(t,s)=>{navigator.clipboard.writeText(s),xe(t),setTimeout(()=>xe(null),2e3)},O=()=>{fetch("/api/mitm/status").then(t=>t.json()).then(t=>{w(!!t.running),t.port&&j(t.port),ee(!!t.certExists),m(!!t.certTrusted),t.certPath&&H(t.certPath),t.fingerprint&&Pe(t.fingerprint),t.routerBaseUrl&&N(t.routerBaseUrl),t.installCommands&&Ie(t.installCommands),t.dnsStatus&&L(s=>{var o,a,c;return{...s,antigravity:!!((o=t.dnsStatus)!=null&&o.antigravity),kiro:!!((a=t.dnsStatus)!=null&&a.kiro),copilot:!!((c=t.dnsStatus)!=null&&c.copilot)}}),t.augmentModels&&K(s=>({...s,...t.augmentModels})),rt.getState().fetchStatus()}).catch(()=>{})},Ge=()=>{De.forEach(t=>{fetch(`/api/mitm/hosts/${t.id}`).then(s=>s.json()).then(s=>{s.entries&&W(o=>({...o,[t.id]:s.entries}))}).catch(()=>{}),fetch(`/api/mitm/mappings/${t.id}`).then(s=>s.json()).then(s=>{Array.isArray(s)&&$(o=>({...o,[t.id]:s}))}).catch(()=>{})})};n.useEffect(()=>{O(),Ge()},[]);const Y=async(t=!1,s)=>{u(null);let o;if(s!==void 0)o=s;else if(y.trim()){const a=Number(y.trim());if(isNaN(a)||!Number.isInteger(a)||a<1||a>65535){u("Port must be an integer between 1 and 65535.");return}o=a}if(b&&!t){w(!1);try{const c=await(await fetch("/api/mitm/toggle-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({running:!1})})).json();w(!!c.running),c.port&&j(c.port),c.dnsStatus&&L({antigravity:!!c.dnsStatus.antigravity,kiro:!!c.dnsStatus.kiro,copilot:!!c.dnsStatus.copilot}),O()}catch(a){u((a==null?void 0:a.message)||"Failed to stop server")}return}t&&C(!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 E=await a.json();x(E.portOwner||{port:o||443,inUse:!0}),w(!1);return}if(!a.ok){const E=await a.json().catch(()=>({}));throw new Error(E.error||`Failed to start server (${a.status})`)}const c=await a.json();w(!!c.running),c.port&&j(c.port),c.dnsStatus&&L({antigravity:!!c.dnsStatus.antigravity,kiro:!!c.dnsStatus.kiro,copilot:!!c.dnsStatus.copilot}),c.warning&&u(c.warning),x(null),O()}catch(a){u((a==null?void 0:a.message)||"Failed to start server")}finally{C(!1)}},Je=async()=>{ge(!0),T(null);try{const s=await(await fetch("/api/mitm/install-cert",{method:"POST"})).json();s.success?(T({type:"success",text:s.message||"Root CA installed successfully!"}),O()):T({type:"error",text:s.message||"Installation failed"})}catch(t){T({type:"error",text:(t==null?void 0:t.message)||"Failed to install certificate"})}finally{ge(!1)}},Ve=async()=>{fe(!0),T(null);try{const s=await(await fetch("/api/mitm/uninstall-cert",{method:"POST"})).json();s.success?(T({type:"success",text:s.message||"Root CA uninstalled successfully!"}),O()):T({type:"error",text:s.message||"Uninstallation failed"})}catch(t){T({type:"error",text:(t==null?void 0:t.message)||"Failed to uninstall certificate"})}finally{fe(!1)}},Ye=async t=>{const s=!ye[t];L(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&&L(c=>({...c,antigravity:!!a.dnsStatus.antigravity,kiro:!!a.dnsStatus.kiro,copilot:!!a.dnsStatus.copilot})),a.warning&&u(a.warning),O()}catch{}},Qe=async t=>{const s=!I[t];K(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&&K(c=>({...c,...a.augmentModels}))}catch{K(o=>({...o,[t]:!s}))}},Xe=async t=>{const s=je[t]||"";try{(await fetch(`/api/mitm/hosts/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:s})})).ok&&(G(a=>({...a,[t]:"Saved hosts successfully."})),se(a=>({...a,[t]:!1})),setTimeout(()=>{G(a=>({...a,[t]:null}))},3e3))}catch{}},Ze=async t=>{try{const o=await(await fetch(`/api/mitm/hosts/${t}/reset`,{method:"POST"})).json();o.entries&&(W(a=>({...a,[t]:o.entries})),G(a=>({...a,[t]:"Hosts reset to default."})),setTimeout(()=>{G(a=>({...a,[t]:null}))},3e3))}catch{}},et=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)&&$(a=>({...a,[t]:o.mappings}))}catch{}},tt=async()=>{if(!R||!oe.trim()||!re.trim())return;const t=R,s={sourceModel:oe.trim(),targetModel:re.trim()};$(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{le(""),ce(""),q(null)}},Se=async t=>{if(!J||!ie.trim())return;let s=ie.trim();ve.has(s.toLowerCase())&&!s.startsWith("combo/")&&(s=`combo/${s}`),$(o=>({...o,[t]:(o[t]||[]).map(a=>a.sourceModel===J?{...a,targetModel:s}:a)}));try{await fetch("/api/mitm/mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ide:t,sourceModel:J,targetModel:s})})}catch{}finally{ne(null),ae(null),V("")}},st=(t,s)=>{$(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 ${b?"rt-badge--success":"rt-badge--muted"}`,children:b?`● 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:()=>Y(),className:`rt-btn text-xs py-1.5 px-3.5 ${b?"rt-btn--danger":"rt-btn--primary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:b?"stop":"play_arrow"}),b?"Stop Server":"Start Server"]})})]}),D&&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:D})]}),e.jsx("button",{type:"button",onClick:()=>u(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:"Mapigate Local Endpoint:"}),e.jsx("code",{className:"text-blue-400 font-mono bg-[#0A0D14] px-3 py-1.5 rounded-lg border border-[#1E293B]",children:S})]}),e.jsx("span",{className:"text-[11px] text-slate-400 italic",children:"Enable DNS per tool below to activate redirection"})]}),e.jsxs("div",{className:"pt-2 border-t border-[#1E293B]/60",children:[e.jsxs("button",{type:"button",onClick:()=>Z(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:B?"expand_less":"tune"}),e.jsx("span",{children:"Advanced / Custom Port Configuration"})]}),B&&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:y,onChange:t=>v(t.target.value),disabled:b,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"}),!b&&y&&e.jsx("button",{type:"button",onClick:()=>v(""),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"}),i?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"]}),U&&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("a",{href:"/api/mitm/cert",download:"mapigate-rootCA.crt",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"]}),i?e.jsxs("button",{disabled:be,onClick:Ve,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:he,onClick:Je,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"}),he?"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:"}),te&&e.jsxs("button",{onClick:()=>_("fp",te),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"}),P==="fp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-purple-300 font-mono text-[11px] block break-all",children:te||"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:"}),M&&e.jsxs("button",{onClick:()=>_("cp",M),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"}),P==="cp"?"Copied":"Copy"]})]}),e.jsx("code",{className:"text-slate-300 font-mono text-[11px] block truncate",children:M||"~/.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:()=>_("winCmd",F.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"}),P==="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:F.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:()=>_("macCmd",F.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"}),P==="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:F.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:Oe.map(t=>{const s=Re===t.id,o=!!ye[t.id],a=!!He[t.id],c=je[t.id]||t.defaultHost,E=Ue[t.id]||"source",Q=ze[t.id]||"asc",ke=xt(qe[t.id]||[],E,Q),Ce=$e[t.id],Me=l=>{E===l?we(k=>({...k,[t.id]:Q==="asc"?"desc":"asc"})):(Fe(k=>({...k,[t.id]:l})),we(k=>({...k,[t.id]:"asc"})))};return e.jsxs("div",{className:"rt-card p-5 space-y-4",children:[e.jsxs("div",{onClick:()=>_e(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(ct,{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:l=>{l.stopPropagation(),Ye(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:()=>{Ne[t.id]!==void 0&&W(l=>({...l,[t.id]:Ne[t.id]})),se(l=>({...l,[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:()=>Xe(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:()=>Ze(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:()=>{Le(l=>({...l,[t.id]:c})),se(l=>({...l,[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,c.split(`
14
- `).length+1),value:c,onChange:l=>W(k=>({...k,[t.id]:l.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"}),Ce&&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"}),Ce]})]}),(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 ${I[t.id]?"rt-badge--success":"rt-badge--muted"}`,children:I[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:()=>Qe(t.id),className:`rt-btn text-xs py-1.5 px-3.5 shrink-0 flex items-center gap-1.5 cursor-pointer ${I[t.id]?"rt-btn--primary":"rt-btn--secondary"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:I[t.id]?"toggle_on":"toggle_off"}),I[t.id]?"Enabled":"Enable"]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"font-bold text-slate-200 block text-xs",children:["Model Redirection Mappings (",t.name,")"]}),e.jsx("p",{className:"text-[11px] 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",{onClick:()=>et(t.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",title:"Reset to default mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{onClick:()=>{q(t.id),le(""),ce("")},className:"rt-btn rt-btn--primary text-xs py-1.5 px-3",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Add Mapping"]})]})]}),e.jsx("div",{className:"rounded-xl border border-[#1E293B] overflow-visible bg-[#0A0D14]",children:ke.length===0?e.jsxs("div",{className:"p-4 text-xs text-slate-500 italic text-center",children:["No model mappings configured for ",t.name,". Click 'Add Mapping' or 'Reset to Default'."]}):e.jsxs("table",{className:"w-full text-left text-xs font-mono",children:[e.jsx("thead",{className:"bg-[#0D121F] text-slate-400 font-sans text-[11px] uppercase tracking-wider border-b border-[#1E293B]",children:e.jsxs("tr",{children:[e.jsx("th",{onClick:()=>Me("source"),className:"p-3 font-semibold 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:E==="source"?Q==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>Me("target"),className:"p-3 font-semibold cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Model (Mapigate)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:E==="target"?Q==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 font-semibold text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:ke.map((l,k)=>{const de=Ke===t.id&&J===l.sourceModel,me=Ae(l.sourceModel),at=!!(me&&me!==l.sourceModel),pe=l.targetModel?Ae(l.targetModel):"",Te=!!(l.targetModel&&(l.targetModel.startsWith("combo/")||ve.has(l.targetModel.toLowerCase()))),X=Te&&!l.targetModel.startsWith("combo/")?`combo/${l.targetModel}`:l.targetModel,nt=!!(X&&pe&&pe!==X);return e.jsxs("tr",{className:`transition-colors ${de?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-slate-100 font-sans font-semibold text-xs leading-snug",children:me||l.sourceModel}),at&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400",children:l.sourceModel})]})}),e.jsx("td",{className:"p-3 text-blue-400",children:de?e.jsxs("div",{className:"flex items-center gap-1.5 w-full max-w-sm",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(Be,{value:ie,onChange:V,onEnter:()=>Se(t.id),placeholder:"Search connected model...",className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-lg px-2.5 py-1 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):l.targetModel?e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),Te&&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-sans font-semibold text-xs leading-snug",children:pe||X})]}),nt&&e.jsx("span",{className:"text-[10.5px] font-mono text-slate-400 pl-4",children:X})]}):e.jsx("span",{className:"text-slate-500 italic text-xs px-2 py-0.5 rounded bg-slate-800/60 border border-slate-700/40",children:"(unmapped)"})}),e.jsx("td",{className:"p-3 text-right space-x-2 whitespace-nowrap",children:de?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Se(t.id),className:"px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white font-sans text-[11px] font-medium transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:()=>{ne(null),ae(null),V("")},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-slate-700 border border-[#1E293B] text-slate-400 hover:text-white font-sans text-[11px] transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{ae(t.id),ne(l.sourceModel),V(l.targetModel)},className:"px-2.5 py-1 rounded bg-[#0E1320] hover:bg-blue-600 hover:text-white border border-[#1E293B] text-slate-300 transition-colors cursor-pointer font-sans text-[11px]",children:"Edit"}),e.jsx("button",{onClick:()=>st(t.id,l.sourceModel),className:"p-1 text-slate-500 hover:text-red-400 transition-colors",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})})]})})]},k)})})]})})]})]})]},t.id)})}),e.jsx(Ee,{isOpen:!!R,onClose:()=>q(null),maxWidthClass:"max-w-md",children:R&&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 (",R.toUpperCase(),")"]}),e.jsx("button",{onClick:()=>q(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(dt,{toolId:R,value:oe,onChange:le,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(Be,{value:re,onChange:ce,placeholder:"Search connected model..."}),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:()=>q(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsx("button",{onClick:tt,className:"rt-btn rt-btn--primary text-xs py-1.5 px-4",children:"Add Mapping"})]})]})}),e.jsx(Ee,{isOpen:!!d,onClose:()=>x(null),maxWidthClass:"max-w-md",children:d&&(()=>{var s;const t=d.pid===0||!!((s=d.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":d.isSystemProcess?"text-rose-400":"text-amber-400"}`,children:t?"hourglass_top":d.isSystemProcess?"gpp_bad":"warning"}),e.jsxs("h4",{className:"text-sm font-bold text-white",children:["Port ",d.port," ",t?"Socket Releasing":d.isSystemProcess?"System Conflict":"Already In Use"]})]}),e.jsx("button",{onClick:()=>x(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 ",d.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:()=>x(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>Y(!1,d.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"]})]})]}):d.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 ",d.port," is occupied by"," ",e.jsx("strong",{children:d.processName||"System"})," (PID ",d.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:()=>_("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:P==="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:()=>_("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:P==="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:()=>x(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>Y(!1,d.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 ",d.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:d.processName||"Unknown"})]}),e.jsxs("div",{children:["PID: ",e.jsx("strong",{className:"text-white",children:d.pid??"Unknown"})]})]}),e.jsxs("p",{className:"text-slate-400 text-[11px]",children:["Kill this process to start MITM Proxy on port ",d.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:()=>x(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3",children:"Cancel"}),e.jsxs("button",{type:"button",disabled:A,onClick:()=>Y(!0,d.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:A?"hourglass_empty":"power_settings_new"}),A?"Terminating...":"Kill & Start"]})]})]})]})})()})]})};export{Nt as MitmTab};
@@ -1 +0,0 @@
1
- import{j as a,r as h}from"./vendor-BcOI2aZ9.js";import{g as Q,a as X}from"./metadataRegistry-7DDoxaR3.js";const v={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},W="[-_/:.]",Z=new RegExp([`(^|${W})(image|img)(${W}|$)`,"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"),ee=new RegExp([`(^|${W})(vision|vl|vlm|multimodal|omni|visual)(${W}|$)`,`[0-9]\\.[0-9]+v(${W}|$)`,`(^|${W})glm-[0-9]+v(${W}|$)`,"(^|[-_/:.])(llava|pixtral|internvl|cogvlm|minicpm-v|moondream|idefics|fuyu)"].join("|"),"i"),z={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}}},M={"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-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},"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 O(i){if(!i)return!1;const n=String(i).toLowerCase();return Z.test(n)?!1:ee.test(n)}function V(i,n){return!i||!n?!1:new RegExp("^"+i.split("*").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*")+"$","i").test(n)}const te=[{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.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive"}},{pattern:"*claude*opus-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive"}},{pattern:"*claude*opus-4.8*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive"}},{pattern:"*claude*sonnet-4.6*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive"}},{pattern:"*claude*sonnet-4.7*",caps:{vision:!0,pdf:!0,reasoning:!0,search:!0,thinkingFormat:"claude-adaptive"}},{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-budget"}},{pattern:"*claude*haiku*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget"}},{pattern:"*claude*opus*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget"}},{pattern:"*claude*sonnet*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget"}},{pattern:"*claude*3.7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget"}},{pattern:"*claude*3-7*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget"}},{pattern:"*claude-3*",caps:{vision:!0}},{pattern:"*claude*",caps:{vision:!0,reasoning:!0,search:!0,thinkingFormat:"claude-budget"}},{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 H(i){if(i){if(Array.isArray(i)){const n={};for(const u of i)typeof u=="string"&&(n[u]=!0);return n}return i}}function U(i,n){if(!n)return{...v};const u=n.includes("/")?n.split("/").pop():n,s=!i&&n.includes("/")?n.split("/")[0]:i;if(s){const t=Q(s);if(t!=null&&t.models){const c=t.models.find(o=>o.id===n||o.id===u||o.upstreamModelId&&(o.upstreamModelId===n||o.upstreamModelId===u));if(c!=null&&c.capabilities){const o=H(c.capabilities);if(o){const m={...v,...o};return!m.vision&&O(n)&&(m.vision=!0),m}}}}else for(const t of X()){if(!t.models)continue;const c=t.models.find(o=>o.id===n||o.id===u||o.upstreamModelId&&(o.upstreamModelId===n||o.upstreamModelId===u));if(c!=null&&c.capabilities){const o=H(c.capabilities);if(o){const m={...v,...o};return!m.vision&&O(n)&&(m.vision=!0),m}}}if(s&&z[s]){const t=z[s];if(t[n])return{...v,...t[n]};if(t[u])return{...v,...t[u]}}if(M[u]){const t={...v,...M[u]};return!t.vision&&O(n)&&(t.vision=!0),t}if(M[n]){const t={...v,...M[n]};return!t.vision&&O(n)&&(t.vision=!0),t}for(const{pattern:t,caps:c}of te)if(V(t,u)||V(t,n)){const o={...v,...c};return!o.vision&&O(n)&&(o.vision=!0),o}const g={...v};return!g.vision&&O(n)&&(g.vision=!0),g}function se(i,n,u=0){if(!i||i.length===0||u>6)return null;const s=i.map(t=>{!t.includes("/")&&(n!=null&&n[t]);const c=t.indexOf("/"),o=c===-1?null:t.slice(0,c),m=c===-1?t:t.slice(c+1);return U(o,m)}),g=s[0];return{vision:s.some(t=>t.vision),pdf:s.some(t=>t.pdf),audioInput:s.some(t=>t.audioInput),videoInput:s.some(t=>t.videoInput),imageOutput:s.some(t=>t.imageOutput),audioOutput:s.some(t=>t.audioOutput),search:s.some(t=>t.search),tools:s.every(t=>t.tools),reasoning:g.reasoning,thinkingFormat:g.thinkingFormat,thinkingCanDisable:g.thinkingCanDisable,thinkingRange:g.thinkingRange,thinkingEffortSupported:g.thinkingEffortSupported,contextWindow:Math.min(...s.map(t=>t.contextWindow)),maxOutput:Math.max(...s.map(t=>t.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 ne(i){if(!i)return null;const n=i.indexOf("/"),u=n===-1?null:i.slice(0,n),s=n===-1?i:i.slice(n+1);return U(u,s)}const ie=({caps:i,model:n,className:u="",showLabels:s=!1,size:g="sm"})=>{const t=i||(n?ne(n):null);if(!t)return null;const c=!!t.vision,o=!!t.pdf,m=!!(t.audioInput||t.audio),E=!!(t.reasoning||t.thinking||t.thinkingFormat&&t.thinkingFormat!==null),x=[];if(c&&x.push(S.vision),o&&x.push(S.pdf),m&&x.push(S.audio),E&&x.push(S.thinking),x.length===0)return null;const N={xs:"text-[12px]",sm:"text-[14px]",md:"text-[16px]"},f={xs:"text-[9.5px]",sm:"text-[10.5px]",md:"text-xs"};return a.jsx("div",{className:`inline-flex items-center gap-1.5 flex-wrap ${u}`,children:x.map(l=>a.jsxs("span",{title:`${l.label}: ${l.desc}`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md border font-medium transition-all ${l.colorClass} ${l.bgClass} ${l.borderClass} ${f[g]}`,children:[a.jsx("span",{className:`material-symbols-outlined leading-none ${N[g]}`,children:l.icon}),s&&a.jsx("span",{children:l.label})]},l.key))})};let D=null,j=null;const L=new Set;function ae(i){return L.add(i),()=>{L.delete(i)}}function ue(){D=null,j=null;for(const i of L)try{i()}catch(n){console.error("Error in model cache invalidation listener:",n)}}function K(){return j?Promise.resolve(j):(D||(D=fetch("/api/models/available").then(i=>{if(!i.ok)throw new Error("Failed to load models");return i.json()}).then(i=>(j=i,i)).catch(i=>{throw D=null,i})),D)}const ce=({value:i,onChange:n,onEnter:u,placeholder:s="Search model (e.g. openai/gpt-4o)...",className:g="",autoFocus:t=!1,connectedOnly:c=!0,disabled:o=!1,excludeValues:m,allowCombos:E=!0})=>{const[x,N]=h.useState([]),[f,l]=h.useState(!1),[b,k]=h.useState(-1),[C,$]=h.useState(c),[G,B]=h.useState("bottom"),y=h.useRef(null),T=h.useRef(null);h.useEffect(()=>{if(f&&y.current){const e=y.current.getBoundingClientRect(),p=280,d=window.innerHeight-e.bottom,w=e.top;d<p&&w>d?B("top"):B("bottom")}},[f]),h.useEffect(()=>{let e=!0;const p=()=>{K().then(w=>{e&&N(w)}).catch(()=>{})};p();const d=ae(()=>{e&&p()});return()=>{e=!1,d()}},[]),h.useEffect(()=>{$(c)},[c]),h.useEffect(()=>{const e=p=>{y.current&&!y.current.contains(p.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const q=h.useMemo(()=>x.some(e=>e.hasConnectedAccount),[x]),F=h.useMemo(()=>{const e=(i||"").trim().toLowerCase(),p=new Set((m||[]).map(r=>r.toLowerCase()));let d=x;if(E===!1&&(d=d.filter(r=>!r.isCombo)),p.size>0&&(d=d.filter(r=>!p.has(r.value.toLowerCase())&&!p.has(r.id.toLowerCase()))),C&&q&&(d=d.filter(r=>r.hasConnectedAccount)),!e)return d.slice(0,50);const w=d.filter(r=>!!(r.value.toLowerCase().includes(e)||r.id.toLowerCase().includes(e)||r.name.toLowerCase().includes(e)||r.providerName.toLowerCase().includes(e)||r.providerId.toLowerCase().includes(e)||r.isCombo&&(r.strategy&&r.strategy.toLowerCase().includes(e)||r.models&&r.models.some(A=>A.toLowerCase().includes(e)))));return w.sort((r,I)=>{const A=r.value.toLowerCase(),R=I.value.toLowerCase(),P=r.id.toLowerCase(),_=I.id.toLowerCase();return A===e||P===e?-1:R===e||_===e?1:A.startsWith(e)||P.startsWith(e)?-1:R.startsWith(e)||_.startsWith(e)?1:r.isCombo&&!I.isCombo?-1:!r.isCombo&&I.isCombo?1:0}),w.slice(0,50)},[x,i,C,q,m,E]);h.useEffect(()=>{if(b>=0&&T.current){const e=T.current.children[b];e&&e.scrollIntoView({block:"nearest"})}},[b]);const Y=e=>{if(!o)if(e.key==="ArrowDown")e.preventDefault(),f?k(p=>p<F.length-1?p+1:0):l(!0);else if(e.key==="ArrowUp")e.preventDefault(),f?k(p=>p>0?p-1:F.length-1):l(!0);else if(e.key==="Enter")if(f&&b>=0&&F[b]){e.preventDefault();const p=F[b];n(p.value),l(!1),k(-1),u&&u()}else l(!1),u&&(e.preventDefault(),u());else e.key==="Escape"&&(e.preventDefault(),l(!1),k(-1))},J=e=>{n(e),l(!1),k(-1)};return a.jsxs("div",{ref:y,className:"relative w-full",children:[a.jsx("input",{type:"text",value:i,onChange:e=>{n(e.target.value),f||l(!0),k(-1)},onFocus:()=>{(x.length===0||!j)&&K().then(e=>N(e)).catch(()=>{}),l(!0)},onKeyDown:Y,placeholder:s,disabled:o,autoFocus:t,className:g||"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"}),i&&!o&&a.jsx("button",{type:"button",onClick:()=>{n(""),k(-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:a.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"close"})}),f&&a.jsxs("div",{className:`absolute left-0 right-0 ${G==="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:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#1E293B] bg-[#05070B] text-[11px]",children:[a.jsxs("span",{className:"text-slate-400 font-mono text-[10.5px]",children:[F.length," models ",i.trim()?"found":"available"]}),a.jsxs("button",{type:"button",onMouseDown:e=>{e.preventDefault(),$(!C)},className:`px-2 py-0.5 rounded-md font-sans text-[10.5px] font-medium flex items-center gap-1 transition-all cursor-pointer ${C?"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:C?"Showing only models from connected accounts. Click to show all catalog models.":"Showing all catalog models. Click to filter by connected accounts.",children:[a.jsx("span",{className:"material-symbols-outlined text-[12px]",children:C?"check":"filter_alt"}),"Connected only"]})]}),a.jsx("div",{ref:T,className:"max-h-56 overflow-y-auto divide-y divide-[#1E293B]/40",children:F.length===0?a.jsxs("div",{className:"p-3 text-center text-xs text-slate-500 space-y-1",children:[a.jsx("p",{children:"No matching models in catalog."}),a.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."}),C&&!q&&a.jsx("button",{type:"button",onMouseDown:e=>{e.preventDefault(),$(!1)},className:"mt-1 text-[11px] text-blue-400 hover:underline",children:"View all registry models"})]}):F.map((e,p)=>{const d=p===b,w=e.value===i;return a.jsxs("div",{onMouseDown:r=>{r.preventDefault(),J(e.value)},onMouseEnter:()=>k(p),className:`px-3 py-2 cursor-pointer transition-colors flex items-center justify-between gap-2.5 ${d?"bg-blue-600/20 text-white":w?"bg-[#141B2D] text-slate-100":"hover:bg-white/5 text-slate-300"}`,children:[a.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[a.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.isCombo?a.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"}):a.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}),a.jsx("span",{className:"font-medium text-xs text-slate-100 truncate",children:e.name}),e.isCombo&&e.strategy&&a.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&&a.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?a.jsxs("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:[a.jsxs("span",{className:"text-cyan-400 font-semibold",children:[e.models.length," model",e.models.length>1?"s":"",":"]})," ",a.jsxs("span",{className:"text-slate-300",children:[e.models.slice(0,3).join(", "),e.models.length>3?` +${e.models.length-3} more`:""]})]}):a.jsx("div",{className:"font-mono text-[10.5px] text-slate-400 truncate",children:e.value})]}),a.jsx("div",{className:"shrink-0 flex items-center gap-1.5",children:a.jsx(ie,{caps:e.caps,size:"xs",showLabels:!1})})]},e.value)})})]})]})};export{ie as C,ce as M,se as a,K as b,U as g,ue as i,ae as o};