@samanhappy/mcphub 1.0.34 → 1.0.35

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 (69) hide show
  1. package/dist/controllers/oauthCallbackController.js +83 -54
  2. package/dist/controllers/oauthCallbackController.js.map +1 -1
  3. package/dist/controllers/serverController.js +46 -37
  4. package/dist/controllers/serverController.js.map +1 -1
  5. package/dist/dao/ServerDao.js +10 -0
  6. package/dist/dao/ServerDao.js.map +1 -1
  7. package/dist/dao/ServerDaoDbImpl.js +43 -3
  8. package/dist/dao/ServerDaoDbImpl.js.map +1 -1
  9. package/dist/dao/SystemConfigDao.js +38 -1
  10. package/dist/dao/SystemConfigDao.js.map +1 -1
  11. package/dist/dao/SystemConfigDaoDbImpl.js +6 -1
  12. package/dist/dao/SystemConfigDaoDbImpl.js.map +1 -1
  13. package/dist/services/vectorSearchService.js +52 -12
  14. package/dist/services/vectorSearchService.js.map +1 -1
  15. package/dist/utils/migration.js +13 -1
  16. package/dist/utils/migration.js.map +1 -1
  17. package/dist/utils/openApiRequestBody.js +14 -2
  18. package/dist/utils/openApiRequestBody.js.map +1 -1
  19. package/dist/utils/serverConfigPersistence.js +77 -9
  20. package/dist/utils/serverConfigPersistence.js.map +1 -1
  21. package/dist/utils/smartRouting.js +10 -4
  22. package/dist/utils/smartRouting.js.map +1 -1
  23. package/frontend/dist/assets/{ActivityPage-BYoyi-IG.js → ActivityPage-B4OBJUBq.js} +2 -2
  24. package/frontend/dist/assets/{ActivityPage-BYoyi-IG.js.map → ActivityPage-B4OBJUBq.js.map} +1 -1
  25. package/frontend/dist/assets/{Dashboard-BOHkLPxE.js → Dashboard-czP-DGHn.js} +2 -2
  26. package/frontend/dist/assets/{Dashboard-BOHkLPxE.js.map → Dashboard-czP-DGHn.js.map} +1 -1
  27. package/frontend/dist/assets/{EndpointCopy-DDVLhiUy.js → EndpointCopy-CDwtdCHE.js} +2 -2
  28. package/frontend/dist/assets/{EndpointCopy-DDVLhiUy.js.map → EndpointCopy-CDwtdCHE.js.map} +1 -1
  29. package/frontend/dist/assets/{GroupsPage-B3bHSWmT.js → GroupsPage-BgUHjkGb.js} +2 -2
  30. package/frontend/dist/assets/{GroupsPage-B3bHSWmT.js.map → GroupsPage-BgUHjkGb.js.map} +1 -1
  31. package/frontend/dist/assets/{LoginPage-CfAnFIbQ.js → LoginPage-BBzViqLx.js} +2 -2
  32. package/frontend/dist/assets/{LoginPage-CfAnFIbQ.js.map → LoginPage-BBzViqLx.js.map} +1 -1
  33. package/frontend/dist/assets/{LogsPage-DT2VotXH.js → LogsPage-CqbaqFiQ.js} +2 -2
  34. package/frontend/dist/assets/{LogsPage-DT2VotXH.js.map → LogsPage-CqbaqFiQ.js.map} +1 -1
  35. package/frontend/dist/assets/{MarketPage-Cn0J7UNX.js → MarketPage-DinCKwrj.js} +2 -2
  36. package/frontend/dist/assets/{MarketPage-Cn0J7UNX.js.map → MarketPage-DinCKwrj.js.map} +1 -1
  37. package/frontend/dist/assets/{OAuthConsentPage-DnKLaKDH.js → OAuthConsentPage-BuPcJ2zS.js} +2 -2
  38. package/frontend/dist/assets/{OAuthConsentPage-DnKLaKDH.js.map → OAuthConsentPage-BuPcJ2zS.js.map} +1 -1
  39. package/frontend/dist/assets/{PromptsPage-Ccg3fJWt.js → PromptsPage-CJ-wYRAL.js} +2 -2
  40. package/frontend/dist/assets/{PromptsPage-Ccg3fJWt.js.map → PromptsPage-CJ-wYRAL.js.map} +1 -1
  41. package/frontend/dist/assets/{ResourcesPage-V45CxfvA.js → ResourcesPage-DRV8gnZV.js} +2 -2
  42. package/frontend/dist/assets/{ResourcesPage-V45CxfvA.js.map → ResourcesPage-DRV8gnZV.js.map} +1 -1
  43. package/frontend/dist/assets/{ServersPage-DA_nkhLB.js → ServersPage-CbtcAcVH.js} +4 -4
  44. package/frontend/dist/assets/{ServersPage-DA_nkhLB.js.map → ServersPage-CbtcAcVH.js.map} +1 -1
  45. package/frontend/dist/assets/SettingsPage-Czv4OhtK.js +12 -0
  46. package/frontend/dist/assets/SettingsPage-Czv4OhtK.js.map +1 -0
  47. package/frontend/dist/assets/{StatusDot-DcjrhMNI.js → StatusDot-CwpmIlJi.js} +2 -2
  48. package/frontend/dist/assets/{StatusDot-DcjrhMNI.js.map → StatusDot-CwpmIlJi.js.map} +1 -1
  49. package/frontend/dist/assets/{ToggleGroup-BSLtGF--.js → ToggleGroup-1qFTkDqh.js} +2 -2
  50. package/frontend/dist/assets/{ToggleGroup-BSLtGF--.js.map → ToggleGroup-1qFTkDqh.js.map} +1 -1
  51. package/frontend/dist/assets/{UsersPage-DKdCe4GT.js → UsersPage-CAMXgywh.js} +2 -2
  52. package/frontend/dist/assets/{UsersPage-DKdCe4GT.js.map → UsersPage-CAMXgywh.js.map} +1 -1
  53. package/frontend/dist/assets/index-Cb6IBpZR.js +3 -0
  54. package/frontend/dist/assets/index-Cb6IBpZR.js.map +1 -0
  55. package/frontend/dist/assets/{resourceService-DIUK5vbC.js → resourceService-BTVgor9F.js} +2 -2
  56. package/frontend/dist/assets/{resourceService-DIUK5vbC.js.map → resourceService-BTVgor9F.js.map} +1 -1
  57. package/frontend/dist/assets/{useCostData-CSeCIQmM.js → useCostData-CDVGUx_e.js} +2 -2
  58. package/frontend/dist/assets/{useCostData-CSeCIQmM.js.map → useCostData-CDVGUx_e.js.map} +1 -1
  59. package/frontend/dist/assets/useSettingsData-92nglN_X.js +2 -0
  60. package/frontend/dist/assets/{useSettingsData-CvAOhPaX.js.map → useSettingsData-92nglN_X.js.map} +1 -1
  61. package/frontend/dist/assets/{variableDetection-BeF9gp9K.js → variableDetection-BlOwsGsz.js} +2 -2
  62. package/frontend/dist/assets/{variableDetection-BeF9gp9K.js.map → variableDetection-BlOwsGsz.js.map} +1 -1
  63. package/frontend/dist/index.html +1 -1
  64. package/package.json +1 -1
  65. package/frontend/dist/assets/SettingsPage-BJjO5cte.js +0 -12
  66. package/frontend/dist/assets/SettingsPage-BJjO5cte.js.map +0 -1
  67. package/frontend/dist/assets/index-DjExFs33.js +0 -3
  68. package/frontend/dist/assets/index-DjExFs33.js.map +0 -1
  69. package/frontend/dist/assets/useSettingsData-CvAOhPaX.js +0 -2
@@ -1,2 +1,2 @@
1
- import{f as c,e as t,h as n}from"./index-DjExFs33.js";import"./framework-vendor-BHAQX05P.js";import"./i18n-vendor-CMcB7XUR.js";import"./icons-vendor-HZHHWeTa.js";const d=async(r,o,s)=>{try{const e=await t(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/toggle`,{enabled:s},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message}}catch(e){return console.error("Error toggling resource",{serverName:r,resourceUri:o,enabled:s,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}},g=async(r,o,s)=>{try{const e=await n(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/description`,{description:s},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message}}catch(e){return console.error("Error updating resource description",{serverName:r,resourceUri:o,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}},m=async(r,o)=>{var s;try{const e=await c(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message,description:(s=e.data)==null?void 0:s.description}}catch(e){return console.error("Error resetting resource description",{serverName:r,resourceUri:o,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}};export{m as resetResourceDescription,d as toggleResource,g as updateResourceDescription};
2
- //# sourceMappingURL=resourceService-DIUK5vbC.js.map
1
+ import{f as c,e as t,h as n}from"./index-Cb6IBpZR.js";import"./framework-vendor-BHAQX05P.js";import"./i18n-vendor-CMcB7XUR.js";import"./icons-vendor-HZHHWeTa.js";const d=async(r,o,s)=>{try{const e=await t(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/toggle`,{enabled:s},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message}}catch(e){return console.error("Error toggling resource",{serverName:r,resourceUri:o,enabled:s,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}},g=async(r,o,s)=>{try{const e=await n(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/description`,{description:s},{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message}}catch(e){return console.error("Error updating resource description",{serverName:r,resourceUri:o,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}},m=async(r,o)=>{var s;try{const e=await c(`/servers/${encodeURIComponent(r)}/resources/${encodeURIComponent(o)}/description`,{headers:{Authorization:`Bearer ${localStorage.getItem("mcphub_token")}`}});return{success:e.success,error:e.success?void 0:e.message,description:(s=e.data)==null?void 0:s.description}}catch(e){return console.error("Error resetting resource description",{serverName:r,resourceUri:o,error:e}),{success:!1,error:e instanceof Error?e.message:"Unknown error occurred"}}};export{m as resetResourceDescription,d as toggleResource,g as updateResourceDescription};
2
+ //# sourceMappingURL=resourceService-BTVgor9F.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resourceService-DIUK5vbC.js","sources":["../../src/services/resourceService.ts"],"sourcesContent":["import { apiDelete, apiPost, apiPut } from '../utils/fetchInterceptor';\n\n/**\n * Toggle a resource's enabled state for a specific server\n */\nexport const toggleResource = async (\n serverName: string,\n resourceUri: string,\n enabled: boolean,\n): Promise<{ success: boolean; error?: string }> => {\n try {\n const response = await apiPost<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/toggle`,\n { enabled },\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n };\n } catch (error) {\n console.error('Error toggling resource', { serverName, resourceUri, enabled, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n\n/**\n * Update a resource's description for a specific server\n */\nexport const updateResourceDescription = async (\n serverName: string,\n resourceUri: string,\n description: string,\n): Promise<{ success: boolean; error?: string }> => {\n try {\n const response = await apiPut<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/description`,\n { description },\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n };\n } catch (error) {\n console.error('Error updating resource description', { serverName, resourceUri, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n\nexport const resetResourceDescription = async (\n serverName: string,\n resourceUri: string,\n): Promise<{ success: boolean; error?: string; description?: string }> => {\n try {\n const response = await apiDelete<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/description`,\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n description: response.data?.description,\n };\n } catch (error) {\n console.error('Error resetting resource description', { serverName, resourceUri, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n"],"names":["toggleResource","serverName","resourceUri","enabled","response","apiPost","error","updateResourceDescription","description","apiPut","resetResourceDescription","apiDelete","_a"],"mappings":"kKAKO,MAAMA,EAAiB,MAC5BC,EACAC,EACAC,IACkD,CAClD,GAAI,CACF,MAAMC,EAAW,MAAMC,EACrB,YAAY,mBAAmBJ,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,UACvF,CAAE,QAAAC,CAAA,EACF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASC,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,OAAA,CAEnD,OAASE,EAAO,CACd,eAAQ,MAAM,0BAA2B,CAAE,WAAAL,EAAY,YAAAC,EAAa,QAAAC,EAAS,MAAAG,EAAO,EAC7E,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF,EAKaC,EAA4B,MACvCN,EACAC,EACAM,IACkD,CAClD,GAAI,CACF,MAAMJ,EAAW,MAAMK,EACrB,YAAY,mBAAmBR,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,eACvF,CAAE,YAAAM,CAAA,EACF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASJ,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,OAAA,CAEnD,OAASE,EAAO,CACd,eAAQ,MAAM,sCAAuC,CAAE,WAAAL,EAAY,YAAAC,EAAa,MAAAI,EAAO,EAChF,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF,EAEaI,EAA2B,MACtCT,EACAC,IACwE,OACxE,GAAI,CACF,MAAME,EAAW,MAAMO,EACrB,YAAY,mBAAmBV,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,eACvF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASE,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,QAC/C,aAAaQ,EAAAR,EAAS,OAAT,YAAAQ,EAAe,WAAA,CAEhC,OAASN,EAAO,CACd,eAAQ,MAAM,uCAAwC,CAAE,WAAAL,EAAY,YAAAC,EAAa,MAAAI,EAAO,EACjF,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF"}
1
+ {"version":3,"file":"resourceService-BTVgor9F.js","sources":["../../src/services/resourceService.ts"],"sourcesContent":["import { apiDelete, apiPost, apiPut } from '../utils/fetchInterceptor';\n\n/**\n * Toggle a resource's enabled state for a specific server\n */\nexport const toggleResource = async (\n serverName: string,\n resourceUri: string,\n enabled: boolean,\n): Promise<{ success: boolean; error?: string }> => {\n try {\n const response = await apiPost<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/toggle`,\n { enabled },\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n };\n } catch (error) {\n console.error('Error toggling resource', { serverName, resourceUri, enabled, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n\n/**\n * Update a resource's description for a specific server\n */\nexport const updateResourceDescription = async (\n serverName: string,\n resourceUri: string,\n description: string,\n): Promise<{ success: boolean; error?: string }> => {\n try {\n const response = await apiPut<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/description`,\n { description },\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n };\n } catch (error) {\n console.error('Error updating resource description', { serverName, resourceUri, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n\nexport const resetResourceDescription = async (\n serverName: string,\n resourceUri: string,\n): Promise<{ success: boolean; error?: string; description?: string }> => {\n try {\n const response = await apiDelete<any>(\n `/servers/${encodeURIComponent(serverName)}/resources/${encodeURIComponent(resourceUri)}/description`,\n {\n headers: {\n Authorization: `Bearer ${localStorage.getItem('mcphub_token')}`,\n },\n },\n );\n\n return {\n success: response.success,\n error: response.success ? undefined : response.message,\n description: response.data?.description,\n };\n } catch (error) {\n console.error('Error resetting resource description', { serverName, resourceUri, error });\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n };\n }\n};\n"],"names":["toggleResource","serverName","resourceUri","enabled","response","apiPost","error","updateResourceDescription","description","apiPut","resetResourceDescription","apiDelete","_a"],"mappings":"kKAKO,MAAMA,EAAiB,MAC5BC,EACAC,EACAC,IACkD,CAClD,GAAI,CACF,MAAMC,EAAW,MAAMC,EACrB,YAAY,mBAAmBJ,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,UACvF,CAAE,QAAAC,CAAA,EACF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASC,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,OAAA,CAEnD,OAASE,EAAO,CACd,eAAQ,MAAM,0BAA2B,CAAE,WAAAL,EAAY,YAAAC,EAAa,QAAAC,EAAS,MAAAG,EAAO,EAC7E,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF,EAKaC,EAA4B,MACvCN,EACAC,EACAM,IACkD,CAClD,GAAI,CACF,MAAMJ,EAAW,MAAMK,EACrB,YAAY,mBAAmBR,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,eACvF,CAAE,YAAAM,CAAA,EACF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASJ,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,OAAA,CAEnD,OAASE,EAAO,CACd,eAAQ,MAAM,sCAAuC,CAAE,WAAAL,EAAY,YAAAC,EAAa,MAAAI,EAAO,EAChF,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF,EAEaI,EAA2B,MACtCT,EACAC,IACwE,OACxE,GAAI,CACF,MAAME,EAAW,MAAMO,EACrB,YAAY,mBAAmBV,CAAU,CAAC,cAAc,mBAAmBC,CAAW,CAAC,eACvF,CACE,QAAS,CACP,cAAe,UAAU,aAAa,QAAQ,cAAc,CAAC,EAAA,CAC/D,CACF,EAGF,MAAO,CACL,QAASE,EAAS,QAClB,MAAOA,EAAS,QAAU,OAAYA,EAAS,QAC/C,aAAaQ,EAAAR,EAAS,OAAT,YAAAQ,EAAe,WAAA,CAEhC,OAASN,EAAO,CACd,eAAQ,MAAM,uCAAwC,CAAE,WAAAL,EAAY,YAAAC,EAAa,MAAAI,EAAO,EACjF,CACL,QAAS,GACT,MAAOA,aAAiB,MAAQA,EAAM,QAAU,wBAAA,CAEpD,CACF"}
@@ -1,2 +1,2 @@
1
- import{n as d,j as f}from"./index-DjExFs33.js";import{r}from"./framework-vendor-BHAQX05P.js";const y=e=>{const a=d(),{refreshIfNeeded:c}=a;return r.useEffect(()=>{e!=null&&e.refreshOnMount&&c()},[e==null?void 0:e.refreshOnMount,c]),a},i=()=>{const[e,a]=r.useState([]),[c,n]=r.useState([]),[l,u]=r.useState(!0),o=r.useCallback(async()=>{try{u(!0);const[t,s]=await Promise.all([f("/cost/servers"),f("/cost/groups")]);t!=null&&t.success&&Array.isArray(t.data)&&a(t.data),s!=null&&s.success&&Array.isArray(s.data)&&n(s.data)}catch(t){console.error("Error fetching context footprint:",t)}finally{u(!1)}},[]);return r.useEffect(()=>{o()},[o]),{serverCosts:e,groupCosts:c,loading:l,refetch:o}};export{i as a,y as u};
2
- //# sourceMappingURL=useCostData-CSeCIQmM.js.map
1
+ import{n as d,j as f}from"./index-Cb6IBpZR.js";import{r}from"./framework-vendor-BHAQX05P.js";const y=e=>{const a=d(),{refreshIfNeeded:c}=a;return r.useEffect(()=>{e!=null&&e.refreshOnMount&&c()},[e==null?void 0:e.refreshOnMount,c]),a},i=()=>{const[e,a]=r.useState([]),[c,n]=r.useState([]),[l,u]=r.useState(!0),o=r.useCallback(async()=>{try{u(!0);const[t,s]=await Promise.all([f("/cost/servers"),f("/cost/groups")]);t!=null&&t.success&&Array.isArray(t.data)&&a(t.data),s!=null&&s.success&&Array.isArray(s.data)&&n(s.data)}catch(t){console.error("Error fetching context footprint:",t)}finally{u(!1)}},[]);return r.useEffect(()=>{o()},[o]),{serverCosts:e,groupCosts:c,loading:l,refetch:o}};export{i as a,y as u};
2
+ //# sourceMappingURL=useCostData-CDVGUx_e.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCostData-CSeCIQmM.js","sources":["../../src/hooks/useServerData.ts","../../src/hooks/useCostData.ts"],"sourcesContent":["// This hook now delegates to the ServerContext to avoid duplicate requests\n// All components will share the same server data and polling mechanism\nimport { useServerContext } from '@/contexts/ServerContext';\nimport { useEffect } from 'react';\n\nexport const useServerData = (options?: { refreshOnMount?: boolean }) => {\n const context = useServerContext();\n const { refreshIfNeeded } = context;\n\n // Optionally refresh on mount for pages that need fresh data\n useEffect(() => {\n if (options?.refreshOnMount) {\n refreshIfNeeded();\n }\n }, [options?.refreshOnMount, refreshIfNeeded]);\n\n return context;\n};\n\n","import { useCallback, useEffect, useState } from 'react';\nimport { apiGet } from '../utils/fetchInterceptor';\nimport type { ApiResponse, ServerCost, GroupCost } from '@/types';\n\nexport const useCostData = () => {\n const [serverCosts, setServerCosts] = useState<ServerCost[]>([]);\n const [groupCosts, setGroupCosts] = useState<GroupCost[]>([]);\n const [loading, setLoading] = useState(true);\n\n const fetchCosts = useCallback(async () => {\n try {\n setLoading(true);\n const [servers, groups] = await Promise.all([\n apiGet('/cost/servers') as Promise<ApiResponse<ServerCost[]>>,\n apiGet('/cost/groups') as Promise<ApiResponse<GroupCost[]>>,\n ]);\n if (servers?.success && Array.isArray(servers.data)) setServerCosts(servers.data);\n if (groups?.success && Array.isArray(groups.data)) setGroupCosts(groups.data);\n } catch (err) {\n console.error('Error fetching context footprint:', err);\n } finally {\n setLoading(false);\n }\n }, []);\n\n useEffect(() => {\n fetchCosts();\n }, [fetchCosts]);\n\n return { serverCosts, groupCosts, loading, refetch: fetchCosts };\n};\n"],"names":["useServerData","options","context","useServerContext","refreshIfNeeded","useEffect","useCostData","serverCosts","setServerCosts","useState","groupCosts","setGroupCosts","loading","setLoading","fetchCosts","useCallback","servers","groups","apiGet","err"],"mappings":"6FAKO,MAAMA,EAAiBC,GAA2C,CACvE,MAAMC,EAAUC,EAAA,EACV,CAAE,gBAAAC,GAAoBF,EAG5BG,OAAAA,EAAAA,UAAU,IAAM,CACVJ,GAAA,MAAAA,EAAS,gBACXG,EAAA,CAEJ,EAAG,CAACH,GAAA,YAAAA,EAAS,eAAgBG,CAAe,CAAC,EAEtCF,CACT,ECbaI,EAAc,IAAM,CAC/B,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAAuB,CAAA,CAAE,EACzD,CAACC,EAAYC,CAAa,EAAIF,EAAAA,SAAsB,CAAA,CAAE,EACtD,CAACG,EAASC,CAAU,EAAIJ,EAAAA,SAAS,EAAI,EAErCK,EAAaC,EAAAA,YAAY,SAAY,CACzC,GAAI,CACFF,EAAW,EAAI,EACf,KAAM,CAACG,EAASC,CAAM,EAAI,MAAM,QAAQ,IAAI,CAC1CC,EAAO,eAAe,EACtBA,EAAO,cAAc,CAAA,CACtB,EACGF,GAAA,MAAAA,EAAS,SAAW,MAAM,QAAQA,EAAQ,IAAI,GAAGR,EAAeQ,EAAQ,IAAI,EAC5EC,GAAA,MAAAA,EAAQ,SAAW,MAAM,QAAQA,EAAO,IAAI,GAAGN,EAAcM,EAAO,IAAI,CAC9E,OAASE,EAAK,CACZ,QAAQ,MAAM,oCAAqCA,CAAG,CACxD,QAAA,CACEN,EAAW,EAAK,CAClB,CACF,EAAG,CAAA,CAAE,EAELR,OAAAA,EAAAA,UAAU,IAAM,CACdS,EAAA,CACF,EAAG,CAACA,CAAU,CAAC,EAER,CAAE,YAAAP,EAAa,WAAAG,EAAY,QAAAE,EAAS,QAASE,CAAA,CACtD"}
1
+ {"version":3,"file":"useCostData-CDVGUx_e.js","sources":["../../src/hooks/useServerData.ts","../../src/hooks/useCostData.ts"],"sourcesContent":["// This hook now delegates to the ServerContext to avoid duplicate requests\n// All components will share the same server data and polling mechanism\nimport { useServerContext } from '@/contexts/ServerContext';\nimport { useEffect } from 'react';\n\nexport const useServerData = (options?: { refreshOnMount?: boolean }) => {\n const context = useServerContext();\n const { refreshIfNeeded } = context;\n\n // Optionally refresh on mount for pages that need fresh data\n useEffect(() => {\n if (options?.refreshOnMount) {\n refreshIfNeeded();\n }\n }, [options?.refreshOnMount, refreshIfNeeded]);\n\n return context;\n};\n\n","import { useCallback, useEffect, useState } from 'react';\nimport { apiGet } from '../utils/fetchInterceptor';\nimport type { ApiResponse, ServerCost, GroupCost } from '@/types';\n\nexport const useCostData = () => {\n const [serverCosts, setServerCosts] = useState<ServerCost[]>([]);\n const [groupCosts, setGroupCosts] = useState<GroupCost[]>([]);\n const [loading, setLoading] = useState(true);\n\n const fetchCosts = useCallback(async () => {\n try {\n setLoading(true);\n const [servers, groups] = await Promise.all([\n apiGet('/cost/servers') as Promise<ApiResponse<ServerCost[]>>,\n apiGet('/cost/groups') as Promise<ApiResponse<GroupCost[]>>,\n ]);\n if (servers?.success && Array.isArray(servers.data)) setServerCosts(servers.data);\n if (groups?.success && Array.isArray(groups.data)) setGroupCosts(groups.data);\n } catch (err) {\n console.error('Error fetching context footprint:', err);\n } finally {\n setLoading(false);\n }\n }, []);\n\n useEffect(() => {\n fetchCosts();\n }, [fetchCosts]);\n\n return { serverCosts, groupCosts, loading, refetch: fetchCosts };\n};\n"],"names":["useServerData","options","context","useServerContext","refreshIfNeeded","useEffect","useCostData","serverCosts","setServerCosts","useState","groupCosts","setGroupCosts","loading","setLoading","fetchCosts","useCallback","servers","groups","apiGet","err"],"mappings":"6FAKO,MAAMA,EAAiBC,GAA2C,CACvE,MAAMC,EAAUC,EAAA,EACV,CAAE,gBAAAC,GAAoBF,EAG5BG,OAAAA,EAAAA,UAAU,IAAM,CACVJ,GAAA,MAAAA,EAAS,gBACXG,EAAA,CAEJ,EAAG,CAACH,GAAA,YAAAA,EAAS,eAAgBG,CAAe,CAAC,EAEtCF,CACT,ECbaI,EAAc,IAAM,CAC/B,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAAuB,CAAA,CAAE,EACzD,CAACC,EAAYC,CAAa,EAAIF,EAAAA,SAAsB,CAAA,CAAE,EACtD,CAACG,EAASC,CAAU,EAAIJ,EAAAA,SAAS,EAAI,EAErCK,EAAaC,EAAAA,YAAY,SAAY,CACzC,GAAI,CACFF,EAAW,EAAI,EACf,KAAM,CAACG,EAASC,CAAM,EAAI,MAAM,QAAQ,IAAI,CAC1CC,EAAO,eAAe,EACtBA,EAAO,cAAc,CAAA,CACtB,EACGF,GAAA,MAAAA,EAAS,SAAW,MAAM,QAAQA,EAAQ,IAAI,GAAGR,EAAeQ,EAAQ,IAAI,EAC5EC,GAAA,MAAAA,EAAQ,SAAW,MAAM,QAAQA,EAAO,IAAI,GAAGN,EAAcM,EAAO,IAAI,CAC9E,OAASE,EAAK,CACZ,QAAQ,MAAM,oCAAqCA,CAAG,CACxD,QAAA,CACEN,EAAW,EAAK,CAClB,CACF,EAAG,CAAA,CAAE,EAELR,OAAAA,EAAAA,UAAU,IAAM,CACdS,EAAA,CACF,EAAG,CAACA,CAAU,CAAC,EAER,CAAE,YAAAP,EAAa,WAAAG,EAAY,QAAAE,EAAS,QAASE,CAAA,CACtD"}
@@ -0,0 +1,2 @@
1
+ import{p as t}from"./index-Cb6IBpZR.js";const e=()=>t();export{e as u};
2
+ //# sourceMappingURL=useSettingsData-92nglN_X.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSettingsData-CvAOhPaX.js","sources":["../../src/hooks/useSettingsData.ts"],"sourcesContent":["import { useSettings } from '@/contexts/SettingsContext';\n\n/**\n * Hook that provides access to settings data via SettingsContext.\n * This hook is a thin wrapper around useSettings to maintain backward compatibility.\n * The actual data fetching happens once in SettingsProvider, avoiding duplicate API calls.\n */\nexport const useSettingsData = () => {\n return useSettings();\n};\n"],"names":["useSettingsData","useSettings"],"mappings":"wCAOO,MAAMA,EAAkB,IACtBC,EAAA"}
1
+ {"version":3,"file":"useSettingsData-92nglN_X.js","sources":["../../src/hooks/useSettingsData.ts"],"sourcesContent":["import { useSettings } from '@/contexts/SettingsContext';\n\n/**\n * Hook that provides access to settings data via SettingsContext.\n * This hook is a thin wrapper around useSettings to maintain backward compatibility.\n * The actual data fetching happens once in SettingsProvider, avoiding duplicate API calls.\n */\nexport const useSettingsData = () => {\n return useSettings();\n};\n"],"names":["useSettingsData","useSettings"],"mappings":"wCAOO,MAAMA,EAAkB,IACtBC,EAAA"}
@@ -1,4 +1,4 @@
1
- import{r as x,j as e}from"./framework-vendor-BHAQX05P.js";import{j as Fr,e as Pr}from"./index-DjExFs33.js";import{f as Mr,a as Vr,O as Rr}from"./contextCost-CilWqGWT.js";import{u as zr}from"./i18n-vendor-CMcB7XUR.js";import{X as Wr}from"./icons-vendor-HZHHWeTa.js";const gr=a=>{const l={};return a.forEach(({key:r,value:d})=>{const m=r.trim();m&&(l[m]=d)}),l},fr=a=>a?a.split(",").map(l=>l.trim()).filter(l=>l.length>0):[],$r=a=>Array.from(new Set((a||[]).map(l=>l.trim()).filter(l=>l.length>0))),Lr=a=>{const l={};return typeof(a==null?void 0:a.timeout)=="number"&&!Number.isNaN(a.timeout)&&(l.timeout=a.timeout),typeof(a==null?void 0:a.resetTimeoutOnProgress)=="boolean"&&(l.resetTimeoutOnProgress=a.resetTimeoutOnProgress),a!=null&&a.maxTotalTimeout&&(l.maxTotalTimeout=a.maxTotalTimeout),l},qr=a=>{var p,v,i,c,w,A,S,C;if(!a)return{};const l={},r=(p=a.clientId)==null?void 0:p.trim(),d=(v=a.clientSecret)==null?void 0:v.trim(),m=(i=a.scopes)==null?void 0:i.trim(),n=(c=a.accessToken)==null?void 0:c.trim(),h=(w=a.refreshToken)==null?void 0:w.trim(),y=(A=a.authorizationEndpoint)==null?void 0:A.trim(),u=(S=a.tokenEndpoint)==null?void 0:S.trim(),b=(C=a.resource)==null?void 0:C.trim();if(r&&(l.clientId=r),d&&(l.clientSecret=d),m){const T=m.split(/[\s,]+/).map(f=>f.trim()).filter(f=>f.length>0);T.length>0&&(l.scopes=T)}return n&&(l.accessToken=n),h&&(l.refreshToken=h),y&&(l.authorizationEndpoint=y),u&&(l.tokenEndpoint=u),b&&(l.resource=b),l},Br=a=>{var y,u,b,p,v,i,c,w,A,S,C,T,f,E,P,I,g,K,M,V,R,z,W;const l={version:((y=a.openapi)==null?void 0:y.version)||"3.1.0",passthroughHeaders:fr((u=a.openapi)==null?void 0:u.passthroughHeaders),cookieSession:((b=a.openapi)==null?void 0:b.cookieSession)===!0?!0:void 0},r=(v=(p=a.openapi)==null?void 0:p.oauth2TokenUrl)==null?void 0:v.trim(),d=(c=(i=a.openapi)==null?void 0:i.oauth2ClientId)==null?void 0:c.trim(),m=(A=(w=a.openapi)==null?void 0:w.oauth2ClientSecret)==null?void 0:A.trim(),n=(C=(S=a.openapi)==null?void 0:S.oauth2Token)==null?void 0:C.trim();if(((T=a.openapi)==null?void 0:T.inputMode)==="url")l.url=((f=a.openapi)==null?void 0:f.url)||"";else if(((E=a.openapi)==null?void 0:E.inputMode)==="schema"&&((P=a.openapi)!=null&&P.schema))try{l.schema=JSON.parse(a.openapi.schema)}catch{throw new Error("Invalid JSON schema format")}(I=a.openapi)!=null&&I.securityType&&a.openapi.securityType!=="none"&&(l.security={type:a.openapi.securityType,...a.openapi.securityType==="apiKey"&&{apiKey:{name:a.openapi.apiKeyName||"",in:a.openapi.apiKeyIn||"header",value:a.openapi.apiKeyValue||""}},...a.openapi.securityType==="http"&&{http:{scheme:a.openapi.httpScheme||"bearer",credentials:a.openapi.httpCredentials||""}},...a.openapi.securityType==="oauth2"&&{oauth2:{...r&&{tokenUrl:r},...d&&{clientId:d},...m&&{clientSecret:m},...n&&{token:n}}},...a.openapi.securityType==="openIdConnect"&&{openIdConnect:{url:a.openapi.openIdConnectUrl||"",token:a.openapi.openIdConnectToken||""}}});const h=(g=a.openapi)==null?void 0:g.specSecurityType;return h&&h!=="none"&&(l.specSecurity={type:h,...h==="apiKey"&&{apiKey:{name:((K=a.openapi)==null?void 0:K.specApiKeyName)||"",in:((M=a.openapi)==null?void 0:M.specApiKeyIn)||"header",value:((V=a.openapi)==null?void 0:V.specApiKeyValue)||""}},...h==="http"&&{http:{scheme:((R=a.openapi)==null?void 0:R.specHttpScheme)||"basic",credentials:((z=a.openapi)==null?void 0:z.specHttpCredentials)||""}},...h==="oauth2"&&{oauth2:{token:((W=a.openapi)==null?void 0:W.specOauth2Token)||""}}}),l},ue=({formData:a,serverType:l,envVars:r,headerVars:d})=>{var b,p,v;const m=gr(r),n=gr(d),h=Lr(a.options),y=((b=a.description)==null?void 0:b.trim())||"",u={type:l,description:y,options:h,visibility:a.visibility??"private",sharedWithUsers:a.visibility==="group"?$r(a.sharedWithUsers):void 0,perSessionClient:a.perSessionClient===!0?!0:void 0,startOnDemand:a.startOnDemand===!0?!0:void 0,idleTimeoutMs:a.startOnDemand===!0?a.idleTimeoutMs??3e5:void 0,proxy:a.proxy};if(l==="openapi")u.headers=n,u.openapi=Br(a);else if(l==="sse"||l==="streamable-http"){const i=((p=a.keepAlive)==null?void 0:p.enabled)===!0;u.url=a.url.trim(),u.env=m,u.headers=n,u.passthroughHeaders=fr(a.passthroughHeaders),u.oauth=qr(a.oauth),u.enableKeepAlive=i,u.keepAliveInterval=i?((v=a.keepAlive)==null?void 0:v.interval)||6e4:void 0}else u.command=a.command.trim(),u.args=a.args,u.env=m;return{name:a.name.trim(),config:u}},_r=(a=[],l=[])=>Array.from(new Set([...a,...l])).sort((r,d)=>r.localeCompare(d)),Xr=(a,l)=>{const r=l.trim().toLowerCase();return r?a.filter(d=>d.toLowerCase().includes(r)):[...a]},Jr=(a,l)=>Array.from(new Set([...a,...l])),Gr=(a,l)=>{const r=new Set(l);return a.filter(d=>!r.has(d))};function jr(a,l=!1){if(l)return!1;const r=a.openapi;return r&&r.securityType&&r.securityType!=="none"?!1:!(r!=null&&r.apiKeyValue)&&!(r!=null&&r.httpCredentials)&&!(r!=null&&r.oauth2TokenUrl)&&!(r!=null&&r.oauth2ClientId)&&!(r!=null&&r.oauth2ClientSecret)&&!(r!=null&&r.oauth2Token)&&!(r!=null&&r.openIdConnectUrl)&&!(r!=null&&r.openIdConnectToken)}function Qr(a,l,r=!1){var m,n,h,y,u;if(!l.declared||!l.supported||!l.prefill||!jr(a,r))return a;const d=l.prefill;return{...a,openapi:{...a.openapi,securityType:d.type,apiKeyName:((m=d.apiKey)==null?void 0:m.name)||"",apiKeyIn:((n=d.apiKey)==null?void 0:n.in)||"header",apiKeyValue:"",httpScheme:((h=d.http)==null?void 0:h.scheme)||"bearer",httpCredentials:"",oauth2TokenUrl:((y=d.oauth2)==null?void 0:y.tokenUrl)||"",oauth2ClientId:"",oauth2ClientSecret:"",oauth2Token:"",openIdConnectUrl:((u=d.openIdConnect)==null?void 0:u.url)||"",openIdConnectToken:""}}}function Zr(a,l){var d,m,n;if(!l.prefill)return!1;const r=a.openapi;if((r==null?void 0:r.securityType)!==l.prefill.type)return!0;switch(r==null?void 0:r.securityType){case"apiKey":return r.apiKeyName!==((d=l.prefill.apiKey)==null?void 0:d.name)||r.apiKeyIn!==((m=l.prefill.apiKey)==null?void 0:m.in);case"http":return r.httpScheme!==((n=l.prefill.http)==null?void 0:n.scheme);default:return!1}}function Yr(a){const l=a.openapi,r=l==null?void 0:l.securityType;if(!r||r==="none")return null;switch(r){case"apiKey":return`API key in ${(l==null?void 0:l.apiKeyIn)||"header"} '${(l==null?void 0:l.apiKeyName)||""}'`;case"http":return`HTTP ${(l==null?void 0:l.httpScheme)||"bearer"}`;case"oauth2":return"OAuth2";case"openIdConnect":return"OpenID Connect";default:return null}}function Dr(a,l,r={}){return l!=null&&l.declared?!jr(a,r.securityTouched)&&Zr(a,l)?{kind:"warning",messageKey:"securityMismatchWarning",values:{summary:l.summary,configured:Yr(a)||"none"}}:l.supported?{kind:"info",messageKey:"securityPrefillNotice",values:{summary:l.summary}}:{kind:"warning",messageKey:"securityUnsupportedNotice",values:{summary:l.summary,reason:l.unsupportedReason||""}}:r.includeNotDeclared?{kind:"info",messageKey:"securityNotDeclared",values:{}}:null}function br(a){var d,m,n,h;const l=((d=a.openapi)==null?void 0:d.inputMode)==="schema"?"schema":"url",r=((h=l==="schema"?(m=a.openapi)==null?void 0:m.schema:(n=a.openapi)==null?void 0:n.url)==null?void 0:h.trim())||"";return{mode:l,value:r,key:r?`${l}:${r}`:""}}function kr(a){if(!a.value)return!1;if(a.mode==="schema")try{const l=JSON.parse(a.value);return l!==null&&typeof l=="object"&&!Array.isArray(l)}catch{return!1}try{const l=new URL(a.value);return l.protocol==="http:"||l.protocol==="https:"}catch{return!1}}function et(a){return!a.isEdit&&a.serverType==="openapi"&&kr(a.source)&&a.source.key!==a.analyzedSourceKey}const Nr=/^[A-Za-z0-9._-]+$/,me=128,vr=a=>{const l=a.trim();return l.length>0&&l.length<=me&&Nr.test(l)&&!l.includes("..")},ot=a=>a.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/\.{2,}/g,".").replace(/^-+|-+$/g,"").slice(0,me)||"server",lt=({onSubmit:a,onCancel:l,initialData:r=null,modalTitle:d,formError:m=null})=>{var Ie,Ke,Oe,Ue,Ee,He,Fe,Pe,Me,Ve,Re,ze,We,$e,Le,qe,Be,_e,Xe,Je,Ge,Qe,Ze,Ye,De,es,ss,rs,ts,ns,as,os,ls,is,cs,ps,ds,us,ms,hs,xs,ys,gs,bs,vs,fs,js,ks,Ns,Ss,Cs,Ts,ws,As,Is,Ks,Os,Us,Es,Hs,Fs,Ps,Ms,Vs,Rs,zs,Ws,$s,Ls,qs,Bs,_s,Xs,Js,Gs,Qs,Zs,Ys,Ds,er,sr,rr,tr,nr,ar,or,lr,ir,cr,pr,dr,ur,mr,hr,xr,yr;const{t:n}=zr(),h=!(r!=null&&r.name)||vr(r.name),y=()=>!r||!r.config?"stdio":r.config.type?r.config.type:r.config.url?"sse":"stdio",u=t=>!t||!t.config||!t.config.env?[]:Object.entries(t.config.env).map(([s,o])=>({key:s,value:o,description:""})),b=t=>{var o;const s=(o=t==null?void 0:t.config)==null?void 0:o.oauth;return{clientId:(s==null?void 0:s.clientId)||"",clientSecret:(s==null?void 0:s.clientSecret)||"",scopes:s!=null&&s.scopes?s.scopes.join(" "):"",accessToken:(s==null?void 0:s.accessToken)||"",refreshToken:(s==null?void 0:s.refreshToken)||"",authorizationEndpoint:(s==null?void 0:s.authorizationEndpoint)||"",tokenEndpoint:(s==null?void 0:s.tokenEndpoint)||"",resource:(s==null?void 0:s.resource)||""}},[p,v]=x.useState(y()),[i,c]=x.useState({name:r&&r.name||"",description:r&&r.config&&r.config.description||"",url:r&&r.config&&r.config.url||"",command:r&&r.config&&r.config.command||"",arguments:r&&r.config&&r.config.args?Array.isArray(r.config.args)?r.config.args.join(" "):String(r.config.args):"",args:r&&r.config&&r.config.args||[],type:y(),env:u(r),headers:[],passthroughHeaders:((Ke=(Ie=r==null?void 0:r.config)==null?void 0:Ie.passthroughHeaders)==null?void 0:Ke.join(", "))||"",visibility:((Oe=r==null?void 0:r.config)==null?void 0:Oe.visibility)??"private",sharedWithUsers:((Ue=r==null?void 0:r.config)==null?void 0:Ue.sharedWithUsers)||[],options:{timeout:r&&r.config&&r.config.options&&r.config.options.timeout||6e4,resetTimeoutOnProgress:((He=(Ee=r==null?void 0:r.config)==null?void 0:Ee.options)==null?void 0:He.resetTimeoutOnProgress)??!0,maxTotalTimeout:r&&r.config&&r.config.options&&r.config.options.maxTotalTimeout||void 0},oauth:b(r),keepAlive:{enabled:((Fe=r==null?void 0:r.config)==null?void 0:Fe.enableKeepAlive)===!0,interval:((Pe=r==null?void 0:r.config)==null?void 0:Pe.keepAliveInterval)||6e4},perSessionClient:((Me=r==null?void 0:r.config)==null?void 0:Me.perSessionClient)===!0,proxy:(Ve=r==null?void 0:r.config)==null?void 0:Ve.proxy,startOnDemand:((Re=r==null?void 0:r.config)==null?void 0:Re.startOnDemand)===!0,idleTimeoutMs:((ze=r==null?void 0:r.config)==null?void 0:ze.idleTimeoutMs)??3e5,openapi:r&&r.config&&r.config.openapi?{url:r.config.openapi.url||"",schema:r.config.openapi.schema?JSON.stringify(r.config.openapi.schema,null,2):"",inputMode:r.config.openapi.url?"url":r.config.openapi.schema?"schema":"url",version:r.config.openapi.version||"3.1.0",securityType:((We=r.config.openapi.security)==null?void 0:We.type)||"none",apiKeyName:((Le=($e=r.config.openapi.security)==null?void 0:$e.apiKey)==null?void 0:Le.name)||"",apiKeyIn:((Be=(qe=r.config.openapi.security)==null?void 0:qe.apiKey)==null?void 0:Be.in)||"header",apiKeyValue:((Xe=(_e=r.config.openapi.security)==null?void 0:_e.apiKey)==null?void 0:Xe.value)||"",httpScheme:((Ge=(Je=r.config.openapi.security)==null?void 0:Je.http)==null?void 0:Ge.scheme)||"bearer",httpCredentials:((Ze=(Qe=r.config.openapi.security)==null?void 0:Qe.http)==null?void 0:Ze.credentials)||"",oauth2TokenUrl:((De=(Ye=r.config.openapi.security)==null?void 0:Ye.oauth2)==null?void 0:De.tokenUrl)||"",oauth2ClientId:((ss=(es=r.config.openapi.security)==null?void 0:es.oauth2)==null?void 0:ss.clientId)||"",oauth2ClientSecret:((ts=(rs=r.config.openapi.security)==null?void 0:rs.oauth2)==null?void 0:ts.clientSecret)||"",oauth2Token:((as=(ns=r.config.openapi.security)==null?void 0:ns.oauth2)==null?void 0:as.token)||"",openIdConnectUrl:((ls=(os=r.config.openapi.security)==null?void 0:os.openIdConnect)==null?void 0:ls.url)||"",openIdConnectToken:((cs=(is=r.config.openapi.security)==null?void 0:is.openIdConnect)==null?void 0:cs.token)||"",specSecurityType:["apiKey","http","oauth2"].includes((ps=r.config.openapi.specSecurity)==null?void 0:ps.type)?r.config.openapi.specSecurity.type:"none",specApiKeyName:((us=(ds=r.config.openapi.specSecurity)==null?void 0:ds.apiKey)==null?void 0:us.name)||"",specApiKeyIn:((hs=(ms=r.config.openapi.specSecurity)==null?void 0:ms.apiKey)==null?void 0:hs.in)||"header",specApiKeyValue:((ys=(xs=r.config.openapi.specSecurity)==null?void 0:xs.apiKey)==null?void 0:ys.value)||"",specHttpScheme:((bs=(gs=r.config.openapi.specSecurity)==null?void 0:gs.http)==null?void 0:bs.scheme)==="bearer"?"bearer":"basic",specHttpCredentials:((fs=(vs=r.config.openapi.specSecurity)==null?void 0:vs.http)==null?void 0:fs.credentials)||"",specOauth2Token:((ks=(js=r.config.openapi.specSecurity)==null?void 0:js.oauth2)==null?void 0:ks.token)||"",passthroughHeaders:r.config.openapi.passthroughHeaders?r.config.openapi.passthroughHeaders.join(", "):"",cookieSession:r.config.openapi.cookieSession===!0}:{inputMode:"url",url:"",schema:"",version:"3.1.0",securityType:"none",specSecurityType:"none",passthroughHeaders:"",cookieSession:!1}}),[w,A]=x.useState([]),[S,C]=x.useState(!1),[T,f]=x.useState(!1),[E,P]=x.useState("");x.useEffect(()=>{if(i.visibility!=="group"||!(r!=null&&r.name))return;let t=!1;return C(!0),f(!1),Fr(`/servers/${encodeURIComponent(r.name)}/share-candidates`).then(s=>{t||(s.success&&Array.isArray(s.data)?A(s.data):f(!0))}).catch(()=>{t||f(!0)}).finally(()=>{t||C(!1)}),()=>{t=!0}},[i.visibility,r==null?void 0:r.name]);const I=_r(i.sharedWithUsers||[],w),g=Xr(I,E),K=new Set(i.sharedWithUsers||[]),M=g.length>0&&g.every(t=>K.has(t)),V=g.length===0||g.every(t=>!K.has(t)),R=t=>{c(s=>{const o=new Set(s.sharedWithUsers||[]);return o.has(t)?o.delete(t):o.add(t),{...s,sharedWithUsers:Array.from(o)}})},z=()=>{c(t=>({...t,sharedWithUsers:Jr(t.sharedWithUsers||[],g)}))},W=()=>{c(t=>({...t,sharedWithUsers:Gr(t.sharedWithUsers||[],g)}))},[k,Z]=x.useState(r&&r.config&&r.config.env?Object.entries(r.config.env).map(([t,s])=>({key:t,value:s})):[]),[N,Y]=x.useState(r&&r.config&&r.config.headers?Object.entries(r.config.headers).map(([t,s])=>({key:t,value:s})):[]),[H,he]=x.useState(null),[D,F]=x.useState(!1),[Sr,ee]=x.useState(!1),se=x.useRef(0),xe=x.useRef(null),ye=x.useRef(!1),re=x.useRef(!!r),$=x.useRef(i);$.current=i;const ge=x.useRef(k);ge.current=k;const be=x.useRef(N);be.current=N;const[L,q]=x.useState(null),[ve,fe]=x.useState(!1),[te,Cr]=x.useState(!1),[ne,Tr]=x.useState(!1),[ae,wr]=x.useState(!1),[oe,Ar]=x.useState(!1),[je,le]=x.useState(null),O=!!r,Ir=()=>{re.current=!0,q(null)},B=t=>{const{name:s,value:o}=t.target;c({...i,[s]:o})},Kr=t=>{const s=t.split(" ").filter(o=>o.trim()!=="");c({...i,arguments:t,args:s})},_=t=>{v(t),c(s=>({...s,type:t}))},X=(t,s,o)=>{const j=[...k];j[t][s]=o,Z(j)},ke=()=>{Z([...k,{key:"",value:""}])},Ne=t=>{const s=[...k];s.splice(t,1),Z(s)},J=(t,s,o)=>{const j=[...N];j[t][s]=o,Y(j)},Se=()=>{Y([...N,{key:"",value:""}])},Ce=t=>{const s=[...N];s.splice(t,1),Y(s)},Te=(t,s)=>{c(o=>({...o,oauth:{...o.oauth||{},[t]:s}}))},ie=(t,s)=>{c(o=>({...o,options:{...o.options,[t]:s}}))},Or=async t=>{try{const s=await Pr("/servers/openapi/tool-stats",{config:t.config},{signal:AbortSignal.timeout(6e4)});return s.success&&s.data?s.data:null}catch{return null}},we=async(t,s,o)=>{const j=++se.current;F(!0),ee(!1);const ce=await Or(t);if(se.current!==j)return;if(!ce){ee(!0),F(!1);return}xe.current=s,he(ce);const Q=$.current,pe=re.current,U=ce.declaredSecurity,Hr=o.allowSecurityPrefill&&!pe&&!O&&!ye.current;o.consumeAutomaticAnalysis&&(ye.current=!0);const de=U!=null&&U.declared&&U.supported&&Hr?Qr(Q,U,pe):Q;de!==Q&&($.current=de,c(de)),q(Dr(Q,U,{includeNotDeclared:!0,securityTouched:pe})),F(!1)},Ur=async()=>{fe(!0);try{const t=ue({formData:i,serverType:p,envVars:k,headerVars:N});await we(t,br(i).key,{allowSecurityPrefill:!O&&!re.current,consumeAutomaticAnalysis:!1})}catch{}finally{fe(!1)}},G=br(i),Ae=p==="openapi"&&kr(G);x.useEffect(()=>{if(se.current+=1,he(null),ee(!1),F(!1),q(null),!et({isEdit:O,serverType:p,source:G,analyzedSourceKey:xe.current}))return;F(!0);const t=window.setTimeout(()=>{const s=ue({formData:$.current,serverType:p,envVars:ge.current,headerVars:be.current});we(s,G.key,{allowSecurityPrefill:!0,consumeAutomaticAnalysis:!0})},600);return()=>{window.clearTimeout(t)}},[O,G.key,p]);const Er=async t=>{if(t.preventDefault(),le(null),(!(r!=null&&r.name)||i.name!==r.name)&&!vr(i.name)){le(n("server.nameInvalid"));return}try{const o=ue({formData:i,serverType:p,envVars:k,headerVars:N});a(o)}catch(o){le(`Error: ${o instanceof Error?o.message:String(o)}`)}};return e.jsxs("div",{className:"hub-card p-6 w-full max-w-3xl max-h-screen overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--hub-ink)]",children:d}),e.jsx("button",{onClick:l,className:"hub-icon-btn","aria-label":"Close",children:e.jsx(Wr,{size:16})})]}),(je||m)&&e.jsx("div",{className:"bg-red-50 text-red-700 p-3 rounded mb-4",children:m||je}),e.jsxs("form",{onSubmit:Er,children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)] mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:n("server.sectionBasicInfo","Basic Info")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"name",children:n("server.name")}),e.jsx("input",{type:"text",name:"name",id:"name",value:i.name,onChange:B,className:"w-full py-2 px-3 form-input",placeholder:"e.g.: time-mcp",pattern:h?Nr.source:void 0,maxLength:h?me:void 0,title:n("server.nameInvalid"),required:!0}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:n("server.nameInvalid")})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"description",children:n("server.description")}),e.jsx("input",{type:"text",name:"description",id:"description",value:i.description||"",onChange:B,className:"w-full py-2 px-3 form-input",placeholder:n("server.descriptionPlaceholder")})]})]})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)] mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:n("server.sectionConnection","Connection")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:n("server.type")}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"command",name:"serverType",value:"command",checked:p==="stdio",onChange:()=>_("stdio"),className:"mr-1"}),e.jsx("label",{htmlFor:"command",className:"text-[var(--hub-ink)]",children:n("server.typeStdio")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"url",name:"serverType",value:"url",checked:p==="sse",onChange:()=>_("sse"),className:"mr-1"}),e.jsx("label",{htmlFor:"url",className:"text-[var(--hub-ink)]",children:n("server.typeSse")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"streamable-http",name:"serverType",value:"streamable-http",checked:p==="streamable-http",onChange:()=>_("streamable-http"),className:"mr-1"}),e.jsx("label",{htmlFor:"streamable-http",className:"text-[var(--hub-ink)]",children:n("server.typeStreamableHttp")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"openapi",name:"serverType",value:"openapi",checked:p==="openapi",onChange:()=>_("openapi"),className:"mr-1"}),e.jsx("label",{htmlFor:"openapi",className:"text-[var(--hub-ink)]",children:n("server.typeOpenapi")})]})]})]}),e.jsx("div",{className:"pl-4 border-l-2 border-gray-200 dark:border-gray-700 ml-2",children:p==="openapi"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:n("server.openapi.inputMode")}),e.jsxs("div",{className:"flex space-x-4",children:[e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"input-mode-url",name:"inputMode",value:"url",checked:((Ns=i.openapi)==null?void 0:Ns.inputMode)==="url",onChange:()=>c(t=>({...t,openapi:{...t.openapi,inputMode:"url"}})),className:"mr-1"}),e.jsx("label",{htmlFor:"input-mode-url",children:n("server.openapi.inputModeUrl")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"input-mode-schema",name:"inputMode",value:"schema",checked:((Ss=i.openapi)==null?void 0:Ss.inputMode)==="schema",onChange:()=>c(t=>({...t,openapi:{...t.openapi,inputMode:"schema"}})),className:"mr-1"}),e.jsx("label",{htmlFor:"input-mode-schema",children:n("server.openapi.inputModeSchema")})]})]})]}),((Cs=i.openapi)==null?void 0:Cs.inputMode)==="url"&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"openapi-url",children:n("server.openapi.specUrl")}),e.jsx("input",{type:"url",name:"openapi-url",id:"openapi-url",value:((Ts=i.openapi)==null?void 0:Ts.url)||"",onChange:t=>c(s=>({...s,openapi:{...s.openapi,url:t.target.value}})),className:"w-full py-2 px-3 form-input",placeholder:"e.g.: https://api.example.com/openapi.json",required:p==="openapi"&&((ws=i.openapi)==null?void 0:ws.inputMode)==="url"})]}),((As=i.openapi)==null?void 0:As.inputMode)==="schema"&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"openapi-schema",children:n("server.openapi.schema")}),e.jsx("textarea",{name:"openapi-schema",id:"openapi-schema",rows:10,value:((Is=i.openapi)==null?void 0:Is.schema)||"",onChange:t=>c(s=>({...s,openapi:{...s.openapi,schema:t.target.value}})),className:"w-full py-2 px-3 form-input font-mono text-sm",placeholder:`{
1
+ import{r as x,j as e}from"./framework-vendor-BHAQX05P.js";import{j as Fr,e as Pr}from"./index-Cb6IBpZR.js";import{f as Mr,a as Vr,O as Rr}from"./contextCost-CilWqGWT.js";import{u as zr}from"./i18n-vendor-CMcB7XUR.js";import{X as Wr}from"./icons-vendor-HZHHWeTa.js";const gr=a=>{const l={};return a.forEach(({key:r,value:d})=>{const m=r.trim();m&&(l[m]=d)}),l},fr=a=>a?a.split(",").map(l=>l.trim()).filter(l=>l.length>0):[],$r=a=>Array.from(new Set((a||[]).map(l=>l.trim()).filter(l=>l.length>0))),Lr=a=>{const l={};return typeof(a==null?void 0:a.timeout)=="number"&&!Number.isNaN(a.timeout)&&(l.timeout=a.timeout),typeof(a==null?void 0:a.resetTimeoutOnProgress)=="boolean"&&(l.resetTimeoutOnProgress=a.resetTimeoutOnProgress),a!=null&&a.maxTotalTimeout&&(l.maxTotalTimeout=a.maxTotalTimeout),l},qr=a=>{var p,v,i,c,w,A,S,C;if(!a)return{};const l={},r=(p=a.clientId)==null?void 0:p.trim(),d=(v=a.clientSecret)==null?void 0:v.trim(),m=(i=a.scopes)==null?void 0:i.trim(),n=(c=a.accessToken)==null?void 0:c.trim(),h=(w=a.refreshToken)==null?void 0:w.trim(),y=(A=a.authorizationEndpoint)==null?void 0:A.trim(),u=(S=a.tokenEndpoint)==null?void 0:S.trim(),b=(C=a.resource)==null?void 0:C.trim();if(r&&(l.clientId=r),d&&(l.clientSecret=d),m){const T=m.split(/[\s,]+/).map(f=>f.trim()).filter(f=>f.length>0);T.length>0&&(l.scopes=T)}return n&&(l.accessToken=n),h&&(l.refreshToken=h),y&&(l.authorizationEndpoint=y),u&&(l.tokenEndpoint=u),b&&(l.resource=b),l},Br=a=>{var y,u,b,p,v,i,c,w,A,S,C,T,f,E,P,I,g,K,M,V,R,z,W;const l={version:((y=a.openapi)==null?void 0:y.version)||"3.1.0",passthroughHeaders:fr((u=a.openapi)==null?void 0:u.passthroughHeaders),cookieSession:((b=a.openapi)==null?void 0:b.cookieSession)===!0?!0:void 0},r=(v=(p=a.openapi)==null?void 0:p.oauth2TokenUrl)==null?void 0:v.trim(),d=(c=(i=a.openapi)==null?void 0:i.oauth2ClientId)==null?void 0:c.trim(),m=(A=(w=a.openapi)==null?void 0:w.oauth2ClientSecret)==null?void 0:A.trim(),n=(C=(S=a.openapi)==null?void 0:S.oauth2Token)==null?void 0:C.trim();if(((T=a.openapi)==null?void 0:T.inputMode)==="url")l.url=((f=a.openapi)==null?void 0:f.url)||"";else if(((E=a.openapi)==null?void 0:E.inputMode)==="schema"&&((P=a.openapi)!=null&&P.schema))try{l.schema=JSON.parse(a.openapi.schema)}catch{throw new Error("Invalid JSON schema format")}(I=a.openapi)!=null&&I.securityType&&a.openapi.securityType!=="none"&&(l.security={type:a.openapi.securityType,...a.openapi.securityType==="apiKey"&&{apiKey:{name:a.openapi.apiKeyName||"",in:a.openapi.apiKeyIn||"header",value:a.openapi.apiKeyValue||""}},...a.openapi.securityType==="http"&&{http:{scheme:a.openapi.httpScheme||"bearer",credentials:a.openapi.httpCredentials||""}},...a.openapi.securityType==="oauth2"&&{oauth2:{...r&&{tokenUrl:r},...d&&{clientId:d},...m&&{clientSecret:m},...n&&{token:n}}},...a.openapi.securityType==="openIdConnect"&&{openIdConnect:{url:a.openapi.openIdConnectUrl||"",token:a.openapi.openIdConnectToken||""}}});const h=(g=a.openapi)==null?void 0:g.specSecurityType;return h&&h!=="none"&&(l.specSecurity={type:h,...h==="apiKey"&&{apiKey:{name:((K=a.openapi)==null?void 0:K.specApiKeyName)||"",in:((M=a.openapi)==null?void 0:M.specApiKeyIn)||"header",value:((V=a.openapi)==null?void 0:V.specApiKeyValue)||""}},...h==="http"&&{http:{scheme:((R=a.openapi)==null?void 0:R.specHttpScheme)||"basic",credentials:((z=a.openapi)==null?void 0:z.specHttpCredentials)||""}},...h==="oauth2"&&{oauth2:{token:((W=a.openapi)==null?void 0:W.specOauth2Token)||""}}}),l},ue=({formData:a,serverType:l,envVars:r,headerVars:d})=>{var b,p,v;const m=gr(r),n=gr(d),h=Lr(a.options),y=((b=a.description)==null?void 0:b.trim())||"",u={type:l,description:y,options:h,visibility:a.visibility??"private",sharedWithUsers:a.visibility==="group"?$r(a.sharedWithUsers):void 0,perSessionClient:a.perSessionClient===!0?!0:void 0,startOnDemand:a.startOnDemand===!0?!0:void 0,idleTimeoutMs:a.startOnDemand===!0?a.idleTimeoutMs??3e5:void 0,proxy:a.proxy};if(l==="openapi")u.headers=n,u.openapi=Br(a);else if(l==="sse"||l==="streamable-http"){const i=((p=a.keepAlive)==null?void 0:p.enabled)===!0;u.url=a.url.trim(),u.env=m,u.headers=n,u.passthroughHeaders=fr(a.passthroughHeaders),u.oauth=qr(a.oauth),u.enableKeepAlive=i,u.keepAliveInterval=i?((v=a.keepAlive)==null?void 0:v.interval)||6e4:void 0}else u.command=a.command.trim(),u.args=a.args,u.env=m;return{name:a.name.trim(),config:u}},_r=(a=[],l=[])=>Array.from(new Set([...a,...l])).sort((r,d)=>r.localeCompare(d)),Xr=(a,l)=>{const r=l.trim().toLowerCase();return r?a.filter(d=>d.toLowerCase().includes(r)):[...a]},Jr=(a,l)=>Array.from(new Set([...a,...l])),Gr=(a,l)=>{const r=new Set(l);return a.filter(d=>!r.has(d))};function jr(a,l=!1){if(l)return!1;const r=a.openapi;return r&&r.securityType&&r.securityType!=="none"?!1:!(r!=null&&r.apiKeyValue)&&!(r!=null&&r.httpCredentials)&&!(r!=null&&r.oauth2TokenUrl)&&!(r!=null&&r.oauth2ClientId)&&!(r!=null&&r.oauth2ClientSecret)&&!(r!=null&&r.oauth2Token)&&!(r!=null&&r.openIdConnectUrl)&&!(r!=null&&r.openIdConnectToken)}function Qr(a,l,r=!1){var m,n,h,y,u;if(!l.declared||!l.supported||!l.prefill||!jr(a,r))return a;const d=l.prefill;return{...a,openapi:{...a.openapi,securityType:d.type,apiKeyName:((m=d.apiKey)==null?void 0:m.name)||"",apiKeyIn:((n=d.apiKey)==null?void 0:n.in)||"header",apiKeyValue:"",httpScheme:((h=d.http)==null?void 0:h.scheme)||"bearer",httpCredentials:"",oauth2TokenUrl:((y=d.oauth2)==null?void 0:y.tokenUrl)||"",oauth2ClientId:"",oauth2ClientSecret:"",oauth2Token:"",openIdConnectUrl:((u=d.openIdConnect)==null?void 0:u.url)||"",openIdConnectToken:""}}}function Zr(a,l){var d,m,n;if(!l.prefill)return!1;const r=a.openapi;if((r==null?void 0:r.securityType)!==l.prefill.type)return!0;switch(r==null?void 0:r.securityType){case"apiKey":return r.apiKeyName!==((d=l.prefill.apiKey)==null?void 0:d.name)||r.apiKeyIn!==((m=l.prefill.apiKey)==null?void 0:m.in);case"http":return r.httpScheme!==((n=l.prefill.http)==null?void 0:n.scheme);default:return!1}}function Yr(a){const l=a.openapi,r=l==null?void 0:l.securityType;if(!r||r==="none")return null;switch(r){case"apiKey":return`API key in ${(l==null?void 0:l.apiKeyIn)||"header"} '${(l==null?void 0:l.apiKeyName)||""}'`;case"http":return`HTTP ${(l==null?void 0:l.httpScheme)||"bearer"}`;case"oauth2":return"OAuth2";case"openIdConnect":return"OpenID Connect";default:return null}}function Dr(a,l,r={}){return l!=null&&l.declared?!jr(a,r.securityTouched)&&Zr(a,l)?{kind:"warning",messageKey:"securityMismatchWarning",values:{summary:l.summary,configured:Yr(a)||"none"}}:l.supported?{kind:"info",messageKey:"securityPrefillNotice",values:{summary:l.summary}}:{kind:"warning",messageKey:"securityUnsupportedNotice",values:{summary:l.summary,reason:l.unsupportedReason||""}}:r.includeNotDeclared?{kind:"info",messageKey:"securityNotDeclared",values:{}}:null}function br(a){var d,m,n,h;const l=((d=a.openapi)==null?void 0:d.inputMode)==="schema"?"schema":"url",r=((h=l==="schema"?(m=a.openapi)==null?void 0:m.schema:(n=a.openapi)==null?void 0:n.url)==null?void 0:h.trim())||"";return{mode:l,value:r,key:r?`${l}:${r}`:""}}function kr(a){if(!a.value)return!1;if(a.mode==="schema")try{const l=JSON.parse(a.value);return l!==null&&typeof l=="object"&&!Array.isArray(l)}catch{return!1}try{const l=new URL(a.value);return l.protocol==="http:"||l.protocol==="https:"}catch{return!1}}function et(a){return!a.isEdit&&a.serverType==="openapi"&&kr(a.source)&&a.source.key!==a.analyzedSourceKey}const Nr=/^[A-Za-z0-9._-]+$/,me=128,vr=a=>{const l=a.trim();return l.length>0&&l.length<=me&&Nr.test(l)&&!l.includes("..")},ot=a=>a.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/\.{2,}/g,".").replace(/^-+|-+$/g,"").slice(0,me)||"server",lt=({onSubmit:a,onCancel:l,initialData:r=null,modalTitle:d,formError:m=null})=>{var Ie,Ke,Oe,Ue,Ee,He,Fe,Pe,Me,Ve,Re,ze,We,$e,Le,qe,Be,_e,Xe,Je,Ge,Qe,Ze,Ye,De,es,ss,rs,ts,ns,as,os,ls,is,cs,ps,ds,us,ms,hs,xs,ys,gs,bs,vs,fs,js,ks,Ns,Ss,Cs,Ts,ws,As,Is,Ks,Os,Us,Es,Hs,Fs,Ps,Ms,Vs,Rs,zs,Ws,$s,Ls,qs,Bs,_s,Xs,Js,Gs,Qs,Zs,Ys,Ds,er,sr,rr,tr,nr,ar,or,lr,ir,cr,pr,dr,ur,mr,hr,xr,yr;const{t:n}=zr(),h=!(r!=null&&r.name)||vr(r.name),y=()=>!r||!r.config?"stdio":r.config.type?r.config.type:r.config.url?"sse":"stdio",u=t=>!t||!t.config||!t.config.env?[]:Object.entries(t.config.env).map(([s,o])=>({key:s,value:o,description:""})),b=t=>{var o;const s=(o=t==null?void 0:t.config)==null?void 0:o.oauth;return{clientId:(s==null?void 0:s.clientId)||"",clientSecret:(s==null?void 0:s.clientSecret)||"",scopes:s!=null&&s.scopes?s.scopes.join(" "):"",accessToken:(s==null?void 0:s.accessToken)||"",refreshToken:(s==null?void 0:s.refreshToken)||"",authorizationEndpoint:(s==null?void 0:s.authorizationEndpoint)||"",tokenEndpoint:(s==null?void 0:s.tokenEndpoint)||"",resource:(s==null?void 0:s.resource)||""}},[p,v]=x.useState(y()),[i,c]=x.useState({name:r&&r.name||"",description:r&&r.config&&r.config.description||"",url:r&&r.config&&r.config.url||"",command:r&&r.config&&r.config.command||"",arguments:r&&r.config&&r.config.args?Array.isArray(r.config.args)?r.config.args.join(" "):String(r.config.args):"",args:r&&r.config&&r.config.args||[],type:y(),env:u(r),headers:[],passthroughHeaders:((Ke=(Ie=r==null?void 0:r.config)==null?void 0:Ie.passthroughHeaders)==null?void 0:Ke.join(", "))||"",visibility:((Oe=r==null?void 0:r.config)==null?void 0:Oe.visibility)??"private",sharedWithUsers:((Ue=r==null?void 0:r.config)==null?void 0:Ue.sharedWithUsers)||[],options:{timeout:r&&r.config&&r.config.options&&r.config.options.timeout||6e4,resetTimeoutOnProgress:((He=(Ee=r==null?void 0:r.config)==null?void 0:Ee.options)==null?void 0:He.resetTimeoutOnProgress)??!0,maxTotalTimeout:r&&r.config&&r.config.options&&r.config.options.maxTotalTimeout||void 0},oauth:b(r),keepAlive:{enabled:((Fe=r==null?void 0:r.config)==null?void 0:Fe.enableKeepAlive)===!0,interval:((Pe=r==null?void 0:r.config)==null?void 0:Pe.keepAliveInterval)||6e4},perSessionClient:((Me=r==null?void 0:r.config)==null?void 0:Me.perSessionClient)===!0,proxy:(Ve=r==null?void 0:r.config)==null?void 0:Ve.proxy,startOnDemand:((Re=r==null?void 0:r.config)==null?void 0:Re.startOnDemand)===!0,idleTimeoutMs:((ze=r==null?void 0:r.config)==null?void 0:ze.idleTimeoutMs)??3e5,openapi:r&&r.config&&r.config.openapi?{url:r.config.openapi.url||"",schema:r.config.openapi.schema?JSON.stringify(r.config.openapi.schema,null,2):"",inputMode:r.config.openapi.url?"url":r.config.openapi.schema?"schema":"url",version:r.config.openapi.version||"3.1.0",securityType:((We=r.config.openapi.security)==null?void 0:We.type)||"none",apiKeyName:((Le=($e=r.config.openapi.security)==null?void 0:$e.apiKey)==null?void 0:Le.name)||"",apiKeyIn:((Be=(qe=r.config.openapi.security)==null?void 0:qe.apiKey)==null?void 0:Be.in)||"header",apiKeyValue:((Xe=(_e=r.config.openapi.security)==null?void 0:_e.apiKey)==null?void 0:Xe.value)||"",httpScheme:((Ge=(Je=r.config.openapi.security)==null?void 0:Je.http)==null?void 0:Ge.scheme)||"bearer",httpCredentials:((Ze=(Qe=r.config.openapi.security)==null?void 0:Qe.http)==null?void 0:Ze.credentials)||"",oauth2TokenUrl:((De=(Ye=r.config.openapi.security)==null?void 0:Ye.oauth2)==null?void 0:De.tokenUrl)||"",oauth2ClientId:((ss=(es=r.config.openapi.security)==null?void 0:es.oauth2)==null?void 0:ss.clientId)||"",oauth2ClientSecret:((ts=(rs=r.config.openapi.security)==null?void 0:rs.oauth2)==null?void 0:ts.clientSecret)||"",oauth2Token:((as=(ns=r.config.openapi.security)==null?void 0:ns.oauth2)==null?void 0:as.token)||"",openIdConnectUrl:((ls=(os=r.config.openapi.security)==null?void 0:os.openIdConnect)==null?void 0:ls.url)||"",openIdConnectToken:((cs=(is=r.config.openapi.security)==null?void 0:is.openIdConnect)==null?void 0:cs.token)||"",specSecurityType:["apiKey","http","oauth2"].includes((ps=r.config.openapi.specSecurity)==null?void 0:ps.type)?r.config.openapi.specSecurity.type:"none",specApiKeyName:((us=(ds=r.config.openapi.specSecurity)==null?void 0:ds.apiKey)==null?void 0:us.name)||"",specApiKeyIn:((hs=(ms=r.config.openapi.specSecurity)==null?void 0:ms.apiKey)==null?void 0:hs.in)||"header",specApiKeyValue:((ys=(xs=r.config.openapi.specSecurity)==null?void 0:xs.apiKey)==null?void 0:ys.value)||"",specHttpScheme:((bs=(gs=r.config.openapi.specSecurity)==null?void 0:gs.http)==null?void 0:bs.scheme)==="bearer"?"bearer":"basic",specHttpCredentials:((fs=(vs=r.config.openapi.specSecurity)==null?void 0:vs.http)==null?void 0:fs.credentials)||"",specOauth2Token:((ks=(js=r.config.openapi.specSecurity)==null?void 0:js.oauth2)==null?void 0:ks.token)||"",passthroughHeaders:r.config.openapi.passthroughHeaders?r.config.openapi.passthroughHeaders.join(", "):"",cookieSession:r.config.openapi.cookieSession===!0}:{inputMode:"url",url:"",schema:"",version:"3.1.0",securityType:"none",specSecurityType:"none",passthroughHeaders:"",cookieSession:!1}}),[w,A]=x.useState([]),[S,C]=x.useState(!1),[T,f]=x.useState(!1),[E,P]=x.useState("");x.useEffect(()=>{if(i.visibility!=="group"||!(r!=null&&r.name))return;let t=!1;return C(!0),f(!1),Fr(`/servers/${encodeURIComponent(r.name)}/share-candidates`).then(s=>{t||(s.success&&Array.isArray(s.data)?A(s.data):f(!0))}).catch(()=>{t||f(!0)}).finally(()=>{t||C(!1)}),()=>{t=!0}},[i.visibility,r==null?void 0:r.name]);const I=_r(i.sharedWithUsers||[],w),g=Xr(I,E),K=new Set(i.sharedWithUsers||[]),M=g.length>0&&g.every(t=>K.has(t)),V=g.length===0||g.every(t=>!K.has(t)),R=t=>{c(s=>{const o=new Set(s.sharedWithUsers||[]);return o.has(t)?o.delete(t):o.add(t),{...s,sharedWithUsers:Array.from(o)}})},z=()=>{c(t=>({...t,sharedWithUsers:Jr(t.sharedWithUsers||[],g)}))},W=()=>{c(t=>({...t,sharedWithUsers:Gr(t.sharedWithUsers||[],g)}))},[k,Z]=x.useState(r&&r.config&&r.config.env?Object.entries(r.config.env).map(([t,s])=>({key:t,value:s})):[]),[N,Y]=x.useState(r&&r.config&&r.config.headers?Object.entries(r.config.headers).map(([t,s])=>({key:t,value:s})):[]),[H,he]=x.useState(null),[D,F]=x.useState(!1),[Sr,ee]=x.useState(!1),se=x.useRef(0),xe=x.useRef(null),ye=x.useRef(!1),re=x.useRef(!!r),$=x.useRef(i);$.current=i;const ge=x.useRef(k);ge.current=k;const be=x.useRef(N);be.current=N;const[L,q]=x.useState(null),[ve,fe]=x.useState(!1),[te,Cr]=x.useState(!1),[ne,Tr]=x.useState(!1),[ae,wr]=x.useState(!1),[oe,Ar]=x.useState(!1),[je,le]=x.useState(null),O=!!r,Ir=()=>{re.current=!0,q(null)},B=t=>{const{name:s,value:o}=t.target;c({...i,[s]:o})},Kr=t=>{const s=t.split(" ").filter(o=>o.trim()!=="");c({...i,arguments:t,args:s})},_=t=>{v(t),c(s=>({...s,type:t}))},X=(t,s,o)=>{const j=[...k];j[t][s]=o,Z(j)},ke=()=>{Z([...k,{key:"",value:""}])},Ne=t=>{const s=[...k];s.splice(t,1),Z(s)},J=(t,s,o)=>{const j=[...N];j[t][s]=o,Y(j)},Se=()=>{Y([...N,{key:"",value:""}])},Ce=t=>{const s=[...N];s.splice(t,1),Y(s)},Te=(t,s)=>{c(o=>({...o,oauth:{...o.oauth||{},[t]:s}}))},ie=(t,s)=>{c(o=>({...o,options:{...o.options,[t]:s}}))},Or=async t=>{try{const s=await Pr("/servers/openapi/tool-stats",{config:t.config},{signal:AbortSignal.timeout(6e4)});return s.success&&s.data?s.data:null}catch{return null}},we=async(t,s,o)=>{const j=++se.current;F(!0),ee(!1);const ce=await Or(t);if(se.current!==j)return;if(!ce){ee(!0),F(!1);return}xe.current=s,he(ce);const Q=$.current,pe=re.current,U=ce.declaredSecurity,Hr=o.allowSecurityPrefill&&!pe&&!O&&!ye.current;o.consumeAutomaticAnalysis&&(ye.current=!0);const de=U!=null&&U.declared&&U.supported&&Hr?Qr(Q,U,pe):Q;de!==Q&&($.current=de,c(de)),q(Dr(Q,U,{includeNotDeclared:!0,securityTouched:pe})),F(!1)},Ur=async()=>{fe(!0);try{const t=ue({formData:i,serverType:p,envVars:k,headerVars:N});await we(t,br(i).key,{allowSecurityPrefill:!O&&!re.current,consumeAutomaticAnalysis:!1})}catch{}finally{fe(!1)}},G=br(i),Ae=p==="openapi"&&kr(G);x.useEffect(()=>{if(se.current+=1,he(null),ee(!1),F(!1),q(null),!et({isEdit:O,serverType:p,source:G,analyzedSourceKey:xe.current}))return;F(!0);const t=window.setTimeout(()=>{const s=ue({formData:$.current,serverType:p,envVars:ge.current,headerVars:be.current});we(s,G.key,{allowSecurityPrefill:!0,consumeAutomaticAnalysis:!0})},600);return()=>{window.clearTimeout(t)}},[O,G.key,p]);const Er=async t=>{if(t.preventDefault(),le(null),(!(r!=null&&r.name)||i.name!==r.name)&&!vr(i.name)){le(n("server.nameInvalid"));return}try{const o=ue({formData:i,serverType:p,envVars:k,headerVars:N});a(o)}catch(o){le(`Error: ${o instanceof Error?o.message:String(o)}`)}};return e.jsxs("div",{className:"hub-card p-6 w-full max-w-3xl max-h-screen overflow-y-auto",children:[e.jsxs("div",{className:"flex justify-between items-center mb-5",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--hub-ink)]",children:d}),e.jsx("button",{onClick:l,className:"hub-icon-btn","aria-label":"Close",children:e.jsx(Wr,{size:16})})]}),(je||m)&&e.jsx("div",{className:"bg-red-50 text-red-700 p-3 rounded mb-4",children:m||je}),e.jsxs("form",{onSubmit:Er,children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)] mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:n("server.sectionBasicInfo","Basic Info")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"md:col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"name",children:n("server.name")}),e.jsx("input",{type:"text",name:"name",id:"name",value:i.name,onChange:B,className:"w-full py-2 px-3 form-input",placeholder:"e.g.: time-mcp",pattern:h?Nr.source:void 0,maxLength:h?me:void 0,title:n("server.nameInvalid"),required:!0}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:n("server.nameInvalid")})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"description",children:n("server.description")}),e.jsx("input",{type:"text",name:"description",id:"description",value:i.description||"",onChange:B,className:"w-full py-2 px-3 form-input",placeholder:n("server.descriptionPlaceholder")})]})]})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)] mb-3 pb-2 border-b border-gray-200 dark:border-gray-700",children:n("server.sectionConnection","Connection")}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:n("server.type")}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"command",name:"serverType",value:"command",checked:p==="stdio",onChange:()=>_("stdio"),className:"mr-1"}),e.jsx("label",{htmlFor:"command",className:"text-[var(--hub-ink)]",children:n("server.typeStdio")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"url",name:"serverType",value:"url",checked:p==="sse",onChange:()=>_("sse"),className:"mr-1"}),e.jsx("label",{htmlFor:"url",className:"text-[var(--hub-ink)]",children:n("server.typeSse")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"streamable-http",name:"serverType",value:"streamable-http",checked:p==="streamable-http",onChange:()=>_("streamable-http"),className:"mr-1"}),e.jsx("label",{htmlFor:"streamable-http",className:"text-[var(--hub-ink)]",children:n("server.typeStreamableHttp")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"openapi",name:"serverType",value:"openapi",checked:p==="openapi",onChange:()=>_("openapi"),className:"mr-1"}),e.jsx("label",{htmlFor:"openapi",className:"text-[var(--hub-ink)]",children:n("server.typeOpenapi")})]})]})]}),e.jsx("div",{className:"pl-4 border-l-2 border-gray-200 dark:border-gray-700 ml-2",children:p==="openapi"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:n("server.openapi.inputMode")}),e.jsxs("div",{className:"flex space-x-4",children:[e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"input-mode-url",name:"inputMode",value:"url",checked:((Ns=i.openapi)==null?void 0:Ns.inputMode)==="url",onChange:()=>c(t=>({...t,openapi:{...t.openapi,inputMode:"url"}})),className:"mr-1"}),e.jsx("label",{htmlFor:"input-mode-url",children:n("server.openapi.inputModeUrl")})]}),e.jsxs("div",{children:[e.jsx("input",{type:"radio",id:"input-mode-schema",name:"inputMode",value:"schema",checked:((Ss=i.openapi)==null?void 0:Ss.inputMode)==="schema",onChange:()=>c(t=>({...t,openapi:{...t.openapi,inputMode:"schema"}})),className:"mr-1"}),e.jsx("label",{htmlFor:"input-mode-schema",children:n("server.openapi.inputModeSchema")})]})]})]}),((Cs=i.openapi)==null?void 0:Cs.inputMode)==="url"&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"openapi-url",children:n("server.openapi.specUrl")}),e.jsx("input",{type:"url",name:"openapi-url",id:"openapi-url",value:((Ts=i.openapi)==null?void 0:Ts.url)||"",onChange:t=>c(s=>({...s,openapi:{...s.openapi,url:t.target.value}})),className:"w-full py-2 px-3 form-input",placeholder:"e.g.: https://api.example.com/openapi.json",required:p==="openapi"&&((ws=i.openapi)==null?void 0:ws.inputMode)==="url"})]}),((As=i.openapi)==null?void 0:As.inputMode)==="schema"&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"openapi-schema",children:n("server.openapi.schema")}),e.jsx("textarea",{name:"openapi-schema",id:"openapi-schema",rows:10,value:((Is=i.openapi)==null?void 0:Is.schema)||"",onChange:t=>c(s=>({...s,openapi:{...s.openapi,schema:t.target.value}})),className:"w-full py-2 px-3 form-input font-mono text-sm",placeholder:`{
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "API",
@@ -13,4 +13,4 @@ import{r as x,j as e}from"./framework-vendor-BHAQX05P.js";import{j as Fr,e as Pr
13
13
  ...
14
14
  }
15
15
  }`,required:p==="openapi"&&((Ks=i.openapi)==null?void 0:Ks.inputMode)==="schema"}),e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:n("server.openapi.schemaHelp")})]}),!O&&Ae&&e.jsx("div",{className:"mb-4 rounded border border-blue-200 bg-blue-50 p-3 text-sm dark:border-blue-900 dark:bg-blue-950/30","aria-live":"polite",children:D?e.jsx("p",{className:"text-blue-700 dark:text-blue-300",children:n("server.openapi.statsMeasuring")}):H?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100",children:n("server.openapi.statsSummary",{toolCount:H.toolCount,bytes:Vr(H.definitionsBytes),tokens:Mr(H.estimatedTokens)})}),H.estimatedTokens>=Rr&&e.jsx("p",{className:"mt-1 text-yellow-700 dark:text-yellow-300",children:n("server.openapi.statsWarning")})]}):Sr?e.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:n("server.openapi.statsUnavailable")}):null}),e.jsxs("div",{className:"mb-4",onChange:Ir,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"block text-sm font-medium text-[var(--hub-ink-2)]",children:n("server.openapi.security")}),e.jsx("button",{type:"button",onClick:()=>void Ur(),disabled:ve||D||!Ae,className:"hub-btn text-xs !h-7 !px-2",children:n(ve||D?"server.openapi.securityDetecting":"server.openapi.securityDetect")})]}),e.jsxs("select",{value:((Os=i.openapi)==null?void 0:Os.securityType)||"none",onChange:t=>c(s=>{var o;return q(null),{...s,openapi:{...s.openapi,securityType:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full py-2 px-3 form-input",children:[e.jsx("option",{value:"none",children:n("server.openapi.securityNone")}),e.jsx("option",{value:"apiKey",children:n("server.openapi.securityApiKey")}),e.jsx("option",{value:"http",children:n("server.openapi.securityHttp")}),e.jsx("option",{value:"oauth2",children:n("server.openapi.securityOAuth2")}),e.jsx("option",{value:"openIdConnect",children:n("server.openapi.securityOpenIdConnect")})]}),L&&e.jsx("p",{className:`mt-2 text-xs ${L.kind==="warning"?"text-yellow-700 dark:text-yellow-300":"text-blue-700 dark:text-blue-300"}`,children:n(`server.openapi.${L.messageKey}`,L.values)})]}),((Us=i.openapi)==null?void 0:Us.securityType)==="apiKey"&&e.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[e.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--hub-ink-2)]",children:n("server.openapi.apiKeyConfig")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[var(--hub-ink-2)] mb-1",children:n("server.openapi.apiKeyName")}),e.jsx("input",{type:"text",value:((Es=i.openapi)==null?void 0:Es.apiKeyName)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,apiKeyName:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm form-input focus:outline-none",placeholder:"Authorization"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[var(--hub-ink-2)] mb-1",children:n("server.openapi.apiKeyIn")}),e.jsxs("select",{value:((Hs=i.openapi)==null?void 0:Hs.apiKeyIn)||"header",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,apiKeyIn:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[e.jsx("option",{value:"header",children:n("server.openapi.apiKeyInHeader")}),e.jsx("option",{value:"query",children:n("server.openapi.apiKeyInQuery")}),e.jsx("option",{value:"cookie",children:n("server.openapi.apiKeyInCookie")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.apiKeyValue")}),e.jsx("input",{type:"password",value:((Fs=i.openapi)==null?void 0:Fs.apiKeyValue)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,apiKeyValue:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"your-api-key"})]})]})]}),((Ps=i.openapi)==null?void 0:Ps.securityType)==="http"&&e.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[e.jsx("h4",{className:"text-sm font-medium mb-3 text-gray-700 dark:text-gray-300",children:n("server.openapi.httpAuthConfig")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.httpScheme")}),e.jsxs("select",{value:((Ms=i.openapi)==null?void 0:Ms.httpScheme)||"bearer",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,httpScheme:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[e.jsx("option",{value:"basic",children:n("server.openapi.httpSchemeBasic")}),e.jsx("option",{value:"bearer",children:n("server.openapi.httpSchemeBearer")}),e.jsx("option",{value:"digest",children:n("server.openapi.httpSchemeDigest")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.httpCredentials")}),e.jsx("input",{type:"password",value:((Vs=i.openapi)==null?void 0:Vs.httpCredentials)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,httpCredentials:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:((Rs=i.openapi)==null?void 0:Rs.httpScheme)==="basic"?"user:password or base64":"bearer-token"}),((zs=i.openapi)==null?void 0:zs.httpScheme)==="basic"&&e.jsx("p",{className:"text-xs text-[var(--hub-ink-3)] mt-1",children:n("server.openapi.httpCredentialsBasicHint")})]})]})]}),((Ws=i.openapi)==null?void 0:Ws.securityType)==="openIdConnect"&&e.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[e.jsx("h4",{className:"text-sm font-medium mb-3 text-gray-700 dark:text-gray-300",children:n("server.openapi.openIdConnectConfig")}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.openIdConnectUrl")}),e.jsx("input",{type:"url",value:(($s=i.openapi)==null?void 0:$s.openIdConnectUrl)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,openIdConnectUrl:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"https://example.com/.well-known/openid_configuration"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.openIdConnectToken")}),e.jsx("input",{type:"password",value:((Ls=i.openapi)==null?void 0:Ls.openIdConnectToken)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,openIdConnectToken:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"id-token"})]})]})]}),((qs=i.openapi)==null?void 0:qs.securityType)==="oauth2"&&e.jsxs("div",{className:"mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[e.jsx("h4",{className:"text-sm font-medium mb-3 text-gray-700 dark:text-gray-300",children:n("server.openapi.oauth2Config")}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.oauth.tokenEndpoint")}),e.jsx("input",{type:"url",value:((Bs=i.openapi)==null?void 0:Bs.oauth2TokenUrl)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,oauth2TokenUrl:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"https://example.com/oauth/token"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.oauth.clientId")}),e.jsx("input",{type:"text",value:((_s=i.openapi)==null?void 0:_s.oauth2ClientId)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,oauth2ClientId:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"client-id"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.oauth.clientSecret")}),e.jsx("input",{type:"password",value:((Xs=i.openapi)==null?void 0:Xs.oauth2ClientSecret)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,oauth2ClientSecret:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"client-secret"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.oauth2Token")}),e.jsx("input",{type:"password",value:((Js=i.openapi)==null?void 0:Js.oauth2Token)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,oauth2Token:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"access-token"})]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center mb-1",children:[e.jsx("input",{type:"checkbox",id:"openapiSpecSecurity",checked:(((Gs=i.openapi)==null?void 0:Gs.specSecurityType)||"none")!=="none",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specSecurityType:t.target.checked?"http":"none"}}}),className:"mr-2"}),e.jsx("label",{htmlFor:"openapiSpecSecurity",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:n("server.openapi.specSecurityToggle")})]}),e.jsx("p",{className:"text-xs text-gray-500 ml-6",children:n("server.openapi.specSecurityHelp")}),(((Qs=i.openapi)==null?void 0:Qs.specSecurityType)||"none")!=="none"&&e.jsxs("div",{className:"mt-2 ml-6 p-4 border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.security")}),e.jsxs("select",{value:((Zs=i.openapi)==null?void 0:Zs.specSecurityType)||"http",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specSecurityType:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[e.jsx("option",{value:"http",children:n("server.openapi.securityHttp")}),e.jsx("option",{value:"apiKey",children:n("server.openapi.securityApiKey")}),e.jsx("option",{value:"oauth2",children:n("server.openapi.securityOAuth2")})]})]}),((Ys=i.openapi)==null?void 0:Ys.specSecurityType)==="http"&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.httpScheme")}),e.jsxs("select",{value:((Ds=i.openapi)==null?void 0:Ds.specHttpScheme)||"basic",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specHttpScheme:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[e.jsx("option",{value:"basic",children:n("server.openapi.httpSchemeBasic")}),e.jsx("option",{value:"bearer",children:n("server.openapi.httpSchemeBearer")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.httpCredentials")}),e.jsx("input",{type:"password",value:((er=i.openapi)==null?void 0:er.specHttpCredentials)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specHttpCredentials:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:((sr=i.openapi)==null?void 0:sr.specHttpScheme)==="basic"?"user:password or base64":"bearer-token"})]})]}),((rr=i.openapi)==null?void 0:rr.specSecurityType)==="apiKey"&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.apiKeyName")}),e.jsx("input",{type:"text",value:((tr=i.openapi)==null?void 0:tr.specApiKeyName)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specApiKeyName:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"X-API-Key"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.apiKeyIn")}),e.jsxs("select",{value:((nr=i.openapi)==null?void 0:nr.specApiKeyIn)||"header",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specApiKeyIn:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",children:[e.jsx("option",{value:"header",children:n("server.openapi.apiKeyInHeader")}),e.jsx("option",{value:"query",children:n("server.openapi.apiKeyInQuery")}),e.jsx("option",{value:"cookie",children:n("server.openapi.apiKeyInCookie")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.apiKeyValue")}),e.jsx("input",{type:"password",value:((ar=i.openapi)==null?void 0:ar.specApiKeyValue)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specApiKeyValue:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input"})]})]}),((or=i.openapi)==null?void 0:or.specSecurityType)==="oauth2"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.openapi.oauth2Token")}),e.jsx("input",{type:"password",value:((lr=i.openapi)==null?void 0:lr.specOauth2Token)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,url:((o=s.openapi)==null?void 0:o.url)||"",specOauth2Token:t.target.value}}}),className:"w-full border rounded px-2 py-1 text-sm focus:outline-none form-input",placeholder:"access-token"})]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center mb-1",children:[e.jsx("input",{type:"checkbox",id:"openapiCookieSession",checked:((ir=i.openapi)==null?void 0:ir.cookieSession)||!1,onChange:t=>c(s=>{var o,j;return{...s,openapi:{...s.openapi,passthroughHeaders:((o=s.openapi)==null?void 0:o.passthroughHeaders)||"",url:((j=s.openapi)==null?void 0:j.url)||"",cookieSession:t.target.checked}}}),className:"mr-2"}),e.jsx("label",{htmlFor:"openapiCookieSession",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:n("server.openapi.cookieSession","Cookie Session Handling")})]}),e.jsx("p",{className:"text-xs text-gray-500 ml-6",children:n("server.openapi.cookieSessionHelp","Capture Set-Cookie from upstream login responses and replay them on later calls within the same downstream session. Isolated per MCP session; not persisted.")})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.headers")}),e.jsx("button",{type:"button",onClick:Se,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),N.map((t,s)=>e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[e.jsx("input",{type:"text",value:t.key,onChange:o=>J(s,"key",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Authorization"}),e.jsx("span",{className:"flex items-center",children:":"}),e.jsx("input",{type:"text",value:t.value,onChange:o=>J(s,"value",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Bearer token..."})]}),e.jsx("button",{type:"button",onClick:()=>Ce(s),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},s))]})]}):p==="sse"||p==="streamable-http"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-gray-700 dark:text-gray-300",htmlFor:"url",children:n("server.url")}),e.jsx("input",{type:"url",name:"url",id:"url",value:i.url,onChange:B,className:"w-full py-2 px-3 form-input",placeholder:p==="streamable-http"?"e.g.: http://localhost:3000/mcp":"e.g.: http://localhost:3000/sse",required:p==="sse"||p==="streamable-http"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.headers")}),e.jsx("button",{type:"button",onClick:Se,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),N.map((t,s)=>e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[e.jsx("input",{type:"text",value:t.key,onChange:o=>J(s,"key",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Authorization"}),e.jsx("span",{className:"flex items-center",children:":"}),e.jsx("input",{type:"text",value:t.value,onChange:o=>J(s,"value",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:"Bearer token..."})]}),e.jsx("button",{type:"button",onClick:()=>Ce(s),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},s))]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.envVars")}),e.jsx("button",{type:"button",onClick:ke,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),k.map((t,s)=>e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[e.jsx("input",{type:"text",value:t.key,onChange:o=>X(s,"key",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:n("server.key")}),e.jsx("span",{className:"flex items-center",children:":"}),e.jsx("input",{type:"text",value:t.value,onChange:o=>X(s,"value",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:n("server.value")})]}),e.jsx("button",{type:"button",onClick:()=>Ne(s),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},s))]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-gray-700 dark:text-gray-300",htmlFor:"command",children:n("server.command")}),e.jsx("input",{type:"text",name:"command",id:"command",value:i.command,onChange:B,className:"w-full py-2 px-3 form-input",placeholder:"e.g.: npx",required:p==="stdio"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-gray-700 dark:text-gray-300",htmlFor:"arguments",children:n("server.arguments")}),e.jsx("input",{type:"text",name:"arguments",id:"arguments",value:i.arguments,onChange:t=>Kr(t.target.value),className:"w-full py-2 px-3 form-input",placeholder:"e.g.: -y time-mcp"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.envVars")}),e.jsx("button",{type:"button",onClick:ke,className:"hub-btn primary !w-[30px] !h-[30px] !p-0 justify-center text-base font-bold",children:"+"})]}),k.map((t,s)=>e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsxs("div",{className:"flex items-center space-x-2 flex-grow",children:[e.jsx("input",{type:"text",value:t.key,onChange:o=>X(s,"key",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:n("server.key")}),e.jsx("span",{className:"flex items-center",children:":"}),e.jsx("input",{type:"text",value:t.value,onChange:o=>X(s,"value",o.target.value),className:"w-1/2 py-2 px-3 form-input",placeholder:n("server.value")})]}),e.jsx("button",{type:"button",onClick:()=>Ne(s),className:"bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-1 px-2 rounded text-sm flex items-center justify-center min-w-[30px] min-h-[30px] ml-2 btn-danger",children:"-"})]},s))]})]})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>Ar(!oe),children:[e.jsx("h3",{className:"text-sm font-semibold text-[var(--hub-ink)]",children:n("server.sectionAdvanced","Advanced Options")}),e.jsx("span",{className:"text-gray-500 text-sm",children:oe?"▼":"▶"})]}),oe&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-white dark:bg-gray-900 border-t-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",htmlFor:"visibility",children:n("server.visibility","Visibility")}),e.jsxs("select",{id:"visibility",name:"visibility",value:i.visibility||"private",onChange:t=>c(s=>({...s,visibility:t.target.value})),className:"w-full py-2 px-3 form-input",children:[e.jsx("option",{value:"private",children:n("server.visibilityPrivate","Private — only the owner and admins")}),e.jsx("option",{value:"group",children:n("server.visibilityGroup","Shared — selected users only")}),e.jsx("option",{value:"public",children:n("server.visibilityPublic","Public — every authenticated user")})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("server.visibilityDescription","Controls which non-admin users can discover and call this server. Admins always have access.")}),i.visibility==="group"&&e.jsxs("div",{className:"mt-4 rounded border border-gray-200 dark:border-gray-700 p-3",children:[e.jsx("div",{className:"text-sm font-medium text-[var(--hub-ink-2)]",children:n("server.shareWithUsers","Share with users")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 mb-3",children:n("server.shareWithUsersDescription","Selected users can discover and call this server, but cannot manage its configuration.")}),r!=null&&r.name?e.jsxs(e.Fragment,{children:[S&&e.jsx("p",{className:"text-sm text-gray-500",children:n("server.shareCandidatesLoading","Loading users...")}),T&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:n("server.shareCandidatesError","Failed to load users.")}),!S&&!T&&I.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:n("server.noShareCandidates","No other users are available.")}),I.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 space-y-2",children:[e.jsx("label",{htmlFor:"share-user-search",className:"block text-xs font-medium text-[var(--hub-ink-2)]",children:n("server.shareUserSearchLabel","Search users")}),e.jsx("input",{id:"share-user-search",type:"search",value:E,onChange:t=>P(t.target.value),placeholder:n("server.shareUserSearchPlaceholder","Search usernames..."),className:"w-full py-2 px-3 form-input text-sm"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:z,disabled:M,className:"hub-btn text-sm",children:n("server.selectAllShareUsers","Select all")}),e.jsx("button",{type:"button",onClick:W,disabled:V,className:"hub-btn text-sm",children:n("server.deselectAllShareUsers","Deselect all")})]})]}),g.length===0?e.jsx("p",{className:"text-sm text-gray-500",children:n("server.noMatchingShareUsers","No users match your search.")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:g.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded border border-gray-200 dark:border-gray-700 px-3 py-2 text-sm text-[var(--hub-ink-2)]",children:[e.jsx("input",{type:"checkbox",checked:K.has(t),onChange:()=>R(t)}),e.jsx("span",{children:t})]},t))})]})]}):e.jsx("p",{className:"text-sm text-gray-500",children:n("server.shareAfterCreate","Save the server before selecting users.")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1.5 text-[var(--hub-ink-2)]",children:n("server.openapi.passthroughHeaders")}),p==="openapi"?e.jsx(e.Fragment,{children:e.jsx("input",{type:"text",value:((cr=i.openapi)==null?void 0:cr.passthroughHeaders)||"",onChange:t=>c(s=>{var o;return{...s,openapi:{...s.openapi,passthroughHeaders:t.target.value,url:((o=s.openapi)==null?void 0:o.url)||""}}}),className:"w-full py-2 px-3 form-input",placeholder:"Authorization, X-API-Key, X-Custom-Header"})}):e.jsx("input",{type:"text",value:i.passthroughHeaders||"",onChange:t=>c(s=>({...s,passthroughHeaders:t.target.value})),className:"w-full py-2 px-3 form-input",placeholder:"Authorization, X-Custom-User-Id"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("server.openapi.passthroughHeadersHelp")})]}),p!=="openapi"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>Tr(!ne),children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.oauth.sectionTitle")}),e.jsx("span",{className:"text-gray-500 text-sm",children:ne?"▼":"▶"})]}),ne&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-gray-50 dark:bg-gray-800 border-t-0",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:n("server.oauth.sectionDescription")}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.oauth.clientId")}),e.jsx("input",{type:"text",value:((pr=i.oauth)==null?void 0:pr.clientId)||"",onChange:t=>Te("clientId",t.target.value),className:"w-full py-2 px-3 form-input",placeholder:"client id",autoComplete:"off"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 mb-1",children:n("server.oauth.clientSecret")}),e.jsx("input",{type:"password",value:((dr=i.oauth)==null?void 0:dr.clientSecret)||"",onChange:t=>Te("clientSecret",t.target.value),className:"w-full py-2 px-3 form-input",placeholder:"client secret",autoComplete:"off"})]})]})]})]}),p!=="openapi"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>Cr(!te),children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.requestOptions")}),e.jsx("span",{className:"text-gray-500 text-sm",children:te?"▼":"▶"})]}),te&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-gray-50 dark:bg-gray-800 border-t-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"timeout",children:n("server.timeout")}),e.jsx("input",{type:"number",id:"timeout",value:((ur=i.options)==null?void 0:ur.timeout)||6e4,onChange:t=>ie("timeout",parseInt(t.target.value)||6e4),className:"w-full py-2 px-3 form-input",placeholder:"30000",min:"1000",max:"300000"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("server.timeoutDescription")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"maxTotalTimeout",children:n("server.maxTotalTimeout")}),e.jsx("input",{type:"number",id:"maxTotalTimeout",value:((mr=i.options)==null?void 0:mr.maxTotalTimeout)||"",onChange:t=>ie("maxTotalTimeout",t.target.value?parseInt(t.target.value):void 0),className:"w-full py-2 px-3 form-input",placeholder:"Optional",min:"1000"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("server.maxTotalTimeoutDescription")})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",checked:((hr=i.options)==null?void 0:hr.resetTimeoutOnProgress)??!0,onChange:t=>ie("resetTimeoutOnProgress",t.target.checked),className:"mr-2"}),e.jsx("span",{className:"text-gray-600 text-sm",children:n("server.resetTimeoutOnProgress")})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 ml-6",children:n("server.resetTimeoutOnProgressDescription")})]})]})]}),(p==="sse"||p==="streamable-http")&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 p-3 rounded border border-gray-200 dark:border-gray-700",onClick:()=>wr(!ae),children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:n("server.keepAlive","Connection Health")}),e.jsx("span",{className:"text-gray-500 text-sm",children:ae?"▼":"▶"})]}),ae&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-b p-4 bg-gray-50 dark:bg-gray-800 border-t-0",children:[e.jsxs("div",{className:"flex items-center mb-3",children:[e.jsx("input",{type:"checkbox",id:"enableKeepAlive",checked:((xr=i.keepAlive)==null?void 0:xr.enabled)||!1,onChange:t=>c(s=>({...s,keepAlive:{...s.keepAlive,enabled:t.target.checked}})),className:"mr-2"}),e.jsx("label",{htmlFor:"enableKeepAlive",className:"text-gray-600 text-sm",children:n("server.enableKeepAlive","Enable Health Checks and Auto Reconnect")})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:n("server.keepAliveDescription","Run periodic health checks and automatically reconnect this remote server when it becomes disconnected.")}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-gray-600 text-sm font-medium mb-1",htmlFor:"keepAliveInterval",children:n("server.keepAliveInterval","Check interval (ms)")}),e.jsx("input",{type:"number",id:"keepAliveInterval",value:((yr=i.keepAlive)==null?void 0:yr.interval)||6e4,onChange:t=>c(s=>({...s,keepAlive:{...s.keepAlive,interval:parseInt(t.target.value)||6e4}})),className:"w-full py-2 px-3 form-input",placeholder:"60000",min:"5000",max:"300000"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("server.keepAliveIntervalDescription","Time between health checks and automatic reconnect attempts in milliseconds (default: 60000ms = 1 minute)")})]})]})]}),p!=="openapi"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center mb-1",children:[e.jsx("input",{type:"checkbox",id:"perSessionClient",checked:i.perSessionClient||!1,onChange:t=>c(s=>({...s,perSessionClient:t.target.checked})),className:"mr-2"}),e.jsx("label",{htmlFor:"perSessionClient",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:n("server.perSessionClient","Per-Session Client Isolation")})]}),e.jsx("p",{className:"text-xs text-gray-500 ml-6",children:n("server.perSessionClientDescription","Create a dedicated upstream connection per session instead of sharing one across all sessions. Enable for stateful servers like Playwright. Increases upstream connections with concurrent sessions.")})]}),p==="stdio"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center mb-1",children:[e.jsx("input",{type:"checkbox",id:"startOnDemand",checked:i.startOnDemand||!1,onChange:t=>c(s=>({...s,startOnDemand:t.target.checked})),className:"mr-2"}),e.jsx("label",{htmlFor:"startOnDemand",className:"text-gray-700 dark:text-gray-300 text-sm font-medium",children:n("server.startOnDemand","Start On Demand")})]}),e.jsx("p",{className:"text-xs text-gray-500 ml-6",children:n("server.startOnDemandDescription","Skip startup connect and spawn this server only when a tool call arrives. The process is shut down automatically after the idle timeout, then restarted on the next call. Reduces persistent memory usage for rarely-used servers.")}),i.startOnDemand&&e.jsxs("div",{className:"ml-6 mt-2",children:[e.jsx("label",{htmlFor:"idleTimeoutMs",className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:n("server.idleTimeoutMs","Idle shutdown timeout (ms)")}),e.jsx("input",{type:"number",id:"idleTimeoutMs",min:1e4,step:1e3,value:i.idleTimeoutMs??3e5,onChange:t=>c(s=>({...s,idleTimeoutMs:Number(t.target.value)})),className:"hub-input w-40 text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:n("server.idleTimeoutMsDescription","Shut down the process after this many milliseconds with no tool calls. Default: 300000 (5 minutes).")})]})]})]})]}),e.jsxs("div",{className:"flex justify-end mt-6",children:[e.jsx("button",{type:"button",onClick:l,className:"hub-btn mr-2",children:n("server.cancel")}),e.jsx("button",{type:"submit",className:"hub-btn primary",children:n(O?"server.save":"server.add")})]})]})]})},it=a=>{const l=new Set,r=/\$\{([^}]+)\}/g,d=n=>{let h;for(;(h=r.exec(n))!==null;)l.add(h[1])},m=(n,h="")=>{typeof n=="string"?d(n):Array.isArray(n)?n.forEach((y,u)=>m(y,`${h}[${u}]`)):n&&typeof n=="object"&&Object.entries(n).forEach(([y,u])=>{m(u,h?`${h}.${y}`:y)})};return m(a),Array.from(l)};export{lt as S,it as d,ot as s};
16
- //# sourceMappingURL=variableDetection-BeF9gp9K.js.map
16
+ //# sourceMappingURL=variableDetection-BlOwsGsz.js.map