switchboard-router 0.6.30 → 0.6.31

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 (118) hide show
  1. package/app/.next-cli-build/BUILD_ID +1 -1
  2. package/app/.next-cli-build/app-path-routes-manifest.json +6 -6
  3. package/app/.next-cli-build/build-manifest.json +2 -2
  4. package/app/.next-cli-build/prerender-manifest.json +3 -3
  5. package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
  6. package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
  7. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
  8. package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  9. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  10. package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
  11. package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
  12. package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  13. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
  14. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
  15. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
  16. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
  17. package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
  18. package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
  19. package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  20. package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  21. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page.js +3 -3
  22. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  23. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  24. package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  25. package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
  26. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
  27. package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
  28. package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
  29. package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  30. package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  31. package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
  32. package/app/.next-cli-build/server/app/_global-error.html +1 -1
  33. package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
  34. package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
  35. package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  36. package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  37. package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
  38. package/app/.next-cli-build/server/app/_not-found.html +1 -1
  39. package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
  40. package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
  41. package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
  42. package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  43. package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
  44. package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
  45. package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
  46. package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
  47. package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
  48. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
  49. package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
  50. package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
  51. package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
  52. package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
  53. package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +2 -2
  54. package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
  55. package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +2 -2
  56. package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +1 -1
  57. package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
  58. package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
  59. package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
  60. package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
  61. package/app/.next-cli-build/server/app/api/v1/models/info/route.js +1 -1
  62. package/app/.next-cli-build/server/app/api/v1beta/models/route.js +1 -1
  63. package/app/.next-cli-build/server/app/api/version/route.js +1 -1
  64. package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
  65. package/app/.next-cli-build/server/app/callback.html +1 -1
  66. package/app/.next-cli-build/server/app/callback.rsc +3 -3
  67. package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
  68. package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
  69. package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +3 -3
  70. package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  71. package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
  72. package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
  73. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
  74. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
  75. package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +3 -3
  76. package/app/.next-cli-build/server/app/index.html +1 -1
  77. package/app/.next-cli-build/server/app/index.rsc +3 -3
  78. package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  79. package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
  80. package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
  81. package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
  82. package/app/.next-cli-build/server/app/landing.html +1 -1
  83. package/app/.next-cli-build/server/app/landing.rsc +3 -3
  84. package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
  85. package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
  86. package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +3 -3
  87. package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
  88. package/app/.next-cli-build/server/app/login.html +1 -1
  89. package/app/.next-cli-build/server/app/login.rsc +3 -3
  90. package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +3 -3
  91. package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
  92. package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +3 -3
  93. package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
  94. package/app/.next-cli-build/server/app-paths-manifest.json +6 -6
  95. package/app/.next-cli-build/server/chunks/1350.js +1 -1
  96. package/app/.next-cli-build/server/chunks/1421.js +1 -1
  97. package/app/.next-cli-build/server/chunks/194.js +1 -1
  98. package/app/.next-cli-build/server/chunks/6985.js +1 -1
  99. package/app/.next-cli-build/server/chunks/7454.js +1 -1
  100. package/app/.next-cli-build/server/chunks/869.js +1 -1
  101. package/app/.next-cli-build/server/chunks/8998.js +4 -4
  102. package/app/.next-cli-build/server/chunks/9062.js +1 -1
  103. package/app/.next-cli-build/server/chunks/9696.js +1 -1
  104. package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
  105. package/app/.next-cli-build/server/middleware.js +8 -8
  106. package/app/.next-cli-build/server/pages/404.html +1 -1
  107. package/app/.next-cli-build/server/pages/500.html +1 -1
  108. package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
  109. package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
  110. package/app/.next-cli-build/static/chunks/1321-91e485d6232fe450.js +1 -0
  111. package/app/.next-cli-build/static/chunks/{5497-53b1dd3f23fb96bc.js → 5497-0cbb034d03b47b7c.js} +1 -1
  112. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-463c649c2ddabc82.js +10 -0
  113. package/app/package.json +1 -1
  114. package/package.json +1 -1
  115. package/app/.next-cli-build/static/chunks/1321-5250bb46aa281ab5.js +0 -1
  116. package/app/.next-cli-build/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-1ec149c6b914249d.js +0 -10
  117. /package/app/.next-cli-build/static/{dTnRQJQsV_UGBAsupqJ2u → _G05wV0ToAcQtfhzFIbzm}/_buildManifest.js +0 -0
  118. /package/app/.next-cli-build/static/{dTnRQJQsV_UGBAsupqJ2u → _G05wV0ToAcQtfhzFIbzm}/_ssgManifest.js +0 -0
@@ -4,4 +4,4 @@
4
4
  `,children:[C.includes(e.name)&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),e.name,(0,s.jsx)("span",{className:"rounded bg-black/10 px-1 py-px text-[9px] font-normal opacity-70 dark:bg-white/10",children:"combo"})]},e.id)})})]}),Object.entries(Z).map(([e,t])=>(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,s.jsx)(d.A,{src:`/providers/${e}.png`,alt:t.name,size:14,fallbackText:(t.name||e).slice(0,2).toUpperCase(),fallbackColor:t.color}),(0,s.jsx)("span",{className:"text-xs font-medium text-primary",children:t.name}),(0,s.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",t.models.length,")"]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.models.map(e=>{let t=l===e.value,a=e.isPlaceholder;return(0,s.jsx)("button",{onClick:()=>ee(e),title:a?"Select to pre-fill, then edit model ID in the input":void 0,className:`
5
5
  px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer
6
6
  ${a?"border-dashed border-border text-text-muted hover:border-primary/50 hover:text-primary bg-surface italic":t?"bg-primary text-on-primary border-primary":C.includes(e.value)?"bg-primary border-primary text-on-primary hover:bg-primary-hover":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
7
- `,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[C.includes(e.value)&&!a&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"}),(0,s.jsx)(c.default,{caps:T(e.value)})]}):(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)(c.default,{caps:T(e.value)})]})]})},e.value)})})]},e)),0===Object.keys(Z).length&&0===X.length&&(0,s.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,s.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}j.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSelect:l().func.isRequired,onDeselect:l().func,selectedModel:l().string,activeProviders:l().arrayOf(l().shape({provider:l().string.isRequired})),title:l().string,modelAliases:l().object,kindFilter:l().string,addedModelValues:l().arrayOf(l().string),closeOnSelect:l().bool,selectionHint:l().string,excludeCombo:l().string}},73579:(e,t,a)=>{a.d(t,{default:()=>x});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(81127),o=a(11910),d=a(92542),c=a(56061),m=a(88105),u=a(98);function x({isOpen:e,connection:t,onSave:a,onClose:n}){let[i,p]=(0,r.useState)({name:"",priority:1,apiKey:""}),[h,f]=(0,r.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[b,g]=(0,r.useState)({accountId:""}),[v,j]=(0,r.useState)(""),[y,N]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),[O,F]=(0,r.useState)(null),[A,I]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(t){p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData&&f({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}),"cloudflare-ai"===t.provider&&t.providerSpecificData&&g({accountId:t.providerSpecificData.accountId||""});let e=m.Q2?.[t.provider];e?.regions&&j(t.providerSpecificData?.region||e.defaultRegion||e.regions[0]?.id||""),w(null),F(null)}},[t]);let T=t?.authType==="oauth",E=t?.provider==="azure",W=t?.provider==="cloudflare-ai",$=!!t&&((0,m.mq)(t.provider)||(0,m.gb)(t.provider)),P=t&&m.Q2?.[t.provider]?.regions||null,M=()=>{if(P&&v)return{...t?.providerSpecificData||{},region:v}},R=async()=>{if(t?.provider){N(!0),w(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),a=await e.json();w(a.valid?"success":"failed")}catch{w("failed")}finally{N(!1)}}},z=async()=>{if(t?.provider&&i.apiKey){S(!0),F(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:i.apiKey,...E?{providerSpecificData:h}:{},...W?{providerSpecificData:b}:{},...P?{providerSpecificData:M()}:{}})}),a=await e.json();F(a.valid?"success":"failed")}catch{F("failed")}finally{S(!1)}}},L=async()=>{if(t){I(!0);try{let e={name:i.name,priority:i.priority};if(!T&&i.apiKey){e.apiKey=i.apiKey;let a="success"===O;if(!a)try{S(!0),F(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:i.apiKey,...E?{providerSpecificData:h}:{},...W?{providerSpecificData:b}:{},...P?{providerSpecificData:M()}:{}})});a=!!(await e.json()).valid,F(a?"success":"failed")}catch{F("failed")}finally{S(!1)}a&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}E&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),W&&(e.providerSpecificData={accountId:b.accountId}),P&&v&&(e.providerSpecificData=M()),await a(e)}finally{I(!1)}}};return t?(0,s.jsx)(l.default,{isOpen:e,title:"Edit Connection",onClose:n,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.default,{label:"Name",value:i.name,onChange:e=>p({...i,name:e.target.value}),placeholder:T?"Account name":"Production Key"}),T&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),(0,s.jsx)(o.default,{label:"Priority",type:"number",min:1,value:i.priority,onChange:e=>p({...i,priority:Number.parseInt(e.target.value,10)||1})}),!T&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.default,{label:"API Key",type:"password",autoComplete:"off",value:i.apiKey,onChange:e=>p({...i,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.default,{onClick:z,disabled:!i.apiKey||C||A,variant:"secondary",children:C?"Checking...":"Check"})})]}),O&&(0,s.jsx)(c.default,{variant:"success"===O?"success":"error",children:"success"===O?"Valid":"Invalid"})]}),E&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,s.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>f({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,s.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>f({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,s.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>f({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,s.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>f({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),P&&(0,s.jsx)(u.default,{label:"Region",value:v,onChange:e=>j(e.target.value),options:P.map(e=>({value:e.id,label:e.label}))}),!$&&!E&&!W&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(d.default,{onClick:R,variant:"secondary",disabled:y,children:y?"Testing...":"Test Connection"}),k&&(0,s.jsx)(c.default,{variant:"success"===k?"success":"error",children:"success"===k?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.default,{onClick:L,fullWidth:!0,disabled:A,children:A?"Saving...":"Save"}),(0,s.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}x.propTypes={isOpen:i().bool.isRequired,connection:i().shape({id:i().string,name:i().string,email:i().string,priority:i().number,authType:i().string,provider:i().string,providerSpecificData:i().object}),onSave:i().func.isRequired,onClose:i().func.isRequired}},76361:(e,t,a)=>{a.d(t,{default:()=>u});var s=a(95155),r=a(12115),n=a(73321),i=a(65921),l=a(92622),o=a(8823),d=a(81127),c=a(77251);function m(){let e=(0,c.I)(e=>e.request),t=(0,c.I)(e=>e.settle);return(0,s.jsx)(d.ConfirmModal,{isOpen:!!e,onClose:()=>t(!1),onConfirm:()=>t(!0),title:e?.title||"Confirm",message:e?.message||"Continue?",confirmText:e?.confirmText||"Confirm",cancelText:e?.cancelText||"Cancel",variant:e?.variant||"danger"})}function u({children:e}){let[t,a]=(0,r.useState)(!1),d=(0,n.usePathname)(),c=(0,i.i)(e=>e.notifications),x=(0,i.i)(e=>e.removeNotification),p="/dashboard/basic-chat"===d;return(0,s.jsxs)("div",{className:"flex h-screen w-full overflow-hidden",style:{background:"#16130E"},children:[(0,s.jsx)("div",{className:"fixed top-4 right-4 z-[80] flex w-[min(92vw,380px)] flex-col gap-2",children:c.map(e=>{var t;let a="success"===(t=e.type)?{wrapper:"border-[#74C08A]/35 bg-[#74C08A]/10 text-[#74C08A]",icon:"check_circle"}:"error"===t?{wrapper:"border-[#E07070]/35 bg-[#E07070]/10 text-[#E07070]",icon:"error"}:"warning"===t?{wrapper:"border-[#E5B454]/35 bg-[#E5B454]/10 text-[#E5B454]",icon:"warning"}:{wrapper:"border-[#8A9EB8]/35 bg-[#8A9EB8]/10 text-[#8A9EB8]",icon:"info"};return(0,s.jsx)("div",{className:`rounded-lg border px-3 py-2 shadow-lg backdrop-blur-sm ${a.wrapper}`,style:{background:"#1E1A13"},children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px] leading-5",children:a.icon}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[e.title?(0,s.jsx)("p",{className:"text-xs font-semibold mb-0.5",children:e.title}):null,(0,s.jsx)("p",{className:"text-xs whitespace-pre-wrap break-words",children:e.message})]}),e.dismissible?(0,s.jsx)("button",{type:"button",onClick:()=>x(e.id),className:"text-current/70 hover:text-current","aria-label":"Dismiss notification",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})}):null]})},e.id)})}),(0,s.jsx)(m,{}),t&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/40 lg:hidden",onClick:()=>a(!1)}),(0,s.jsx)("div",{className:"hidden lg:flex h-full",children:(0,s.jsx)(l.default,{})}),(0,s.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(l.default,{onClose:()=>a(!1)})}),(0,s.jsxs)("main",{className:"flex flex-col flex-1 h-full min-w-0 relative isolate",children:[(0,s.jsx)(o.default,{onMenuClick:()=>a(!0)},d),(0,s.jsx)("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${p?"flex flex-col overflow-hidden":""}`,style:{background:"#16130E"},children:(0,s.jsx)("div",{className:p?"flex-1 w-full h-full flex flex-col":"w-full",style:p?void 0:{padding:22},children:e})})]})]})}},80752:(e,t,a)=>{a.d(t,{default:()=>m});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(1620),o=a(40197),d=a(81127);function c({icon:e,label:t,onClick:a,trailing:r,danger:n}){return(0,s.jsxs)("button",{onClick:a,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${n?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[20px] ${n?"":"text-text-muted"}`,children:e}),(0,s.jsx)("span",{className:"flex-1 text-left",children:t}),r&&(0,s.jsx)("span",{className:"text-base",children:r})]})}function m(){let[e,t]=(0,r.useState)(!1),[a,n]=(0,r.useState)(!1),[i,m]=(0,r.useState)(!1),[u,x]=(0,r.useState)(!1),{toggleTheme:p,isDark:h}=(0,l.D)(),f=(0,r.useRef)(null),b=async()=>{x(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}x(!1),m(!1)};return(0,r.useEffect)(()=>{let a=e=>{f.current&&!f.current.contains(e.target)&&t(!1)};if(e)return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[e]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",ref:f,children:[(0,s.jsx)("button",{onClick:()=>t(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),e&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,s.jsx)(c,{icon:"history",label:"Change Log",onClick:()=>{t(!1),n(!0)}}),(0,s.jsx)(c,{icon:h?"light_mode":"dark_mode",label:"Theme",onClick:()=>{p(),t(!1)}}),(0,s.jsx)(c,{icon:"power_settings_new",label:"Shutdown",danger:!0,onClick:()=>{t(!1),m(!0)}})]})]}),(0,s.jsx)(o.default,{isOpen:a,onClose:()=>n(!1)}),(0,s.jsx)(d.ConfirmModal,{isOpen:i,onClose:()=>m(!1),onConfirm:b,title:"Shutdown",message:"Are you sure you want to close the proxy server?",confirmText:"Shutdown",cancelText:"Cancel",variant:"danger",loading:u})]})}c.propTypes={icon:i().string.isRequired,label:i().string.isRequired,onClick:i().func.isRequired,trailing:i().node,danger:i().bool}},81127:(e,t,a)=>{a.d(t,{ConfirmModal:()=>d,default:()=>o});var s=a(95155),r=a(12115),n=a(31474),i=a(92542),l=a(97677);function o({isOpen:e,onClose:t,title:a,children:i,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:u=!0,className:x}){return((0,r.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,r.useEffect)(()=>{let a=a=>{"Escape"===a.key&&e&&t()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t]),e)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,s.jsxs)("div",{className:(0,n.cn)("relative w-full bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],x),children:[(a||u)&&(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[u&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,s.jsx)(l.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,s.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,s.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),a&&(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:a})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,s.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:i}),d&&(0,s.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:a,title:r="Confirm",message:n,confirmText:l="Confirm",cancelText:c="Cancel",variant:m="danger",loading:u=!1}){return(0,s.jsx)(o,{isOpen:e,onClose:t,title:r,size:"sm",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.default,{variant:"ghost",onClick:t,disabled:u,children:c}),(0,s.jsx)(i.default,{variant:m,onClick:a,loading:u,children:l})]}),children:(0,s.jsx)("p",{className:"text-text-muted",children:n})})}},81231:(e,t,a)=>{a.d(t,{Iz:()=>r,M0:()=>l,R3:()=>i,qi:()=>o,uJ:()=>n});var s=a(36861);function r(e,t=""){return new Set((Array.isArray(e)?e:[]).map(e=>(0,s.v)(e,t)).filter(Boolean))}function n(e,t,a=""){return e.has((0,s.v)(t,a))}function i({customModels:e=[],modelAliases:t={},providerAlias:a,builtInModels:s=[],type:r="llm",includeLegacyAliases:n=!0}){let l=new Set(s.map(e=>e.id)),o=new Set,d=[];for(let t of e){if(!t?.id||t.providerAlias!==a)continue;let e=t?.kind||t?.type||"llm";if(r&&e!==r||l.has(t.id))continue;let s=`${a}/${t.id}`;o.has(s)||(o.add(s),d.push({id:t.id,name:t.name||t.id,fullModel:s,source:"custom",type:e}))}if(!n)return d;let c=`${a}/`;for(let[e,a]of Object.entries(t||{})){if("string"!=typeof a||!a.startsWith(c))continue;let t=a.slice(c.length);!t||l.has(t)||o.has(a)||(o.add(a),d.push({id:t,alias:e,fullModel:a,source:"legacyAlias",type:r||"llm"}))}return d}function l({providerAlias:e,builtInModels:t=[],customModels:a=[],modelAliases:s={},liveModels:r=[],liveCatalogLoaded:n=!1}){let o=[],d=new Map,c=e=>{!e?.id||!e?.value||d.has(e.value)||(d.set(e.value,e),o.push(e))};for(let a of t)a?.id&&c({...a,name:a.name||a.id,value:`${e}/${a.id}`});for(let r of i({customModels:a,modelAliases:s,providerAlias:e,builtInModels:t,type:"llm"}))c({id:r.id,name:r.name||r.alias||r.id,value:r.fullModel,type:r.type,isCustom:!0});if(!n)return o;let m=[],u=new Set,x=`${e}/`;for(let e of r){if("string"!=typeof e?.id||!e.id.startsWith(x))continue;let t=e.id.slice(x.length);if(!t||u.has(e.id))continue;u.add(e.id);let a=d.get(e.id);m.push({...a||{},id:t,name:e.name||a?.name||t,value:e.id,kind:e.kind||a?.kind,capabilities:e.capabilities||a?.capabilities,isCustom:a?.isCustom||!a})}return m}function o({providerId:e,providerAlias:t,customModels:a=[],modelAliases:s={},liveModels:r=[],liveCatalogLoaded:n=!1}){let i=new Map,l=[],d=e=>{!e?.id||!e?.value||i.has(e.value)||(i.set(e.value,e),l.push(e))};for(let[a,r]of Object.entries(s||{})){let s=`${e}/`;if("string"!=typeof r||!r.startsWith(s))continue;let n=r.slice(s.length);d({id:n,name:a,value:`${t}/${n}`})}for(let s of a)s?.id&&s.providerAlias===e&&d({id:s.id,name:s.name||s.id,value:`${t}/${s.id}`,isCustom:!0});if(!n)return l;let c=`${t}/`,m=[],u=new Set;for(let e of r){if("string"!=typeof e?.id||!e.id.startsWith(c)||u.has(e.id))continue;let t=e.id.slice(c.length);if(!t)continue;u.add(e.id);let a=i.get(e.id);m.push({...a||{},id:t,name:e.name||a?.name||t,value:e.id,kind:e.kind||a?.kind,capabilities:e.capabilities||a?.capabilities,isCustom:a?.isCustom||!a})}return m.length>0?m:l}},90882:(e,t,a)=>{a.d(t,{default:()=>c});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497),o=a(11059),d=a(78559);function c({isOpen:e,provider:t,providerInfo:a,onSuccess:n,onClose:i,oauthMeta:m,idcConfig:u}){let[x,p]=(0,r.useState)("waiting"),[h,f]=(0,r.useState)(null),[b,g]=(0,r.useState)(""),[v,j]=(0,r.useState)(null),[y,N]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),O=(0,r.useRef)(null),F=(0,r.useRef)(!1),A=(0,r.useRef)(!1),{copied:I,copy:T}=(0,o.C)(),[E,W]=(0,r.useState)(!1),[$,P]=(0,r.useState)("/callback?code=..."),M=(0,r.useRef)(!1);(0,r.useEffect)(()=>{W("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),P(`${window.location.origin}/callback?code=...`)},[]);let R=(0,r.useCallback)(async(e,a)=>{if(h)try{let s=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:h.redirectUri,codeVerifier:h.codeVerifier,state:a,...m?{meta:m}:{}})}),r=await s.json();if(!s.ok)throw Error(r.error);p("success"),n?.()}catch(e){j(e.message),p("error")}},[h,t,n,m]),z=(0,r.useCallback)(async e=>{if(h?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:h.state})}),a=await t.json();if(!t.ok)throw Error(a.error);p("success"),n?.()}catch(e){j(e.message),p("error")}},[h,n]),L=(0,r.useCallback)(async(e,a,s,r,i)=>{F.current=!1,S(!0);let l=Date.now()+(Number.isFinite(i)&&i>0?i:12e4);for(;Date.now()<l;){if(F.current||(await new Promise(e=>setTimeout(e,1e3*s)),F.current))return void S(!1);try{let i=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:a,extraData:r})}),l=await i.json();if(l.success){F.current=!0,p("success"),S(!1),n?.();return}if("expired_token"===l.error||"access_denied"===l.error)throw Error(l.errorDescription||l.error);"slow_down"===l.error&&(s=Math.min(s+5,30))}catch(e){j(e.message),p("error"),S(!1);return}}j("Authorization timeout"),p("error"),S(!1)},[t,n]),q=(0,r.useCallback)(async()=>{if(t)try{let e;if(j(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy-cn","qoder"].includes(t)){N(!0),p("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&u?.startUrl&&(e.searchParams.set("start_url",u.startUrl),u.region&&e.searchParams.set("region",u.region),e.searchParams.set("auth_method","idc"));let a=await fetch(e.toString()),s=await a.json();if(!a.ok)throw Error(s.error);w(s);let r=s.verification_uri_complete||s.verification_uri;r&&window.open(r,"_blank","noopener,noreferrer");let n="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region,_authMethod:s._authMethod,_startUrl:s._startUrl,_profileArn:u?.profileArn}:"qoder"===t?{_qoderNonce:s._qoderNonce,_qoderMachineId:s._qoderMachineId,_qoderVerifier:s.codeVerifier}:null;L(s.device_code,s.codeVerifier,s.interval||5,n,Number.isFinite(s.expires_in)&&s.expires_in>0?1e3*s.expires_in:void 0);return}let a=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":`http://localhost:${a}/callback`;let s=new URL(`/api/oauth/${t}/authorize`,window.location.origin);s.searchParams.set("redirect_uri",e),m&&Object.entries(m).forEach(([e,t])=>{t&&"clientSecret"!==e&&s.searchParams.set(e,t)});let r=await fetch(s.toString()),n=await r.json();if(!r.ok)throw Error(n.error);let i=!1,l=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",a),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let s=await fetch(t.toString()),r=await s.json();i=r.success,l=!!r.serverSide}catch{i=!1}let o=!1,d=!1;if("xai"===t)try{let t=new URL("/api/oauth/xai/start-proxy",window.location.origin);t.searchParams.set("app_port",a),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let s=await fetch(t.toString()),r=await s.json();if(o=r.success,d=!!r.serverSide,!o&&"port_busy"===r.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;o=!1}f({...n,redirectUri:e,codexServerSide:l,xaiServerSide:d}),"codex"===t&&i||"xai"===t&&o||E&&"codex"!==t&&"xai"!==t?(p("waiting"),O.current=window.open(n.authUrl,"oauth_popup","width=600,height=700"),O.current||p("input")):(p("input"),window.open(n.authUrl,"_blank"))}catch(e){j(e.message),p("error")}},[t,E,L,m,u]);(0,r.useEffect)(()=>{e&&t?A.current||(A.current=!0,f(null),g(""),j(null),N(!1),w(null),S(!1),F.current=!1,q()):e||(F.current=!0,A.current=!1,"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}))},[e,t,q]),(0,r.useEffect)(()=>{let e=h?.codexServerSide?"codex":h?.xaiServerSide?"xai":null;if(!e||!h?.state||M.current)return;let t=!1,a=0,s=async()=>{if(!t&&!M.current){a+=1;try{let a=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(h.state)}`),s=await a.json();if(t||M.current)return;if("done"===s.status){M.current=!0,p("success"),n?.();return}if("error"===s.status){M.current=!0,j(s.error||"Authentication failed"),p("error");return}}catch{}if(a>=200){M.current=!0,j("Authentication timeout"),p("error");return}setTimeout(s,1500)}};return setTimeout(s,1500),()=>{t=!0}},[h,n]),(0,r.useEffect)(()=>{let e;if(!h)return;M.current=!1;let t=async e=>{if(M.current)return;let{code:t,token:a,state:s,error:r,errorDescription:n}=e;if(r){M.current=!0,j(n||r),p("error");return}(a||t)&&(M.current=!0,await R(a||t,s))},a=e=>{let a=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),s=e.origin===window.location.origin;(a||s)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",a);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){}let s=e=>{if("oauth_callback"===e.key&&e.newValue)try{let a=JSON.parse(e.newValue);t(a),localStorage.removeItem("oauth_callback")}catch(e){(0,d.s)("Failed to parse localStorage data")}};window.addEventListener("storage",s);try{let e=localStorage.getItem("oauth_callback");if(e){let a=JSON.parse(e);a.timestamp&&Date.now()-a.timestamp<3e4&&t(a),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",a),window.removeEventListener("storage",s),e&&e.close()}},[h,R]);let _=async()=>{try{j(null);let e=b.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await R(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await z(e);if("kimchi"===t&&e&&!e.includes("://")&&!e.includes("?"))return void await R(e,null);let a=new URL(e),s=a.searchParams.get("code"),r=a.searchParams.get("token"),n=a.searchParams.get("state"),i=a.searchParams.get("error");if(i)throw Error(a.searchParams.get("error_description")||i);if(!s&&!r)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"kimchi"===t?"No Kimchi token found in URL":"No authorization code found in URL");await R(r||s,n)}catch(e){j(e.message),p("error")}},D=(0,r.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}),i()},[i,t]);if(!t||!a)return null;let U="xai"===t,K="kimchi"===t,B=k?.verification_uri_complete||k?.verification_uri||"",V=U?"Connect Grok Build OAuth":`Connect ${a.name}`,J=U?"http://127.0.0.1:56121/callback?code=... or copied code":K?`${$.replace("code=...","token=...")} or copied token`:$;return(0,s.jsx)(l.aF,{isOpen:e,title:V,onClose:D,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===x||"input"===x)&&!y&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,s.jsx)("span",{className:"text-sm",children:U?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",U?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.pd,{value:h?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(l.$n,{variant:"secondary",icon:"auth_url"===I?"check":"content_copy",onClick:()=>T(h?.authUrl,"auth_url"),disabled:!h?.authUrl,children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":K?"callback URL or copied token":"callback URL"," here"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":K?"After authorization, copy the full callback URL or token from your browser.":"After authorization, copy the full URL from your browser."}),(0,s.jsx)(l.pd,{value:b,onChange:e=>g(e.target.value),placeholder:J,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:_,fullWidth:!0,disabled:!b,children:"Connect"}),(0,s.jsx)(l.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===x&&y&&k&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-sm break-all",children:B}),(0,s.jsx)(l.$n,{size:"sm",variant:"ghost",icon:"login_url"===I?"check":"content_copy",onClick:()=>T(B,"login_url"),disabled:!B}),(0,s.jsx)(l.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(B,"_blank","noopener,noreferrer"),disabled:!B,children:"Open"})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:k.user_code}),(0,s.jsx)(l.$n,{size:"sm",variant:"ghost",icon:"user_code"===I?"check":"content_copy",onClick:()=>T(k.user_code,"user_code")})]})]})]}),C&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",a.name," account has been connected."]}),(0,s.jsx)(l.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:v}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:q,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(l.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}c.propTypes={isOpen:i().bool.isRequired,provider:i().string,providerInfo:i().shape({name:i().string}),onSuccess:i().func,onClose:i().func.isRequired,oauthMeta:i().object,idcConfig:i().shape({startUrl:i().string,region:i().string,profileArn:i().string})}},91450:(e,t,a)=>{a.d(t,{default:()=>l});var s=a(95155),r=a(14051),n=a.n(r),i=a(38587);function l({children:e}){return(0,s.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,s.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,s.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,s.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,s.jsx)(i.default,{variant:"card"})}),(0,s.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}l.propTypes={children:n().node.isRequired}},92173:(e,t,a)=>{a.d(t,{default:()=>c});var s=a(95155),r=a(98500),n=a.n(r),i=a(90620);let l=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,s.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,s.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,s.jsx)("div",{className:"size-6 text-primary",children:(0,s.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,s.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,s.jsx)("span",{className:"text-xl font-bold text-text-main",children:i.vQ.name})]}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:l.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,s.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",i.vQ.name," Inc. All rights reserved."]}),(0,s.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,s.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,s.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,a)=>{a.d(t,{default:()=>l});var s=a(95155),r=a(31474);let n={primary:"bg-brand-500 hover:bg-brand-400 text-[#1B1710] border border-brand-500/80 shadow-sm disabled:bg-surface-3 disabled:text-text-muted disabled:border-transparent",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40 bg-transparent",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main border border-transparent",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},i={sm:"h-8 px-3 text-xs rounded-[7px]",md:"h-9 px-3.5 text-sm rounded-[8px]",lg:"h-11 px-5 text-sm rounded-[10px]"};function l({children:e,variant:t="primary",size:a="md",icon:o,iconRight:d,disabled:c=!1,loading:m=!1,fullWidth:u=!1,className:x,...p}){return(0,s.jsxs)("button",{type:"button",className:(0,r.cn)("inline-flex items-center justify-center gap-1.5 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",n[t],i[a],u&&"w-full",x),disabled:c||m,...p,children:[m?(0,s.jsx)("span",{className:"material-symbols-outlined leading-none animate-spin shrink-0",style:{fontSize:18},children:"progress_activity"}):o?(0,s.jsx)("span",{className:"material-symbols-outlined leading-none shrink-0",style:{fontSize:18},children:o}):null,e?(0,s.jsx)("span",{className:"leading-none",children:e}):null,d&&!m?(0,s.jsx)("span",{className:"material-symbols-outlined leading-none shrink-0",style:{fontSize:18},children:d}):null]})}},92622:(e,t,a)=>{a.d(t,{default:()=>p});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(98500),o=a.n(l),d=a(73321),c=a(90620),m=a(11059),u=a(81127);let x=[{id:"operate",label:"Operate",items:[{href:"/dashboard",label:"Overview",match:e=>"/dashboard"===e},{href:"/dashboard/combos",label:"Combos",match:e=>e.startsWith("/dashboard/combos")},{href:"/dashboard/usage",label:"Usage",match:e=>e.startsWith("/dashboard/usage")},{href:"/dashboard/quota",label:"Quota",match:e=>e.startsWith("/dashboard/quota")}]},{id:"connect",label:"Connect",items:[{href:"/dashboard/providers",label:"Providers",match:e=>e.startsWith("/dashboard/providers")},{href:"/dashboard/endpoint",label:"Endpoint & keys",match:e=>e.startsWith("/dashboard/endpoint")}]},{id:"tools",label:"Tools",items:[{href:"/dashboard/token-saver",label:"Token saver",match:e=>e.startsWith("/dashboard/token-saver")},{href:"/dashboard/media-providers",label:"Media",match:e=>e.startsWith("/dashboard/media-providers")},{href:"/dashboard/skills",label:"Skills",match:e=>e.startsWith("/dashboard/skills")},{href:"/dashboard/agent-library",label:"Agent library",match:e=>e.startsWith("/dashboard/agent-library")},{href:"/dashboard/cli-tools",label:"CLI tools",match:e=>e.startsWith("/dashboard/cli-tools")},{href:"/dashboard/profile",label:"Settings",match:e=>e.startsWith("/dashboard/profile")}]}];function p({onClose:e}){let t=(0,d.usePathname)(),[a,n]=(0,r.useState)(!1),[i,l]=(0,r.useState)(null),[h,f]=(0,r.useState)(!1),[b,g]=(0,r.useState)(!1),[v,j]=(0,r.useState)(0),[y,N]=(0,r.useState)(`127.0.0.1:${c.h0.appPort}`),{copied:k,copy:w}=(0,m.C)(2e3),C=c.h0.installCmdLatest;(0,r.useEffect)(()=>{N(window.location.host||`127.0.0.1:${c.h0.appPort}`)},[]),(0,r.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>{e&&!0===e.hasUpdate&&e.latestVersion&&e.currentVersion&&e.latestVersion!==e.currentVersion?l(e):l(null)}).catch(()=>{l(null)})},[]);let S=async()=>{try{await navigator.clipboard.writeText(C)}catch{}w(C);let e=c.h0.shutdownCountdownSec;j(e);let t=setInterval(()=>{j(e-=1),e<=0&&(clearInterval(t),fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),n(!0))},1e3)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:"flex flex-col min-h-full",style:{width:236,flex:"0 0 236px",background:"#1A160F",borderRight:"1px solid #332C1E"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-[11px]",style:{padding:"16px 18px",borderBottom:"1px solid #2A2418"},children:[(0,s.jsxs)(o(),{href:"/dashboard",onClick:e,className:"flex items-center gap-[11px] min-w-0",children:[(0,s.jsx)("div",{className:"flex items-center justify-center shrink-0",style:{width:27,height:27,borderRadius:7,background:"#E5B454",color:"#1B1710",fontWeight:700,fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace",fontSize:15},children:"S"}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0",style:{lineHeight:1.15},children:[(0,s.jsx)("span",{style:{fontWeight:600,fontSize:14,letterSpacing:"0.2px",color:"#ECE4D2"},children:c.vQ.name}),(0,s.jsx)("span",{style:{fontSize:10.5,color:"#6F6653",fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace"},children:"routing gateway"})]})]}),e?(0,s.jsx)("button",{type:"button",onClick:e,className:"lg:hidden ml-auto text-[#6F6653] hover:text-[#ECE4D2]","aria-label":"Close menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})}):null]}),i&&(0,s.jsxs)("div",{className:"mx-2.5 mt-2 rounded-lg border border-[#332C1E] bg-[#211C14] px-2.5 py-2",children:[(0,s.jsxs)("span",{className:"text-[11px] font-semibold text-[#E5B454]",children:["↑ v",i.latestVersion," available"]}),(0,s.jsx)("button",{type:"button",onClick:()=>f(!0),className:"mt-1 block text-[11px] text-[#A99E86] hover:text-[#E5B454]",children:"Update now"})]}),(0,s.jsxs)("nav",{className:"flex-1 overflow-y-auto custom-scrollbar flex flex-col",style:{padding:"12px 10px",gap:2},children:[x.map(a=>(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"console-nav-section",children:a.label}),a.items.map(a=>{let r=a.match(t);return(0,s.jsxs)(o(),{href:a.href,onClick:e,className:"console-nav-item","data-active":r?"true":"false",children:[(0,s.jsx)("span",{className:"console-nav-dot"}),a.label]},a.href)})]},a.id)),(0,s.jsxs)("div",{style:{marginTop:16,padding:"11px 12px",border:"1px dashed #332C1E",borderRadius:8},children:[(0,s.jsx)("div",{style:{fontSize:10,letterSpacing:"1.4px",color:"#6F6653",textTransform:"uppercase",fontWeight:600,marginBottom:6},children:"Diagnostics"}),(0,s.jsxs)("div",{style:{fontSize:11,color:"#7A7059",fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace",lineHeight:1.7},children:[(0,s.jsx)(o(),{href:"/dashboard/console-log",onClick:e,className:"hover:text-[#E5B454]",children:"console"})," \xb7 ",(0,s.jsx)(o(),{href:"/dashboard/translator",onClick:e,className:"hover:text-[#E5B454]",children:"translator"}),(0,s.jsx)("br",{}),(0,s.jsx)(o(),{href:"/dashboard/mitm",onClick:e,className:"hover:text-[#E5B454]",children:"mitm"})," \xb7 ",(0,s.jsx)(o(),{href:"/dashboard/cli-tools",onClick:e,className:"hover:text-[#E5B454]",children:"cli tools"})]})]})]}),(0,s.jsx)("div",{style:{padding:12,borderTop:"1px solid #2A2418"},children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",style:{background:"#211C14",border:"1px solid #2A2418",borderRadius:8,padding:"9px 11px"},children:[(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{style:{fontSize:9.5,letterSpacing:"1px",color:"#6F6653",textTransform:"uppercase"},children:"Endpoint"}),(0,s.jsx)("span",{className:"truncate",style:{fontSize:11,fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace",color:"#A99E86"},children:y})]}),(0,s.jsx)("span",{className:"console-online-dot",title:"online"})]})})]}),(0,s.jsx)(u.ConfirmModal,{isOpen:h,onClose:()=>f(!1),onConfirm:()=>{f(!1),g(!0)},title:"Update Switchboard",message:"Copy the install command and restart the server after update.",confirmText:"Continue"}),b&&(0,s.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 p-4",children:(0,s.jsxs)("div",{className:"card-soft max-w-md w-full p-5 space-y-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Manual update"}),(0,s.jsx)("code",{className:"block text-[11px] font-mono text-primary break-all bg-surface-2 p-2 rounded",children:C}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:S,className:"px-3 py-1.5 rounded-lg bg-primary text-[#1B1710] text-xs font-semibold",children:[k?"Copied":"Copy & shutdown",v>0?` (${v})`:""]}),(0,s.jsx)("button",{type:"button",onClick:()=>{g(!1),j(0)},className:"px-3 py-1.5 rounded-lg border border-border text-text-muted text-xs",children:"Cancel"})]}),a&&(0,s.jsx)("p",{className:"text-[11px] text-text-subtle font-mono",children:"Server shutting down…"})]})})]})}p.propTypes={onClose:i().func}},94230:(e,t,a)=>{a.d(t,{default:()=>d});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497),o=a(11059);function d({isOpen:e,provider:t,onSuccess:a,onClose:n}){let[i,c]=(0,r.useState)("loading"),[m,u]=(0,r.useState)(""),[x,p]=(0,r.useState)(null),[h,f]=(0,r.useState)(""),[b,g]=(0,r.useState)(null),{copied:v,copy:j}=(0,o.C)(),y=(0,r.useRef)(!1);(0,r.useEffect)(()=>{e||(y.current=!1)},[e]),(0,r.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),a=await e.json();if(!e.ok)throw Error(a.error);p(a),u(a.authUrl),c("input"),y.current||(y.current=!0,window.open(a.authUrl,"_blank"))}catch(e){g(e.message),c("error")}})()},[e,t]);let N=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let s=e.searchParams.get("code");e.searchParams.get("state");let r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!s)throw Error("No authorization code found in URL");let n=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:s,codeVerifier:x.codeVerifier,provider:t})}),i=await n.json();if(!n.ok)throw Error(i.error);c("success"),a?.()}catch(e){g(e.message),c("error")}},k="google"===t?"Google":"GitHub";return(0,s.jsx)(l.aF,{isOpen:e,title:`Connect Kiro via ${k}`,onClose:n,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===i&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",k," authentication"]})]}),"input"===i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(l.$n,{variant:"secondary",icon:"auth_url"===v?"check":"content_copy",onClick:()=>j(m,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(l.pd,{value:h,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:N,fullWidth:!0,disabled:!h,children:"Connect"}),(0,s.jsx)(l.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===i&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",k," has been connected."]}),(0,s.jsx)(l.$n,{onClick:n,fullWidth:!0,children:"Done"})]}),"error"===i&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:b}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(l.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:i().bool.isRequired,provider:i().oneOf(["google","github"]).isRequired,onSuccess:i().func,onClose:i().func.isRequired}},95088:(e,t,a)=>{a.d(t,{default:()=>d});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:a,onClose:n}){let i,[c,m]=(0,r.useState)(null),[u,x]=(0,r.useState)(o),[p,h]=(0,r.useState)(""),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)(null),[w,C]=(0,r.useState)(!1),[S,O]=(0,r.useState)(null),F=()=>{m(null),x(o),h(""),b(""),v(""),k(null),y(!1),C(!1),O(null),n()},A=async()=>{if(!g.trim())return void k("Personal Access Token is required");y(!0),k(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:u.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");a?.(),F()}catch(e){k(e.message)}finally{y(!1)}};return e?w&&S?(0,s.jsx)(l.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{a?.(),F()},onClose:()=>{C(!1),O(null)}}):(0,s.jsx)(l.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:F,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,s.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(i=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${i}/callback`)})]}),(0,s.jsx)(l.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(l.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,s.jsx)(l.pd,{label:"Client Secret (optional for PKCE)",value:f,onChange:e=>b(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:()=>{p.trim()?(k(null),O({baseUrl:u.trim()||o,clientId:p.trim(),clientSecret:f.trim()}),C(!0)):k("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,s.jsx)(l.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,s.jsx)(l.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(l.pd,{label:"Personal Access Token",value:g,onChange:e=>v(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:A,fullWidth:!0,disabled:!g.trim()||j,loading:j,children:"Connect"}),(0,s.jsx)(l.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:i().bool.isRequired,providerInfo:i().shape({name:i().string}),onSuccess:i().func,onClose:i().func.isRequired}},96748:(e,t,a)=>{a.d(t,{default:()=>c});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497),o=a(78559);let d="https://api.openai.com/v1";function c({isOpen:e,onClose:t,onCreated:a,onSaved:n,node:i}){let m=!!i,[u,x]=(0,r.useState)({name:"",baseUrl:d}),[p,h]=(0,r.useState)(!1),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&(k(null),b(""),v(""),m?x({name:i.name||"",baseUrl:i.baseUrl||d}):x({name:"",baseUrl:d}))},[e,m,i]);let w=async()=>{if(u.name.trim()&&u.baseUrl.trim()){h(!0);try{let e=m?`/api/provider-nodes/${i.id}`:"/api/provider-nodes",t=m?"PUT":"POST",s={name:u.name.trim(),baseUrl:u.baseUrl.trim()};m||(s.type="custom-embedding");let r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),l=await r.json();r.ok&&(m?n?.(l.node):a?.(l.node))}catch(e){(0,o.s)("Error saving custom embedding node:",e)}finally{h(!1)}}},C=async()=>{y(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:u.baseUrl,apiKey:f,type:"custom-embedding",modelId:g.trim()||void 0})}),t=await e.json();k(t)}catch{k({valid:!1,error:"Network error"})}finally{y(!1)}};return(0,s.jsx)(l.aF,{isOpen:e,title:m?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(l.pd,{label:"Name",value:u.name,onChange:e=>x({...u,name:e.target.value}),placeholder:"Voyage AI",hint:"Friendly label for this embedding provider."}),(0,s.jsx)(l.pd,{label:"Base URL",value:u.baseUrl,onChange:e=>x({...u,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"OpenAI-compatible embeddings base URL (Voyage, Cohere, Jina, Mistral…)."}),m&&i?.prefix?(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:i.prefix})," ","(auto-assigned)."]}):null,(0,s.jsx)(l.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:f,onChange:e=>b(e.target.value)}),(0,s.jsx)(l.pd,{label:"Model ID (for Check)",value:g,onChange:e=>v(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0",hint:"Required for validation. Sends a small embeddings request."}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(l.$n,{onClick:C,disabled:!f||!g.trim()||j||!u.baseUrl.trim(),variant:"secondary",children:j?"Checking...":"Check"}),(()=>{if(!N)return null;let{valid:e,error:t,dimensions:a}=N;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.Ex,{variant:"success",children:"Valid"}),a&&(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:[a," dims"]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(l.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:w,fullWidth:!0,disabled:!u.name.trim()||!u.baseUrl.trim()||p,children:p?m?"Saving...":"Creating...":m?"Save":"Create"}),(0,s.jsx)(l.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}c.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func,onSaved:i().func,node:i().shape({id:i().string,name:i().string,prefix:i().string,baseUrl:i().string})}},97677:(e,t,a)=>{a.d(t,{default:()=>r});var s=a(95155);function r({text:e,children:t,position:a="top",color:n}){let i=n?"":"bg-gray-900";return(0,s.jsxs)("div",{className:"relative inline-flex group/tt",children:[t,(0,s.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[a]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${i} text-white opacity-0 group-hover/tt:opacity-100 transition-opacity duration-150 whitespace-normal`,style:n?{backgroundColor:n}:{},children:e})]})}},98542:(e,t,a)=>{a.d(t,{default:()=>n});var s=a(95155),r=a(31474);function n({checked:e=!1,onChange:t,label:a,description:i,disabled:l=!1,size:o="md",className:d,title:c}){let m={sm:{track:"w-8 h-4",thumb:"size-3",on:"translate-x-4",off:"translate-x-0.5"},md:{track:"w-11 h-6",thumb:"size-5",on:"translate-x-5",off:"translate-x-0.5"},lg:{track:"w-14 h-7",thumb:"size-6",on:"translate-x-7",off:"translate-x-0.5"}},u=m[o]||m.md;return(0,s.jsxs)("div",{className:(0,r.cn)("flex items-center gap-3",l&&"opacity-50 cursor-not-allowed",d),children:[(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":e,title:c,disabled:l,onClick:()=>{!l&&t&&t(!e)},className:(0,r.cn)("relative inline-flex shrink-0 cursor-pointer items-center rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/35",e?"bg-brand-500":"bg-surface-3 border border-border",u.track,l&&"cursor-not-allowed"),children:(0,s.jsx)("span",{className:(0,r.cn)("pointer-events-none inline-block rounded-full shadow-sm",e?"bg-[#1B1710]":"bg-[#ECE4D2]","transform transition duration-200 ease-in-out",e?u.on:u.off,u.thumb,"mt-0.5")})}),(a||i)&&(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[a&&(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:a}),i&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:i})]})]})}}}]);
7
+ `,children:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[C.includes(e.value)&&!a&&(0,s.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"edit"}),e.name]}):e.isCustom?(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)("span",{className:"text-[9px] opacity-60 font-normal",children:"custom"}),(0,s.jsx)(c.default,{caps:T(e.value)})]}):(0,s.jsxs)(s.Fragment,{children:[e.name,(0,s.jsx)(c.default,{caps:T(e.value)})]})]})},e.value)})})]},e)),0===Object.keys(Z).length&&0===X.length&&(0,s.jsxs)("div",{className:"text-center py-4 text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl mb-1 block",children:"search_off"}),(0,s.jsx)("p",{className:"text-xs",children:"No models found"})]})]})]})}j.propTypes={isOpen:l().bool.isRequired,onClose:l().func.isRequired,onSelect:l().func.isRequired,onDeselect:l().func,selectedModel:l().string,activeProviders:l().arrayOf(l().shape({provider:l().string.isRequired})),title:l().string,modelAliases:l().object,kindFilter:l().string,addedModelValues:l().arrayOf(l().string),closeOnSelect:l().bool,selectionHint:l().string,excludeCombo:l().string}},73579:(e,t,a)=>{a.d(t,{default:()=>x});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(81127),o=a(11910),d=a(92542),c=a(56061),m=a(88105),u=a(98);function x({isOpen:e,connection:t,onSave:a,onClose:n}){let[i,p]=(0,r.useState)({name:"",priority:1,apiKey:""}),[h,f]=(0,r.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[b,g]=(0,r.useState)({accountId:""}),[v,j]=(0,r.useState)(""),[y,N]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),[O,F]=(0,r.useState)(null),[A,I]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(t){p({name:t.name||"",priority:t.priority||1,apiKey:""}),"azure"===t.provider&&t.providerSpecificData&&f({azureEndpoint:t.providerSpecificData.azureEndpoint||"",apiVersion:t.providerSpecificData.apiVersion||"2024-10-01-preview",deployment:t.providerSpecificData.deployment||"",organization:t.providerSpecificData.organization||""}),"cloudflare-ai"===t.provider&&t.providerSpecificData&&g({accountId:t.providerSpecificData.accountId||""});let e=m.Q2?.[t.provider];e?.regions&&j(t.providerSpecificData?.region||e.defaultRegion||e.regions[0]?.id||""),w(null),F(null)}},[t]);let T=t?.authType==="oauth",E=t?.provider==="azure",W=t?.provider==="cloudflare-ai",$=!!t&&((0,m.mq)(t.provider)||(0,m.gb)(t.provider)),P=t&&m.Q2?.[t.provider]?.regions||null,M=()=>{if(P&&v)return{...t?.providerSpecificData||{},region:v}},R=async()=>{if(t?.provider){N(!0),w(null);try{let e=await fetch(`/api/providers/${t.id}/test`,{method:"POST"}),a=await e.json();w(a.valid?"success":"failed")}catch{w("failed")}finally{N(!1)}}},z=async()=>{if(t?.provider&&i.apiKey){S(!0),F(null);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:i.apiKey,...E?{providerSpecificData:h}:{},...W?{providerSpecificData:b}:{},...P?{providerSpecificData:M()}:{}})}),a=await e.json();F(a.valid?"success":"failed")}catch{F("failed")}finally{S(!1)}}},L=async()=>{if(t){I(!0);try{let e={name:i.name,priority:i.priority};if(!T&&i.apiKey){e.apiKey=i.apiKey;let a="success"===O;if(!a)try{S(!0),F(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t.provider,apiKey:i.apiKey,...E?{providerSpecificData:h}:{},...W?{providerSpecificData:b}:{},...P?{providerSpecificData:M()}:{}})});a=!!(await e.json()).valid,F(a?"success":"failed")}catch{F("failed")}finally{S(!1)}a&&(e.testStatus="active",e.lastError=null,e.lastErrorAt=null)}E&&(e.providerSpecificData={azureEndpoint:h.azureEndpoint,apiVersion:h.apiVersion,deployment:h.deployment,organization:h.organization}),W&&(e.providerSpecificData={accountId:b.accountId}),P&&v&&(e.providerSpecificData=M()),await a(e)}finally{I(!1)}}};return t?(0,s.jsx)(l.default,{isOpen:e,title:"Edit Connection",onClose:n,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(o.default,{label:"Name",value:i.name,onChange:e=>p({...i,name:e.target.value}),placeholder:T?"Account name":"Production Key"}),T&&t.email&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,s.jsx)("p",{className:"font-medium",children:t.email})]}),(0,s.jsx)(o.default,{label:"Priority",type:"number",min:1,value:i.priority,onChange:e=>p({...i,priority:Number.parseInt(e.target.value,10)||1})}),!T&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(o.default,{label:"API Key",type:"password",autoComplete:"off",value:i.apiKey,onChange:e=>p({...i,apiKey:e.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,s.jsx)("div",{className:"pt-6",children:(0,s.jsx)(d.default,{onClick:z,disabled:!i.apiKey||C||A,variant:"secondary",children:C?"Checking...":"Check"})})]}),O&&(0,s.jsx)(c.default,{variant:"success"===O?"success":"error",children:"success"===O?"Valid":"Invalid"})]}),E&&(0,s.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,s.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)(o.default,{label:"Azure Endpoint",value:h.azureEndpoint,onChange:e=>f({...h,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,s.jsx)(o.default,{label:"Deployment Name",value:h.deployment,onChange:e=>f({...h,deployment:e.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,s.jsx)(o.default,{label:"API Version",value:h.apiVersion,onChange:e=>f({...h,apiVersion:e.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,s.jsx)(o.default,{label:"Organization",value:h.organization,onChange:e=>f({...h,organization:e.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),P&&(0,s.jsx)(u.default,{label:"Region",value:v,onChange:e=>j(e.target.value),options:P.map(e=>({value:e.id,label:e.label}))}),!$&&!E&&!W&&(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(d.default,{onClick:R,variant:"secondary",disabled:y,children:y?"Testing...":"Test Connection"}),k&&(0,s.jsx)(c.default,{variant:"success"===k?"success":"error",children:"success"===k?"Valid":"Failed"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(d.default,{onClick:L,fullWidth:!0,disabled:A,children:A?"Saving...":"Save"}),(0,s.jsx)(d.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}x.propTypes={isOpen:i().bool.isRequired,connection:i().shape({id:i().string,name:i().string,email:i().string,priority:i().number,authType:i().string,provider:i().string,providerSpecificData:i().object}),onSave:i().func.isRequired,onClose:i().func.isRequired}},76361:(e,t,a)=>{a.d(t,{default:()=>u});var s=a(95155),r=a(12115),n=a(73321),i=a(65921),l=a(92622),o=a(8823),d=a(81127),c=a(77251);function m(){let e=(0,c.I)(e=>e.request),t=(0,c.I)(e=>e.settle);return(0,s.jsx)(d.ConfirmModal,{isOpen:!!e,onClose:()=>t(!1),onConfirm:()=>t(!0),title:e?.title||"Confirm",message:e?.message||"Continue?",confirmText:e?.confirmText||"Confirm",cancelText:e?.cancelText||"Cancel",variant:e?.variant||"danger"})}function u({children:e}){let[t,a]=(0,r.useState)(!1),d=(0,n.usePathname)(),c=(0,i.i)(e=>e.notifications),x=(0,i.i)(e=>e.removeNotification),p="/dashboard/basic-chat"===d;return(0,s.jsxs)("div",{className:"flex h-screen w-full overflow-hidden",style:{background:"#16130E"},children:[(0,s.jsx)("div",{className:"fixed top-4 right-4 z-[80] flex w-[min(92vw,380px)] flex-col gap-2",children:c.map(e=>{var t;let a="success"===(t=e.type)?{wrapper:"border-[#74C08A]/35 bg-[#74C08A]/10 text-[#74C08A]",icon:"check_circle"}:"error"===t?{wrapper:"border-[#E07070]/35 bg-[#E07070]/10 text-[#E07070]",icon:"error"}:"warning"===t?{wrapper:"border-[#E5B454]/35 bg-[#E5B454]/10 text-[#E5B454]",icon:"warning"}:{wrapper:"border-[#8A9EB8]/35 bg-[#8A9EB8]/10 text-[#8A9EB8]",icon:"info"};return(0,s.jsx)("div",{className:`rounded-lg border px-3 py-2 shadow-lg backdrop-blur-sm ${a.wrapper}`,style:{background:"#1E1A13"},children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[18px] leading-5",children:a.icon}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[e.title?(0,s.jsx)("p",{className:"text-xs font-semibold mb-0.5",children:e.title}):null,(0,s.jsx)("p",{className:"text-xs whitespace-pre-wrap break-words",children:e.message})]}),e.dismissible?(0,s.jsx)("button",{type:"button",onClick:()=>x(e.id),className:"text-current/70 hover:text-current","aria-label":"Dismiss notification",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})}):null]})},e.id)})}),(0,s.jsx)(m,{}),t&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/40 lg:hidden",onClick:()=>a(!1)}),(0,s.jsx)("div",{className:"hidden lg:flex h-full",children:(0,s.jsx)(l.default,{})}),(0,s.jsx)("div",{className:`fixed inset-y-0 left-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(l.default,{onClose:()=>a(!1)})}),(0,s.jsxs)("main",{className:"flex flex-col flex-1 h-full min-w-0 relative isolate",children:[(0,s.jsx)(o.default,{onMenuClick:()=>a(!0)},d),(0,s.jsx)("div",{className:`flex-1 overflow-y-auto custom-scrollbar ${p?"flex flex-col overflow-hidden":""}`,style:{background:"#16130E"},children:(0,s.jsx)("div",{className:p?"flex-1 w-full h-full flex flex-col":"w-full",style:p?void 0:{padding:22},children:e})})]})]})}},80752:(e,t,a)=>{a.d(t,{default:()=>m});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(1620),o=a(40197),d=a(81127);function c({icon:e,label:t,onClick:a,trailing:r,danger:n}){return(0,s.jsxs)("button",{onClick:a,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${n?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[20px] ${n?"":"text-text-muted"}`,children:e}),(0,s.jsx)("span",{className:"flex-1 text-left",children:t}),r&&(0,s.jsx)("span",{className:"text-base",children:r})]})}function m(){let[e,t]=(0,r.useState)(!1),[a,n]=(0,r.useState)(!1),[i,m]=(0,r.useState)(!1),[u,x]=(0,r.useState)(!1),{toggleTheme:p,isDark:h}=(0,l.D)(),f=(0,r.useRef)(null),b=async()=>{x(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(e){}x(!1),m(!1)};return(0,r.useEffect)(()=>{let a=e=>{f.current&&!f.current.contains(e.target)&&t(!1)};if(e)return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[e]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative",ref:f,children:[(0,s.jsx)("button",{onClick:()=>t(e=>!e),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),e&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[(0,s.jsx)(c,{icon:"history",label:"Change Log",onClick:()=>{t(!1),n(!0)}}),(0,s.jsx)(c,{icon:h?"light_mode":"dark_mode",label:"Theme",onClick:()=>{p(),t(!1)}}),(0,s.jsx)(c,{icon:"power_settings_new",label:"Shutdown",danger:!0,onClick:()=>{t(!1),m(!0)}})]})]}),(0,s.jsx)(o.default,{isOpen:a,onClose:()=>n(!1)}),(0,s.jsx)(d.ConfirmModal,{isOpen:i,onClose:()=>m(!1),onConfirm:b,title:"Shutdown",message:"Are you sure you want to close the proxy server?",confirmText:"Shutdown",cancelText:"Cancel",variant:"danger",loading:u})]})}c.propTypes={icon:i().string.isRequired,label:i().string.isRequired,onClick:i().func.isRequired,trailing:i().node,danger:i().bool}},81127:(e,t,a)=>{a.d(t,{ConfirmModal:()=>d,default:()=>o});var s=a(95155),r=a(12115),n=a(31474),i=a(92542),l=a(97677);function o({isOpen:e,onClose:t,title:a,children:i,footer:d,size:c="md",closeOnOverlay:m=!0,showTrafficLights:u=!0,className:x}){return((0,r.useEffect)(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),(0,r.useEffect)(()=>{let a=a=>{"Escape"===a.key&&e&&t()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t]),e)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-[2px] fade-in",onClick:m?t:void 0}),(0,s.jsxs)("div",{className:(0,n.cn)("relative w-full bg-surface","border border-border-subtle","rounded-[14px] shadow-[var(--shadow-elev)]","fade-in",{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl",full:"max-w-4xl"}[c],x),children:[(a||u)&&(0,s.jsxs)("div",{className:"flex items-center justify-between p-2 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[u&&(0,s.jsxs)("div",{className:"hidden md:flex items-center gap-2 mr-4 ml-2",children:[(0,s.jsx)(l.default,{text:"Close",position:"top",color:"#FF5F56",children:(0,s.jsx)("button",{onClick:t,"aria-label":"Close",title:"Close",className:"w-4 h-4 rounded-full bg-[#FF5F56] hover:brightness-90 transition-all cursor-pointer flex items-center justify-center group/dot",children:(0,s.jsx)("span",{className:"text-[9px] font-bold text-white opacity-0 group-hover/dot:opacity-100 transition-opacity leading-none",children:"✕"})})}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"}),(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-[#3a3a3a]/20 dark:bg-white/15 cursor-not-allowed"})]}),a&&(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:a})]}),(0,s.jsx)("button",{onClick:t,"aria-label":"Close",className:"md:hidden p-1.5 rounded-[10px] text-text-muted hover:bg-surface-2 hover:text-text-main transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,s.jsx)("div",{className:"p-6 max-h-[calc(85vh-100px)] overflow-y-auto custom-scrollbar",children:i}),d&&(0,s.jsx)("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-border-subtle",children:d})]})]}):null}function d({isOpen:e,onClose:t,onConfirm:a,title:r="Confirm",message:n,confirmText:l="Confirm",cancelText:c="Cancel",variant:m="danger",loading:u=!1}){return(0,s.jsx)(o,{isOpen:e,onClose:t,title:r,size:"sm",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.default,{variant:"ghost",onClick:t,disabled:u,children:c}),(0,s.jsx)(i.default,{variant:m,onClick:a,loading:u,children:l})]}),children:(0,s.jsx)("p",{className:"text-text-muted",children:n})})}},81231:(e,t,a)=>{a.d(t,{Iz:()=>n,M0:()=>o,R3:()=>l,qi:()=>d,uJ:()=>i});var s=a(36861),r=a(68501);function n(e,t=""){return new Set((Array.isArray(e)?e:[]).map(e=>(0,s.v)(e,t)).filter(Boolean))}function i(e,t,a=""){return e.has((0,s.v)(t,a))}function l({customModels:e=[],modelAliases:t={},providerAlias:a,builtInModels:s=[],type:n="llm",includeLegacyAliases:i=!0}){let o=new Set(s.map(e=>e.id)),d=new Set,c=[];for(let t of e){if(!t?.id||t.providerAlias!==a)continue;let e=(0,r.ki)(t?.kind||t?.type||"llm");if(n&&e!==n||o.has(t.id))continue;let s=`${a}/${t.id}`;d.has(s)||(d.add(s),c.push({id:t.id,name:t.name||t.id,fullModel:s,source:"custom",type:e}))}if(!i)return c;let m=`${a}/`;for(let[e,a]of Object.entries(t||{})){if("string"!=typeof a||!a.startsWith(m))continue;let t=a.slice(m.length);!t||o.has(t)||d.has(a)||(d.add(a),c.push({id:t,alias:e,fullModel:a,source:"legacyAlias",type:n||"llm"}))}return c}function o({providerAlias:e,builtInModels:t=[],customModels:a=[],modelAliases:s={},liveModels:r=[],liveCatalogLoaded:n=!1}){let i=[],d=new Map,c=e=>{!e?.id||!e?.value||d.has(e.value)||(d.set(e.value,e),i.push(e))};for(let a of t)a?.id&&c({...a,name:a.name||a.id,value:`${e}/${a.id}`});for(let r of l({customModels:a,modelAliases:s,providerAlias:e,builtInModels:t,type:"llm"}))c({id:r.id,name:r.name||r.alias||r.id,value:r.fullModel,type:r.type,isCustom:!0});if(!n)return i;let m=[],u=new Set,x=`${e}/`;for(let e of r){if("string"!=typeof e?.id||!e.id.startsWith(x))continue;let t=e.id.slice(x.length);if(!t||u.has(e.id))continue;u.add(e.id);let a=d.get(e.id);m.push({...a||{},id:t,name:e.name||a?.name||t,value:e.id,kind:e.kind||a?.kind,capabilities:e.capabilities||a?.capabilities,isCustom:a?.isCustom||!a})}return m}function d({providerId:e,providerAlias:t,customModels:a=[],modelAliases:s={},liveModels:r=[],liveCatalogLoaded:n=!1}){let i=new Map,l=[],o=e=>{!e?.id||!e?.value||i.has(e.value)||(i.set(e.value,e),l.push(e))};for(let[a,r]of Object.entries(s||{})){let s=`${e}/`;if("string"!=typeof r||!r.startsWith(s))continue;let n=r.slice(s.length);o({id:n,name:a,value:`${t}/${n}`})}for(let s of a)s?.id&&s.providerAlias===e&&o({id:s.id,name:s.name||s.id,value:`${t}/${s.id}`,isCustom:!0});if(!n)return l;let c=`${t}/`,m=[],u=new Set;for(let e of r){if("string"!=typeof e?.id||!e.id.startsWith(c)||u.has(e.id))continue;let t=e.id.slice(c.length);if(!t)continue;u.add(e.id);let a=i.get(e.id);m.push({...a||{},id:t,name:e.name||a?.name||t,value:e.id,kind:e.kind||a?.kind,capabilities:e.capabilities||a?.capabilities,isCustom:a?.isCustom||!a})}return m.length>0?m:l}},90882:(e,t,a)=>{a.d(t,{default:()=>c});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497),o=a(11059),d=a(78559);function c({isOpen:e,provider:t,providerInfo:a,onSuccess:n,onClose:i,oauthMeta:m,idcConfig:u}){let[x,p]=(0,r.useState)("waiting"),[h,f]=(0,r.useState)(null),[b,g]=(0,r.useState)(""),[v,j]=(0,r.useState)(null),[y,N]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),[C,S]=(0,r.useState)(!1),O=(0,r.useRef)(null),F=(0,r.useRef)(!1),A=(0,r.useRef)(!1),{copied:I,copy:T}=(0,o.C)(),[E,W]=(0,r.useState)(!1),[$,P]=(0,r.useState)("/callback?code=..."),M=(0,r.useRef)(!1);(0,r.useEffect)(()=>{W("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname),P(`${window.location.origin}/callback?code=...`)},[]);let R=(0,r.useCallback)(async(e,a)=>{if(h)try{let s=await fetch(`/api/oauth/${t}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:h.redirectUri,codeVerifier:h.codeVerifier,state:a,...m?{meta:m}:{}})}),r=await s.json();if(!s.ok)throw Error(r.error);p("success"),n?.()}catch(e){j(e.message),p("error")}},[h,t,n,m]),z=(0,r.useCallback)(async e=>{if(h?.state)try{let t=await fetch("/api/oauth/xai/manual-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,state:h.state})}),a=await t.json();if(!t.ok)throw Error(a.error);p("success"),n?.()}catch(e){j(e.message),p("error")}},[h,n]),L=(0,r.useCallback)(async(e,a,s,r,i)=>{F.current=!1,S(!0);let l=Date.now()+(Number.isFinite(i)&&i>0?i:12e4);for(;Date.now()<l;){if(F.current||(await new Promise(e=>setTimeout(e,1e3*s)),F.current))return void S(!1);try{let i=await fetch(`/api/oauth/${t}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e,codeVerifier:a,extraData:r})}),l=await i.json();if(l.success){F.current=!0,p("success"),S(!1),n?.();return}if("expired_token"===l.error||"access_denied"===l.error)throw Error(l.errorDescription||l.error);"slow_down"===l.error&&(s=Math.min(s+5,30))}catch(e){j(e.message),p("error"),S(!1);return}}j("Authorization timeout"),p("error"),S(!1)},[t,n]),q=(0,r.useCallback)(async()=>{if(t)try{let e;if(j(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy-cn","qoder"].includes(t)){N(!0),p("waiting");let e=new URL(`/api/oauth/${t}/device-code`,window.location.origin);"kiro"===t&&u?.startUrl&&(e.searchParams.set("start_url",u.startUrl),u.region&&e.searchParams.set("region",u.region),e.searchParams.set("auth_method","idc"));let a=await fetch(e.toString()),s=await a.json();if(!a.ok)throw Error(s.error);w(s);let r=s.verification_uri_complete||s.verification_uri;r&&window.open(r,"_blank","noopener,noreferrer");let n="kiro"===t?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region,_authMethod:s._authMethod,_startUrl:s._startUrl,_profileArn:u?.profileArn}:"qoder"===t?{_qoderNonce:s._qoderNonce,_qoderMachineId:s._qoderMachineId,_qoderVerifier:s.codeVerifier}:null;L(s.device_code,s.codeVerifier,s.interval||5,n,Number.isFinite(s.expires_in)&&s.expires_in>0?1e3*s.expires_in:void 0);return}let a=window.location.port||("https:"===window.location.protocol?"443":"80");e="codex"===t?"http://localhost:1455/auth/callback":"xai"===t?"http://127.0.0.1:56121/callback":`http://localhost:${a}/callback`;let s=new URL(`/api/oauth/${t}/authorize`,window.location.origin);s.searchParams.set("redirect_uri",e),m&&Object.entries(m).forEach(([e,t])=>{t&&"clientSecret"!==e&&s.searchParams.set(e,t)});let r=await fetch(s.toString()),n=await r.json();if(!r.ok)throw Error(n.error);let i=!1,l=!1;if("codex"===t)try{let t=new URL("/api/oauth/codex/start-proxy",window.location.origin);t.searchParams.set("app_port",a),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let s=await fetch(t.toString()),r=await s.json();i=r.success,l=!!r.serverSide}catch{i=!1}let o=!1,d=!1;if("xai"===t)try{let t=new URL("/api/oauth/xai/start-proxy",window.location.origin);t.searchParams.set("app_port",a),t.searchParams.set("state",n.state),t.searchParams.set("code_verifier",n.codeVerifier),t.searchParams.set("redirect_uri",e);let s=await fetch(t.toString()),r=await s.json();if(o=r.success,d=!!r.serverSide,!o&&"port_busy"===r.reason)throw Error("Port 56121 in use; close the conflicting process and retry")}catch(e){if(e?.message)throw e;o=!1}f({...n,redirectUri:e,codexServerSide:l,xaiServerSide:d}),"codex"===t&&i||"xai"===t&&o||E&&"codex"!==t&&"xai"!==t?(p("waiting"),O.current=window.open(n.authUrl,"oauth_popup","width=600,height=700"),O.current||p("input")):(p("input"),window.open(n.authUrl,"_blank"))}catch(e){j(e.message),p("error")}},[t,E,L,m,u]);(0,r.useEffect)(()=>{e&&t?A.current||(A.current=!0,f(null),g(""),j(null),N(!1),w(null),S(!1),F.current=!1,q()):e||(F.current=!0,A.current=!1,"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}))},[e,t,q]),(0,r.useEffect)(()=>{let e=h?.codexServerSide?"codex":h?.xaiServerSide?"xai":null;if(!e||!h?.state||M.current)return;let t=!1,a=0,s=async()=>{if(!t&&!M.current){a+=1;try{let a=await fetch(`/api/oauth/${e}/poll-status?state=${encodeURIComponent(h.state)}`),s=await a.json();if(t||M.current)return;if("done"===s.status){M.current=!0,p("success"),n?.();return}if("error"===s.status){M.current=!0,j(s.error||"Authentication failed"),p("error");return}}catch{}if(a>=200){M.current=!0,j("Authentication timeout"),p("error");return}setTimeout(s,1500)}};return setTimeout(s,1500),()=>{t=!0}},[h,n]),(0,r.useEffect)(()=>{let e;if(!h)return;M.current=!1;let t=async e=>{if(M.current)return;let{code:t,token:a,state:s,error:r,errorDescription:n}=e;if(r){M.current=!0,j(n||r),p("error");return}(a||t)&&(M.current=!0,await R(a||t,s))},a=e=>{let a=e.origin.includes("localhost")||e.origin.includes("127.0.0.1"),s=e.origin===window.location.origin;(a||s)&&e.data?.type==="oauth_callback"&&t(e.data.data)};window.addEventListener("message",a);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){}let s=e=>{if("oauth_callback"===e.key&&e.newValue)try{let a=JSON.parse(e.newValue);t(a),localStorage.removeItem("oauth_callback")}catch(e){(0,d.s)("Failed to parse localStorage data")}};window.addEventListener("storage",s);try{let e=localStorage.getItem("oauth_callback");if(e){let a=JSON.parse(e);a.timestamp&&Date.now()-a.timestamp<3e4&&t(a),localStorage.removeItem("oauth_callback")}}catch{}return()=>{window.removeEventListener("message",a),window.removeEventListener("storage",s),e&&e.close()}},[h,R]);let _=async()=>{try{j(null);let e=b.trim();if(e.startsWith("eyJ")&&e.includes("."))return void await R(e,null);if("xai"===t&&e&&!e.includes("://")&&!e.includes("?")&&!e.includes("code="))return void await z(e);if("kimchi"===t&&e&&!e.includes("://")&&!e.includes("?"))return void await R(e,null);let a=new URL(e),s=a.searchParams.get("code"),r=a.searchParams.get("token"),n=a.searchParams.get("state"),i=a.searchParams.get("error");if(i)throw Error(a.searchParams.get("error_description")||i);if(!s&&!r)throw Error("xai"===t?"Paste the callback URL or copied xAI code":"kimchi"===t?"No Kimchi token found in URL":"No authorization code found in URL");await R(r||s,n)}catch(e){j(e.message),p("error")}},D=(0,r.useCallback)(()=>{"codex"===t?fetch("/api/oauth/codex/stop-proxy").catch(()=>{}):"xai"===t&&fetch("/api/oauth/xai/stop-proxy").catch(()=>{}),i()},[i,t]);if(!t||!a)return null;let U="xai"===t,K="kimchi"===t,B=k?.verification_uri_complete||k?.verification_uri||"",V=U?"Connect Grok Build OAuth":`Connect ${a.name}`,J=U?"http://127.0.0.1:56121/callback?code=... or copied code":K?`${$.replace("code=...","token=...")} or copied token`:$;return(0,s.jsx)(l.aF,{isOpen:e,title:V,onClose:D,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[("waiting"===x||"input"===x)&&!y&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,s.jsx)("span",{className:"text-sm",children:U?"Waiting for Grok Build OAuth…":"Waiting for popup authorization…"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 my-1",children:[(0,s.jsx)("div",{className:"flex-1 h-px bg-border"}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Or paste callback URL manually"}),(0,s.jsx)("div",{className:"flex-1 h-px bg-border"})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 1: Open this ",U?"Grok Build OAuth URL":"URL"," in your browser"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.pd,{value:h?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(l.$n,{variant:"secondary",icon:"auth_url"===I?"check":"content_copy",onClick:()=>T(h?.authUrl,"auth_url"),disabled:!h?.authUrl,children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-medium mb-2",children:["Step 2: Paste the ","xai"===t?"callback URL or copied code":K?"callback URL or copied token":"callback URL"," here"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"xai"===t?"If xAI shows a code instead of redirecting, paste that code here.":K?"After authorization, copy the full callback URL or token from your browser.":"After authorization, copy the full URL from your browser."}),(0,s.jsx)(l.pd,{value:b,onChange:e=>g(e.target.value),placeholder:J,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:_,fullWidth:!0,disabled:!b,children:"Connect"}),(0,s.jsx)(l.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"waiting"===x&&y&&k&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("code",{className:"flex-1 text-sm break-all",children:B}),(0,s.jsx)(l.$n,{size:"sm",variant:"ghost",icon:"login_url"===I?"check":"content_copy",onClick:()=>T(B,"login_url"),disabled:!B}),(0,s.jsx)(l.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(B,"_blank","noopener,noreferrer"),disabled:!B,children:"Open"})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:k.user_code}),(0,s.jsx)(l.$n,{size:"sm",variant:"ghost",icon:"user_code"===I?"check":"content_copy",onClick:()=>T(k.user_code,"user_code")})]})]})]}),C&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"success"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",a.name," account has been connected."]}),(0,s.jsx)(l.$n,{onClick:D,fullWidth:!0,children:"Done"})]}),"error"===x&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:v}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:q,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(l.$n,{onClick:D,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}c.propTypes={isOpen:i().bool.isRequired,provider:i().string,providerInfo:i().shape({name:i().string}),onSuccess:i().func,onClose:i().func.isRequired,oauthMeta:i().object,idcConfig:i().shape({startUrl:i().string,region:i().string,profileArn:i().string})}},91450:(e,t,a)=>{a.d(t,{default:()=>l});var s=a(95155),r=a(14051),n=a.n(r),i=a(38587);function l({children:e}){return(0,s.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,s.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,s.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,s.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,s.jsx)(i.default,{variant:"card"})}),(0,s.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}l.propTypes={children:n().node.isRequired}},92173:(e,t,a)=>{a.d(t,{default:()=>c});var s=a(95155),r=a(98500),n=a.n(r),i=a(90620);let l=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],o=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],d=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function c(){return(0,s.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,s.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,s.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,s.jsx)("div",{className:"size-6 text-primary",children:(0,s.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,s.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,s.jsx)("span",{className:"text-xl font-bold text-text-main",children:i.vQ.name})]}),(0,s.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,s.jsxs)("div",{className:"flex gap-4",children:[(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,s.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,s.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:l.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:o.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,s.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:d.map(e=>(0,s.jsx)("li",{children:(0,s.jsx)(n(),{href:e.href,className:"hover:text-primary transition-colors",children:e.label})},e.label))})]})]}),(0,s.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",i.vQ.name," Inc. All rights reserved."]}),(0,s.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,s.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,s.jsx)(n(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},92542:(e,t,a)=>{a.d(t,{default:()=>l});var s=a(95155),r=a(31474);let n={primary:"bg-brand-500 hover:bg-brand-400 text-[#1B1710] border border-brand-500/80 shadow-sm disabled:bg-surface-3 disabled:text-text-muted disabled:border-transparent",secondary:"bg-surface-2 hover:bg-surface-3 text-text-main border border-border disabled:opacity-50",outline:"border border-border text-text-main hover:bg-surface-2 hover:border-brand-500/40 bg-transparent",ghost:"text-text-muted hover:bg-surface-2 hover:text-text-main border border-transparent",danger:"bg-red-500 hover:bg-red-600 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted",success:"bg-green-600 hover:bg-green-700 text-white shadow-sm disabled:bg-surface-3 disabled:text-text-muted"},i={sm:"h-8 px-3 text-xs rounded-[7px]",md:"h-9 px-3.5 text-sm rounded-[8px]",lg:"h-11 px-5 text-sm rounded-[10px]"};function l({children:e,variant:t="primary",size:a="md",icon:o,iconRight:d,disabled:c=!1,loading:m=!1,fullWidth:u=!1,className:x,...p}){return(0,s.jsxs)("button",{type:"button",className:(0,r.cn)("inline-flex items-center justify-center gap-1.5 font-semibold transition-all duration-150 ease-out cursor-pointer","active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed disabled:active:scale-100",n[t],i[a],u&&"w-full",x),disabled:c||m,...p,children:[m?(0,s.jsx)("span",{className:"material-symbols-outlined leading-none animate-spin shrink-0",style:{fontSize:18},children:"progress_activity"}):o?(0,s.jsx)("span",{className:"material-symbols-outlined leading-none shrink-0",style:{fontSize:18},children:o}):null,e?(0,s.jsx)("span",{className:"leading-none",children:e}):null,d&&!m?(0,s.jsx)("span",{className:"material-symbols-outlined leading-none shrink-0",style:{fontSize:18},children:d}):null]})}},92622:(e,t,a)=>{a.d(t,{default:()=>p});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(98500),o=a.n(l),d=a(73321),c=a(90620),m=a(11059),u=a(81127);let x=[{id:"operate",label:"Operate",items:[{href:"/dashboard",label:"Overview",match:e=>"/dashboard"===e},{href:"/dashboard/combos",label:"Combos",match:e=>e.startsWith("/dashboard/combos")},{href:"/dashboard/usage",label:"Usage",match:e=>e.startsWith("/dashboard/usage")},{href:"/dashboard/quota",label:"Quota",match:e=>e.startsWith("/dashboard/quota")}]},{id:"connect",label:"Connect",items:[{href:"/dashboard/providers",label:"Providers",match:e=>e.startsWith("/dashboard/providers")},{href:"/dashboard/endpoint",label:"Endpoint & keys",match:e=>e.startsWith("/dashboard/endpoint")}]},{id:"tools",label:"Tools",items:[{href:"/dashboard/token-saver",label:"Token saver",match:e=>e.startsWith("/dashboard/token-saver")},{href:"/dashboard/media-providers",label:"Media",match:e=>e.startsWith("/dashboard/media-providers")},{href:"/dashboard/skills",label:"Skills",match:e=>e.startsWith("/dashboard/skills")},{href:"/dashboard/agent-library",label:"Agent library",match:e=>e.startsWith("/dashboard/agent-library")},{href:"/dashboard/cli-tools",label:"CLI tools",match:e=>e.startsWith("/dashboard/cli-tools")},{href:"/dashboard/profile",label:"Settings",match:e=>e.startsWith("/dashboard/profile")}]}];function p({onClose:e}){let t=(0,d.usePathname)(),[a,n]=(0,r.useState)(!1),[i,l]=(0,r.useState)(null),[h,f]=(0,r.useState)(!1),[b,g]=(0,r.useState)(!1),[v,j]=(0,r.useState)(0),[y,N]=(0,r.useState)(`127.0.0.1:${c.h0.appPort}`),{copied:k,copy:w}=(0,m.C)(2e3),C=c.h0.installCmdLatest;(0,r.useEffect)(()=>{N(window.location.host||`127.0.0.1:${c.h0.appPort}`)},[]),(0,r.useEffect)(()=>{fetch("/api/version").then(e=>e.json()).then(e=>{e&&!0===e.hasUpdate&&e.latestVersion&&e.currentVersion&&e.latestVersion!==e.currentVersion?l(e):l(null)}).catch(()=>{l(null)})},[]);let S=async()=>{try{await navigator.clipboard.writeText(C)}catch{}w(C);let e=c.h0.shutdownCountdownSec;j(e);let t=setInterval(()=>{j(e-=1),e<=0&&(clearInterval(t),fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),n(!0))},1e3)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{className:"flex flex-col min-h-full",style:{width:236,flex:"0 0 236px",background:"#1A160F",borderRight:"1px solid #332C1E"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-[11px]",style:{padding:"16px 18px",borderBottom:"1px solid #2A2418"},children:[(0,s.jsxs)(o(),{href:"/dashboard",onClick:e,className:"flex items-center gap-[11px] min-w-0",children:[(0,s.jsx)("div",{className:"flex items-center justify-center shrink-0",style:{width:27,height:27,borderRadius:7,background:"#E5B454",color:"#1B1710",fontWeight:700,fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace",fontSize:15},children:"S"}),(0,s.jsxs)("div",{className:"flex flex-col min-w-0",style:{lineHeight:1.15},children:[(0,s.jsx)("span",{style:{fontWeight:600,fontSize:14,letterSpacing:"0.2px",color:"#ECE4D2"},children:c.vQ.name}),(0,s.jsx)("span",{style:{fontSize:10.5,color:"#6F6653",fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace"},children:"routing gateway"})]})]}),e?(0,s.jsx)("button",{type:"button",onClick:e,className:"lg:hidden ml-auto text-[#6F6653] hover:text-[#ECE4D2]","aria-label":"Close menu",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})}):null]}),i&&(0,s.jsxs)("div",{className:"mx-2.5 mt-2 rounded-lg border border-[#332C1E] bg-[#211C14] px-2.5 py-2",children:[(0,s.jsxs)("span",{className:"text-[11px] font-semibold text-[#E5B454]",children:["↑ v",i.latestVersion," available"]}),(0,s.jsx)("button",{type:"button",onClick:()=>f(!0),className:"mt-1 block text-[11px] text-[#A99E86] hover:text-[#E5B454]",children:"Update now"})]}),(0,s.jsxs)("nav",{className:"flex-1 overflow-y-auto custom-scrollbar flex flex-col",style:{padding:"12px 10px",gap:2},children:[x.map(a=>(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"console-nav-section",children:a.label}),a.items.map(a=>{let r=a.match(t);return(0,s.jsxs)(o(),{href:a.href,onClick:e,className:"console-nav-item","data-active":r?"true":"false",children:[(0,s.jsx)("span",{className:"console-nav-dot"}),a.label]},a.href)})]},a.id)),(0,s.jsxs)("div",{style:{marginTop:16,padding:"11px 12px",border:"1px dashed #332C1E",borderRadius:8},children:[(0,s.jsx)("div",{style:{fontSize:10,letterSpacing:"1.4px",color:"#6F6653",textTransform:"uppercase",fontWeight:600,marginBottom:6},children:"Diagnostics"}),(0,s.jsxs)("div",{style:{fontSize:11,color:"#7A7059",fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace",lineHeight:1.7},children:[(0,s.jsx)(o(),{href:"/dashboard/console-log",onClick:e,className:"hover:text-[#E5B454]",children:"console"})," \xb7 ",(0,s.jsx)(o(),{href:"/dashboard/translator",onClick:e,className:"hover:text-[#E5B454]",children:"translator"}),(0,s.jsx)("br",{}),(0,s.jsx)(o(),{href:"/dashboard/mitm",onClick:e,className:"hover:text-[#E5B454]",children:"mitm"})," \xb7 ",(0,s.jsx)(o(),{href:"/dashboard/cli-tools",onClick:e,className:"hover:text-[#E5B454]",children:"cli tools"})]})]})]}),(0,s.jsx)("div",{style:{padding:12,borderTop:"1px solid #2A2418"},children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",style:{background:"#211C14",border:"1px solid #2A2418",borderRadius:8,padding:"9px 11px"},children:[(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("span",{style:{fontSize:9.5,letterSpacing:"1px",color:"#6F6653",textTransform:"uppercase"},children:"Endpoint"}),(0,s.jsx)("span",{className:"truncate",style:{fontSize:11,fontFamily:"var(--font-mono), 'IBM Plex Mono', monospace",color:"#A99E86"},children:y})]}),(0,s.jsx)("span",{className:"console-online-dot",title:"online"})]})})]}),(0,s.jsx)(u.ConfirmModal,{isOpen:h,onClose:()=>f(!1),onConfirm:()=>{f(!1),g(!0)},title:"Update Switchboard",message:"Copy the install command and restart the server after update.",confirmText:"Continue"}),b&&(0,s.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 p-4",children:(0,s.jsxs)("div",{className:"card-soft max-w-md w-full p-5 space-y-3",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Manual update"}),(0,s.jsx)("code",{className:"block text-[11px] font-mono text-primary break-all bg-surface-2 p-2 rounded",children:C}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:S,className:"px-3 py-1.5 rounded-lg bg-primary text-[#1B1710] text-xs font-semibold",children:[k?"Copied":"Copy & shutdown",v>0?` (${v})`:""]}),(0,s.jsx)("button",{type:"button",onClick:()=>{g(!1),j(0)},className:"px-3 py-1.5 rounded-lg border border-border text-text-muted text-xs",children:"Cancel"})]}),a&&(0,s.jsx)("p",{className:"text-[11px] text-text-subtle font-mono",children:"Server shutting down…"})]})})]})}p.propTypes={onClose:i().func}},94230:(e,t,a)=>{a.d(t,{default:()=>d});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497),o=a(11059);function d({isOpen:e,provider:t,onSuccess:a,onClose:n}){let[i,c]=(0,r.useState)("loading"),[m,u]=(0,r.useState)(""),[x,p]=(0,r.useState)(null),[h,f]=(0,r.useState)(""),[b,g]=(0,r.useState)(null),{copied:v,copy:j}=(0,o.C)(),y=(0,r.useRef)(!1);(0,r.useEffect)(()=>{e||(y.current=!1)},[e]),(0,r.useEffect)(()=>{e&&t&&(async()=>{try{g(null),c("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${t}`),a=await e.json();if(!e.ok)throw Error(a.error);p(a),u(a.authUrl),c("input"),y.current||(y.current=!0,window.open(a.authUrl,"_blank"))}catch(e){g(e.message),c("error")}})()},[e,t]);let N=async()=>{try{let e;g(null);try{e=new URL(h)}catch(e){throw Error("Invalid callback URL format")}let s=e.searchParams.get("code");e.searchParams.get("state");let r=e.searchParams.get("error");if(r)throw Error(e.searchParams.get("error_description")||r);if(!s)throw Error("No authorization code found in URL");let n=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:s,codeVerifier:x.codeVerifier,provider:t})}),i=await n.json();if(!n.ok)throw Error(i.error);c("success"),a?.()}catch(e){g(e.message),c("error")}},k="google"===t?"Google":"GitHub";return(0,s.jsx)(l.aF,{isOpen:e,title:`Connect Kiro via ${k}`,onClose:n,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===i&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",k," authentication"]})]}),"input"===i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.pd,{value:m,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(l.$n,{variant:"secondary",icon:"auth_url"===v?"check":"content_copy",onClick:()=>j(m,"auth_url"),children:"Copy"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,s.jsx)(l.pd,{value:h,onChange:e=>f(e.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:N,fullWidth:!0,disabled:!h,children:"Connect"}),(0,s.jsx)(l.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===i&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,s.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",k," has been connected."]}),(0,s.jsx)(l.$n,{onClick:n,fullWidth:!0,children:"Done"})]}),"error"===i&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:b}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:()=>c("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,s.jsx)(l.$n,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}d.propTypes={isOpen:i().bool.isRequired,provider:i().oneOf(["google","github"]).isRequired,onSuccess:i().func,onClose:i().func.isRequired}},95088:(e,t,a)=>{a.d(t,{default:()=>d});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497);let o="https://gitlab.com";function d({isOpen:e,providerInfo:t,onSuccess:a,onClose:n}){let i,[c,m]=(0,r.useState)(null),[u,x]=(0,r.useState)(o),[p,h]=(0,r.useState)(""),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)(null),[w,C]=(0,r.useState)(!1),[S,O]=(0,r.useState)(null),F=()=>{m(null),x(o),h(""),b(""),v(""),k(null),y(!1),C(!1),O(null),n()},A=async()=>{if(!g.trim())return void k("Personal Access Token is required");y(!0),k(null);try{let e=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:g.trim(),baseUrl:u.trim()||o})}),t=await e.json();if(!e.ok)throw Error(t.error||"Authentication failed");a?.(),F()}catch(e){k(e.message)}finally{y(!1)}};return e?w&&S?(0,s.jsx)(l.LF,{isOpen:!0,provider:"gitlab",providerInfo:t,oauthMeta:S,onSuccess:()=>{a?.(),F()},onClose:()=>{C(!1),O(null)}}):(0,s.jsx)(l.aF,{isOpen:e,title:"Connect GitLab Duo",onClose:F,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[!c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("button",{onClick:()=>m("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,s.jsxs)("button",{onClick:()=>m("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:(i=window.location.port||("https:"===window.location.protocol?"443":"80"),`http://localhost:${i}/callback`)})]}),(0,s.jsx)(l.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(l.pd,{label:"Client ID",value:p,onChange:e=>h(e.target.value),placeholder:"Your OAuth application client ID"}),(0,s.jsx)(l.pd,{label:"Client Secret (optional for PKCE)",value:f,onChange:e=>b(e.target.value),placeholder:"Leave empty for public PKCE app"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:()=>{p.trim()?(k(null),O({baseUrl:u.trim()||o,clientId:p.trim(),clientSecret:f.trim()}),C(!0)):k("Client ID is required")},fullWidth:!0,disabled:!p.trim(),children:"Authorize"}),(0,s.jsx)(l.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,s.jsx)("a",{href:`${u.trim()||o}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,s.jsx)(l.pd,{label:"GitLab Base URL",value:u,onChange:e=>x(e.target.value),placeholder:o}),(0,s.jsx)(l.pd,{label:"Personal Access Token",value:g,onChange:e=>v(e.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),N&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:N}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:A,fullWidth:!0,disabled:!g.trim()||j,loading:j,children:"Connect"}),(0,s.jsx)(l.$n,{onClick:()=>{m(null),k(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}d.propTypes={isOpen:i().bool.isRequired,providerInfo:i().shape({name:i().string}),onSuccess:i().func,onClose:i().func.isRequired}},96748:(e,t,a)=>{a.d(t,{default:()=>c});var s=a(95155),r=a(12115),n=a(14051),i=a.n(n),l=a(35497),o=a(78559);let d="https://api.openai.com/v1";function c({isOpen:e,onClose:t,onCreated:a,onSaved:n,node:i}){let m=!!i,[u,x]=(0,r.useState)({name:"",baseUrl:d}),[p,h]=(0,r.useState)(!1),[f,b]=(0,r.useState)(""),[g,v]=(0,r.useState)(""),[j,y]=(0,r.useState)(!1),[N,k]=(0,r.useState)(null);(0,r.useEffect)(()=>{e&&(k(null),b(""),v(""),m?x({name:i.name||"",baseUrl:i.baseUrl||d}):x({name:"",baseUrl:d}))},[e,m,i]);let w=async()=>{if(u.name.trim()&&u.baseUrl.trim()){h(!0);try{let e=m?`/api/provider-nodes/${i.id}`:"/api/provider-nodes",t=m?"PUT":"POST",s={name:u.name.trim(),baseUrl:u.baseUrl.trim()};m||(s.type="custom-embedding");let r=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),l=await r.json();r.ok&&(m?n?.(l.node):a?.(l.node))}catch(e){(0,o.s)("Error saving custom embedding node:",e)}finally{h(!1)}}},C=async()=>{y(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:u.baseUrl,apiKey:f,type:"custom-embedding",modelId:g.trim()||void 0})}),t=await e.json();k(t)}catch{k({valid:!1,error:"Network error"})}finally{y(!1)}};return(0,s.jsx)(l.aF,{isOpen:e,title:m?"Edit Custom Embedding":"Add Custom Embedding",onClose:t,children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(l.pd,{label:"Name",value:u.name,onChange:e=>x({...u,name:e.target.value}),placeholder:"Voyage AI",hint:"Friendly label for this embedding provider."}),(0,s.jsx)(l.pd,{label:"Base URL",value:u.baseUrl,onChange:e=>x({...u,baseUrl:e.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"OpenAI-compatible embeddings base URL (Voyage, Cohere, Jina, Mistral…)."}),m&&i?.prefix?(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,s.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:i.prefix})," ","(auto-assigned)."]}):null,(0,s.jsx)(l.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:f,onChange:e=>b(e.target.value)}),(0,s.jsx)(l.pd,{label:"Model ID (for Check)",value:g,onChange:e=>v(e.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0",hint:"Required for validation. Sends a small embeddings request."}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(l.$n,{onClick:C,disabled:!f||!g.trim()||j||!u.baseUrl.trim(),variant:"secondary",children:j?"Checking...":"Check"}),(()=>{if(!N)return null;let{valid:e,error:t,dimensions:a}=N;return e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l.Ex,{variant:"success",children:"Valid"}),a&&(0,s.jsxs)("span",{className:"text-sm text-text-muted",children:[a," dims"]})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)(l.Ex,{variant:"error",children:"Invalid"}),t&&(0,s.jsx)("span",{className:"text-sm text-red-500",children:t})]})})()]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(l.$n,{onClick:w,fullWidth:!0,disabled:!u.name.trim()||!u.baseUrl.trim()||p,children:p?m?"Saving...":"Creating...":m?"Save":"Create"}),(0,s.jsx)(l.$n,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}c.propTypes={isOpen:i().bool.isRequired,onClose:i().func.isRequired,onCreated:i().func,onSaved:i().func,node:i().shape({id:i().string,name:i().string,prefix:i().string,baseUrl:i().string})}},97677:(e,t,a)=>{a.d(t,{default:()=>r});var s=a(95155);function r({text:e,children:t,position:a="top",color:n}){let i=n?"":"bg-gray-900";return(0,s.jsxs)("div",{className:"relative inline-flex group/tt",children:[t,(0,s.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[a]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${i} text-white opacity-0 group-hover/tt:opacity-100 transition-opacity duration-150 whitespace-normal`,style:n?{backgroundColor:n}:{},children:e})]})}},98542:(e,t,a)=>{a.d(t,{default:()=>n});var s=a(95155),r=a(31474);function n({checked:e=!1,onChange:t,label:a,description:i,disabled:l=!1,size:o="md",className:d,title:c}){let m={sm:{track:"w-8 h-4",thumb:"size-3",on:"translate-x-4",off:"translate-x-0.5"},md:{track:"w-11 h-6",thumb:"size-5",on:"translate-x-5",off:"translate-x-0.5"},lg:{track:"w-14 h-7",thumb:"size-6",on:"translate-x-7",off:"translate-x-0.5"}},u=m[o]||m.md;return(0,s.jsxs)("div",{className:(0,r.cn)("flex items-center gap-3",l&&"opacity-50 cursor-not-allowed",d),children:[(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":e,title:c,disabled:l,onClick:()=>{!l&&t&&t(!e)},className:(0,r.cn)("relative inline-flex shrink-0 cursor-pointer items-center rounded-full","transition-colors duration-200 ease-in-out","focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/35",e?"bg-brand-500":"bg-surface-3 border border-border",u.track,l&&"cursor-not-allowed"),children:(0,s.jsx)("span",{className:(0,r.cn)("pointer-events-none inline-block rounded-full shadow-sm",e?"bg-[#1B1710]":"bg-[#ECE4D2]","transform transition duration-200 ease-in-out",e?u.on:u.off,u.thumb,"mt-0.5")})}),(a||i)&&(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[a&&(0,s.jsx)("span",{className:"text-sm font-medium text-text-main",children:a}),i&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:i})]})]})}}}]);
@@ -0,0 +1,10 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{7687:(e,t,s)=>{Promise.resolve().then(s.bind(s,42710))},42710:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>H});var a=s(95155),i=s(12115),r=s(73321),l=s(98500),n=s.n(l),o=s(5772),d=s(35497),c=s(88105),m=s(28777),p=s(16600),u=s(47224);let x=["none","low","medium","high"],h=["none","thinking"],f=["none","low","medium","high","max"],y={openai:["none","minimal","low","medium","high","xhigh"],"claude-adaptive":f,"claude-budget":["none","low","medium","high","xhigh","max"],"gemini-level":["minimal","low","medium","high"],"gemini-budget":x,zai:h,qwen:x,kimi:f,deepseek:["none","high","max"],minimax:h,hunyuan:x,step:x},g=[{pattern:"*codex*",levels:["low","medium","high","xhigh"]}];function b(e,t){let s=(0,p.nl)(e,t);if(!s.reasoning)return null;let a=g.find(e=>(0,u.gH)(e.pattern,t)),i=a?.levels||y[s.thinkingFormat]||x;return!1===s.thinkingCanDisable&&(i=i.filter(e=>"none"!==e)),i}var v=s(11059),j=s(929),w=s(73006);let k=new Map;async function N(e){if(!e?.url||!e?.type||e.requiresAuth)return[];let t=k.get(e.url);if(t&&Date.now()<t.expiresAt)return t.data;try{let t=new URLSearchParams({url:e.url,type:e.type}),s=await fetch(`/api/providers/suggested-models?${t}`);if(!s.ok)return[];let a=(await s.json()).data??[];return k.set(e.url,{data:a,expiresAt:Date.now()+6e5}),a}catch{return[]}}var C=s(81231),S=s(68501),$=s(14051),A=s.n($);function T({model:e,fullModel:t,alias:s,copied:i,onCopy:r,testStatus:l,isCustom:n,isFree:o,onDeleteAlias:c,onTest:m,isTesting:p,onDisable:u,caps:x,thinkingSuffix:h,latencyMs:f,probeState:y}){let g=h?`${t}(${h})`:t,b="ok"===l?"#22c55e":"error"===l?"#ef4444":void 0;return(0,a.jsx)("div",{className:`group min-w-0 max-w-full rounded-lg border px-3 py-2 ${"ok"===l?"border-green-500/40":"error"===l?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:(0,a.jsxs)("div",{className:"flex min-w-0 items-start gap-2 sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base",style:b?{color:b}:void 0,children:"ok"===l?"check_circle":"error"===l?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("code",{className:"max-w-[72vw] truncate rounded bg-sidebar px-1.5 py-0.5 font-mono text-xs text-text-muted sm:max-w-[360px]",children:g}),y&&("testing"===y?(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 animate-spin text-[14px] text-text-muted",title:"Testing...",children:"progress_activity"}):(0,a.jsx)("span",{title:"ok"===y?"Reachable":"dead"===y?"Unavailable (dead)":"Retry later",className:`shrink-0 inline-block h-2 w-2 rounded-full ${"ok"===y?"bg-green-500":"dead"===y?"bg-red-500":"bg-amber-500"}`}))]}),(0,a.jsxs)("span",{className:"flex min-w-0 items-center text-[9px] gap-1 pl-1",children:[e.name&&(0,a.jsx)("span",{className:"truncate text-[9px] italic text-text-muted/70",children:e.name}),Number.isFinite(f)&&(0,a.jsxs)("span",{className:"shrink-0 text-[9px] text-text-muted/70 tabular-nums",children:[Math.round(f),"ms"]}),(0,a.jsx)(d.nh,{caps:x,colorOverride:"text-text-muted/70",size:12})]})]}),m&&(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:m,disabled:p,className:`rounded p-0.5 text-text-muted transition-opacity hover:bg-sidebar hover:text-primary ${p?"opacity-100":"opacity-100 sm:opacity-0 sm:group-hover:opacity-100"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:p?{animation:"spin 1s linear infinite"}:void 0,children:p?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:p?"Testing...":"Test"})]}),(0,a.jsxs)("div",{className:"relative shrink-0 group/btn",children:[(0,a.jsx)("button",{onClick:()=>r(g,`model-${e.id}`),className:"rounded p-0.5 text-text-muted hover:bg-sidebar hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:i===`model-${e.id}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute mt-1 top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:i===`model-${e.id}`?"Copied!":"Copy"})]}),n?(0,a.jsx)("button",{onClick:c,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Remove custom model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):u?(0,a.jsx)("button",{onClick:u,className:"ml-auto rounded p-0.5 text-text-muted opacity-100 transition-opacity hover:bg-red-500/10 hover:text-red-500 sm:opacity-0 sm:group-hover:opacity-100",title:"Disable this model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})}):null]})})}T.propTypes={model:A().shape({id:A().string.isRequired}).isRequired,fullModel:A().string.isRequired,alias:A().string,copied:A().string,onCopy:A().func.isRequired,testStatus:A().oneOf(["ok","error"]),isCustom:A().bool,isFree:A().bool,onDeleteAlias:A().func,onTest:A().func,isTesting:A().bool,onDisable:A().func,caps:A().object,thinkingSuffix:A().string,latencyMs:A().number,probeState:A().string};var O=s(78559);function E({modelId:e,fullModel:t,copied:s,onCopy:i,onDeleteAlias:r,onTest:l,testStatus:n,isTesting:o}){let d="ok"===n?"#22c55e":"error"===n?"#ef4444":void 0;return(0,a.jsxs)("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${"ok"===n?"border-green-500/40":"error"===n?"border-red-500/40":"border-border"} hover:bg-sidebar/50`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",style:d?{color:d}:void 0,children:"ok"===n?"check_circle":"error"===n?"cancel":"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:e}),(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1",children:[(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:t}),(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:()=>i(t,`model-${e}`),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:s===`model-${e}`?"check":"content_copy"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:s===`model-${e}`?"Copied!":"Copy"})]}),l&&(0,a.jsxs)("div",{className:"relative group/btn",children:[(0,a.jsx)("button",{onClick:l,disabled:o,className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary transition-colors",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",style:o?{animation:"spin 1s linear infinite"}:void 0,children:o?"progress_activity":"science"})}),(0,a.jsx)("span",{className:"pointer-events-none absolute top-5 left-1/2 -translate-x-1/2 text-[10px] text-text-muted whitespace-nowrap opacity-0 group-hover/btn:opacity-100 transition-opacity",children:o?"Testing...":"Test"})]})]})]}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-red-50 rounded text-red-500",title:"Remove model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"delete"})})]})}function R({providerStorageAlias:e,providerDisplayAlias:t,modelAliases:s,customModels:r,copied:l,onCopy:n,onDeleteAlias:o,onAddCustomModel:c,onDeleteCustomModel:m,onRefreshModels:p,connections:u,isAnthropic:x,disabledModelIds:h=[],onEnableModel:f}){let[y,g]=(0,i.useState)(""),[b,v]=(0,i.useState)(!1),[j,w]=(0,i.useState)(!1),[k,N]=(0,i.useState)(""),[S,$]=(0,i.useState)(null),[A,T]=(0,i.useState)({}),I=async t=>{if(!S){$(t);try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${e}/${t}`})}),a=await s.json();T(e=>({...e,[t]:a.ok?"ok":"error"}))}catch{T(e=>({...e,[t]:"error"}))}finally{$(null)}}},D=(0,C.Iz)(h,e),M=[...D],P=(0,C.R3)({customModels:r,modelAliases:s,providerAlias:e,type:"llm"}),z=P.filter(t=>!(0,C.uJ)(D,t.id,e)),U=async()=>{if(!y.trim()||b)return;let t=y.trim();if(z.some(e=>e.id===t))return void(0,O.s)("Model already exists for this provider.");v(!0);try{if((0,C.uJ)(D,t,e)){let e=await f?.(t);if(!1===e)throw Error("Failed to enable removed model")}await c(t),g("")}catch(e){(0,O.s)("Error adding model:",e)}finally{v(!1)}},q=async()=>{if(j)return;let t=u.find(e=>!1!==e.isActive);if(t){w(!0),N("");try{let s=await fetch(`/api/providers/${t.id}/models`),a=await s.json().catch(()=>({}));if(!s.ok)return void(0,O.s)(a.error||"Failed to import models");let i=a.models||[];if(0===i.length)return void(0,O.s)("No models returned from /models.");let r=new Set(P.map(e=>e.id)),l=[],n=new Set;for(let t of i){let s=String(t.id||t.name||t.model||"").trim();!s||r.has(s)||n.has(s)||(0,C.uJ)(D,s,e)||(n.add(s),l.push({providerAlias:e,id:s,type:"llm",name:t.display_name||t.displayName||t.name||s}))}if(0===l.length)return void N("All models already in list");let o=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:l})}),d=await o.json().catch(()=>({}));if(!o.ok){let e=0;for(let t of l)await c(t.id),e+=1;N(e?`Imported ${e} model(s)`:"No new models were added");return}N(`Imported ${d.added??l.length} model(s)`),"function"==typeof p?await p():window.dispatchEvent(new CustomEvent("customModelChanged"))}catch(e){(0,O.s)("Error importing models:",e),(0,O.s)(e?.message||"Import failed")}finally{w(!1)}}},_=u.some(e=>!1!==e.isActive);return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("p",{className:"text-sm text-text-muted",children:["Add ",x?"Anthropic":"OpenAI","-compatible models manually or import them from the /models endpoint."]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 flex-wrap",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-[240px]",children:[(0,a.jsx)("label",{htmlFor:"new-compatible-model-input",className:"text-xs text-text-muted mb-1 block",children:"Model ID"}),(0,a.jsx)("input",{id:"new-compatible-model-input",type:"text",value:y,onChange:e=>g(e.target.value),onKeyDown:e=>"Enter"===e.key&&U(),placeholder:x?"claude-3-opus-20240229":"gpt-4o",className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary"})]}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:U,disabled:!y.trim()||b,children:b?"Adding...":"Add"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"cloud_download",onClick:q,disabled:!_||j,children:j?"Importing...":"Import models"})]}),!_&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Add a connection to enable importing models."}),k&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:k}),z.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:z.map(({id:s,alias:i,source:r})=>(0,a.jsx)(E,{modelId:s,fullModel:`${t}/${s}`,copied:l,onCopy:n,onDeleteAlias:()=>"custom"===r?m(s):o(i),onTest:u.length>0?()=>I(s):void 0,testStatus:A[s],isTesting:S===s},`${r}-${e}/${s}`))}),M.length>0&&(0,a.jsxs)("details",{className:"rounded-lg border border-border bg-surface/30 p-3",children:[(0,a.jsxs)("summary",{className:"cursor-pointer text-sm font-medium text-text-main",children:["Removed models (",M.length,")"]}),(0,a.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Enable a model to make it available for import and selection again."}),(0,a.jsx)("div",{className:"mt-3 flex max-h-56 flex-col gap-1.5 overflow-y-auto",children:M.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded border border-border bg-background px-2 py-1.5",children:[(0,a.jsx)("code",{className:"min-w-0 flex-1 truncate text-xs",title:e,children:e}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",onClick:()=>f?.(e),children:"Enable"})]},e))})]})]})}A().string.isRequired,A().string.isRequired,A().string,A().func.isRequired,A().func.isRequired,A().func,A().oneOf(["ok","error"]),A().bool,A().string.isRequired,A().object.isRequired,A().arrayOf(A().object),A().string,A().func.isRequired,A().func.isRequired,A().func.isRequired,A().func.isRequired,R.propTypes={providerStorageAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,modelAliases:A().object.isRequired,customModels:A().arrayOf(A().object),copied:A().string,onCopy:A().func.isRequired,onDeleteAlias:A().func.isRequired,onAddCustomModel:A().func.isRequired,onDeleteCustomModel:A().func.isRequired,onRefreshModels:A().func,connections:A().arrayOf(A().shape({id:A().string,isActive:A().bool})).isRequired,isAnthropic:A().bool,disabledModelIds:A().arrayOf(A().string),onEnableModel:A().func};var I=s(70217);function D({until:e}){let[t,s]=(0,i.useState)("");return((0,i.useEffect)(()=>{let t=()=>{let t=new Date(e).getTime()-Date.now();if(t<=0)return void s("");let a=Math.floor(t/1e3);if(a<60)s(`${a}s`);else if(a<3600)s(`${Math.floor(a/60)}m ${a%60}s`);else{let e=Math.floor(a/3600),t=Math.floor(a%3600/60);s(`${e}h ${t}m`)}};t();let a=setInterval(t,1e3);return()=>clearInterval(a)},[e]),t)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",t]}):null}function M({connection:e,isOAuth:t,isFirst:s,isLast:r,onMoveUp:l,onMoveDown:n,onToggleActive:o,onEdit:c,onDelete:m,onAllowlistHost:p=null,oneByOneStatus:u=null,autoPing:x=null}){let h=/SSRF blocked|Blocked URL: (private IP|internal host)/i.test(e.lastError||""),f=e.providerSpecificData?.connectionProxyEnabled===!0&&!!e.providerSpecificData?.connectionProxyUrl,y=f?`Proxy: ${e.providerSpecificData?.connectionProxyUrl}`:"",g=x?.provider==="codex"?"Auto-starts the next 5h Codex window after reset by sending a tiny gpt-5.5 request. Consumes a small amount of quota.":"When your 5h quota runs out, auto-sends a request the moment it resets so a new window starts right away.",b="";if(e.providerSpecificData?.connectionProxyUrl){let t=e.providerSpecificData?.connectionProxyUrl;try{let e=new URL(t);b=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`}catch{b=t}}let v=e.providerSpecificData?.connectionNoProxy||"",j=f?"success":"default",w=e.authType||(t?"oauth":"apikey"),k="oauth"===w,N="cookie"===w,C=e.name?.trim()||e.email?.trim()||e.displayName?.trim()||(k?"OAuth Account":N?"Cookie Account":"API Key"),S=e.name?.trim()&&e.email?.trim()&&e.name.trim()!==e.email.trim()?e.email.trim():e.name?.trim()&&e.displayName?.trim()&&e.name.trim()!==e.displayName.trim()?e.displayName.trim():null,[$,A]=(0,i.useState)(!1),T=Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>!!e).sort()[0]||null;(0,i.useEffect)(()=>{let t=()=>{A(!!Object.entries(e).filter(([e])=>e.startsWith("modelLock_")).map(([,e])=>e).filter(e=>e&&new Date(e).getTime()>Date.now()).sort()[0])};t();let s=T?setInterval(t,1e3):null;return()=>{s&&clearInterval(s)}},[e,T]);let O="unavailable"!==e.testStatus||$?e.testStatus:"active",E=()=>u?"queued"===u.state?"queued":"testing"===u.state?"testing":"success"===u.state?"success":"failed"===u.state?u.error?`failed: ${u.error}`:"failed":null:null;return(0,a.jsxs)("div",{className:`group flex min-w-0 flex-col gap-3 rounded-lg p-2 transition-colors hover:bg-black/[0.02] dark:hover:bg-white/[0.02] sm:flex-row sm:items-center sm:justify-between ${!1===e.isActive?"opacity-60":""}`,children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-start gap-2 sm:items-center sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-col",children:[(0,a.jsx)("button",{onClick:l,disabled:s,className:`p-0.5 rounded ${s?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_up"})}),(0,a.jsx)("button",{onClick:n,disabled:r,className:`p-0.5 rounded ${r?"text-text-muted/30 cursor-not-allowed":"hover:bg-sidebar text-text-muted hover:text-primary"}`,children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"keyboard_arrow_down"})})]}),(0,a.jsx)("span",{className:"material-symbols-outlined shrink-0 text-base text-text-muted",children:N?"cookie":k?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:C}),S&&(0,a.jsx)("p",{className:"text-xs text-text-muted truncate",children:S}),(0,a.jsxs)("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1.5 sm:gap-2",children:[(0,a.jsx)(d.Ex,{variant:(0,I.g)(e.isActive,O),size:"sm",dot:!0,children:!1===e.isActive?"disabled":O||"Unknown"}),(0,a.jsx)(d.Ex,{variant:"default",size:"sm",children:k?"OAuth":N?"Cookie":"API Key"}),f&&(0,a.jsx)(d.Ex,{variant:j,size:"sm",children:"Proxy"}),$&&!1!==e.isActive&&(0,a.jsx)(D,{until:T}),e.lastError&&!1!==e.isActive&&(0,a.jsx)("span",{className:"max-w-full truncate text-xs text-red-500 sm:max-w-[300px]",title:e.lastError,children:e.lastError}),h&&!1!==e.isActive&&p&&(0,a.jsxs)("button",{onClick:p,title:"Trust this host past the SSRF guard and retry",className:"inline-flex items-center gap-1 rounded border border-amber-500/40 px-1.5 py-0.5 text-xs text-amber-600 hover:bg-amber-500/10 dark:text-amber-400",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"verified_user"}),"Add to allow list"]}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",e.priority]}),e.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",e.globalPriority]}),E()&&(0,a.jsx)(d.Ex,{variant:u?"success"===u.state?"success":"failed"===u.state?"error":"testing"===u.state?"primary":"default":"default",size:"sm",children:E()})]}),f&&(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-2 flex-wrap",children:[(0,a.jsx)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[420px]",title:y,children:y}),b&&(0,a.jsx)("code",{className:"max-w-full truncate rounded bg-black/5 px-1 py-0.5 font-mono text-[10px] text-text-muted dark:bg-white/5 sm:max-w-[260px]",children:b}),v&&(0,a.jsxs)("span",{className:"max-w-full truncate text-[11px] text-text-muted sm:max-w-[320px]",title:v,children:["no_proxy: ",v]})]})]})]}),(0,a.jsxs)("div",{className:"flex w-full items-center justify-between gap-2 sm:w-auto sm:justify-end",children:[(0,a.jsxs)("div",{className:"grid flex-1 grid-cols-3 gap-1 sm:flex sm:flex-none",children:[x&&(0,a.jsx)(d.m_,{text:g,children:(0,a.jsxs)("button",{onClick:()=>x.onToggle(!x.on),className:`flex w-full flex-col items-center rounded px-2 py-1 transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${x.on?"text-primary":"text-text-muted hover:text-primary"}`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"bolt"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Auto-ping"})]})}),(0,a.jsxs)("button",{onClick:c,className:"flex flex-col items-center rounded px-2 py-1 text-text-muted hover:bg-black/5 hover:text-primary dark:hover:bg-white/5",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"edit"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Edit"})]}),(0,a.jsxs)("button",{onClick:m,className:"flex flex-col items-center rounded px-2 py-1 text-red-500 hover:bg-red-500/10",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"delete"}),(0,a.jsx)("span",{className:"text-[10px] leading-tight",children:"Delete"})]})]}),(0,a.jsx)(d.lM,{size:"sm",checked:e.isActive??!0,onChange:o,title:e.isActive??!0?"Disable connection":"Enable connection"})]})]})}D.propTypes={until:A().string.isRequired},M.propTypes={connection:A().shape({id:A().string,name:A().string,email:A().string,displayName:A().string,modelLockUntil:A().string,testStatus:A().string,isActive:A().bool,lastError:A().string,priority:A().number,globalPriority:A().number,providerSpecificData:A().object}).isRequired,isOAuth:A().bool.isRequired,isFirst:A().bool.isRequired,isLast:A().bool.isRequired,onMoveUp:A().func.isRequired,onMoveDown:A().func.isRequired,onToggleActive:A().func.isRequired,onEdit:A().func.isRequired,onDelete:A().func.isRequired,onAllowlistHost:A().func,oneByOneStatus:A().shape({state:A().string,error:A().string}),autoPing:A().shape({on:A().bool,onToggle:A().func,provider:A().string})};let P=`name1|sk-key1
2
+ name2|sk-key2
3
+ sk-key-only-auto-named`;function z({isOpen:e,provider:t,providerName:s,isCompatible:r,isAnthropic:l,authType:n,authHint:o,website:m,error:p,onSave:u,onBulkDone:x,onClose:h}){let f="ollama-local"===t,y="cookie"===n,g="xai"===t&&!y,b=y?"Cookie Value":"API Key",v="azure"===t,j="cloudflare-ai"===t,w=c.Q2?.[t]?.regions||null,k=c.Q2?.[t]?.defaultRegion||w?.[0]?.id||"",[N,C]=(0,i.useState)({name:"",apiKey:"",defaultModel:"",priority:1,ollamaHostUrl:""}),[S,$]=(0,i.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[A,T]=(0,i.useState)({accountId:""}),[O,E]=(0,i.useState)(k),[R,I]=(0,i.useState)(!1),[D,M]=(0,i.useState)(null),[U,q]=(0,i.useState)(!1),[_,F]=(0,i.useState)("single"),[J,L]=(0,i.useState)(""),[K,B]=(0,i.useState)(null),H=N.name.trim().length>0,V=N.apiKey.trim().length>0,W=()=>f&&N.ollamaHostUrl.trim()?{baseUrl:N.ollamaHostUrl.trim()}:v?{azureEndpoint:S.azureEndpoint,apiVersion:S.apiVersion,deployment:S.deployment,organization:S.organization}:j?{accountId:A.accountId}:w&&O?{region:O}:void 0,G=async()=>{let e=N.apiKey.trim();if(e){I(!0);try{let s=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:e,providerSpecificData:W()})}),a=await s.json();M(a.valid?"success":"failed")}catch{M("failed")}finally{I(!1)}}},Q=async()=>{if(!t)return;let e=N.name.trim(),s=N.apiKey.trim();if((f||s)&&(f||e)&&(!r||N.defaultModel.trim())){q(!0);try{let a=!1;try{I(!0),M(null);let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:s,providerSpecificData:W()})});a=!!(await e.json()).valid,M(a?"success":"failed")}catch{M("failed")}finally{I(!1)}await u({name:e||(f?"Ollama Local":""),apiKey:s,defaultModel:r?N.defaultModel.trim():void 0,priority:N.priority,testStatus:a?"active":"unknown",providerSpecificData:W()})}finally{q(!1)}}},Z=async()=>{let e=J.split("\n").map(e=>e.trim()).filter(Boolean);if(!e.length)return;q(!0),B(null);let s=0,a=0;for(let i=0;i<e.length;i++){let r=e[i].split("|"),l=r.length>=2?r.slice(1).join("|").trim():r[0].trim();if(!l){a++;continue}let n=r.length>=2&&r[0].trim()||"Key",o=`${n} ${i+1}`;try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,apiKey:l,name:o,priority:1,testStatus:"unknown"})})).ok?s++:a++}catch{a++}}q(!1),B({success:s,failed:a}),s>0&&x&&x()};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Add ${s||t} ${b}`,onClose:h,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{size:"sm",variant:"single"===_?"primary":"ghost",onClick:()=>{F("single"),B(null)},children:"Single"}),(0,a.jsx)(d.$n,{size:"sm",variant:"bulk"===_?"primary":"ghost",onClick:()=>{F("bulk"),B(null)},children:"Bulk Add"})]}),"bulk"===_&&(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["One key per line. Format: ",(0,a.jsx)("code",{children:"name|apiKey"})," or just ",(0,a.jsx)("code",{children:"apiKey"})," (auto-named by index)."]}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[140px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:P,value:J,onChange:e=>L(e.target.value)}),K&&(0,a.jsxs)("div",{className:`text-sm font-medium ${K.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",K.success," added",K.failed>0?`, ✗ ${K.failed} failed`:""]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Z,fullWidth:!0,disabled:U||!J.trim(),children:U?"Adding...":"Add All Keys"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"single"===_&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.pd,{label:"Name",value:N.name,onChange:e=>C({...N,name:e.target.value}),placeholder:f?"Ollama Local":"Production Key"}),f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"Ollama Host URL",value:N.ollamaHostUrl,onChange:e=>C({...N,ollamaHostUrl:e.target.value}),placeholder:"http://localhost:11434",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:R||U,variant:"secondary",children:R?"Checking...":"Check"})})]}),!f&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:b,type:y?"text":"password",autoComplete:"off",value:N.apiKey,onChange:e=>C({...N,apiKey:e.target.value}),placeholder:y?"grok-web"===t?"sso=xxxxx... or just the raw value":"eyJhbGciOi...":g?"xai-...":"",className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:G,disabled:!N.apiKey||R||U,variant:"secondary",children:R?"Checking...":"Check"})})]}),g&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Use a direct xAI API key from console.x.ai. This is separate from Grok Build OAuth."}),y&&o&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[o,m&&(0,a.jsxs)(a.Fragment,{children:[" ",(0,a.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:["Open ",m.replace(/^https?:\/\//,"")]})]})]}),w&&(0,a.jsx)(d.l6,{label:"Region",value:O,onChange:e=>E(e.target.value),options:w.map(e=>({value:e.id,label:e.label}))}),r&&(0,a.jsx)(d.pd,{label:"Default Model",value:N.defaultModel,onChange:e=>C({...N,defaultModel:e.target.value}),placeholder:l?"claude-3-5-sonnet-latest":"gpt-4o-mini"}),f&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Leave blank to use ",(0,a.jsx)("code",{children:"http://localhost:11434"}),". For remote Ollama, enter the full host URL (e.g. ",(0,a.jsx)("code",{children:"http://192.168.1.10:11434"}),")."]}),D&&(0,a.jsx)(d.Ex,{variant:"success"===D?"success":"error",children:"success"===D?"Valid":"Invalid"}),p&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:p}),r&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:"Enter the model ID exactly as your compatible endpoint expects it. This model will be saved as the connection default."}),j&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Cloudflare Workers AI"}),(0,a.jsx)(d.pd,{label:"Account ID",value:A.accountId,onChange:e=>T({...A,accountId:e.target.value}),placeholder:"abc123def456..."}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-2",children:["Find your Account ID in the right sidebar of ",(0,a.jsx)("a",{href:"https://dash.cloudflare.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"dash.cloudflare.com"})]})]}),v&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,a.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(d.pd,{label:"Azure Endpoint",value:S.azureEndpoint,onChange:e=>$({...S,azureEndpoint:e.target.value}),placeholder:"https://your-resource.openai.azure.com"}),(0,a.jsx)(d.pd,{label:"Deployment Name",value:S.deployment,onChange:e=>$({...S,deployment:e.target.value}),placeholder:"gpt-4"}),(0,a.jsx)(d.pd,{label:"API Version",value:S.apiVersion,onChange:e=>$({...S,apiVersion:e.target.value}),placeholder:"2024-10-01-preview"}),(0,a.jsx)(d.pd,{label:"Organization",value:S.organization,onChange:e=>$({...S,organization:e.target.value}),placeholder:"Organization ID"})]})]}),(0,a.jsx)(d.pd,{label:"Priority",type:"number",min:1,value:N.priority,onChange:e=>C({...N,priority:Number.parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:Q,fullWidth:!0,disabled:U||!f&&(!H||!V)||r&&!N.defaultModel.trim()||v&&(!S.azureEndpoint||!S.deployment||!S.organization)||j&&!A.accountId,children:U?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:h,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})}):null}function U({isOpen:e,node:t,onSave:s,onClose:r,isAnthropic:l}){let[n,o]=(0,i.useState)({name:"",apiType:"chat",baseUrl:"https://api.openai.com/v1"}),[c,m]=(0,i.useState)(!1),[p,u]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[f,y]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),v=function(e){try{return["http:","https:"].includes(new URL(e).protocol)}catch{return!1}}(n.baseUrl.trim());(0,i.useEffect)(()=>{t&&(o({name:t.name||"",apiType:t.apiType||"chat",baseUrl:t.baseUrl||(l?"https://api.anthropic.com/v1":"https://api.openai.com/v1")}),b(null),u(""),h(""))},[t,l]);let j=async()=>{if(n.name.trim()&&v){m(!0);try{let e={name:n.name.trim(),baseUrl:n.baseUrl.trim()};l||(e.apiType=n.apiType),await s(e)}finally{m(!1)}}},w=async()=>{y(!0);try{let e=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n.baseUrl,apiKey:p,type:l?"anthropic-compatible":"openai-compatible",modelId:x.trim()||void 0})}),t=await e.json();b(t.valid?"success":"failed")}catch{b("failed")}finally{y(!1)}};return t?(0,a.jsx)(d.aF,{isOpen:e,title:`Edit ${l?"Anthropic":"OpenAI"} Compatible`,onClose:r,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(d.pd,{label:"Name",value:n.name,onChange:e=>o({...n,name:e.target.value}),placeholder:`${l?"Anthropic":"OpenAI"} Compatible`,hint:"Friendly label for this provider."}),!l&&(0,a.jsx)(d.l6,{label:"API Type",options:[{value:"chat",label:"Chat Completions"},{value:"responses",label:"Responses API"}],value:n.apiType,onChange:e=>o({...n,apiType:e.target.value})}),(0,a.jsx)(d.pd,{label:"Base URL",value:n.baseUrl,onChange:e=>o({...n,baseUrl:e.target.value}),placeholder:l?"https://api.anthropic.com/v1":"https://api.openai.com/v1",hint:`Base URL ending in /v1 for your ${l?"Anthropic":"OpenAI"}-compatible API.`}),t.prefix?(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Model IDs use prefix ",(0,a.jsx)("code",{className:"bg-sidebar px-1 rounded font-mono",children:t.prefix})," ","(auto-assigned; stable so combos keep working)."]}):null,(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.pd,{label:"API Key (for Check)",type:"password",autoComplete:"off",value:p,onChange:e=>u(e.target.value),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(d.$n,{onClick:w,disabled:!p||f||!v,variant:"secondary",children:f?"Checking...":"Check"})})]}),(0,a.jsx)(d.pd,{label:"Model ID (optional)",value:x,onChange:e=>h(e.target.value),placeholder:"e.g. my-model-id",hint:"If the provider has no /models endpoint, test with a model ID."}),g&&(0,a.jsx)(d.Ex,{variant:"success"===g?"success":"error",children:"success"===g?"Valid":"Invalid"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:j,fullWidth:!0,disabled:!n.name.trim()||!v||c,children:c?"Saving...":"Save"}),(0,a.jsx)(d.$n,{onClick:r,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function q({isOpen:e,providerAlias:t,providerDisplayAlias:s,onSave:r,onClose:l}){let[n,o]=(0,i.useState)(""),[c,m]=(0,i.useState)(null),[p,u]=(0,i.useState)(""),[x,h]=(0,i.useState)(!1);(0,i.useEffect)(()=>{e&&(o(""),m(null),u(""))},[e]);let f=e=>{let s=`${t}/`;return e.startsWith(s)?e.slice(s.length):e},y=async()=>{let e=f(n.trim());if(e){m("testing"),u("");try{let s=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${t}/${e}`})}),a=await s.json();m(a.ok?"ok":"error"),u(a.error||"")}catch(e){m("error"),u(e.message)}}},g=async()=>{let e=f(n.trim());if(e&&!x){h(!0);try{await r(e)}finally{h(!1)}}};return(0,a.jsx)(d.aF,{isOpen:e,onClose:l,title:"Add Custom Model",children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Model ID"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{type:"text",value:n,onChange:e=>{o(e.target.value),m(null),u("")},onKeyDown:e=>{"Enter"===e.key&&y()},placeholder:"e.g. claude-opus-4-5",className:"flex-1 px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",autoFocus:!0}),(0,a.jsx)(d.$n,{variant:"secondary",icon:"science",loading:"testing"===c,onClick:y,disabled:!n.trim()||"testing"===c,children:"testing"===c?"Testing...":"Test"})]}),(0,a.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:["Sent to provider as: ",(0,a.jsx)("code",{className:"font-mono bg-sidebar px-1 rounded",children:f(n.trim())||"model-id"})]})]}),"ok"===c&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-green-600",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"check_circle"}),"Model is reachable"]}),"error"===c&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm text-red-500",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base shrink-0",children:"cancel"}),(0,a.jsx)("span",{children:p||"Model not reachable"})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,a.jsx)(d.$n,{onClick:l,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,a.jsx)(d.$n,{onClick:g,fullWidth:!0,size:"sm",disabled:!n.trim()||x,children:x?"Adding...":"Add Model"})]})]})})}z.propTypes={isOpen:A().bool.isRequired,provider:A().string,providerName:A().string,isCompatible:A().bool,isAnthropic:A().bool,authType:A().string,authHint:A().string,website:A().string,error:A().string,onSave:A().func.isRequired,onBulkDone:A().func,onClose:A().func.isRequired},U.propTypes={isOpen:A().bool.isRequired,node:A().shape({id:A().string,name:A().string,prefix:A().string,apiType:A().string,baseUrl:A().string}),onSave:A().func.isRequired,onClose:A().func.isRequired,isAnthropic:A().bool},q.propTypes={isOpen:A().bool.isRequired,providerAlias:A().string.isRequired,providerDisplayAlias:A().string.isRequired,onSave:A().func.isRequired,onClose:A().func.isRequired};let _=`[
4
+ {
5
+ "accessToken": "eyJhbGc...",
6
+ "refreshToken": "rt_...",
7
+ "idToken": "eyJhbGc...",
8
+ "email": "user@example.com"
9
+ }
10
+ ]`;function F({isOpen:e,onClose:t,onSuccess:s}){let[r,l]=(0,i.useState)(""),[n,o]=(0,i.useState)(!1),[c,m]=(0,i.useState)(""),[p,u]=(0,i.useState)(null),x=()=>{n||(l(""),m(""),u(null),t())},h=async()=>{var e;let t;m(""),u(null);let a=r.trim();if(!a)return;try{t=JSON.parse(a)}catch(e){m(`${(0,w.Tl)("Invalid JSON")}: ${e.message}`);return}let i=Array.isArray(e=t)?e:e&&"object"==typeof e?Array.isArray(e.accounts)?e.accounts:[e]:null;if(!i||0===i.length)return void m((0,w.Tl)("No accounts found in input"));o(!0);try{let e=await fetch("/api/oauth/codex/bulk-import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accounts:i})}),t=await e.json();if(!e.ok)return void m(t?.error||`Request failed: ${e.status}`);u(t),t.success>0&&"function"==typeof s&&s()}catch(e){m(e.message||(0,w.Tl)("Request failed"))}finally{o(!1)}},f=p?.results?.filter(e=>!e.ok)||[];return(0,a.jsx)(d.aF,{isOpen:e,title:(0,w.Tl)("Bulk Add Codex Accounts"),onClose:x,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(0,w.Tl)("Paste an array of codex account JSON objects. Each must include accessToken (and ideally refreshToken, idToken).")}),(0,a.jsx)("textarea",{className:"w-full rounded border border-accent/30 bg-sidebar p-2 text-sm font-mono resize-y min-h-[240px] focus:outline-none focus:ring-1 focus:ring-primary",placeholder:_,value:r,onChange:e=>l(e.target.value),disabled:n}),c&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:c}),p&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:`text-sm font-medium ${p.failed>0?"text-yellow-400":"text-green-400"}`,children:["✓ ",p.success," ",(0,w.Tl)("added"),p.failed>0?`, ✗ ${p.failed} ${(0,w.Tl)("failed")}`:""]}),f.length>0&&(0,a.jsx)("ul",{className:"rounded border border-accent/20 bg-sidebar/50 p-2 text-xs font-mono max-h-40 overflow-y-auto",children:f.map(e=>(0,a.jsxs)("li",{className:"text-red-400",children:["[",e.index,"] ",e.error]},e.index))})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.$n,{onClick:h,fullWidth:!0,disabled:n||!r.trim(),children:n?(0,w.Tl)("Importing..."):(0,w.Tl)("Import All")}),(0,a.jsx)(d.$n,{onClick:x,variant:"ghost",fullWidth:!0,disabled:n,children:(0,w.Tl)("Close")})]})]})})}F.propTypes={isOpen:A().bool.isRequired,onClose:A().func.isRequired,onSuccess:A().func};var J=s(77251);function L({connectionId:e,providerAlias:t,models:s,jobSnapshot:r,onComplete:l,onStarted:n,onClose:o}){let[c,m]=(0,i.useState)(4),[p,u]=(0,i.useState)(50),[x,h]=(0,i.useState)(Math.round(20)),[f,y]=(0,i.useState)(!1),[g,b]=(0,i.useState)(null),[v,j]=(0,i.useState)(null),[w,k]=(0,i.useState)(""),[N,C]=(0,i.useState)(""),[S,$]=(0,i.useState)(""),A=(0,i.useRef)({onComplete:l,onStarted:n}),T=(0,i.useRef)(null),O=(0,i.useRef)(e),E=(0,i.useRef)(null),R=s?.length||0,I=(0,i.useMemo)(()=>`max concurrency 16 \xb7 batch 200 \xb7 timeout ${60}s`,[]);function D(e){if(e){if("idle"===e.status){E.current=null,y(!1);return}if(b({done:e.done||0,total:e.total||0,ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0}),"running"===e.status&&(E.current=e.connectionId||O.current,T.current=null,y(!0)),e.currentRange&&C(`Probing ${e.currentRange.from}–${e.currentRange.to} of ${e.total}…`),e.error&&k(e.error),"done"===e.status||"cancelled"===e.status||"error"===e.status){E.current=null,y(!1);let t={ok:e.ok||0,dead:e.dead||0,retryable:e.retryable||0,tested:e.done||0,skippedDead:e.skippedDead||0,skippedDup:e.skippedDup||0,cancelled:"cancelled"===e.status,retryableAuthOnly:!0===e.retryableAuthOnly};j(t),C("cancelled"===e.status?"Cancelled (partial results saved).":"error"===e.status?"Stopped.":"Done.");let s=`${e.startedAt||"unknown"}:${e.status}`;T.current!==s&&(T.current=s,A.current.onComplete?.(t))}}}async function M(){if(f||!e||0===R)return;y(!0),k(""),j(null),C("Starting…");let a={concurrency:Math.max(1,Math.min(16,Number(c)||4)),batchSize:Math.max(1,Math.min(200,Number(p)||50)),timeoutMs:Math.max(1e3,Math.min(6e4,1e3*(Number(x)||20)))};E.current=e;try{let i=await fetch(`/api/providers/${e}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:s,providerAlias:t,...a,timeoutMs:a.timeoutMs})}),r=await i.json().catch(()=>({}));if(O.current!==e){E.current=null,y(!1);return}if(!i.ok){E.current=null,k(r.error||"Failed to start"),y(!1);return}A.current.onStarted?.(r),D(r),"running"!==r.status&&y(!1)}catch(e){E.current=null,k(e?.message||"Verify failed"),y(!1)}}async function P(){let t=E.current||e;await fetch(`/api/providers/${t}/model-probes/verify/cancel`,{method:"POST"}).catch(()=>{})}async function z(s){if(!e)return;let a="retryable"===s,i=a?Number(v?.retryable||0):Number(v?.dead||0);if(!a||await (0,J.l)({title:"Remove retry-failed models?",message:`Review ${i} retryable result(s) and remove the eligible models? Timeouts, rate limits, network failures, and provider errors may be temporary. Credential failures are kept. Removed models can be enabled or imported again later.`,confirmText:"Remove eligible"})){$(s),k(""),C(`Removing ${a?"retry-failed":"dead"} models…`);try{let i=await fetch(`/api/providers/${e}/model-probes/remove-unavailable`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:t,kind:"llm",status:s})}),r=await i.json().catch(()=>({}));if(!i.ok)return void k(r.error||"Remove failed");let l=Number(r.removed||0),n=Number(r.kept||0),o=v?{...v,[a?"retryable":"dead"]:n,...a?{retryableAuthOnly:n>0}:{}}:v;j(o),C(`Removed ${l} ${a?"retry-failed":"dead"} model(s).`+(n>0?` Kept ${n} credential failure(s).`:"")),A.current.onComplete?.({...o||{},removed:l,kept:n,removedStatus:s})}catch(e){k(e?.message||"Remove failed")}finally{$("")}}}async function U(){if(!e)return;let t=await fetch(`/api/providers/${e}/model-probes/cache`,{method:"DELETE"}),s=await t.json().catch(()=>({}));t.ok?(C(`Cleared probe cache (${s.cleared||0} rows). Next verify will re-test everything.`),j(null),b(null),A.current.onComplete?.({cacheCleared:!0,cleared:s.cleared||0})):k(s.error||"Clear cache failed")}(0,i.useEffect)(()=>{A.current={onComplete:l,onStarted:n},O.current=e}),(0,i.useEffect)(()=>{D(r)},[r]);let q=g?.total?Math.min(100,Math.round(g.done/g.total*100)):0;return(0,a.jsxs)("div",{className:"mb-4 rounded-lg border border-border bg-sidebar/40 p-3 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-text-main",children:"Verify models"}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted mt-0.5",children:["Batch-ping availability and latency. Dead = permanently unavailable (missing, blocked, or deprecated) and can be removed; retry = transient (timeout/429/5xx). Known-dead models are skipped until you Clear cache. Caps: ",I,"."]})]}),o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"p-1 text-text-muted hover:text-text-main rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Concurrency",(0,a.jsx)("input",{type:"number",min:1,max:16,value:c,disabled:f,onChange:e=>m(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Batch size",(0,a.jsx)("input",{type:"number",min:1,max:200,value:p,disabled:f,onChange:e=>u(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("label",{className:"text-xs text-text-muted",children:["Timeout (s)",(0,a.jsx)("input",{type:"number",min:1,max:60,value:x,disabled:f,onChange:e=>h(e.target.value),className:"mt-1 block w-20 rounded-md border border-border bg-background px-2 py-1 text-xs"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[f?(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"stop",onClick:P,children:"Cancel"}):(0,a.jsx)(d.$n,{size:"sm",icon:"science",onClick:M,disabled:!e||0===R,children:"Start"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete_sweep",onClick:U,disabled:f,children:"Clear cache"})]})]}),g&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("div",{className:"h-1.5 w-full rounded-full bg-border overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary transition-all",style:{width:`${q}%`}})}),(0,a.jsxs)("p",{className:"text-[11px] text-text-muted flex flex-wrap gap-x-2",children:[(0,a.jsxs)("span",{title:"Models probed this run",children:[g.done,"/",g.total," tested"]}),(0,a.jsxs)("span",{title:"Reachable",children:["\xb7 ok ",g.ok]}),(0,a.jsxs)("span",{title:"Permanently unavailable this run (missing, blocked, or deprecated)",children:["\xb7 dead ",g.dead]}),(0,a.jsxs)("span",{title:"Transient failure this run (timeout / 429 / 5xx / network); re-testable",children:["\xb7 retry ",g.retryable]}),g.skippedDead?(0,a.jsxs)("span",{title:"Not probed — cache already marks them dead. Clear cache to re-test.",children:["\xb7 skipped known-dead ",g.skippedDead]}):null,g.skippedDup?(0,a.jsxs)("span",{title:"Duplicate ids collapsed",children:["\xb7 dupes ",g.skippedDup]}):null]})]}),N&&(0,a.jsx)("p",{className:"text-xs text-text-muted",children:N}),w&&(0,a.jsx)("p",{className:"text-xs text-red-500 break-words",children:w}),v&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[(0,a.jsxs)("span",{className:"text-xs text-text-main",children:["Summary: ",v.ok," ok \xb7 ",v.dead," dead \xb7 ",v.retryable," retry",v.skippedDead?` \xb7 ${v.skippedDead} skipped known-dead`:"",v.cancelled?" \xb7 cancelled":""]}),v.dead>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"primary",icon:"delete_sweep",onClick:()=>z("dead"),disabled:f||!!S,loading:"dead"===S,children:["Remove ",v.dead," dead"]}),v.retryable>0&&!v.retryableAuthOnly&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete_sweep",onClick:()=>z("retryable"),disabled:f||!!S,loading:"retryable"===S,children:["Remove ",v.retryable," retry failures"]})]})]})}L.propTypes={connectionId:A().string,providerAlias:A().string,models:A().arrayOf(A().object),jobSnapshot:A().object,onComplete:A().func,onStarted:A().func,onClose:A().func};var K=s(36861);let B={claude:"claudeAutoPing",codex:"codexAutoPing"};function H(){let e,t,s,l=(0,r.useParams)(),p=(0,r.useRouter)(),u=l.id,{getCaps:x}=(0,j.y)(),[h,f]=(0,i.useState)([]),[y,g]=(0,i.useState)([]),[k,$]=(0,i.useState)(!0),[A,E]=(0,i.useState)(null),[I,D]=(0,i.useState)(!1),[P,_]=(0,i.useState)(!1),[J,H]=(0,i.useState)(!1),[V,W]=(0,i.useState)(""),[G,Q]=(0,i.useState)(!1),[Z,X]=(0,i.useState)(!1),[Y,ee]=(0,i.useState)(!1),[et,es]=(0,i.useState)(null),[ea,ei]=(0,i.useState)({}),[er,el]=(0,i.useState)([]),[en,eo]=(0,i.useState)(!1),[ed,ec]=(0,i.useState)({}),[em,ep]=(0,i.useState)(""),[eu,ex]=(0,i.useState)(()=>new Set),[eh,ef]=(0,i.useState)(!1),[ey,eg]=(0,i.useState)(null),[eb,ev]=(0,i.useState)(""),[ej,ew]=(0,i.useState)("auto"),[ek,eN]=(0,i.useState)({enabled:!1,connections:{}}),[eC,eS]=(0,i.useState)([]),[e$,eA]=(0,i.useState)([]),[eT,eO]=(0,i.useState)([]),[eE,eR]=(0,i.useState)([]),[eI,eD]=(0,i.useState)(null),[eM,eP]=(0,i.useState)(!1),[ez,eU]=(0,i.useState)(!1),[eq,e_]=(0,i.useState)(!1),[eF,eJ]=(0,i.useState)(null),[eL,eK]=(0,i.useState)({}),[eB,eH]=(0,i.useState)(null),eV=(0,i.useRef)(!1),eW=(0,i.useRef)(null),eG=(0,i.useRef)(0),eQ=(0,i.useRef)(0),[eZ,eX]=(0,i.useState)(!1),[eY,e0]=(0,i.useState)(""),[e1,e2]=(0,i.useState)(!1),[e5,e3]=(0,i.useState)(null),[e4,e6]=(0,i.useState)({}),[e7,e8]=(0,i.useState)({}),[e9,te]=(0,i.useState)("all"),{copied:tt,copy:ts}=(0,v.C)(),ta="ag_risk_confirmed",ti=()=>{D(!0)},tr=()=>{"antigravity"===u&&"true"!==window.localStorage.getItem(ta)?eP(!0):tc?ti():(W(""),H(!0))},tl=()=>{W(""),H(!0)},tn=()=>{tc?tr():tl()},to=A?{id:A.id,name:A.name||("anthropic-compatible"===A.type?"Anthropic Compatible":"OpenAI Compatible"),color:"anthropic-compatible"===A.type?"#D97757":"#10A37F",textIcon:"anthropic-compatible"===A.type?"AC":"OC",apiType:A.apiType,baseUrl:A.baseUrl,type:A.type}:c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u]||c.br[u],td=to?.authModes||[],tc=!!c.zN[u]||!!c.IS[u]||td.includes("oauth"),tm=!!c.fg[u]||td.includes("apikey"),tp=!!c.IS[u]?.noAuth,tu=(0,m.KC)(u),tx=(()=>{let e=new Map(tu.map(e=>[e.id,e]));for(let t of e$)t?.id&&e.set(t.id,{...e.get(t.id),...t});return[...e.values()]})(),th=(0,c.wG)(u),tf=(0,c.mq)(u),ty=(0,c.gb)(u),tg=tf||ty,tb=h.some(e=>!1!==e.isActive),tv=function({isCompatible:e,hasActiveConnection:t}){let s=!e,a=!e;return{showToolbar:s||t||a,showImport:s,showVerify:t,showBulkControls:a}}({isCompatible:tg,hasActiveConnection:tb}),tj=!tg&&tc&&tm,tw="xai"===u?"Grok Build OAuth":"OAuth",tk="xai"===u?"xAI API Key":"API Key",tN=e=>{if(!ej||"auto"===ej)return null;let t=b(u,e);return t&&t.includes(ej)?ej:null},tC=(()=>{let e=new Set;for(let t of tx){let s=b(u,t.id);s&&s.forEach(t=>{"none"!==t&&e.add(t)})}return e.size?["auto",...e]:null})(),tS=tg?u:th,t$=tg?A?.prefix||u:th,tA=(0,C.Iz)(eE,tS),tT=e=>(0,C.uJ)(tA,e,tS),tO=(0,i.useCallback)(async()=>{try{let e=await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tS)}`,{cache:"no-store"}),t=await e.json();e.ok&&eR(t.ids||[])}catch(e){(0,O.s)("Error fetching disabled models:",e)}},[tS]),tE=async e=>{try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tS,ids:[e]})})).ok&&await tO()}catch(e){(0,O.s)("Error disabling model:",e)}},tR=async e=>{try{if(!(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tS)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok)return!1;return await tO(),!0}catch(e){return(0,O.s)("Error enabling model:",e),!1}},tI=async e=>{e.length&&eD({title:"Disable All Models",message:`Disable all ${e.length} model(s)?`,onConfirm:async()=>{eD(null);try{(await fetch("/api/models/disabled",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:tS,ids:e})})).ok&&await tO()}catch(e){(0,O.s)("Error disabling all models:",e)}}})},tD=async()=>{try{(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tS)}`,{method:"DELETE"})).ok&&await tO()}catch(e){(0,O.s)("Error enabling all models:",e)}},tM=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&ei(t.aliases||{})}catch(e){(0,O.s)("Error fetching aliases:",e)}},[]),tP=(0,i.useCallback)(async()=>{try{let e=await fetch("/api/models/custom",{cache:"no-store"}),t=await e.json();e.ok&&el(t.models||[])}catch(e){(0,O.s)("Error fetching custom models:",e)}},[]);(0,i.useEffect)(()=>{"kilocode"===u&&fetch("/api/providers/kilo/free-models").then(e=>e.json()).then(e=>{e.models?.length&&eO(e.models)}).catch(()=>{})},[u]);let tz=(0,i.useCallback)(async()=>{try{let[e,t,s]=await Promise.all([fetch("/api/providers",{cache:"no-store"}),fetch("/api/provider-nodes",{cache:"no-store"}),fetch("/api/settings",{cache:"no-store"})]),a=await e.json(),i=await t.json(),r=s.ok?await s.json():{};if(e.ok){let e=(a.connections||[]).filter(e=>e.provider===u);f(e)}let l=(r.providerStrategies||{})[u]||{};eg(l.fallbackStrategy||null),ev(null!=l.stickyRoundRobinLimit?String(l.stickyRoundRobinLimit):"1");let n=(r.providerThinking||{})[u]||{};ew(n.mode||"auto");let o=B[u],d=o&&r[o]||{};if(eN({enabled:!0===d.enabled,connections:d.connections||{}}),t.ok){let e=(i.nodes||[]).find(e=>e.id===u)||null;if(!e&&tg)for(let t=0;t<3;t+=1){await new Promise(e=>setTimeout(e,150));let t=await fetch("/api/provider-nodes",{cache:"no-store"});if(t.ok&&(e=((await t.json()).nodes||[]).find(e=>e.id===u)||null))break}E(e)}}catch(e){(0,O.s)("Error fetching connections:",e)}finally{$(!1)}},[u,tg]),tU=(0,i.useCallback)(async(e=null)=>{let t=++eQ.current,s=e?h.find(t=>t.id===e&&!1!==t.isActive):h.find(e=>y.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!s){e8({}),e6({});return}try{let e=await fetch(`/api/providers/${s.id}/model-probes`,{cache:"no-store"});if(!e.ok)return;let a=await e.json().catch(()=>({})),i={},r={};for(let e of a.probes||[])i[e.modelId]="ok"===e.status?"ok":"dead"===e.status?"dead":"retry",null!=e.latencyMs&&(r[e.modelId]=e.latencyMs);if(t!==eQ.current)return;e8(i),e6(r)}catch{}},[h,y]),tq=async e=>{try{let t=await fetch(`/api/provider-nodes/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();t.ok&&(E(s.node),await tz(),ee(!1))}catch(e){(0,O.s)("Error updating provider node:",e)}},t_=async(e,t)=>{try{let s=await fetch("/api/settings",{cache:"no-store"}),a=(s.ok?await s.json():{}).providerStrategies||{},i={};e&&(i.fallbackStrategy=e),"round-robin"===e&&""!==t&&(i.stickyRoundRobinLimit=Number(t)||3);let r={...a};0===Object.keys(i).length?delete r[u]:r[u]=i,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:r})})}catch(e){(0,O.s)("Error saving provider strategy:",e)}},tF=async e=>{try{let t=await fetch("/api/settings",{cache:"no-store"}),s={...(t.ok?await t.json():{}).providerThinking||{}};e&&"auto"!==e?s[u]={mode:e}:delete s[u],await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerThinking:s})})}catch(e){(0,O.s)("Error saving thinking config:",e)}},tJ=async e=>{let t=B[u];if(t){eN(e);try{await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[t]:e})})}catch(e){(0,O.s)("Error saving auto-ping config:",e)}}};(0,i.useEffect)(()=>{tz(),tM(),tP(),tO()},[tz,tM,tP,tO]),(0,i.useEffect)(()=>{tU()},[tU]),(0,i.useEffect)(()=>{if(tg)return;let e=h.find(e=>!1!==e.isActive);if(!e)return void eA([]);let t=!1;return fetch(`/api/providers/${e.id}/models`,{cache:"no-store"}).then(e=>e.json().catch(()=>({}))).then(e=>{!t&&Array.isArray(e.models)&&e.models.length>0&&eA(e.models)}).catch(()=>{}),()=>{t=!0}},[h,tg]),(0,i.useEffect)(()=>{let e=(c.zN[u]||c.fg[u]||c.IS[u]||c.nJ[u])?.modelsFetcher;e&&N(e).then(eS)},[u]);let tL=(0,i.useCallback)(e=>{let t=++eG.current;eW.current&&(clearTimeout(eW.current),eW.current=null);let s=async()=>{try{let a=await fetch(`/api/providers/${e}/model-probes/verify/status`,{cache:"no-store"}),i=await a.json().catch(()=>null);if(t!==eG.current)return;if(!a.ok||!i?.status)throw Error("Verify status temporarily unavailable");e3(i&&i.status?i:null),i?.status==="running"?eW.current=setTimeout(s,1500):(eW.current=null,await tU(e))}catch{t===eG.current&&(eW.current=setTimeout(s,1500))}};eW.current=setTimeout(s,0)},[tU]);(0,i.useEffect)(()=>{let e=h.find(e=>y.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);return e?(tL(e.id),()=>{eG.current+=1,eW.current&&(clearTimeout(eW.current),eW.current=null)}):void e3(null)},[h,y,tL]);let tK=async(e,t,s=th)=>{let a=`${s}/${e}`;try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a,alias:t})});if(e.ok)await tM();else{let t=await e.json();(0,O.s)(t.error||"Failed to set alias")}}catch(e){(0,O.s)("Error setting alias:",e)}},tB=async e=>{try{(await fetch(`/api/models/alias?alias=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&await tM()}catch(e){(0,O.s)("Error deleting alias:",e)}},tH=async(e,t="llm",s=tS)=>{try{let a=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerAlias:s,id:e,type:t})});if(a.ok)await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"));else{let e=await a.json();(0,O.s)(e.error||"Failed to add custom model")}}catch(e){(0,O.s)("Error adding custom model:",e)}},tV=async(e,t="llm",s=tS)=>{try{let a=new URLSearchParams({providerAlias:s,id:e,type:t});(await fetch(`/api/models/custom?${a}`,{method:"DELETE"})).ok&&(await tP(),window.dispatchEvent(new CustomEvent("customModelChanged")))}catch(e){(0,O.s)("Error deleting custom model:",e)}},tW=async()=>{if(eZ)return;let e=h.find(e=>y.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive);if(!e)return void(0,O.s)((0,w.Tl)("Add an active connection first"));eX(!0),e0("");try{let t=await fetch(`/api/providers/${e.id}/models`),s=await t.json().catch(()=>({}));if(!t.ok)return void(0,O.s)(s.error||(0,w.Tl)("Failed to fetch models"));let a=s.models||[];if(0===a.length)return void(0,O.s)(s.warning||(0,w.Tl)("No models returned"));let i=new Set;try{let t=await fetch(`/api/providers/${e.id}/model-probes`,{cache:"no-store"});for(let e of(await t.json().catch(()=>({}))).probes||[])"dead"===e.status&&i.add(e.modelId)}catch{}let r=0,l=new Set(tx.map(e=>e.id)),n=[],o=[],d=new Set;for(let e of a){let t=(0,S.R2)(e,tS);if(!t)continue;let{id:s,name:a,type:c}=t;if(i.has((0,K.v)(s,tS))){r+=1;continue}let m=`${c}|${s}`;if(d.has(m))continue;if(d.add(m),l.has(s)){tT(s)&&o.push(s);continue}if(er.some(e=>e.providerAlias===tS&&e.id===s&&(0,S.ki)(e.kind||e.type||"llm")===c))continue;let p=`${tS}/${s}`;Object.values(ea).includes(p)||n.push({providerAlias:tS,id:s,type:c,name:a})}let c=0;if(o.length>0)try{for(let e of o)(await fetch(`/api/models/disabled?providerAlias=${encodeURIComponent(tS)}&id=${encodeURIComponent(e)}`,{method:"DELETE"})).ok&&(c+=1);await tO()}catch{}let m=0;if(n.length>0){let e=await fetch("/api/models/custom",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:n})}),t=await e.json().catch(()=>({}));if(!e.ok)return void(0,O.s)(t.error||(0,w.Tl)("Failed to save models"));m=t.added??n.length,await tP(),window.dispatchEvent(new CustomEvent("customModelChanged"))}let p=n.filter(e=>"llm"!==e.type).length,u=[];if(m>0&&u.push(`${m} new`),c>0&&u.push(`${c} re-enabled`),0===u.length)e0((0,w.Tl)("All models already in list"));else{let e=`Imported ${u.join(" \xb7 ")} (${a.length} from provider)`;p>0&&(e+=" \xb7 non-chat types stored for media pages"),s.warning&&(e+=` \xb7 ${s.warning}`),e0(e)}if(r>0&&e0(e=>`${e} \xb7 ${r} skipped (known dead)`),m>0||c>0)try{let t=[...tx,...n.map(e=>({id:e.id,name:e.name,kind:e.type}))],s=await fetch(`/api/providers/${e.id}/model-probes/verify/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t,providerAlias:tS})}),a=await s.json().catch(()=>({}));if(!s.ok)throw Error(a.error||"Failed to start auto-verify");e3(a&&a.status?a:null),tL(e.id)}catch(e){e0(t=>`${t} \xb7 auto-verify failed: ${e?.message||e}`)}}catch(e){(0,O.s)("Error importing models:",e),(0,O.s)((0,w.Tl)("Error fetching models")+": "+(e?.message||e))}finally{eX(!1)}},tG=async()=>{if(ez||0===h.length)return;let e=Object.fromEntries(h.map(e=>[e.id,{state:"queued",error:null}]));eV.current=!1,eU(!0),e_(!1),eJ(null),eK(e),eH({total:h.length,completed:0,passed:0,failed:0,stopped:!1});let t=0,s=0;try{for(let e=0;e<h.length;e+=1){if(eV.current){eH({total:h.length,completed:e,passed:t,failed:s,stopped:!0});break}let a=h[e];eJ(a.id),eK(e=>({...e,[a.id]:{state:"testing",error:null}}));try{let e=await fetch(`/api/providers/${a.id}/test`,{method:"POST"}),i=await e.json(),r=!!i.valid;r?t+=1:s+=1,eK(e=>({...e,[a.id]:{state:r?"success":"failed",error:r?null:i.error||null}}))}catch(e){s+=1,eK(t=>({...t,[a.id]:{state:"failed",error:e.message||"Test failed"}}))}eH({total:h.length,completed:e+1,passed:t,failed:s,stopped:!1}),e<h.length-1&&await new Promise(e=>setTimeout(e,1e3))}}finally{eJ(null),eU(!1),e_(!1),eV.current=!1}},tQ=async e=>{let t=h.find(t=>t.id===e),s=t?.name?.trim()||t?.email?.trim()||e;eD({title:"Delete Connection",message:`Delete connection “${s}”?`,onConfirm:async()=>{eD(null);try{(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok&&f(t=>t.filter(t=>t.id!==e))}catch(e){(0,O.s)("Error deleting connection:",e)}}})},tZ=()=>{tz(),D(!1)},tX=async e=>{W("");try{let t=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:u,...e})}),s=null;try{s=await t.json()}catch{s=null}if(t.ok){await tz(),H(!1);return}W(s?.error||"Failed to save connection")}catch(e){(0,O.s)("Error saving connection:",e),W("Failed to save connection")}},tY=async e=>{try{(await fetch(`/api/providers/${et.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await tz(),X(!1))}catch(e){(0,O.s)("Error updating connection:",e)}},t0=async(e,t)=>{try{(await fetch(`/api/providers/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok&&f(s=>s.map(s=>s.id===e?{...s,isActive:t}:s))}catch(e){(0,O.s)("Error updating connection status:",e)}},t1=async e=>{let t,s=e?.providerSpecificData?.baseUrl;if(s){try{t=new URL(s).hostname.toLowerCase().replace(/^\[|\]$/g,"")}catch{(0,O.s)("Cannot allow-list: invalid base URL",s);return}try{let e=await fetch("/api/settings",{cache:"no-store"});if(!e.ok)throw Error(`Failed to load settings (${e.status})`);let s=await e.json(),a=[...new Set([...s.ssrfAllowHosts||[],t])],i=await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({ssrfAllowHosts:a})});if(!i.ok)throw Error(`Failed to update allow list (${i.status})`);await tz()}catch(e){(0,O.s)("Error adding host to allow list:",e)}}},t2=async(e,t)=>{let s=[...h];[s[e],s[t]]=[s[t],s[e]],f(s);try{await Promise.all([fetch(`/api/providers/${s[e].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e})}),fetch(`/api/providers/${s[t].id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t})})])}catch(e){(0,O.s)("Error swapping priority:",e),await tz()}},t5=h.length>0&&y.length===h.length,t3=(0,a.jsx)("div",{className:"flex min-w-0 flex-col divide-y divide-black/[0.03] dark:divide-white/[0.03]",children:h.map((e,t)=>(0,a.jsxs)("div",{className:"flex min-w-0 items-stretch",children:[(0,a.jsx)("div",{className:"flex shrink-0 items-center pl-1 sm:pl-2",children:(0,a.jsx)("input",{type:"checkbox",checked:y.includes(e.id),onChange:()=>{var t;return t=e.id,void g(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(M,{connection:e,isOAuth:tc,isFirst:0===t,isLast:t===h.length-1,onMoveUp:()=>t2(t,t-1),onMoveDown:()=>t2(t,t+1),onToggleActive:t=>t0(e.id,t),autoPing:B[u]&&"oauth"===e.authType?{on:!0===ek.connections[e.id],onToggle:t=>{var s;return s=e.id,void tJ({...ek,connections:{...ek.connections,[s]:t}})},provider:u}:null,onEdit:()=>{es(e),X(!0)},onDelete:()=>tQ(e.id),onAllowlistHost:()=>t1(e),oneByOneStatus:eL[e.id]||null})})]},e.id))}),t4=async e=>{if(!eu.has(e)){ex(t=>new Set(t).add(e));try{let t=await fetch("/api/models/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:`${tS}/${e}`})}),s=await t.json();ec(t=>({...t,[e]:s.ok?"ok":"error"})),ep(s.ok?"":s.error||"Model not reachable")}catch{ec(t=>({...t,[e]:"error"})),ep("Network error")}finally{ex(t=>{let s=new Set(t);return s.delete(e),s})}}};return k?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(d.Qv,{}),(0,a.jsx)(d.Qv,{})]}):to?(0,a.jsxs)("div",{className:"flex min-w-0 flex-col gap-6 px-1 sm:gap-8 sm:px-0",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)(n(),{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[(0,a.jsx)("div",{className:"flex size-12 shrink-0 items-center justify-center rounded-lg",style:{backgroundColor:`${to.color}15`},children:en?(0,a.jsx)("span",{className:"text-sm font-bold",style:{color:to.color},children:to.textIcon||to.id.slice(0,2).toUpperCase()}):(0,a.jsx)(o.default,{src:tf&&to.apiType?"responses"===to.apiType?"/providers/oai-r.png":"/providers/oai-cc.png":ty?"/providers/anthropic-m.png":`/providers/${to.id}.png`,alt:to.name,width:48,height:48,className:"max-h-12 max-w-12 rounded-lg object-contain",sizes:"48px",onError:()=>eo(!0)})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)("h1",{className:"truncate text-2xl font-semibold tracking-tight sm:text-3xl",children:to.name}),(to.notice?.apiKeyUrl||to.notice?.signupUrl||to.website)&&(0,a.jsxs)("a",{href:to.notice?.apiKeyUrl||to.notice?.signupUrl||to.website,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),to.notice?.apiKeyUrl?"Get API Key":"Sign up / Learn more"]})]}),(0,a.jsxs)("p",{className:"text-text-muted",children:[h.length," connection",1===h.length?"":"s"]})]})]})]}),to.deprecated&&(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-yellow-500 mt-0.5 shrink-0",children:"warning"}),(0,a.jsx)("p",{className:"text-xs text-red-600 dark:text-yellow-400 leading-relaxed",children:to.deprecationNotice})]}),to.notice?.text&&!to.deprecated&&(0,a.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 sm:flex-row sm:items-center",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[16px] text-blue-500 shrink-0",children:"info"}),(0,a.jsx)("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-blue-600 dark:text-blue-400",children:to.notice.text}),to.notice.apiKeyUrl&&(0,a.jsx)("a",{href:to.notice.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex justify-center rounded bg-blue-500 px-2 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-600 sm:py-0.5",children:"Get API Key →"})]}),tg&&A&&(0,a.jsx)(d.Zp,{children:(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:ty?"Anthropic Compatible Details":"OpenAI Compatible Details"}),(0,a.jsxs)("p",{className:"break-all text-sm text-text-muted",children:[ty?"Messages API":"responses"===A.apiType?"Responses API":"Chat Completions"," \xb7 ",(A.baseUrl||"").replace(/\/$/,""),"/",ty?"messages":"responses"===A.apiType?"responses":"chat/completions"]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:()=>{W(""),H(!0)},className:"w-full sm:w-auto",children:"Add API Key"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"edit",onClick:()=>ee(!0),className:"w-full sm:w-auto",children:"Edit"}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"delete",onClick:async()=>{eD({title:"Delete Compatible Node",message:`Delete this ${ty?"Anthropic":"OpenAI"} Compatible node?`,onConfirm:async()=>{eD(null);try{(await fetch(`/api/provider-nodes/${u}`,{method:"DELETE"})).ok&&p.push("/dashboard/providers")}catch(e){(0,O.s)("Error deleting provider node:",e)}}})},className:"w-full sm:w-auto",children:"Delete"})]})]})}),tp?(0,a.jsx)(d.gw,{providerId:u}):(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",children:[h.length>0&&(0,a.jsxs)(a.Fragment,{children:[y.length>0&&(0,a.jsxs)(d.$n,{size:"sm",variant:"danger",icon:"delete",onClick:()=>{let e=y.length;0!==e&&eD({title:`Delete ${e} Connection${e>1?"s":""}`,message:`Delete ${e} connection${e>1?"s":""}? This cannot be undone.`,onConfirm:async()=>{eD(null);let e=0,t=[...y];for(let s of t)try{(await fetch(`/api/providers/${s}`,{method:"DELETE"})).ok||(e+=1)}catch(t){(0,O.s)("Error deleting connection:",t),e+=1}f(e=>e.filter(e=>!t.includes(e.id))),g([]),e>0&&(0,O.s)(`Deleted ${t.length-e} connection(s), ${e} failed.`)}})},children:["Delete Selected (",y.length,")"]}),(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"sync",onClick:tG,disabled:ez,children:ez?"Testing Connection One-by-One...":"Test Connection One-by-One"}),ez&&(0,a.jsx)(d.$n,{size:"sm",variant:"ghost",icon:"stop",onClick:()=>{ez&&(eV.current=!0,e_(!0))},disabled:eq,children:eq?"Stopping...":"Stop"})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted font-medium",children:"Round Robin"}),(0,a.jsx)(d.lM,{checked:"round-robin"===ey,onChange:e=>{let t=e?"round-robin":null,s=e?eb||"1":eb;e&&!eb&&ev("1"),eg(t),t_(t,s)}}),"round-robin"===ey&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"text-xs text-text-muted",children:"Sticky:"}),(0,a.jsx)("input",{type:"number",min:1,value:eb,onChange:e=>{var t;ev(t=e.target.value),t_("round-robin",t)},placeholder:"1",className:"w-14 px-2 py-1 text-xs border border-border rounded-md bg-background focus:outline-none focus:border-primary"})]})]})]})]}),0===h.length?(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"inline-flex items-center justify-center w-9 h-9 rounded-full bg-primary/10 text-primary shrink-0",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:tc?"lock":"key"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"}),tj&&(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:["Choose ",tw," or ",tk,"."]})]})]}),(0,a.jsx)("div",{className:"flex gap-2",children:tj?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tr,children:tw}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,children:tk})]}):(0,a.jsxs)(a.Fragment,{children:[!tg&&"iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),children:"Cookie"}),"codex"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Q(!0),children:(0,w.Tl)("Bulk Add")}),(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tn,children:tg?"Add API Key":"iflow"===u?"OAuth":"Add Connection"})]})})]}):(0,a.jsxs)(a.Fragment,{children:[eB&&(0,a.jsx)("div",{className:"mb-4 rounded-lg border border-black/10 bg-black/[0.02] px-3 py-2 text-xs text-text-muted dark:border-white/10 dark:bg-white/[0.03]",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,a.jsxs)("span",{children:["Total: ",eB.total]}),(0,a.jsxs)("span",{children:["Completed: ",eB.completed]}),(0,a.jsxs)("span",{children:["Passed: ",eB.passed]}),(0,a.jsxs)("span",{children:["Failed: ",eB.failed]}),eB.stopped&&(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Stopped"}),ez&&eF&&(0,a.jsxs)("span",{children:["Running: ",h.find(e=>e.id===eF)?.name||eF]})]})}),h.length>0&&(0,a.jsx)("div",{className:"mb-3 flex items-center gap-2 border-b border-black/[0.03] pb-2 dark:border-white/[0.03]",children:(0,a.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-xs text-text-muted hover:text-primary",children:[(0,a.jsx)("input",{type:"checkbox",checked:t5,onChange:()=>{t5?g([]):g(h.map(e=>e.id))},className:"h-3.5 w-3.5 rounded border-gray-300 text-primary focus:ring-primary"}),"Select All"]})}),t3,!tg&&(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2 sm:flex",children:["iflow"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"cookie",variant:"secondary",onClick:()=>_(!0),title:"Add connection using browser cookie",className:"w-full sm:w-auto",children:"Cookie"}),"codex"===u&&(0,a.jsx)(d.$n,{size:"sm",icon:"playlist_add",variant:"secondary",onClick:()=>Q(!0),title:(0,w.Tl)("Bulk import codex accounts from JSON"),className:"w-full sm:w-auto",children:(0,w.Tl)("Bulk Add")}),tj?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.$n,{size:"sm",icon:"lock",variant:"secondary",onClick:tr,className:"w-full sm:w-auto",children:tw}),(0,a.jsx)(d.$n,{size:"sm",icon:"key",onClick:tl,className:"w-full sm:w-auto",children:tk})]}):(0,a.jsx)(d.$n,{size:"sm",icon:"add",onClick:tn,className:"w-full sm:w-auto",children:"Add"})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Available Models"}),tC&&(0,a.jsx)("select",{value:ej,onChange:e=>{var t;ew(t=e.target.value),tF(t)},title:"Appends (level) suffix to copied model names",className:"rounded-md border border-border bg-background px-2 py-1 text-xs focus:border-primary focus:outline-none",children:tC.map(e=>(0,a.jsx)("option",{value:e,children:`Thinking: ${e.charAt(0).toUpperCase()+e.slice(1)}`},e))})]}),tv.showToolbar&&(e=(tv.showBulkControls?[...tx,...eT.filter(e=>!tx.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}).map(e=>e.id):[]).filter(e=>!tT(e)),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[tv.showImport&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:eZ?"progress_activity":"cloud_download",onClick:tW,disabled:eZ||!tb,title:tb?"Import models from the active connection":"Add an active connection to import models",children:eZ?"Importing...":"Import models"}),tv.showVerify&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:e5?.status==="running"?"progress_activity":"science",onClick:()=>e2(e=>!e),children:e5?.status==="running"?`Verifying ${e5.done}/${e5.total}`:e1?"Hide verify":"Verify models"}),tv.showBulkControls&&eE.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"restart_alt",onClick:tD,children:"Active All"}),tv.showBulkControls&&e.length>0&&(0,a.jsx)(d.$n,{size:"sm",variant:"secondary",icon:"block",onClick:()=>tI(e),children:"Disable All"})]}))]}),!!em&&(0,a.jsx)("p",{className:"text-xs text-red-500 mb-3 break-words",children:em}),eY&&(0,a.jsx)("p",{className:"text-xs text-text-muted mb-3",children:eY}),e1&&(t=h.find(e=>y.includes(e.id)&&!1!==e.isActive)||h.find(e=>!1!==e.isActive),s=[...(0,C.R3)({customModels:er,modelAliases:ea,providerAlias:tS,builtInModels:tx,type:"llm"}).filter(e=>!tT(e.id)).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"})),...tx.filter(e=>{let t=(0,m.CP)(e);return(!t||"llm"===t)&&!tT(e.id)}).map(e=>({id:e.id,name:e.name||e.id,kind:"llm"}))],(0,a.jsx)(L,{connectionId:t?.id,providerAlias:tS,models:s,jobSnapshot:e5,onClose:()=>e2(!1),onStarted:e=>{e3(e&&e.status?e:null);let s=e?.connectionId||t?.id;s&&tL(s)},onComplete:async e=>{e?.removedStatus&&e3(t=>t?{...t,dead:Number(e.dead??t.dead??0),retryable:Number(e.retryable??t.retryable??0),retryableAuthOnly:!0===e.retryableAuthOnly}:t),e?.removed>0&&await tP(),e?.removed>0&&await tO(),(e?.removed>0||e?.cacheCleared)&&await tU(t?.id)}})),(()=>{let e,t,s;if(tg)return(0,a.jsx)(R,{providerStorageAlias:tS,providerDisplayAlias:t$,modelAliases:ea,customModels:er,copied:tt,onCopy:ts,onSetAlias:tK,onDeleteAlias:tB,onAddCustomModel:e=>tH(e,"llm",tS),onDeleteCustomModel:e=>tV(e,"llm",tS),onRefreshModels:tP,connections:h,isAnthropic:ty,disabledModelIds:eE,onEnableModel:tR});let i=[...tx,...eT.filter(e=>!tx.some(t=>t.id===e.id))].filter(e=>{let t=(0,m.CP)(e);return!t||"llm"===t}),r=i.filter(e=>!tT(e.id)),l=i.filter(e=>tT(e.id)),n=(0,C.R3)({customModels:er,modelAliases:ea,providerAlias:tS,builtInModels:tx,type:"llm"}),o=n.filter(e=>!tT(e.id)&&("all"===e9||(e7[(0,K.v)(e.id,tS)]||null)===e9)),d=r.filter(e=>"all"===e9||(e7[(0,K.v)(e.id,tS)]||null)===e9);return(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)("div",{className:"mb-2 flex gap-1 text-xs",children:["all","ok","dead","retry"].map(e=>(0,a.jsx)("button",{onClick:()=>te(e),className:`rounded px-2 py-0.5 ${e9===e?"bg-primary text-white":"text-text-muted hover:bg-black/5 dark:hover:bg-white/5"}`,children:"all"===e?"All":"ok"===e?"OK":"dead"===e?"Dead":"Retry"},e))}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3",children:[o.map(e=>{let t=(0,K.v)(e.id,tS);return(0,a.jsx)(T,{model:{id:e.id,name:e.name},fullModel:`${t$}/${e.id}`,alias:e.alias,copied:tt,onCopy:ts,onSetAlias:()=>{},onDeleteAlias:()=>{"custom"===e.source?tV(e.id,"llm",tS):tB(e.alias)},testStatus:ed[e.id],onTest:h.length>0||tp?()=>t4(e.id):void 0,isTesting:eu.has(e.id),isCustom:!0,isFree:!1,caps:x(`${u}/${e.id}`),thinkingSuffix:tN(e.id),latencyMs:e4[e.id]??e4[t],probeState:e5?.status==="running"&&e5?.perModel?.[t]?e5.perModel[t]:e7[t]||null},`${e.source}-${e.fullModel}`)}),d.map(e=>{let t=`${tS}/${e.id}`,s=`${u}/${e.id}`,i=Object.entries(ea).find(([,e])=>e===t||e===s)?.[0],r=(0,K.v)(e.id,tS);return(0,a.jsx)(T,{model:e,fullModel:`${t$}/${e.id}`,alias:i,copied:tt,onSetAlias:t=>tK(e.id,t,tS),onCopy:ts,onDeleteAlias:()=>tB(i),testStatus:ed[e.id],onTest:h.length>0||tp?()=>t4(e.id):void 0,isTesting:eu.has(e.id),isFree:e.isFree,onDisable:()=>tE(e.id),caps:x(`${u}/${e.id}`),thinkingSuffix:tN(e.id),latencyMs:e4[e.id]??e4[r],probeState:e5?.status==="running"&&e5?.perModel?.[r]?e5.perModel[r]:e7[r]||null},e.id)}),(0,a.jsxs)("button",{onClick:()=>ef(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-primary/40 px-3 py-2 text-xs text-primary transition-colors hover:border-primary hover:bg-primary/5 sm:w-auto",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:"add"}),"Add Model"]}),eC.length>0&&(e=new Set([...Object.values(ea),...n.map(e=>e.fullModel)]),t=new Set(tx.map(e=>e.id)),0===(s=eC.filter(s=>!e.has(`${tS}/${s.id}`)&&!t.has(s.id))).length?null:(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"Suggested free models (≥200k context):"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(e=>(0,a.jsxs)("button",{onClick:async()=>{await tH(e.id,"llm",tS)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:`${e.name} \xb7 ${(e.contextLength/1e3).toFixed(0)}k ctx`,children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id.split("/").pop()]},e.id))})]})),l.length>0&&(0,a.jsxs)("div",{className:"w-full mt-2",children:[(0,a.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Disabled models (",l.length,"):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,a.jsxs)("button",{onClick:()=>tR(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border border-dashed border-black/10 dark:border-white/10 text-xs text-text-muted hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors",title:"Restore model",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"add"}),e.id]},e.id))})]})]})]})})()]}),"kiro"===u?(0,a.jsx)(d.Mh,{isOpen:I,providerInfo:to,onSuccess:tZ,onClose:()=>D(!1)}):"cursor"===u?(0,a.jsx)(d.G9,{isOpen:I,onSuccess:tZ,onClose:()=>D(!1)}):"gitlab"===u?(0,a.jsx)(d.vj,{isOpen:I,providerInfo:to,onSuccess:tZ,onClose:()=>D(!1)}):(0,a.jsx)(d.LF,{isOpen:I,provider:u,providerInfo:to,onSuccess:tZ,onClose:()=>D(!1)}),"iflow"===u&&(0,a.jsx)(d.vE,{isOpen:P,onSuccess:()=>{tz(),_(!1)},onClose:()=>_(!1)}),(0,a.jsx)(z,{isOpen:J,provider:u,providerName:to.name,isCompatible:tg,isAnthropic:ty,authType:to?.authType,authHint:to?.authHint,website:to?.website,error:V,onSave:tX,onBulkDone:tz,onClose:()=>{W(""),H(!1)}}),(0,a.jsx)(d.wI,{isOpen:Z,connection:et,onSave:tY,onClose:()=>X(!1)}),tg&&(0,a.jsx)(U,{isOpen:Y,node:A,onSave:tq,onClose:()=>ee(!1),isAnthropic:ty}),!tg&&(0,a.jsx)(q,{isOpen:eh,providerAlias:tS,providerDisplayAlias:t$,onSave:async e=>{await tH(e,"llm",tS),ef(!1)},onClose:()=>ef(!1)}),"codex"===u&&(0,a.jsx)(F,{isOpen:G,onClose:()=>Q(!1),onSuccess:tz}),(0,a.jsx)(d.uo,{isOpen:eM,onClose:()=>eP(!1),onConfirm:()=>{(window.localStorage.setItem(ta,"true"),eP(!1),tc)?ti():tl()},title:"Risk Notice",message:to?.deprecationNotice,confirmText:"I Understand, Continue",cancelText:"Cancel",variant:"danger"}),(0,a.jsx)(d.uo,{isOpen:!!eI,onClose:()=>eD(null),onConfirm:eI?.onConfirm,title:eI?.title||"Confirm",message:eI?.message,variant:"danger"})]}):(0,a.jsxs)("div",{className:"text-center py-20",children:[(0,a.jsx)("p",{className:"text-text-muted",children:"Provider not found"}),(0,a.jsx)(n(),{href:"/dashboard/providers",className:"text-primary mt-4 inline-block",children:"Back to Providers"})]})}},70217:(e,t,s)=>{"use strict";function a(e,t){return!1===e?"default":"active"===t||"success"===t?"success":"error"===t||"expired"===t||"unavailable"===t?"error":"default"}s.d(t,{g:()=>a})}},e=>{e.O(0,[2574,3862,782,8500,594,1321,7592,5497,8441,3794,7358],()=>e(e.s=7687)),_N_E=e.O()}]);