9router 0.2.16 → 0.2.17

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 (183) hide show
  1. package/LICENSE +4 -0
  2. package/app/.next/BUILD_ID +1 -1
  3. package/app/.next/app-build-manifest.json +136 -136
  4. package/app/.next/app-path-routes-manifest.json +19 -19
  5. package/app/.next/build-manifest.json +5 -5
  6. package/app/.next/prerender-manifest.json +34 -34
  7. package/app/.next/react-loadable-manifest.json +13 -0
  8. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js +5 -5
  9. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page.js.nft.json +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js +2 -2
  12. package/app/.next/server/app/(dashboard)/dashboard/combos/page.js.nft.json +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page.js.nft.json +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/page.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/page.js.nft.json +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js +2 -2
  21. package/app/.next/server/app/(dashboard)/dashboard/profile/page.js.nft.json +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +2 -2
  24. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js.nft.json +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page.js.nft.json +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js +2 -2
  30. package/app/.next/server/app/(dashboard)/dashboard/providers/page.js.nft.json +1 -1
  31. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/_not-found/page.js +2 -2
  33. package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
  34. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/_not-found.html +1 -1
  36. package/app/.next/server/app/_not-found.rsc +2 -2
  37. package/app/.next/server/app/api/cli-tools/claude-settings/route_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/api/cli-tools/codex-settings/route_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/api/cloud/auth/route.js +1 -1
  40. package/app/.next/server/app/api/cloud/auth/route_client-reference-manifest.js +1 -1
  41. package/app/.next/server/app/api/cloud/credentials/update/route.js +1 -1
  42. package/app/.next/server/app/api/cloud/credentials/update/route_client-reference-manifest.js +1 -1
  43. package/app/.next/server/app/api/cloud/model/resolve/route.js +1 -1
  44. package/app/.next/server/app/api/cloud/model/resolve/route_client-reference-manifest.js +1 -1
  45. package/app/.next/server/app/api/cloud/models/alias/route.js +1 -1
  46. package/app/.next/server/app/api/cloud/models/alias/route_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/api/combos/[id]/route.js +1 -1
  48. package/app/.next/server/app/api/combos/[id]/route_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/api/combos/route.js +1 -1
  50. package/app/.next/server/app/api/combos/route_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/api/init/route.js +1 -1
  52. package/app/.next/server/app/api/init/route.js.nft.json +1 -1
  53. package/app/.next/server/app/api/init/route_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/api/keys/[id]/route.js +1 -1
  55. package/app/.next/server/app/api/keys/[id]/route_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/api/keys/route.js +1 -1
  57. package/app/.next/server/app/api/keys/route_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/api/models/alias/route.js +1 -1
  59. package/app/.next/server/app/api/models/alias/route_client-reference-manifest.js +1 -1
  60. package/app/.next/server/app/api/models/route.js +1 -1
  61. package/app/.next/server/app/api/models/route.js.nft.json +1 -1
  62. package/app/.next/server/app/api/models/route_client-reference-manifest.js +1 -1
  63. package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +1 -1
  64. package/app/.next/server/app/api/oauth/[provider]/[action]/route_client-reference-manifest.js +1 -1
  65. package/app/.next/server/app/api/providers/[id]/models/route.js +1 -1
  66. package/app/.next/server/app/api/providers/[id]/models/route_client-reference-manifest.js +1 -1
  67. package/app/.next/server/app/api/providers/[id]/route.js +1 -1
  68. package/app/.next/server/app/api/providers/[id]/route_client-reference-manifest.js +1 -1
  69. package/app/.next/server/app/api/providers/[id]/test/route.js +1 -1
  70. package/app/.next/server/app/api/providers/[id]/test/route_client-reference-manifest.js +1 -1
  71. package/app/.next/server/app/api/providers/client/route.js +1 -1
  72. package/app/.next/server/app/api/providers/client/route_client-reference-manifest.js +1 -1
  73. package/app/.next/server/app/api/providers/route.js +1 -1
  74. package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
  75. package/app/.next/server/app/api/providers/route_client-reference-manifest.js +1 -1
  76. package/app/.next/server/app/api/providers/validate/route_client-reference-manifest.js +1 -1
  77. package/app/.next/server/app/api/settings/route.js +1 -1
  78. package/app/.next/server/app/api/settings/route_client-reference-manifest.js +1 -1
  79. package/app/.next/server/app/api/shutdown/route_client-reference-manifest.js +1 -1
  80. package/app/.next/server/app/api/sync/cloud/route.js +1 -1
  81. package/app/.next/server/app/api/sync/cloud/route_client-reference-manifest.js +1 -1
  82. package/app/.next/server/app/api/sync/initialize/route.js +1 -1
  83. package/app/.next/server/app/api/sync/initialize/route.js.nft.json +1 -1
  84. package/app/.next/server/app/api/sync/initialize/route_client-reference-manifest.js +1 -1
  85. package/app/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  86. package/app/.next/server/app/api/usage/[connectionId]/route.js +1 -1
  87. package/app/.next/server/app/api/usage/[connectionId]/route_client-reference-manifest.js +1 -1
  88. package/app/.next/server/app/api/v1/api/chat/route.js +1 -1
  89. package/app/.next/server/app/api/v1/api/chat/route.js.nft.json +1 -1
  90. package/app/.next/server/app/api/v1/api/chat/route_client-reference-manifest.js +1 -1
  91. package/app/.next/server/app/api/v1/chat/completions/route.js +1 -1
  92. package/app/.next/server/app/api/v1/chat/completions/route.js.nft.json +1 -1
  93. package/app/.next/server/app/api/v1/chat/completions/route_client-reference-manifest.js +1 -1
  94. package/app/.next/server/app/api/v1/messages/count_tokens/route_client-reference-manifest.js +1 -1
  95. package/app/.next/server/app/api/v1/messages/route.js +1 -1
  96. package/app/.next/server/app/api/v1/messages/route.js.nft.json +1 -1
  97. package/app/.next/server/app/api/v1/messages/route_client-reference-manifest.js +1 -1
  98. package/app/.next/server/app/api/v1/responses/route.js +1 -1
  99. package/app/.next/server/app/api/v1/responses/route.js.nft.json +1 -1
  100. package/app/.next/server/app/api/v1/responses/route_client-reference-manifest.js +1 -1
  101. package/app/.next/server/app/api/v1/route_client-reference-manifest.js +1 -1
  102. package/app/.next/server/app/api/v1beta/models/[...path]/route.js +1 -1
  103. package/app/.next/server/app/api/v1beta/models/[...path]/route.js.nft.json +1 -1
  104. package/app/.next/server/app/api/v1beta/models/[...path]/route_client-reference-manifest.js +1 -1
  105. package/app/.next/server/app/api/v1beta/models/route.js +1 -1
  106. package/app/.next/server/app/api/v1beta/models/route.js.nft.json +1 -1
  107. package/app/.next/server/app/api/v1beta/models/route_client-reference-manifest.js +1 -1
  108. package/app/.next/server/app/callback/page.js +1 -1
  109. package/app/.next/server/app/callback/page.js.nft.json +1 -1
  110. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  111. package/app/.next/server/app/callback.html +1 -1
  112. package/app/.next/server/app/callback.rsc +2 -2
  113. package/app/.next/server/app/dashboard/cli-tools.html +1 -1
  114. package/app/.next/server/app/dashboard/cli-tools.rsc +4 -4
  115. package/app/.next/server/app/dashboard/combos.html +1 -1
  116. package/app/.next/server/app/dashboard/combos.rsc +4 -4
  117. package/app/.next/server/app/dashboard/endpoint.html +1 -1
  118. package/app/.next/server/app/dashboard/endpoint.rsc +4 -4
  119. package/app/.next/server/app/dashboard/profile.html +1 -1
  120. package/app/.next/server/app/dashboard/profile.rsc +4 -4
  121. package/app/.next/server/app/dashboard/providers/new.html +1 -1
  122. package/app/.next/server/app/dashboard/providers/new.rsc +4 -4
  123. package/app/.next/server/app/dashboard/providers.html +1 -1
  124. package/app/.next/server/app/dashboard/providers.rsc +4 -4
  125. package/app/.next/server/app/dashboard.html +1 -1
  126. package/app/.next/server/app/dashboard.rsc +4 -4
  127. package/app/.next/server/app/index.html +1 -1
  128. package/app/.next/server/app/index.rsc +2 -2
  129. package/app/.next/server/app/landing/page.js +1 -1
  130. package/app/.next/server/app/landing/page.js.nft.json +1 -1
  131. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  132. package/app/.next/server/app/landing.html +1 -1
  133. package/app/.next/server/app/landing.rsc +2 -2
  134. package/app/.next/server/app/page.js +1 -1
  135. package/app/.next/server/app/page.js.nft.json +1 -1
  136. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  137. package/app/.next/server/app-paths-manifest.json +19 -19
  138. package/app/.next/server/chunks/1354.js +3 -3
  139. package/app/.next/server/chunks/3103.js +1 -1
  140. package/app/.next/server/chunks/5170.js +1 -1
  141. package/app/.next/server/chunks/533.js +1 -0
  142. package/app/.next/server/chunks/{6689.js → 5451.js} +2 -2
  143. package/app/.next/server/chunks/5977.js +1 -1
  144. package/app/.next/server/chunks/9858.js +1 -0
  145. package/app/.next/server/middleware-build-manifest.js +1 -1
  146. package/app/.next/server/middleware-react-loadable-manifest.js +1 -1
  147. package/app/.next/server/pages/404.html +1 -1
  148. package/app/.next/server/pages/500.html +1 -1
  149. package/app/.next/server/webpack-runtime.js +1 -1
  150. package/app/.next/static/chunks/1393-74e0710828062f40.js +1 -0
  151. package/app/.next/static/chunks/2819-00dd2839ed1323e4.js +1 -0
  152. package/app/.next/static/chunks/3431.b7e68d807c631773.js +1 -0
  153. package/app/.next/static/chunks/9220.745ac8c97d067b9a.js +1 -0
  154. package/app/.next/static/chunks/9955-cba200dfd971f126.js +1 -0
  155. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-1ef1ec29086061fd.js +1 -0
  156. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-f18c8b5778e91a72.js +1 -0
  157. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-636932605724d0ce.js +1 -0
  158. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-81c3e3fb971037c1.js +1 -0
  159. package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/page-327e2f8b73368cc2.js +1 -0
  160. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-800270dff34413c0.js +1 -0
  161. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-9e075d79ef785c9b.js +1 -0
  162. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/page-eea1c0bf95c10035.js +1 -0
  163. package/app/.next/static/chunks/app/(dashboard)/{layout-239cdcb35472d644.js → layout-65f98ae0eccfc7b8.js} +1 -1
  164. package/app/.next/static/chunks/webpack-5865472aea7b6340.js +1 -0
  165. package/app/package.json +2 -0
  166. package/cli.js +11 -38
  167. package/package.json +1 -1
  168. package/app/.next/server/chunks/1582.js +0 -1
  169. package/app/.next/server/chunks/3576.js +0 -1
  170. package/app/.next/static/chunks/1393-c0bf788a0bc19102.js +0 -1
  171. package/app/.next/static/chunks/4244-0a98cf2e73799efe.js +0 -1
  172. package/app/.next/static/chunks/9955-a027f64b1a9bf4e5.js +0 -1
  173. package/app/.next/static/chunks/app/(dashboard)/dashboard/cli-tools/page-9009a2a4fdcd878c.js +0 -1
  174. package/app/.next/static/chunks/app/(dashboard)/dashboard/combos/page-95da854765deba41.js +0 -1
  175. package/app/.next/static/chunks/app/(dashboard)/dashboard/endpoint/page-98e477f1e2603f2b.js +0 -1
  176. package/app/.next/static/chunks/app/(dashboard)/dashboard/page-1dce481cbcf036bc.js +0 -1
  177. package/app/.next/static/chunks/app/(dashboard)/dashboard/profile/page-c3dd45dfdb0b9dec.js +0 -1
  178. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-60e73b7047f9e428.js +0 -1
  179. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/new/page-1f016f32f42ef1f9.js +0 -1
  180. package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/page-407c2ce547816028.js +0 -1
  181. package/app/.next/static/chunks/webpack-e009a29a8139b7cb.js +0 -1
  182. /package/app/.next/static/{CjtizKLK3s08esa00wWI0 → jTOq4rGDmshmQFiyCGWaU}/_buildManifest.js +0 -0
  183. /package/app/.next/static/{CjtizKLK3s08esa00wWI0 → jTOq4rGDmshmQFiyCGWaU}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2326],{2016:(e,t,s)=>{Promise.resolve().then(s.bind(s,6445))},6445:(e,t,s)=>{"use strict";s.d(t,{default:()=>p});var l=s(5155),a=s(2115),r=s(4244);let o={claude:{id:"claude",name:"Claude Code",icon:"terminal",color:"#D97757",description:"Anthropic Claude Code CLI",configType:"env",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","haiku","opusplan"],settingsFile:"~/.claude/settings.json",defaultModels:[{id:"opus",name:"Claude Opus",alias:"opus",envKey:"ANTHROPIC_DEFAULT_OPUS_MODEL",defaultValue:"cc/claude-opus-4-5-20251101"},{id:"sonnet",name:"Claude Sonnet",alias:"sonnet",envKey:"ANTHROPIC_DEFAULT_SONNET_MODEL",defaultValue:"cc/claude-sonnet-4-5-20250929"},{id:"haiku",name:"Claude Haiku",alias:"haiku",envKey:"ANTHROPIC_DEFAULT_HAIKU_MODEL",defaultValue:"cc/claude-haiku-4-5-20251001"}]},codex:{id:"codex",name:"OpenAI Codex CLI",image:"/providers/codex.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"custom"},cursor:{id:"cursor",name:"Cursor",image:"/providers/cursor.png",color:"#000000",description:"Cursor AI Code Editor",configType:"guide",requiresCloud:!0,notes:[{type:"warning",text:"Requires Cursor Pro account to use this feature."},{type:"cloudCheck",text:"Cursor routes requests through its own server, so local endpoint is not supported. Please enable Cloud Endpoint in Settings."}],guideSteps:[{step:1,title:"Open Settings",desc:"Go to Settings → Models"},{step:2,title:"Enable OpenAI API",desc:'Enable "OpenAI API key" option'},{step:3,title:"Base URL",value:"{{baseUrl}}/v1",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Add Custom Model",desc:'Click "View All Model" → "Add Custom Model"'},{step:6,title:"Select Model",type:"modelSelector"}]},cline:{id:"cline",name:"CLINE",image:"/providers/cline.png",color:"#00D1B2",description:"CLINE AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to CLINE Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},roo:{id:"roo",name:"Roo",image:"/providers/roo.png",color:"#FF6B6B",description:"Roo AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Settings",desc:"Go to Roo Settings panel"},{step:2,title:"Select Provider",desc:"Choose API Provider → Ollama"},{step:3,title:"Base URL",value:"{{baseUrl}}",copyable:!0},{step:4,title:"API Key",type:"apiKeySelector"},{step:5,title:"Select Model",type:"modelSelector"}]},continue:{id:"continue",name:"Continue",image:"/providers/continue.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"guide",guideSteps:[{step:1,title:"Open Config",desc:"Open Continue configuration file"},{step:2,title:"API Key",type:"apiKeySelector"},{step:3,title:"Select Model",type:"modelSelector"},{step:4,title:"Add Model Config",desc:"Add the following configuration to your models array:"}],codeBlock:{language:"json",code:'{\n "apiBase": "{{baseUrl}}",\n "title": "{{model}}",\n "model": "{{model}}",\n "provider": "openai",\n "apiKey": "{{apiKey}}"\n}'}}};var n=s(505),i=s(5239);let c="https://9router.com";function d(e){let{tool:t,isExpanded:s,onToggle:o,activeProviders:n,modelMappings:d,onModelMappingChange:x,baseUrl:m,hasActiveProviders:u,apiKeys:p,cloudEnabled:h}=e,[g,y]=(0,a.useState)(null),[f,b]=(0,a.useState)(!1),[j,v]=(0,a.useState)(!1),[N,k]=(0,a.useState)(!1),[C,w]=(0,a.useState)(null),[S,_]=(0,a.useState)(!1),[A,E]=(0,a.useState)(!1),[O,I]=(0,a.useState)(null),[P,T]=(0,a.useState)(""),[L,K]=(0,a.useState)(!1),[M,R]=(0,a.useState)({}),U=(()=>{var e,t;if(!(null==g?void 0:g.installed))return null;let s=null==(t=g.settings)||null==(e=t.env)?void 0:e.ANTHROPIC_BASE_URL;if(!s)return"not_configured";let l=s.includes("localhost")||s.includes("127.0.0.1"),a=h&&c&&s.startsWith(c);return l||a?"configured":"other"})();(0,a.useEffect)(()=>{(null==p?void 0:p.length)>0&&!P&&T(p[0].key)},[p]),(0,a.useEffect)(()=>{s&&!g&&(D(),H())},[s]);let H=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&R(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(null==g?void 0:g.installed){var e;let s=(null==(e=g.settings)?void 0:e.env)||{};t.defaultModels.forEach(e=>{if(e.envKey){let t=s[e.envKey]||e.defaultValue||"";t&&x(e.alias,t)}});let l=s.ANTHROPIC_AUTH_TOKEN;l&&(null==p?void 0:p.some(e=>e.key===l))&&T(l)}},[g,p]);let D=async()=>{b(!0);try{let e=await fetch("/api/cli-tools/claude-settings"),t=await e.json();y(t)}catch(e){y({installed:!1,error:e.message})}finally{b(!1)}},F=async()=>{v(!0),w(null);try{let e={ANTHROPIC_BASE_URL:m},s=(null==P?void 0:P.trim())||((null==p?void 0:p.length)>0?p[0].key:null)||(h?null:"sk_9router");s&&(e.ANTHROPIC_AUTH_TOKEN=s),t.defaultModels.forEach(t=>{let s=d[t.alias];s&&t.envKey&&(e[t.envKey]=s)});let l=await fetch("/api/cli-tools/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:e})}),a=await l.json();l.ok?(w({type:"success",text:"Settings applied successfully!"}),y(t=>({...t,hasBackup:!0,settings:{...null==t?void 0:t.settings,env:e}}))):w({type:"error",text:a.error||"Failed to apply settings"})}catch(e){w({type:"error",text:e.message})}finally{v(!1)}},z=async()=>{k(!0),w(null);try{let e=await fetch("/api/cli-tools/claude-settings",{method:"DELETE"}),s=await e.json();e.ok?(w({type:"success",text:"Settings reset successfully!"}),t.defaultModels.forEach(e=>x(e.alias,e.defaultValue||"")),T("")):w({type:"error",text:s.error||"Failed to reset settings"})}catch(e){w({type:"error",text:e.message})}finally{k(!1)}},B=()=>{let e={ANTHROPIC_BASE_URL:m,ANTHROPIC_AUTH_TOKEN:P&&P.trim()?P:h?"<API_KEY_FROM_DASHBOARD>":"sk_9router"};return t.defaultModels.forEach(t=>{let s=d[t.alias];s&&t.envKey&&(e[t.envKey]=s)}),JSON.stringify({env:e},null,2)},$=async e=>{try{await navigator.clipboard.writeText(e),K(!0),setTimeout(()=>K(!1),2e3)}catch(e){console.log("Failed to copy:",e)}};return(0,l.jsxs)(r.Zp,{className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:o,children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)("div",{className:"size-12 rounded-xl flex items-center justify-center",style:{backgroundColor:"".concat(t.color,"15")},children:(0,l.jsx)(i.default,{src:"/providers/claude.png",alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-semibold text-lg",children:t.name}),"configured"===U&&(0,l.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===U&&(0,l.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===U&&(0,l.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other endpoint"})]}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:t.description})]})]}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted transition-transform ".concat(s?"rotate-180":""),children:"expand_more"})]}),s&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[f&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Claude CLI..."})]}),!f&&g&&!g.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Claude CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Claude CLI to use this feature."})]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>_(!S),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:S?"expand_less":"help"}),S?"Hide":"How to Install"]})]}),S&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @anthropic-ai/claude-code"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"claude"})," to verify."]})]})]})]}),!f&&(null==g?void 0:g.installed)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-green-500 text-[16px]",children:"check_circle"}),(0,l.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"URL:"}),(0,l.jsx)("code",{className:"text-xs font-mono text-text-main truncate",children:m})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"Key:"}),p.length>0?(0,l.jsx)("select",{value:P,onChange:e=>T(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:p.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"text-xs text-text-muted",children:h?"No API keys - Create one in Keys page":"sk_9router"})]}),(0,l.jsx)("div",{className:"flex flex-col gap-2",children:t.defaultModels.map(e=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-32 shrink-0 text-sm font-semibold text-text-main text-right",children:e.name}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:d[e.alias]||"",onChange:t=>x(e.alias,t.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>{I(e.alias),E(!0)},disabled:!u,className:"px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ".concat(u?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"),children:"Select Model"}),d[e.alias]&&(0,l.jsx)("button",{onClick:()=>x(e.alias,""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]},e.alias))}),C&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs ".concat("success"===C.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===C.type?"check_circle":"error"}),(0,l.jsx)("span",{children:C.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:F,disabled:!u,loading:j,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:z,disabled:!(null==g?void 0:g.has9Router),loading:N,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:D,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]}),(0,l.jsxs)("div",{className:"pt-4 border-t border-border flex flex-col gap-3",children:[(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Or copy config manually:"}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("span",{className:"text-xs font-medium text-text-main",children:"~/.claude/settings.json"}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>$(B()),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:L?"check":"content_copy"}),L?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-40 overflow-y-auto",children:B()})]})]})]})]}),(0,l.jsx)(r.rq,{isOpen:A,onClose:()=>E(!1),onSelect:e=>{O&&x(O,e.value)},selectedModel:O?d[O]:null,activeProviders:n,modelAliases:M,title:"Select model for ".concat(O)})]})}function x(e){let{tool:t,isExpanded:s,onToggle:o,baseUrl:n,apiKeys:c,activeProviders:d,cloudEnabled:x}=e,[m,u]=(0,a.useState)(null),[p,h]=(0,a.useState)(!1),[g,y]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),[j,v]=(0,a.useState)(null),[N,k]=(0,a.useState)(!1),[C,w]=(0,a.useState)(""),[S,_]=(0,a.useState)(""),[A,E]=(0,a.useState)(!1),[O,I]=(0,a.useState)(!1),[P,T]=(0,a.useState)({});(0,a.useEffect)(()=>{(null==c?void 0:c.length)>0&&!C&&w(c[0].key)},[c]),(0,a.useEffect)(()=>{s&&!m&&(M(),L())},[s]);let L=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&T(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}};(0,a.useEffect)(()=>{if(null==m?void 0:m.config){let e=m.config.match(/^model\s*=\s*"([^"]+)"/m);e&&_(e[1])}},[m]);let K=(null==m?void 0:m.installed)?m.config?m.config.includes(n)||m.config.includes("localhost")||m.config.includes("127.0.0.1")?"configured":"other":"not_configured":null,M=async()=>{h(!0);try{let e=await fetch("/api/cli-tools/codex-settings"),t=await e.json();u(t)}catch(e){u({installed:!1,error:e.message})}finally{h(!1)}},R=async()=>{y(!0),v(null);try{let e=C&&C.trim()||x?C:"sk_9router",t=await fetch("/api/cli-tools/codex-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:n,apiKey:e,model:S})}),s=await t.json();t.ok?(v({type:"success",text:"Settings applied successfully!"}),M()):v({type:"error",text:s.error||"Failed to apply settings"})}catch(e){v({type:"error",text:e.message})}finally{y(!1)}},U=async()=>{b(!0),v(null);try{let e=await fetch("/api/cli-tools/codex-settings",{method:"DELETE"}),t=await e.json();e.ok?(v({type:"success",text:"Settings reset successfully!"}),_(""),M()):v({type:"error",text:t.error||"Failed to reset settings"})}catch(e){v({type:"error",text:e.message})}finally{b(!1)}},H='# 9Router Configuration for Codex CLI\nmodel = "'.concat(S,'"\nmodel_provider = "9router"\n\n[model_providers.9router]\nname = "9Router"\nbase_url = "').concat(n,'/v1"\nwire_api = "responses"\n'),D=JSON.stringify({OPENAI_API_KEY:C&&C.trim()?C:x?"<API_KEY_FROM_DASHBOARD>":"sk_9router"},null,2),F=async e=>{try{await navigator.clipboard.writeText(e),E(!0),setTimeout(()=>E(!1),2e3)}catch(e){console.log("Failed to copy:",e)}};return(0,l.jsxs)(r.Zp,{className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:o,children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)("div",{className:"size-12 rounded-xl flex items-center justify-center",style:{backgroundColor:"".concat(t.color,"15")},children:(0,l.jsx)(i.default,{src:"/providers/codex.png",alt:t.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h3",{className:"font-semibold text-lg",children:t.name}),"configured"===K&&(0,l.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full",children:"Connected"}),"not_configured"===K&&(0,l.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 rounded-full",children:"Not configured"}),"other"===K&&(0,l.jsx)("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 rounded-full",children:"Other endpoint"})]}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:t.description})]})]}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted transition-transform ".concat(s?"rotate-180":""),children:"expand_more"})]}),s&&(0,l.jsxs)("div",{className:"mt-4 pt-4 border-t border-border flex flex-col gap-4",children:[p&&(0,l.jsxs)("div",{className:"flex items-center gap-2 text-text-muted",children:[(0,l.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),(0,l.jsx)("span",{children:"Checking Codex CLI..."})]}),!p&&m&&!m.installed&&(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"Codex CLI not installed"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please install Codex CLI to use auto-apply feature."})]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:()=>k(!N),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[18px] mr-1",children:N?"expand_less":"help"}),N?"Hide":"How to Install"]})]}),N&&(0,l.jsxs)("div",{className:"p-4 bg-surface border border-border rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium mb-3",children:"Installation Guide"}),(0,l.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-text-muted mb-1",children:"macOS / Linux / Windows:"}),(0,l.jsx)("code",{className:"block px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs",children:"npm install -g @openai/codex"})]}),(0,l.jsxs)("p",{className:"text-text-muted",children:["After installation, run ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"codex"})," to verify."]}),(0,l.jsx)("div",{className:"pt-2 border-t border-border",children:(0,l.jsxs)("p",{className:"text-text-muted text-xs",children:["Codex uses ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"~/.codex/auth.json"})," with ",(0,l.jsx)("code",{className:"px-1 bg-black/5 dark:bg-white/5 rounded",children:"OPENAI_API_KEY"}),'. Click "Apply" to auto-configure.']})})]})]})]}),!p&&(null==m?void 0:m.installed)&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-green-500 text-[16px]",children:"check_circle"}),(0,l.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"URL:"}),(0,l.jsxs)("code",{className:"text-xs font-mono text-text-main truncate",children:[n,"/v1"]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted shrink-0",children:"Key:"}),c.length>0?(0,l.jsx)("select",{value:C,onChange:e=>w(e.target.value),className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:c.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}):(0,l.jsx)("span",{className:"text-xs text-text-muted",children:x?"No API keys - Create one in Keys page":"sk_9router"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"w-16 shrink-0 text-sm font-semibold text-text-main text-right",children:"Model"}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[14px]",children:"arrow_forward"}),(0,l.jsx)("input",{type:"text",value:S,onChange:e=>_(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-2 py-1.5 bg-surface rounded border border-border text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>I(!0),disabled:!(null==d?void 0:d.length),className:"px-2 py-1.5 rounded border text-xs transition-colors shrink-0 whitespace-nowrap ".concat((null==d?void 0:d.length)?"bg-surface border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"),children:"Select Model"}),S&&(0,l.jsx)("button",{onClick:()=>_(""),className:"p-1 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),j&&(0,l.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded text-xs ".concat("success"===j.type?"bg-green-500/10 text-green-600":"bg-red-500/10 text-red-600"),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"success"===j.type?"check_circle":"error"}),(0,l.jsx)("span",{children:j.text})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(r.$n,{variant:"primary",size:"sm",onClick:R,disabled:!C||!S,loading:g,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"save"}),"Apply"]}),(0,l.jsxs)(r.$n,{variant:"outline",size:"sm",onClick:U,disabled:!m.has9Router,loading:f,children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:"restore"}),"Reset"]}),(0,l.jsx)(r.$n,{variant:"ghost",size:"sm",onClick:M,children:(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"refresh"})})]})]}),(0,l.jsxs)("div",{className:"pt-4 border-t border-border flex flex-col gap-3",children:[(0,l.jsx)("p",{className:"text-xs text-text-muted",children:"Or copy config manually:"}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("span",{className:"text-xs font-medium text-text-main",children:"~/.codex/config.toml"}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(H),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:A?"check":"content_copy"}),A?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-32 overflow-y-auto",children:H})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("span",{className:"text-xs font-medium text-text-main",children:"~/.codex/auth.json"}),(0,l.jsxs)(r.$n,{variant:"ghost",size:"sm",onClick:()=>F(D),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:A?"check":"content_copy"}),A?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-32 overflow-y-auto",children:D})]})]})]}),(0,l.jsx)(r.rq,{isOpen:O,onClose:()=>I(!1),onSelect:e=>{_(e.value),I(!1)},selectedModel:S,activeProviders:d,modelAliases:P,title:"Select Model for Codex"})]})}function m(e){let{toolId:t,tool:s,isExpanded:o,onToggle:n,baseUrl:c,apiKeys:d,activeProviders:x=[],cloudEnabled:m=!1}=e,[u,p]=(0,a.useState)(null),[h,g]=(0,a.useState)(!1),[y,f]=(0,a.useState)(""),[b,j]=(0,a.useState)(()=>(null==d?void 0:d.length)>0?d[0].key:""),v=e=>{let t=b&&b.trim()?b:m?"your-api-key":"sk_9router";return e.replace(/\{\{baseUrl\}\}/g,c||"http://localhost:3000").replace(/\{\{apiKey\}\}/g,t).replace(/\{\{model\}\}/g,y||"provider/model-id")},N=async(e,t)=>{await navigator.clipboard.writeText(v(e)),p(t),setTimeout(()=>p(null),2e3)},k=x.length>0,C=()=>!s.requiresCloud||!!m;return(0,l.jsxs)(r.Zp,{className:"overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between hover:cursor-pointer",onClick:n,children:[(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)("div",{className:"size-12 rounded-xl flex items-center justify-center",style:{backgroundColor:"".concat(s.color,"15")},children:s.image?(0,l.jsx)(i.default,{src:s.image,alt:s.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:e=>{e.target.style.display="none"}}):s.icon?(0,l.jsx)("span",{className:"material-symbols-outlined text-2xl",style:{color:s.color},children:s.icon}):(0,l.jsx)(i.default,{src:"/providers/".concat(t,".png"),alt:s.name,width:32,height:32,className:"size-8 object-contain rounded-lg",onError:e=>{e.target.style.display="none"}})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"font-semibold text-lg",children:s.name}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:s.description})]})]}),(0,l.jsx)("span",{className:"material-symbols-outlined text-text-muted transition-transform ".concat(o?"rotate-180":""),children:"expand_more"})]}),o&&(0,l.jsx)("div",{className:"mt-6 pt-6 border-t border-border",children:s.guideSteps?(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[s.notes&&0!==s.notes.length?(0,l.jsx)("div",{className:"flex flex-col gap-2 mb-4",children:s.notes.map((e,t)=>{if("cloudCheck"===e.type&&m)return null;let s="warning"===e.type,a="cloudCheck"===e.type&&!m,r="bg-blue-500/10 border-blue-500/30",o="text-blue-600 dark:text-blue-400",n="text-blue-500",i="info";return s?(r="bg-yellow-500/10 border-yellow-500/30",o="text-yellow-600 dark:text-yellow-400",n="text-yellow-500",i="warning"):a&&(r="bg-red-500/10 border-red-500/30",o="text-red-600 dark:text-red-400",n="text-red-500",i="error"),(0,l.jsxs)("div",{className:"flex items-start gap-3 p-3 rounded-lg border ".concat(r),children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-lg ".concat(n),children:i}),(0,l.jsx)("p",{className:"text-sm ".concat(o),children:e.text})]},t)})}):null,C()&&s.guideSteps.map(e=>(0,l.jsxs)("div",{className:"flex items-start gap-4",children:[(0,l.jsx)("div",{className:"size-8 rounded-full flex items-center justify-center shrink-0 text-sm font-semibold text-white",style:{backgroundColor:s.color},children:e.step}),(0,l.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,l.jsx)("p",{className:"font-medium text-text",children:e.title}),e.desc&&(0,l.jsx)("p",{className:"text-sm text-text-muted mt-0.5",children:e.desc}),"apiKeySelector"===e.type&&(0,l.jsx)("div",{className:"mt-2 flex items-center gap-2",children:d&&d.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("select",{value:b,onChange:e=>j(e.target.value),className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:d.map(e=>(0,l.jsx)("option",{value:e.key,children:e.key},e.id))}),(0,l.jsx)("button",{onClick:()=>N(b,"apiKey"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"apiKey"===u?"check":"content_copy"})})]}):(0,l.jsx)("span",{className:"text-sm text-text-muted",children:m?"No API keys - Create one in Keys page":"sk_9router"})}),"modelSelector"===e.type&&(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,l.jsx)("input",{type:"text",value:y,onChange:e=>f(e.target.value),placeholder:"provider/model-id",className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,l.jsx)("button",{onClick:()=>g(!0),disabled:!k,className:"shrink-0 px-3 py-2 rounded-lg border text-sm transition-colors ".concat(k?"bg-bg-secondary border-border text-text-main hover:border-primary cursor-pointer":"opacity-50 cursor-not-allowed border-border"),children:"Select Model"}),y&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{onClick:()=>N(y,"model"),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"model"===u?"check":"content_copy"})}),(0,l.jsx)("button",{onClick:()=>f(""),className:"p-2 text-text-muted hover:text-red-500 rounded transition-colors",title:"Clear",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"close"})})]})]}),e.value&&(0,l.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,l.jsx)("code",{className:"flex-1 px-3 py-2 bg-bg-secondary rounded-lg text-sm font-mono border border-border truncate",children:v(e.value)}),e.copyable&&(0,l.jsx)("button",{onClick:()=>N(e.value,"".concat(e.step,"-").concat(e.title)),className:"shrink-0 px-3 py-2 bg-bg-secondary hover:bg-bg-tertiary rounded-lg border border-border transition-colors",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:u==="".concat(e.step,"-").concat(e.title)?"check":"content_copy"})})]})]})]},e.step)),C()&&s.codeBlock&&(0,l.jsxs)("div",{className:"mt-2",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:s.codeBlock.language}),(0,l.jsxs)("button",{onClick:()=>N(s.codeBlock.code,"codeblock"),className:"flex items-center gap-1 px-2 py-1 text-xs bg-bg-secondary hover:bg-bg-tertiary rounded border border-border transition-colors",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-sm",children:"codeblock"===u?"check":"content_copy"}),"codeblock"===u?"Copied!":"Copy"]})]}),(0,l.jsx)("pre",{className:"p-4 bg-bg-secondary rounded-lg border border-border overflow-x-auto",children:(0,l.jsx)("code",{className:"text-sm font-mono whitespace-pre",children:v(s.codeBlock.code)})})]})]}):(0,l.jsx)("p",{className:"text-text-muted text-sm",children:"Coming soon..."})}),(0,l.jsx)(r.rq,{isOpen:h,onClose:()=>g(!1),onSelect:e=>{f(e.value)},selectedModel:y,activeProviders:x,title:"Select Model"})]})}let u="https://9router.com";function p(e){let{machineId:t}=e,[s,i]=(0,a.useState)([]),[c,p]=(0,a.useState)(!0),[h,g]=(0,a.useState)(null),[y,f]=(0,a.useState)({}),[b,j]=(0,a.useState)(!1),[v,N]=(0,a.useState)([]);(0,a.useEffect)(()=>{w(),k(),C()},[]);let k=async()=>{try{let e=await fetch("/api/settings");if(e.ok){let t=await e.json();j(t.cloudEnabled||!1)}}catch(e){console.log("Error loading cloud settings:",e)}},C=async()=>{try{let e=await fetch("/api/keys");if(e.ok){let t=await e.json();N(t.keys||[])}}catch(e){console.log("Error fetching API keys:",e)}},w=async()=>{try{let e=await fetch("/api/providers"),t=await e.json();e.ok&&i(t.connections||[])}catch(e){console.log("Error fetching connections:",e)}finally{p(!1)}},S=()=>s.filter(e=>!1!==e.isActive);if(c)return(0,l.jsx)("div",{className:"flex flex-col gap-6",children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsx)(r.Qv,{}),(0,l.jsx)(r.Qv,{}),(0,l.jsx)(r.Qv,{})]})});let _=(()=>{let e=S(),t=[],s=new Set;return e.forEach(e=>{let l=n.Xg[e.provider]||e.provider;(0,n.KC)(e.provider).forEach(a=>{let r="".concat(l,"/").concat(a.id);s.has(r)||(s.add(r),t.push({value:r,label:"".concat(l,"/").concat(a.id),provider:e.provider,alias:l,connectionName:e.name,modelId:a.id}))})}),0===t.length&&Object.entries(n.vq).forEach(e=>{let[s,l]=e;l.forEach(e=>{let l="".concat(s,"/").concat(e.id);t.push({value:l,label:"".concat(s,"/").concat(e.id),provider:s,alias:s,connectionName:s,modelId:e.id})})}),t})().length>0;return(0,l.jsxs)("div",{className:"flex flex-col gap-6",children:[!_&&(0,l.jsx)(r.Zp,{className:"border-yellow-500/50 bg-yellow-500/5",children:(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-yellow-500",children:"warning"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"font-medium text-yellow-600 dark:text-yellow-400",children:"No active providers"}),(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"Please add and connect providers first to configure CLI tools."})]})]})}),(0,l.jsx)("div",{className:"flex flex-col gap-4",children:Object.entries(o).map(e=>{let[t,s]=e,a={tool:s,isExpanded:h===t,onToggle:()=>g(h===t?null:t),baseUrl:b&&u?u:window.location.origin,apiKeys:v};switch(t){case"claude":return(0,l.jsx)(d,{...a,activeProviders:S(),modelMappings:y[t]||{},onModelMappingChange:(e,s)=>{f(l=>({...l,[t]:{...l[t],[e]:s}}))},hasActiveProviders:_,cloudEnabled:b},t);case"codex":return(0,l.jsx)(x,{...a,activeProviders:S(),cloudEnabled:b},t);default:return(0,l.jsx)(m,{toolId:t,...a,activeProviders:S(),cloudEnabled:b},t)}})})]})}}},e=>{e.O(0,[1760,5239,9955,4244,8441,1255,7358],()=>e(e.s=2016)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3649],{3170:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>r});var l=s(5155),a=s(2115),o=s(4244),i=s(2694);let n=/^[a-zA-Z0-9_-]+$/;function r(){let[e,t]=(0,a.useState)([]),[s,n]=(0,a.useState)(!0),[r,m]=(0,a.useState)(!1),[x,h]=(0,a.useState)(null),[u,p]=(0,a.useState)([]),{copied:b,copy:j}=(0,i.C)();(0,a.useEffect)(()=>{f()},[]);let f=async()=>{try{let[e,s]=await Promise.all([fetch("/api/combos"),fetch("/api/providers")]),l=await e.json(),a=await s.json();if(e.ok&&t(l.combos||[]),s.ok){let e=(a.connections||[]).filter(e=>"active"===e.testStatus||"success"===e.testStatus);p(e)}}catch(e){console.log("Error fetching data:",e)}finally{n(!1)}},v=async e=>{try{let t=await fetch("/api/combos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.ok)await f(),m(!1);else{let e=await t.json();alert(e.error||"Failed to create combo")}}catch(e){console.log("Error creating combo:",e)}},N=async(e,t)=>{try{let s=await fetch("/api/combos/".concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok)await f(),h(null);else{let e=await s.json();alert(e.error||"Failed to update combo")}}catch(e){console.log("Error updating combo:",e)}},y=async s=>{if(confirm("Delete this combo?"))try{(await fetch("/api/combos/".concat(s),{method:"DELETE"})).ok&&t(e.filter(e=>e.id!==s))}catch(e){console.log("Error deleting combo:",e)}};return s?(0,l.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,l.jsx)(o.Qv,{}),(0,l.jsx)(o.Qv,{})]}):(0,l.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h1",{className:"text-2xl font-semibold",children:"Combos"}),(0,l.jsx)("p",{className:"text-sm text-text-muted mt-1",children:"Create model combos with fallback support"})]}),(0,l.jsx)(o.$n,{icon:"add",onClick:()=>m(!0),children:"Create Combo"})]}),0===e.length?(0,l.jsx)(o.Zp,{children:(0,l.jsxs)("div",{className:"text-center py-12",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-5xl text-text-muted mb-3 block",children:"layers"}),(0,l.jsx)("p",{className:"text-text-muted mb-4",children:"No combos yet"}),(0,l.jsx)(o.$n,{icon:"add",onClick:()=>m(!0),children:"Create your first combo"})]})}):(0,l.jsx)("div",{className:"flex flex-col gap-4",children:e.map(e=>(0,l.jsx)(c,{combo:e,copied:b,onCopy:j,onEdit:()=>h(e),onDelete:()=>y(e.id)},e.id))}),(0,l.jsx)(d,{isOpen:r,onClose:()=>m(!1),onSave:v,activeProviders:u},"create"),(0,l.jsx)(d,{isOpen:!!x,combo:x,onClose:()=>h(null),onSave:e=>N(x.id,e),activeProviders:u},(null==x?void 0:x.id)||"new")]})}function c(e){let{combo:t,copied:s,onCopy:a,onEdit:i,onDelete:n}=e;return(0,l.jsx)(o.Zp,{children:(0,l.jsxs)("div",{className:"flex items-start justify-between",children:[(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,l.jsx)("span",{className:"material-symbols-outlined text-primary",children:"layers"}),(0,l.jsx)("code",{className:"text-lg font-semibold font-mono",children:t.name}),(0,l.jsx)("button",{onClick:()=>a(t.name,"combo-".concat(t.id)),className:"p-1 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy combo name",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-sm",children:s==="combo-".concat(t.id)?"check":"content_copy"})})]}),(0,l.jsx)("div",{className:"flex flex-col gap-1.5",children:0===t.models.length?(0,l.jsx)("p",{className:"text-sm text-text-muted italic",children:"No models added"}):t.models.map((e,t)=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)("span",{className:"text-xs text-text-muted w-5",children:[t+1,"."]}),(0,l.jsx)("code",{className:"text-sm font-mono bg-sidebar px-2 py-0.5 rounded",children:e}),0===t&&(0,l.jsx)("span",{className:"text-xs text-primary font-medium",children:"Primary"}),t>0&&(0,l.jsx)("span",{className:"text-xs text-text-muted",children:"Fallback"})]},t))})]}),(0,l.jsxs)("div",{className:"flex gap-1",children:[(0,l.jsx)("button",{onClick:i,className:"p-2 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Edit",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"edit"})}),(0,l.jsx)("button",{onClick:n,className:"p-2 hover:bg-red-50 rounded text-red-500",title:"Delete",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-lg",children:"delete"})})]})]})})}function d(e){let{isOpen:t,combo:s,onClose:i,onSave:r,activeProviders:c}=e,[d,m]=(0,a.useState)((null==s?void 0:s.name)||""),[x,h]=(0,a.useState)((null==s?void 0:s.models)||[]),[u,p]=(0,a.useState)(!1),[b,j]=(0,a.useState)(!1),[f,v]=(0,a.useState)(""),[N,y]=(0,a.useState)({});(0,a.useEffect)(()=>{t&&(async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&y(t.aliases||{})}catch(e){console.log("Error fetching model aliases:",e)}})()},[t]);let g=e=>e.trim()?n.test(e)?(v(""),!0):(v("Only letters, numbers, - and _ allowed"),!1):(v("Name is required"),!1),C=async()=>{g(d)&&(j(!0),await r({name:d.trim(),models:x}),j(!1))},k=!!s;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.aF,{isOpen:t,onClose:i,title:k?"Edit Combo":"Create Combo",size:"md",children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(o.pd,{label:"Combo Name",value:d,onChange:e=>{let t=e.target.value;m(t),t?g(t):v("")},placeholder:"my-combo",error:f}),(0,l.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Only letters, numbers, - and _ allowed"})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("label",{className:"text-sm font-medium",children:"Models"}),(0,l.jsx)(o.$n,{size:"sm",variant:"secondary",icon:"add",onClick:()=>p(!0),children:"Add Model"})]}),0===x.length?(0,l.jsxs)("div",{className:"text-center py-6 border border-dashed border-border rounded-lg",children:[(0,l.jsx)("p",{className:"text-sm text-text-muted",children:"No models added"}),(0,l.jsx)("p",{className:"text-xs text-text-muted mt-1",children:'Click "Add Model" to add'})]}):(0,l.jsx)("div",{className:"flex flex-col gap-2 max-h-[240px] overflow-y-auto",children:x.map((e,t)=>(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-0",children:[(0,l.jsx)("button",{onClick:()=>(e=>{if(0===e)return;let t=[...x];[t[e-1],t[e]]=[t[e],t[e-1]],h(t)})(t),disabled:0===t,className:"p-0.5 rounded ".concat(0===t?"text-text-muted/30":"hover:bg-surface text-text-muted hover:text-primary"),children:(0,l.jsx)("span",{className:"material-symbols-outlined text-sm leading-none",children:"keyboard_arrow_up"})}),(0,l.jsx)("button",{onClick:()=>(e=>{if(e===x.length-1)return;let t=[...x];[t[e],t[e+1]]=[t[e+1],t[e]],h(t)})(t),disabled:t===x.length-1,className:"p-0.5 rounded ".concat(t===x.length-1?"text-text-muted/30":"hover:bg-surface text-text-muted hover:text-primary"),children:(0,l.jsx)("span",{className:"material-symbols-outlined text-sm leading-none",children:"keyboard_arrow_down"})})]}),(0,l.jsx)(o.pd,{value:e,onChange:e=>((e,t)=>{let s=[...x];s[e]=t,h(s)})(t,e.target.value),placeholder:"model-name",className:"flex-1"}),(0,l.jsx)("button",{onClick:()=>{h(x.filter((e,s)=>s!==t))},className:"p-2 hover:bg-red-50 rounded text-red-500",children:(0,l.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"})})]},t))})]}),(0,l.jsxs)("div",{className:"flex gap-2 pt-2",children:[(0,l.jsx)(o.$n,{onClick:C,fullWidth:!0,disabled:!d.trim()||!!f||b,children:b?"Saving...":"Apply"}),(0,l.jsx)(o.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}),(0,l.jsx)(o.rq,{isOpen:u,onClose:()=>p(!1),onSelect:e=>{x.includes(e.value)||h([...x,e.value])},activeProviders:c,modelAliases:N,title:"Add Model to Combo"})]})}},3822:(e,t,s)=>{Promise.resolve().then(s.bind(s,3170))}},e=>{e.O(0,[1760,9955,4244,8441,1255,7358],()=>e(e.s=3822)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6099],{},_=>{_.O(0,[1760,9955,4244,1393,8441,1255,7358],()=>_(_.s=1393)),_N_E=_.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6337],{},_=>{_.O(0,[1760,9955,4244,1393,8441,1255,7358],()=>_(_.s=1393)),_N_E=_.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3471],{4074:(e,s,l)=>{"use strict";l.r(s),l.d(s,{default:()=>i});var t=l(5155),a=l(4244),r=l(5157),d=l(4156);function i(){let{theme:e,setTheme:s,isDark:l}=(0,r.D)();return(0,t.jsx)("div",{className:"max-w-2xl mx-auto",children:(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)(a.Zp,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-4 mb-4",children:[(0,t.jsx)("div",{className:"size-12 rounded-lg bg-green-500/10 text-green-500 flex items-center justify-center",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-2xl",children:"computer"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Local Mode"}),(0,t.jsx)("p",{className:"text-text-muted",children:"Running on your machine"})]})]}),(0,t.jsx)("div",{className:"pt-4 border-t border-border",children:(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["All data is stored locally in the ",(0,t.jsx)("code",{className:"bg-sidebar px-1 rounded",children:"data/db.json"})," file."]})})]}),(0,t.jsxs)(a.Zp,{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Appearance"}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"Dark Mode"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Switch between light and dark themes"})]}),(0,t.jsx)(a.lM,{checked:l,onChange:()=>s(l?"light":"dark")})]}),(0,t.jsx)("div",{className:"flex gap-3 pt-4 border-t border-border",children:["light","dark","system"].map(l=>(0,t.jsxs)("button",{onClick:()=>s(l),className:"flex-1 flex flex-col items-center gap-2 p-4 rounded-lg border transition-all ".concat(e===l?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-2xl",children:"light"===l?"light_mode":"dark"===l?"dark_mode":"contrast"}),(0,t.jsx)("span",{className:"text-sm font-medium capitalize",children:l})]},l))})]})]}),(0,t.jsxs)(a.Zp,{children:[(0,t.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Data"}),(0,t.jsx)("div",{className:"flex flex-col gap-3",children:(0,t.jsx)("div",{className:"flex items-center justify-between p-4 rounded-lg bg-bg border border-border",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-medium",children:"Database Location"}),(0,t.jsx)("p",{className:"text-sm text-text-muted font-mono",children:"~/9router/data/db.json"})]})})})]}),(0,t.jsxs)("div",{className:"text-center text-sm text-text-muted py-4",children:[(0,t.jsxs)("p",{children:[d.vQ.name," v",d.vQ.version]}),(0,t.jsx)("p",{className:"mt-1",children:"Local Mode - All data stored on your machine"})]})]})})}},6086:(e,s,l)=>{Promise.resolve().then(l.bind(l,4074))}},e=>{e.O(0,[1760,9955,4244,8441,1255,7358],()=>e(e.s=6086)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2134],{2397:(e,t,s)=>{Promise.resolve().then(s.bind(s,5259))},5259:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>x});var a=s(5155),l=s(2115),r=s(63),i=s(2619),n=s.n(i);s(5239);var o=s(4244),c=s(9608),d=s(505);s(4156);var m=s(2694);function x(){let e=(0,r.useParams)().id,[t,s]=(0,l.useState)([]),[i,x]=(0,l.useState)(!0),[h,y]=(0,l.useState)(!1),[b,g]=(0,l.useState)(!1),[N,C]=(0,l.useState)(!1),[w,k]=(0,l.useState)(null),[S,E]=(0,l.useState)({}),{copied:A,copy:O}=(0,m.C)(),P=c.zN[e]||c.fg[e],T=!!c.zN[e],D=(0,d.KC)(e),I=(0,c.wG)(e);(0,l.useEffect)(()=>{U(),K()},[e]);let K=async()=>{try{let e=await fetch("/api/models/alias"),t=await e.json();e.ok&&E(t.aliases||{})}catch(e){console.log("Error fetching aliases:",e)}},_=async(e,t)=>{let s="".concat(I,"/").concat(e);try{let e=await fetch("/api/models/alias",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:s,alias:t})});if(e.ok)await K();else{let t=await e.json();alert(t.error||"Failed to set alias")}}catch(e){console.log("Error setting alias:",e)}},M=async e=>{try{(await fetch("/api/models/alias?alias=".concat(encodeURIComponent(e)),{method:"DELETE"})).ok&&await K()}catch(e){console.log("Error deleting alias:",e)}},U=async()=>{try{let t=await fetch("/api/providers"),a=await t.json();if(t.ok){let t=(a.connections||[]).filter(t=>t.provider===e);s(t)}}catch(e){console.log("Error fetching connections:",e)}finally{x(!1)}},L=async e=>{if(confirm("Delete this connection?"))try{(await fetch("/api/providers/".concat(e),{method:"DELETE"})).ok&&s(t.filter(t=>t.id!==e))}catch(e){console.log("Error deleting connection:",e)}},$=async t=>{try{(await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,...t})})).ok&&(await U(),g(!1))}catch(e){console.log("Error saving connection:",e)}},z=async e=>{try{(await fetch("/api/providers/".concat(w.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).ok&&(await U(),C(!1))}catch(e){console.log("Error updating connection:",e)}},F=async(e,t)=>{if(e&&t)try{await Promise.all([fetch("/api/providers/".concat(e.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:t.priority})}),fetch("/api/providers/".concat(t.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:e.priority})})]),await U()}catch(e){console.log("Error swapping priority:",e)}};return P?i?(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsx)(o.Qv,{}),(0,a.jsx)(o.Qv,{})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,a.jsxs)("div",{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 items-center gap-4",children:[(0,a.jsx)("div",{className:"rounded-lg flex items-center justify-center",style:{backgroundColor:"".concat(P.color,"15")},children:(0,a.jsx)("img",{src:"/providers/".concat(P.id,".png"),alt:P.name,className:"size-12 object-contain rounded-lg",onError:e=>{e.target.style.display="none"}})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:P.name}),(0,a.jsxs)("p",{className:"text-text-muted",children:[t.length," connection",1!==t.length?"s":""]})]})]})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Connections"}),(0,a.jsx)(o.$n,{size:"sm",icon:"add",onClick:()=>T?y(!0):g(!0),children:"Add"})]}),0===t.length?(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-4xl text-text-muted mb-2",children:T?"lock":"key"}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No connections yet"})]}):(0,a.jsx)("div",{className:"flex flex-col gap-2",children:t.sort((e,t)=>(e.priority||0)-(t.priority||0)).map((e,s)=>(0,a.jsx)(f,{connection:e,isOAuth:T,isFirst:0===s,isLast:s===t.length-1,onMoveUp:()=>F(e,t[s-1]),onMoveDown:()=>F(e,t[s+1]),onEdit:()=>{k(e),C(!0)},onDelete:()=>L(e.id)},e.id))})]}),(0,a.jsxs)(o.Zp,{children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-4",children:P.passthroughModels?"Model Aliases":"Available Models"}),P.passthroughModels?(0,a.jsx)(u,{providerAlias:I,modelAliases:S,copied:A,onCopy:O,onSetAlias:_,onDeleteAlias:M}):0===D.length?(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"No models configured"}):(0,a.jsx)("div",{className:"flex flex-wrap gap-3",children:D.map(t=>{var s;let l="".concat(I,"/").concat(t.id),r="".concat(e,"/").concat(t.id),i=null==(s=Object.entries(S).find(e=>{let[,t]=e;return t===l||t===r}))?void 0:s[0];return(0,a.jsx)(p,{model:t,fullModel:l,alias:i,copied:A,onCopy:O,onSetAlias:e=>_(t.id,e),onDeleteAlias:()=>M(i)},t.id)})})]}),(0,a.jsx)(o.LF,{isOpen:h,provider:e,providerInfo:P,onSuccess:()=>{U(),y(!1)},onClose:()=>y(!1)}),(0,a.jsx)(v,{isOpen:b,provider:e,onSave:$,onClose:()=>g(!1)}),(0,a.jsx)(j,{isOpen:N,connection:w,onSave:z,onClose:()=>C(!1)})]}):(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"})]})}function p(e){let{model:t,fullModel:s,alias:l,copied:r,onCopy:i}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,a.jsx)("code",{className:"text-xs text-text-muted font-mono bg-sidebar px-1.5 py-0.5 rounded",children:s}),(0,a.jsx)("button",{onClick:()=>i(s,"model-".concat(t.id)),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:r==="model-".concat(t.id)?"check":"content_copy"})})]})}function u(e){let{providerAlias:t,modelAliases:s,copied:r,onCopy:i,onSetAlias:n,onDeleteAlias:c}=e,[d,m]=(0,l.useState)(""),[x,p]=(0,l.useState)(!1),u=Object.entries(s).filter(e=>{let[,s]=e;return s.startsWith("".concat(t,"/"))}).map(e=>{let[s,a]=e;return{modelId:a.replace("".concat(t,"/"),""),fullModel:a,alias:s}}),y=async()=>{if(!d.trim()||x)return;let e=d.trim(),t=(e=>{let t=e.split("/");return t[t.length-1]})(e);if(s[t])return void alert('Alias "'.concat(t,'" already exists. Please use a different model or edit existing alias.'));p(!0);try{await n(e,t),m("")}catch(e){console.log("Error adding model:",e)}finally{p(!1)}};return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"OpenRouter supports any model. Add models and create aliases for quick access."}),(0,a.jsxs)("div",{className:"flex items-end gap-2",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Model ID (from OpenRouter)"}),(0,a.jsx)("input",{type:"text",value:d,onChange:e=>m(e.target.value),onKeyDown:e=>"Enter"===e.key&&y(),placeholder:"anthropic/claude-3-opus",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)(o.$n,{size:"sm",icon:"add",onClick:y,disabled:!d.trim()||x,children:x?"Adding...":"Add"})]}),u.length>0&&(0,a.jsx)("div",{className:"flex flex-col gap-3",children:u.map(e=>{let{modelId:t,fullModel:s,alias:l}=e;return(0,a.jsx)(h,{modelId:t,fullModel:s,copied:r,onCopy:i,onDeleteAlias:()=>c(l)},s)})})]})}function h(e){let{modelId:t,fullModel:s,copied:l,onCopy:r,onDeleteAlias:i}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border hover:bg-sidebar/50",children:[(0,a.jsx)("span",{className:"material-symbols-outlined text-base text-text-muted",children:"smart_toy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:t}),(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:s}),(0,a.jsx)("button",{onClick:()=>r(s,"model-".concat(t)),className:"p-0.5 hover:bg-sidebar rounded text-text-muted hover:text-primary",title:"Copy model",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-sm",children:l==="model-".concat(t)?"check":"content_copy"})})]})]}),(0,a.jsx)("button",{onClick:i,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 y(e){let{until:t}=e,[s,r]=(0,l.useState)("");return((0,l.useEffect)(()=>{let e=()=>{let e=new Date(t).getTime()-Date.now();if(e<=0)return void r("");let s=Math.floor(e/1e3);if(s<60)r("".concat(s,"s"));else if(s<3600)r("".concat(Math.floor(s/60),"m ").concat(s%60,"s"));else{let e=Math.floor(s/3600),t=Math.floor(s%3600/60);r("".concat(e,"h ").concat(t,"m"))}};e();let s=setInterval(e,1e3);return()=>clearInterval(s)},[t]),s)?(0,a.jsxs)("span",{className:"text-xs text-orange-500 font-mono",children:["⏱ ",s]}):null}function f(e){let{connection:t,isOAuth:s,isFirst:r,isLast:i,onMoveUp:n,onMoveDown:c,onEdit:d,onDelete:m}=e,x=s?t.name||t.email||t.displayName||"OAuth Account":t.name,[p,u]=(0,l.useState)(!1);(0,l.useEffect)(()=>{let e=()=>{u(t.rateLimitedUntil&&new Date(t.rateLimitedUntil).getTime()>Date.now())};e();let s=t.rateLimitedUntil?setInterval(e,1e3):null;return()=>{s&&clearInterval(s)}},[t.rateLimitedUntil]);let h="unavailable"!==t.testStatus||p?t.testStatus:"active";return(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border hover:bg-sidebar/50 hover:cursor-pointer",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("button",{onClick:n,disabled:r,className:"p-0.5 rounded ".concat(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_up"})}),(0,a.jsx)("button",{onClick:c,disabled:i,className:"p-0.5 rounded ".concat(i?"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 text-base text-text-muted",children:s?"lock":"key"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:x}),(0,a.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,a.jsx)(o.Ex,{variant:"active"===h||"success"===h?"success":"error"===h||"expired"===h||"unavailable"===h?"error":"default",size:"sm",dot:!0,children:h||"Unknown"}),p&&(0,a.jsx)(y,{until:t.rateLimitedUntil}),t.lastError&&(0,a.jsx)("span",{className:"text-xs text-red-500 truncate max-w-[300px]",title:t.lastError,children:t.lastError}),(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["#",t.priority]}),t.globalPriority&&(0,a.jsxs)("span",{className:"text-xs text-text-muted",children:["Auto: ",t.globalPriority]})]})]})]}),(0,a.jsxs)("div",{className:"flex gap-1",children:[(0,a.jsx)("button",{onClick:d,className:"p-2 hover:bg-sidebar rounded",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"edit"})}),(0,a.jsx)("button",{onClick:m,className:"p-2 hover:bg-red-50 rounded text-red-500",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-base",children:"delete"})})]})]})}function v(e){let{isOpen:t,provider:s,onSave:r,onClose:i}=e,[n,c]=(0,l.useState)({name:"",apiKey:"",priority:1}),[d,m]=(0,l.useState)(!1),[x,p]=(0,l.useState)(null),u=async()=>{m(!0);try{let e=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:s,apiKey:n.apiKey})}),t=await e.json();p(t.valid?"success":"failed")}catch(e){p("failed")}finally{m(!1)}};return s?(0,a.jsx)(o.aF,{isOpen:t,title:"Add ".concat(s," API Key"),onClose:i,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(o.pd,{label:"Name",value:n.name,onChange:e=>c({...n,name:e.target.value}),placeholder:"Production Key"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(o.pd,{label:"API Key",type:"password",value:n.apiKey,onChange:e=>c({...n,apiKey:e.target.value}),className:"flex-1"}),(0,a.jsx)("div",{className:"pt-6",children:(0,a.jsx)(o.$n,{onClick:u,disabled:!n.apiKey||d,variant:"secondary",children:d?"Checking...":"Check"})})]}),x&&(0,a.jsx)(o.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Invalid"}),(0,a.jsx)(o.pd,{label:"Priority",type:"number",value:n.priority,onChange:e=>c({...n,priority:parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(o.$n,{onClick:()=>{r({name:n.name,apiKey:n.apiKey,priority:n.priority,testStatus:"success"===x?"active":"unknown"})},fullWidth:!0,disabled:!n.name||!n.apiKey,children:"Save"}),(0,a.jsx)(o.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}function j(e){let{isOpen:t,connection:s,onSave:r,onClose:i}=e,[n,c]=(0,l.useState)({name:"",priority:1}),[d,m]=(0,l.useState)(!1),[x,p]=(0,l.useState)(null);(0,l.useEffect)(()=>{s&&(c({name:s.name||"",priority:s.priority||1}),p(null))},[s]);let u=async()=>{if(null==s?void 0:s.provider){m(!0),p(null);try{let e=await fetch("/api/providers/".concat(s.id,"/test"),{method:"POST"}),t=await e.json();p(t.valid?"success":"failed"),t.valid?r({testStatus:"active",lastError:null,lastErrorAt:null}):r({testStatus:"error",lastError:t.error,lastErrorAt:new Date().toISOString()})}catch(e){p("failed")}finally{m(!1)}}};if(!s)return null;let h="oauth"===s.authType;return(0,a.jsx)(o.aF,{isOpen:t,title:"Edit Connection",onClose:i,children:(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)(o.pd,{label:"Name",value:n.name,onChange:e=>c({...n,name:e.target.value}),placeholder:h?"Account name":"Production Key"}),h&&s.email&&(0,a.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,a.jsx)("p",{className:"font-medium",children:s.email})]}),(0,a.jsx)(o.pd,{label:"Priority",type:"number",value:n.priority,onChange:e=>c({...n,priority:parseInt(e.target.value)||1})}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(o.$n,{onClick:u,variant:"secondary",disabled:d,children:d?"Testing...":"Test Connection"}),x&&(0,a.jsx)(o.Ex,{variant:"success"===x?"success":"error",children:"success"===x?"Valid":"Failed"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(o.$n,{onClick:()=>{r({name:n.name,priority:n.priority})},fullWidth:!0,children:"Save"}),(0,a.jsx)(o.$n,{onClick:i,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}}},e=>{e.O(0,[1760,5239,9955,4244,8441,1255,7358],()=>e(e.s=2397)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9089],{60:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>u});var a=t(5155),s=t(2115),i=t(63),l=t(2619),d=t.n(l),n=t(4244),o=t(4156);let c=Object.values(o.Q2).map(e=>({value:e.id,label:e.name})),p=Object.values(o.MA).map(e=>({value:e.id,label:e.name}));function u(){let e=(0,i.useRouter)(),[r,t]=(0,s.useState)(!1),[l,u]=(0,s.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[h,m]=(0,s.useState)({}),x=(e,r)=>{u(t=>({...t,[e]:r})),h[e]&&m(r=>({...r,[e]:null}))},b=async r=>{if(r.preventDefault(),(()=>{let e={};return l.provider||(e.provider="Please select a provider"),"api_key"!==l.authMethod||l.apiKey||(e.apiKey="API Key is required"),m(e),0===Object.keys(e).length})()){t(!0);try{let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(r.ok)e.push("/dashboard/providers");else{let e=await r.json();m({submit:e.error||"Failed to create provider"})}}catch(e){m({submit:"An error occurred. Please try again."})}finally{t(!1)}}},v=o.Q2[l.provider];return(0,a.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsxs)(d(),{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.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,a.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,a.jsx)(n.Zp,{children:(0,a.jsxs)("form",{onSubmit:b,className:"flex flex-col gap-6",children:[(0,a.jsx)(n.l6,{label:"Provider",options:c,value:l.provider,onChange:e=>x("provider",e.target.value),placeholder:"Select a provider",error:h.provider,required:!0}),v&&(0,a.jsxs)(n.Zp.Section,{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium",children:v.name}),(0,a.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("div",{className:"flex gap-3",children:p.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>x("authMethod",e.value),className:"flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ".concat(l.authMethod===e.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"),children:[(0,a.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===e.value?"key":"lock"}),(0,a.jsx)("span",{className:"font-medium",children:e.label})]},e.value))})]}),"api_key"===l.authMethod&&(0,a.jsx)(n.pd,{label:"API Key",type:"password",placeholder:"Enter your API key",value:l.apiKey,onChange:e=>x("apiKey",e.target.value),error:h.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===l.authMethod&&(0,a.jsxs)(n.Zp.Section,{children:[(0,a.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,a.jsx)(n.$n,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,a.jsx)(n.pd,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:l.displayName,onChange:e=>x("displayName",e.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,a.jsx)(n.lM,{checked:l.isActive,onChange:e=>x("isActive",e),label:"Active",description:"Enable this provider for use in your applications"}),h.submit&&(0,a.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:h.submit}),(0,a.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,a.jsx)(d(),{href:"/dashboard/providers",className:"flex-1",children:(0,a.jsx)(n.$n,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,a.jsx)(n.$n,{type:"submit",loading:r,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}},5390:(e,r,t)=>{Promise.resolve().then(t.bind(t,60))}},e=>{e.O(0,[1760,9955,4244,8441,1255,7358],()=>e(e.s=5390)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8460],{859:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>o});var s=r(5155),l=r(2115),n=r(4244),a=r(4156);r(5239);var c=r(2619),i=r.n(c);function o(){let[e,t]=(0,l.useState)([]),[r,c]=(0,l.useState)(!0);(0,l.useEffect)(()=>{i()},[]);let i=async()=>{try{let e=await fetch("/api/providers"),r=await e.json();e.ok&&t(r.connections||[])}catch(e){console.log("Error fetching data:",e)}finally{c(!1)}},o=(t,r)=>{let s=e.filter(e=>e.provider===t&&e.authType===r),l=e=>{let t=e.rateLimitedUntil&&new Date(e.rateLimitedUntil).getTime()>Date.now();return"unavailable"!==e.testStatus||t?e.testStatus:"active"},n=s.filter(e=>{let t=l(e);return"active"===t||"success"===t}).length,a=s.filter(e=>{let t=l(e);return"error"===t||"expired"===t||"unavailable"===t}),c=a.length,i=s.length,o=a.sort((e,t)=>new Date(t.lastErrorAt||0)-new Date(e.lastErrorAt||0))[0];return{connected:n,error:c,total:i,errorCode:o?function(e){if(!e)return null;let t=e.match(/\b([45]\d{2})\b/);return t?t[1]:"ERR"}(o.lastError):null,errorTime:(null==o?void 0:o.lastErrorAt)?function(e){if(!e)return"";let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return"".concat(t,"m ago");let r=Math.floor(t/60);if(r<24)return"".concat(r,"h ago");let s=Math.floor(r/24);return"".concat(s,"d ago")}(o.lastErrorAt):null}};return r?(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsx)(n.Qv,{}),(0,s.jsx)(n.Qv,{})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"OAuth Providers"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(a.zN).map(e=>{let[t,r]=e;return(0,s.jsx)(d,{providerId:t,provider:r,stats:o(t,"oauth")},t)})})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"API Key Providers"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Object.entries(a.fg).map(e=>{let[t,r]=e;return(0,s.jsx)(x,{providerId:t,provider:r,stats:o(t,"apikey")},t)})})]})]})}function d(e){let{providerId:t,provider:r,stats:a}=e,{connected:c,error:o,errorCode:d,errorTime:x}=a,[h,m]=(0,l.useState)(!1);return(0,s.jsx)(i(),{href:"/dashboard/providers/".concat(t),children:(0,s.jsx)(n.Zp,{className:"h-full hover:border-primary/50 transition-colors cursor-pointer",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center",style:{backgroundColor:"".concat(r.color,"15")},children:h?(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:r.color},children:r.textIcon||r.id.slice(0,2).toUpperCase()}):(0,s.jsx)("img",{src:"/providers/".concat(r.id,".png"),alt:r.name,className:"size-10 object-contain rounded-lg",onError:()=>m(!0)})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-semibold",children:r.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[(()=>{let e=[];if(c>0&&e.push((0,s.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[c," Connected"]},"connected")),o>0){let t=d?"".concat(o," Error (").concat(d,")"):"".concat(o," Error");e.push((0,s.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:t},"error"))}return 0===e.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):e})(),x&&(0,s.jsxs)("span",{className:"text-text-muted",children:["• ",x]})]})]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted",children:"chevron_right"})]})})})}function x(e){let{providerId:t,provider:r,stats:l}=e,{connected:a,error:c,errorCode:o,errorTime:d}=l;return(0,s.jsx)(i(),{href:"/dashboard/providers/".concat(t),children:(0,s.jsx)(n.Zp,{className:"h-full hover:border-primary/50 transition-colors cursor-pointer",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center",style:{backgroundColor:"".concat(r.color,"15")},children:(0,s.jsx)("span",{className:"text-sm font-bold",style:{color:r.color},children:r.textIcon||r.id.slice(0,2).toUpperCase()})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-semibold",children:r.name}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[(()=>{let e=[];if(a>0&&e.push((0,s.jsxs)(n.Ex,{variant:"success",size:"sm",dot:!0,children:[a," Connected"]},"connected")),c>0){let t=o?"".concat(c," Error (").concat(o,")"):"".concat(c," Error");e.push((0,s.jsx)(n.Ex,{variant:"error",size:"sm",dot:!0,children:t},"error"))}return 0===e.length?(0,s.jsx)("span",{className:"text-text-muted",children:"No connections"}):e})(),d&&(0,s.jsxs)("span",{className:"text-text-muted",children:["• ",d]})]})]})]}),(0,s.jsx)("span",{className:"material-symbols-outlined text-text-muted",children:"chevron_right"})]})})})}},3117:(e,t,r)=>{Promise.resolve().then(r.bind(r,859))}},e=>{e.O(0,[1760,5239,9955,4244,8441,1255,7358],()=>e(e.s=3117)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e={},t={};function r(o){var a=t[o];if(void 0!==a)return a.exports;var n=t[o]={exports:{}},i=!0;try{e[o](n,n.exports,r),i=!1}finally{i&&delete t[o]}return n.exports}r.m=e,(()=>{var e=[];r.O=(t,o,a,n)=>{if(o){n=n||0;for(var i=e.length;i>0&&e[i-1][2]>n;i--)e[i]=e[i-1];e[i]=[o,a,n];return}for(var c=1/0,i=0;i<e.length;i++){for(var[o,a,n]=e[i],u=!0,l=0;l<o.length;l++)(!1&n||c>=n)&&Object.keys(r.O).every(e=>r.O[e](o[l]))?o.splice(l--,1):(u=!1,n<c&&(c=n));if(u){e.splice(i--,1);var d=a();void 0!==d&&(t=d)}}return t}})(),r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;r.t=function(o,a){if(1&a&&(o=this(o)),8&a||"object"==typeof o&&o&&(4&a&&o.__esModule||16&a&&"function"==typeof o.then))return o;var n=Object.create(null);r.r(n);var i={};e=e||[null,t({}),t([]),t(t)];for(var c=2&a&&o;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach(e=>i[e]=()=>o[e]);return i.default=()=>o,r.d(n,i),n}})(),r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.f={},r.e=e=>Promise.all(Object.keys(r.f).reduce((t,o)=>(r.f[o](e,t),t),[])),r.u=e=>"static/chunks/"+e+"."+({197:"83743acbae435446",1055:"0f91ab6513ec317b",1441:"7b9fc2e539f71e56",3433:"dfc71de88505c41d",3592:"2bc2e6e506f250e3",5812:"5dc8861d62b394fe",6899:"44ddb324d06f2b00",7712:"6576b07aa7d6f955",8456:"50ee5fc36ad7054f"})[e]+".js",r.miniCssF=e=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={},t="_N_E:";r.l=(o,a,n,i)=>{if(e[o])return void e[o].push(a);if(void 0!==n)for(var c,u,l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var f=l[d];if(f.getAttribute("src")==o||f.getAttribute("data-webpack")==t+n){c=f;break}}c||(u=!0,(c=document.createElement("script")).charset="utf-8",c.timeout=120,r.nc&&c.setAttribute("nonce",r.nc),c.setAttribute("data-webpack",t+n),c.src=r.tu(o)),e[o]=[a];var s=(t,r)=>{c.onerror=c.onload=null,clearTimeout(b);var a=e[o];if(delete e[o],c.parentNode&&c.parentNode.removeChild(c),a&&a.forEach(e=>e(r)),t)return t(r)},b=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),u&&document.head.appendChild(c)}})(),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;r.tt=()=>(void 0===e&&(e={createScriptURL:e=>e},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(e=trustedTypes.createPolicy("nextjs#bundler",e))),e)})(),r.tu=e=>r.tt().createScriptURL(e),r.p="/_next/",(()=>{var e={8068:0,2328:0};r.f.j=(t,o)=>{var a=r.o(e,t)?e[t]:void 0;if(0!==a)if(a)o.push(a[2]);else if(/^(232|806)8$/.test(t))e[t]=0;else{var n=new Promise((r,o)=>a=e[t]=[r,o]);o.push(a[2]=n);var i=r.p+r.u(t),c=Error();r.l(i,o=>{if(r.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var n=o&&("load"===o.type?"missing":o.type),i=o&&o.target&&o.target.src;c.message="Loading chunk "+t+" failed.\n("+n+": "+i+")",c.name="ChunkLoadError",c.type=n,c.request=i,a[1](c)}},"chunk-"+t,t)}},r.O.j=t=>0===e[t];var t=(t,o)=>{var a,n,[i,c,u]=o,l=0;if(i.some(t=>0!==e[t])){for(a in c)r.o(c,a)&&(r.m[a]=c[a]);if(u)var d=u(r)}for(t&&t(o);l<i.length;l++)n=i[l],r.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return r.O(d)},o=self.webpackChunk_N_E=self.webpackChunk_N_E||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})()})();