@samanhappy/mcphub 1.0.42 → 1.0.43

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 (94) hide show
  1. package/dist/config/index.js +19 -9
  2. package/dist/config/index.js.map +1 -1
  3. package/dist/controllers/groupController.js +14 -0
  4. package/dist/controllers/groupController.js.map +1 -1
  5. package/dist/controllers/serverController.js +102 -3
  6. package/dist/controllers/serverController.js.map +1 -1
  7. package/dist/controllers/smartRoutingController.js +15 -5
  8. package/dist/controllers/smartRoutingController.js.map +1 -1
  9. package/dist/db/entities/Group.js.map +1 -1
  10. package/dist/db/repositories/VectorEmbeddingRepository.js +21 -1
  11. package/dist/db/repositories/VectorEmbeddingRepository.js.map +1 -1
  12. package/dist/server.js +3 -2
  13. package/dist/server.js.map +1 -1
  14. package/dist/services/contextCostService.js +11 -4
  15. package/dist/services/contextCostService.js.map +1 -1
  16. package/dist/services/groupService.js +19 -2
  17. package/dist/services/groupService.js.map +1 -1
  18. package/dist/services/mcpOAuthProvider.js +26 -10
  19. package/dist/services/mcpOAuthProvider.js.map +1 -1
  20. package/dist/services/mcpService.js +138 -34
  21. package/dist/services/mcpService.js.map +1 -1
  22. package/dist/services/oauthClientRegistration.js +53 -8
  23. package/dist/services/oauthClientRegistration.js.map +1 -1
  24. package/dist/services/oauthSettingsStore.js +5 -3
  25. package/dist/services/oauthSettingsStore.js.map +1 -1
  26. package/dist/services/smartRoutingService.js +109 -50
  27. package/dist/services/smartRoutingService.js.map +1 -1
  28. package/dist/services/sseService.js +49 -2
  29. package/dist/services/sseService.js.map +1 -1
  30. package/dist/services/vectorSearchService.js +72 -18
  31. package/dist/services/vectorSearchService.js.map +1 -1
  32. package/dist/utils/mcpRequestGroup.js +8 -0
  33. package/dist/utils/mcpRequestGroup.js.map +1 -0
  34. package/dist/utils/serverConfigPersistence.js +13 -2
  35. package/dist/utils/serverConfigPersistence.js.map +1 -1
  36. package/dist/utils/smartRouting.js +32 -0
  37. package/dist/utils/smartRouting.js.map +1 -1
  38. package/frontend/dist/assets/{ActivityPage-DTouw-He.js → ActivityPage-Y8gIRxkd.js} +2 -2
  39. package/frontend/dist/assets/{ActivityPage-DTouw-He.js.map → ActivityPage-Y8gIRxkd.js.map} +1 -1
  40. package/frontend/dist/assets/{CopyClientConfigDialog-BtO0YcVK.js → CopyClientConfigDialog-BHijFbyw.js} +2 -2
  41. package/frontend/dist/assets/{CopyClientConfigDialog-BtO0YcVK.js.map → CopyClientConfigDialog-BHijFbyw.js.map} +1 -1
  42. package/frontend/dist/assets/{CredentialsPage-BeSMd9m4.js → CredentialsPage-1UqVqEMQ.js} +2 -2
  43. package/frontend/dist/assets/{CredentialsPage-BeSMd9m4.js.map → CredentialsPage-1UqVqEMQ.js.map} +1 -1
  44. package/frontend/dist/assets/{Dashboard-DuaKaJAK.js → Dashboard-CswKNreX.js} +2 -2
  45. package/frontend/dist/assets/{Dashboard-DuaKaJAK.js.map → Dashboard-CswKNreX.js.map} +1 -1
  46. package/frontend/dist/assets/{EndpointCopy-Bos3ZWUc.js → EndpointCopy-B0yIEBjO.js} +2 -2
  47. package/frontend/dist/assets/{EndpointCopy-Bos3ZWUc.js.map → EndpointCopy-B0yIEBjO.js.map} +1 -1
  48. package/frontend/dist/assets/GroupsPage-KJJsAprG.js +33 -0
  49. package/frontend/dist/assets/GroupsPage-KJJsAprG.js.map +1 -0
  50. package/frontend/dist/assets/{LoginPage-DUnjHB-q.js → LoginPage-B1heSsJ6.js} +2 -2
  51. package/frontend/dist/assets/{LoginPage-DUnjHB-q.js.map → LoginPage-B1heSsJ6.js.map} +1 -1
  52. package/frontend/dist/assets/{LogsPage-BxjYh1MS.js → LogsPage-C4BOgOSW.js} +2 -2
  53. package/frontend/dist/assets/{LogsPage-BxjYh1MS.js.map → LogsPage-C4BOgOSW.js.map} +1 -1
  54. package/frontend/dist/assets/{MarketPage-BnxAofuO.js → MarketPage-D0RXyf6g.js} +2 -2
  55. package/frontend/dist/assets/{MarketPage-BnxAofuO.js.map → MarketPage-D0RXyf6g.js.map} +1 -1
  56. package/frontend/dist/assets/{OAuthConsentPage-rAx5ELdp.js → OAuthConsentPage-DLveAKh7.js} +2 -2
  57. package/frontend/dist/assets/{OAuthConsentPage-rAx5ELdp.js.map → OAuthConsentPage-DLveAKh7.js.map} +1 -1
  58. package/frontend/dist/assets/{PromptsPage-Bh4Woe2Q.js → PromptsPage-cPHf4CM9.js} +2 -2
  59. package/frontend/dist/assets/{PromptsPage-Bh4Woe2Q.js.map → PromptsPage-cPHf4CM9.js.map} +1 -1
  60. package/frontend/dist/assets/{ResourcesPage-BREUhWYG.js → ResourcesPage-DcXEwXg9.js} +2 -2
  61. package/frontend/dist/assets/{ResourcesPage-BREUhWYG.js.map → ResourcesPage-DcXEwXg9.js.map} +1 -1
  62. package/frontend/dist/assets/{ServersPage-DCqew7Dq.js → ServersPage-CIPZUbqT.js} +4 -4
  63. package/frontend/dist/assets/{ServersPage-DCqew7Dq.js.map → ServersPage-CIPZUbqT.js.map} +1 -1
  64. package/frontend/dist/assets/SettingsPage-vMxO3bOc.js +12 -0
  65. package/frontend/dist/assets/SettingsPage-vMxO3bOc.js.map +1 -0
  66. package/frontend/dist/assets/{StatusDot-CYPIH-Iz.js → StatusDot-LGEKnAGN.js} +2 -2
  67. package/frontend/dist/assets/{StatusDot-CYPIH-Iz.js.map → StatusDot-LGEKnAGN.js.map} +1 -1
  68. package/frontend/dist/assets/{ToggleGroup-B4Lt01jM.js → ToggleGroup-Ad_I2spO.js} +2 -2
  69. package/frontend/dist/assets/{ToggleGroup-B4Lt01jM.js.map → ToggleGroup-Ad_I2spO.js.map} +1 -1
  70. package/frontend/dist/assets/{UsersPage-LvOfLsJc.js → UsersPage-CbfajFCc.js} +2 -2
  71. package/frontend/dist/assets/{UsersPage-LvOfLsJc.js.map → UsersPage-CbfajFCc.js.map} +1 -1
  72. package/frontend/dist/assets/{clipboard--jmjkvaW.js → clipboard-CjtPOmJs.js} +2 -2
  73. package/frontend/dist/assets/{clipboard--jmjkvaW.js.map → clipboard-CjtPOmJs.js.map} +1 -1
  74. package/frontend/dist/assets/{icons-vendor-CNEaJWqW.js → icons-vendor-CvmEvkQ-.js} +69 -64
  75. package/frontend/dist/assets/icons-vendor-CvmEvkQ-.js.map +1 -0
  76. package/frontend/dist/assets/index-Cla8rRxG.css +1 -0
  77. package/frontend/dist/assets/index-DJUr-vo3.js +3 -0
  78. package/frontend/dist/assets/index-DJUr-vo3.js.map +1 -0
  79. package/frontend/dist/assets/{resourceService-DkIvmxRC.js → resourceService-D4dgqjzY.js} +2 -2
  80. package/frontend/dist/assets/{resourceService-DkIvmxRC.js.map → resourceService-D4dgqjzY.js.map} +1 -1
  81. package/frontend/dist/assets/{useCostData-B-uPi7i8.js → useCostData-CT2iwvzx.js} +2 -2
  82. package/frontend/dist/assets/{useCostData-B-uPi7i8.js.map → useCostData-CT2iwvzx.js.map} +1 -1
  83. package/frontend/dist/assets/{variableDetection-RlrBM33Q.js → variableDetection-BHrhKDaj.js} +2 -2
  84. package/frontend/dist/assets/{variableDetection-RlrBM33Q.js.map → variableDetection-BHrhKDaj.js.map} +1 -1
  85. package/frontend/dist/index.html +3 -3
  86. package/package.json +1 -1
  87. package/frontend/dist/assets/GroupsPage-Cv3lZSCh.js +0 -33
  88. package/frontend/dist/assets/GroupsPage-Cv3lZSCh.js.map +0 -1
  89. package/frontend/dist/assets/SettingsPage-DGAB-Jy8.js +0 -12
  90. package/frontend/dist/assets/SettingsPage-DGAB-Jy8.js.map +0 -1
  91. package/frontend/dist/assets/icons-vendor-CNEaJWqW.js.map +0 -1
  92. package/frontend/dist/assets/index-Cv7we3z-.css +0 -1
  93. package/frontend/dist/assets/index-qPkrYLbl.js +0 -3
  94. package/frontend/dist/assets/index-qPkrYLbl.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{r as t,j as e,d as De,b as Ue,i as He}from"./framework-vendor-_YL27Pfc.js";import{e as O,i as ve,j as We}from"./index-qPkrYLbl.js";import{u as te}from"./i18n-vendor-BMaj5qV8.js";import{a as je,d as _e,s as xe}from"./variableDetection-RlrBM33Q.js";import{C as Ne,_ as Fe,a4 as Oe,a6 as Qe,l as qe,X as Ge,G as Je,u as Xe}from"./icons-vendor-CNEaJWqW.js";import{P as Ye}from"./Pagination-CLUvn47x.js";import"./contextCost-CilWqGWT.js";const Ze=()=>{const{t:s}=te(),[f,j]=t.useState([]),[o,u]=t.useState([]),[i,a]=t.useState([]),[c,b]=t.useState([]),[P,_]=t.useState(""),[T,$]=t.useState(""),[D,U]=t.useState(""),[B,w]=t.useState(!0),[V,L]=t.useState(null),[E,W]=t.useState(null),[q,R]=t.useState([]),[I,z]=t.useState(1),[N,X]=t.useState(9),[Q,v]=t.useState(1),h=t.useCallback(async()=>{try{w(!0);const r=await O("/market/servers");r&&r.success&&Array.isArray(r.data)?(u(r.data),C(r.data,I)):(console.error("Invalid market servers data format",{data:r}),L(s("market.fetchError")))}catch(r){console.error("Error fetching market servers",{err:r}),L(r instanceof Error?r.message:String(r))}finally{w(!1)}},[s]),C=t.useCallback((r,l,F=N)=>{const K=r.length,H=Math.ceil(K/F);v(H);const G=Math.max(1,Math.min(l,H));G!==l&&z(G);const Y=(G-1)*F,ee=r.slice(Y,Y+F);j(ee)},[N]),Z=t.useCallback(r=>{z(r),C(o,r,N)},[o,C,N]),g=t.useCallback(async()=>{try{const r=await O("/market/categories");r&&r.success&&Array.isArray(r.data)?a(r.data):console.error("Invalid categories data format",{data:r})}catch(r){console.error("Error fetching categories",{err:r})}},[]),y=t.useCallback(async()=>{try{const r=await O("/market/tags");r&&r.success&&Array.isArray(r.data)?b(r.data):console.error("Invalid tags data format",{data:r})}catch(r){console.error("Error fetching tags",{err:r})}},[]),p=t.useCallback(async r=>{try{w(!0);const l=await O(`/market/servers/${r}`);return l&&l.success&&l.data?(W(l.data),l.data):(console.error("Invalid market server data format",{name:r,data:l}),L(s("market.serverNotFound")),null)}catch(l){return console.error("Error fetching market server",{name:r,err:l}),L(l instanceof Error?l.message:String(l)),null}finally{w(!1)}},[s]),S=t.useCallback(async r=>{try{if(w(!0),U(r),!r.trim()){h();return}const l=await O(`/market/servers/search?query=${encodeURIComponent(r)}`);l&&l.success&&Array.isArray(l.data)?(u(l.data),z(1),C(l.data,1)):(console.error("Invalid market search results format",{query:r,data:l}),L(s("market.searchError")))}catch(l){console.error("Error searching market servers",{query:r,err:l}),L(l instanceof Error?l.message:String(l))}finally{w(!1)}},[s,o,C,h]),n=t.useCallback(async r=>{try{if(w(!0),_(r),$(""),!r){h();return}const l=await O(`/market/categories/${encodeURIComponent(r)}`);l&&l.success&&Array.isArray(l.data)?(u(l.data),z(1),C(l.data,1)):(console.error("Invalid market category filter results format",{category:r,data:l}),L(s("market.filterError")))}catch(l){console.error("Error filtering market servers by category",{category:r,err:l}),L(l instanceof Error?l.message:String(l))}finally{w(!1)}},[s,h,C]),m=t.useCallback(async r=>{try{if(w(!0),$(r),_(""),!r){h();return}const l=await O(`/market/tags/${encodeURIComponent(r)}`);l&&l.success&&Array.isArray(l.data)?(u(l.data),z(1),C(l.data,1)):(console.error("Invalid market tag filter results format",{tag:r,data:l}),L(s("market.tagFilterError")))}catch(l){console.error("Error filtering market servers by tag",{tag:r,err:l}),L(l instanceof Error?l.message:String(l))}finally{w(!1)}},[s,h,C]),d=t.useCallback(async()=>{try{const r=await O("/servers");if(r&&r.success&&Array.isArray(r.data)){const l=r.data.map(F=>F.name);R(l)}}catch(r){console.error("Error fetching installed servers",{err:r})}},[]),M=t.useCallback(r=>q.includes(r),[q]),oe=t.useCallback(async(r,l)=>{var F,K;try{const H=(F=r.installations)!=null&&F.npm?"npm":Object.keys(r.installations||{}).length>0?Object.keys(r.installations)[0]:null;if(!H||!((K=r.installations)!=null&&K[H]))return L(s("market.noInstallationMethod")),!1;const G=r.installations[H],Y={name:r.name,config:l.type==="stdio"?{command:l.command||G.command||"",args:l.args||G.args||[],env:{...G.env,...l.env}}:l},ee=await ve("/servers",Y);if(!ee.success)throw new Error(ee.message||"Failed to install server");return await d(),!0}catch(H){return console.error("Error installing market server",{serverName:r.name,err:H}),L(H instanceof Error?H.message:String(H)),!1}},[s,d]),ce=t.useCallback(r=>{X(r),z(1),C(o,1,r)},[o,C]);return t.useEffect(()=>{h(),g(),y(),d()},[h,g,y,d]),{servers:f,allServers:o,categories:i,tags:c,selectedCategory:P,selectedTag:T,searchQuery:D,loading:B,error:V,setError:L,currentServer:E,fetchMarketServers:h,fetchServerByName:p,searchServers:S,filterByCategory:n,filterByTag:m,installServer:oe,currentPage:I,totalPages:Q,serversPerPage:N,changePage:Z,changeServersPerPage:ce,isServerInstalled:M}},Ke=()=>{const{t:s}=te(),[f,j]=t.useState([]),[o,u]=t.useState([]),[i,a]=t.useState(!0),[c,b]=t.useState(null),[P,_]=t.useState(""),[T,$]=t.useState(1),[D,U]=t.useState(9),[B,w]=t.useState(null),[V,L]=t.useState(!1),[E,W]=t.useState([]),[q]=t.useState(1),R=t.useCallback(async(g,y)=>{try{a(!0),b(null);const p=new URLSearchParams;p.append("limit",D.toString()),g&&p.append("cursor",g);const S=y!==void 0?y:P;S.trim()&&p.append("search",S.trim());const n=await O(`/registry/servers?${p.toString()}`);if(n&&n.success&&n.data){const m=n.data;if(m.servers&&Array.isArray(m.servers)){j(m.servers);const d=m.metadata.count===D&&!!m.metadata.nextCursor;L(d),w(m.metadata.nextCursor||null),u(g?M=>[...M,...m.servers]:m.servers)}else console.error("Invalid registry servers data format",{data:m}),b(s("registry.fetchError"))}else b(s("registry.fetchError"))}catch(p){console.error("Error fetching registry servers",{cursor:g,search:y,err:p});const S=p instanceof Error?p.message:String(p);b(S)}finally{a(!1)}},[s,D]),I=t.useCallback(async()=>{if(!V||!B)return;const g=E[E.length-1]||"";W(y=>[...y,g]),$(y=>y+1),await R(B,P)},[V,B,E,P,R]),z=t.useCallback(async()=>{if(T<=1)return;const g=[...E];g.pop();const y=g[g.length-1];W(g),$(p=>p-1),await R(y||void 0,P)},[T,E,P,R]),N=t.useCallback(async g=>{g!==T&&(g>T&&V?await I():g<T&&T>1&&await z())},[T,V,I,z]),X=t.useCallback(async g=>{U(g),$(1),W([]),u([]),await R(void 0,P)},[P,R]),Q=t.useCallback(async g=>{try{a(!0),b(null);const y=encodeURIComponent(g),p=await O(`/registry/servers/versions?serverName=${y}`);if(p&&p.success&&p.data){const S=p.data;return S.servers&&Array.isArray(S.servers)&&S.servers.length>0?S.servers[0]:(console.error("Invalid registry server data format",{serverName:g,data:S}),b(s("registry.serverNotFound")),null)}else return b(s("registry.serverNotFound")),null}catch(y){console.error("Error fetching registry server",{serverName:g,err:y});const p=y instanceof Error?y.message:String(y);return b(p),null}finally{a(!1)}},[s]),v=t.useCallback(async g=>{try{b(null);const y=encodeURIComponent(g),p=await O(`/registry/servers/versions?serverName=${y}`);if(p&&p.success&&p.data){const S=p.data;return S.servers&&Array.isArray(S.servers)?S.servers:(console.error("Invalid registry server versions data format",{serverName:g,data:S}),[])}else return[]}catch(y){console.error("Error fetching versions for registry server",{serverName:g,err:y});const p=y instanceof Error?y.message:String(y);return b(p),[]}},[]),h=t.useCallback(async(g,y)=>{try{b(null);const p=encodeURIComponent(g),S=encodeURIComponent(y),n=await O(`/registry/servers/version?serverName=${p}&version=${S}`);if(n&&n.success&&n.data){const m=n.data;return m&&m.server?m:(console.error("Invalid registry server version data format",{serverName:g,version:y,data:m}),null)}else return null}catch(p){console.error("Error fetching specific registry server version",{serverName:g,version:y,err:p});const S=p instanceof Error?p.message:String(p);return b(S),null}},[]),C=t.useCallback(async g=>{console.log("Searching registry servers",{query:g}),_(g),$(1),W([]),u([]),await R(void 0,g)},[R]),Z=t.useCallback(async()=>{_(""),$(1),W([]),u([]),await R(void 0,"")},[R]);return t.useEffect(()=>{R(void 0,P)},[]),{servers:f,allServers:o,loading:i,error:c,setError:b,searchQuery:P,searchServers:C,clearSearch:Z,fetchServerByName:Q,fetchServerVersions:v,fetchServerVersion:h,currentPage:T,totalPages:q,hasNextPage:V,hasPreviousPage:T>1,changePage:N,goToNextPage:I,goToPreviousPage:z,serversPerPage:D,changeServersPerPage:X}},es=s=>s.split(" ").map(f=>f.charAt(0)).join("").toUpperCase().slice(0,2),ss=({server:s,onClick:f})=>{var i,a,c;const{t:j}=te(),o=(s.tags||[]).slice(0,3),u=(i=s.categories)==null?void 0:i[0];return e.jsxs("div",{className:"hub-card flex flex-col cursor-pointer transition-colors h-full overflow-hidden",onClick:()=>f(s),onMouseEnter:b=>b.currentTarget.style.borderColor="var(--hub-ink-2)",onMouseLeave:b=>b.currentTarget.style.borderColor="var(--hub-line)",children:[e.jsxs("div",{className:"p-3.5 flex-1 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"hub-mono",style:{width:28,height:28,borderRadius:7,background:"var(--hub-ink)",color:"var(--hub-bg)",display:"grid",placeItems:"center",fontWeight:600,fontSize:13,flexShrink:0},children:es(s.display_name||s.name)[0]||"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate",style:{fontSize:14,fontWeight:500,letterSpacing:"-0.01em"},children:s.display_name}),s.is_official&&e.jsxs("span",{className:"inline-flex items-center gap-0.5",style:{fontSize:10,color:"var(--hub-accent)",background:"var(--hub-accent-soft)",padding:"0 5px",height:16,borderRadius:3,fontWeight:500},children:[e.jsx(Ne,{size:9,strokeWidth:2.5}),j("market.official")]})]}),e.jsxs("div",{className:"hub-mono truncate",style:{fontSize:11,color:"var(--hub-ink-3)"},children:["@",((a=s.author)==null?void 0:a.name)||j("market.unknown")]})]})]}),e.jsx("div",{className:"flex-1 line-clamp-2",style:{fontSize:12.5,color:"var(--hub-ink-2)",lineHeight:1.5},children:s.description}),o.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:o.map(b=>e.jsxs("span",{className:"hub-tag",style:{background:"oklch(0.96 0.04 145)",color:"oklch(0.4 0.1 145)",border:0},children:["#",b]},b))})]}),e.jsx("div",{className:"flex items-center justify-between px-3.5 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)"},children:e.jsxs("div",{className:"hub-mono flex items-center gap-3",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Fe,{size:11}),((c=s.tools)==null?void 0:c.length)??0," ",j("server.tools").toLowerCase()]}),u&&e.jsx("span",{className:"truncate",children:u})]})})]})},rs=({server:s,onBack:f,onInstall:j,installing:o=!1,isInstalled:u=!1})=>{var N,X,Q;const{t:i}=te(),[a,c]=t.useState(!1),[b,P]=t.useState(null),[_,T]=t.useState(!1),[$,D]=t.useState(null),[U,B]=t.useState([]),w=()=>u?{className:"bg-green-600 cursor-default px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:i("market.installed")}:o?{className:"bg-gray-400 cursor-not-allowed px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:i("market.installing")}:{className:"hub-btn primary",disabled:!1,text:i("market.install")},V=()=>{c(!a),P(null),T(!1),D(null)},L=async()=>{$&&(await E($),T(!1),D(null))},E=async v=>{try{P(null),j(s,v.config),c(!1)}catch(h){console.error("Error installing server:",h),P(i("errors.serverInstall"))}},W=()=>{u||V()},q=()=>{if(!s.installations)return;if(s.installations.npm)return s.installations.npm;if(s.installations.uvx)return s.installations.uvx;if(s.installations.default)return s.installations.default;const v=Object.keys(s.installations);if(v.length>0)return s.installations[v[0]]},R=async v=>{try{const h=_e(v);h.length>0?(B(h),D(v),T(!0)):await E(v)}catch(h){console.error("Error processing server installation:",h),P(i("errors.serverInstall"))}},I=w(),z=q();return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("div",{className:"mb-4",children:e.jsxs("button",{onClick:f,className:"text-gray-600 hover:text-gray-900 flex items-center",children:[e.jsx("svg",{className:"h-5 w-5 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})}),i("market.backToList")]})}),e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("div",{children:e.jsxs("h2",{className:"text-2xl font-bold text-gray-900 flex items-center flex-wrap",children:[s.display_name,e.jsxs("span",{className:"text-sm font-normal text-gray-500 ml-2",children:["(",s.name,")"]}),e.jsxs("span",{className:"text-sm font-normal text-gray-600 ml-4",children:[i("market.author"),": ",((N=s.author)==null?void 0:N.name)||i("market.unknown")," •"," ",i("market.license"),": ",s.license," •",e.jsx("a",{href:s.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline ml-1",children:i("market.repository")})]})]})}),e.jsxs("div",{className:"flex items-center",children:[s.is_official&&e.jsx("span",{className:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300 text-sm font-normal px-4 py-2 rounded mr-2 flex items-center label-primary",children:i("market.official")}),e.jsx("button",{onClick:W,disabled:I.disabled,className:I.className,children:I.text})]})]}),e.jsx("p",{className:"text-gray-700 mb-6",children:s.description}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-semibold mb-3",children:[i("market.categories")," & ",i("market.tags")]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(X=s.categories)==null?void 0:X.map((v,h)=>e.jsx("span",{className:"bg-gray-100 dark:bg-gray-800 text-gray-800 px-3 py-1 rounded",children:v},`cat-${h}`)),s.tags&&s.tags.map((v,h)=>e.jsxs("span",{className:"bg-gray-100 dark:bg-gray-800 text-green-700 px-2 py-1 rounded text-sm",children:["#",v]},`tag-${h}`))]})]}),s.arguments&&Object.keys(s.arguments).length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:i("market.arguments")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.argumentName")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.description")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.required")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.example")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Object.entries(s.arguments).map(([v,h],C)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:v}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:h.description}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:h.required?e.jsx("span",{className:"text-green-600",children:"✓"}):e.jsx("span",{className:"text-gray-600",children:"✗"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:h.example})})]},C))})]})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:i("market.tools")}),e.jsx("div",{className:"space-y-4",children:(Q=s.tools)==null?void 0:Q.map((v,h)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-4",children:[e.jsxs("h4",{className:"font-medium mb-2",children:[v.name,e.jsx("button",{type:"button",onClick:()=>{const C=document.getElementById(`schema-${h}`);C&&C.classList.toggle("hidden")},className:"text-sm text-blue-500 font-normal hover:underline focus:outline-none ml-2",children:i("market.viewSchema")})]}),e.jsx("p",{className:"text-gray-600 mb-2",children:v.description}),e.jsx("div",{className:"mt-2",children:e.jsx("pre",{id:`schema-${h}`,className:"hidden bg-gray-50 dark:bg-gray-800 p-3 rounded text-sm overflow-auto mt-2",children:JSON.stringify(v.inputSchema,null,2)})})]},h))})]}),s.examples&&s.examples.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:i("market.examples")}),e.jsx("div",{className:"space-y-4",children:s.examples.map((v,h)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:v.title}),e.jsx("p",{className:"text-gray-600 mb-2",children:v.description}),e.jsx("pre",{className:"bg-gray-50 dark:bg-gray-800 p-3 rounded text-sm overflow-auto",children:v.prompt})]},h))})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{onClick:W,disabled:I.disabled,className:I.className,children:I.text})}),a&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(je,{onSubmit:R,onCancel:V,modalTitle:i("market.installServer",{name:s.display_name}),formError:b,initialData:{name:s.name,status:"disconnected",config:z?{command:z.command||"",args:z.args||[],env:z.env||{}}:void 0}})}),_&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card p-6 w-full max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:i("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:i("server.variablesDetected")}),e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded p-3 mb-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-yellow-800",children:[i("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:U.map((v,h)=>e.jsxs("li",{className:"font-mono",children:["$",`{${v}}`]},h))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:i("market.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{T(!1),D(null)},className:"hub-btn",children:i("common.cancel")}),e.jsx("button",{onClick:L,className:"hub-btn primary",children:i("market.confirmAndInstall")})]})]})})]})},ts=s=>{if(!s)return"";try{const f=new Date(s),j=f.getFullYear(),o=(f.getMonth()+1).toString().padStart(2,"0"),u=f.getDate().toString().padStart(2,"0");return`${j}/${o}/${u}`}catch{return""}},as=({serverEntry:s,onClick:f})=>{var D,U;const{t:j}=te(),{server:o,_meta:u}=s,i=u==null?void 0:u["io.modelcontextprotocol.registry/official"],a=i==null?void 0:i.isLatest,c=i==null?void 0:i.publishedAt,b=i==null?void 0:i.updatedAt,P=((D=o.packages)==null?void 0:D.length)||0,_=((U=o.remotes)==null?void 0:U.length)||0,T=o.description?o.description.length<=150?o.description:o.description.slice(0,150)+"...":j("registry.noDescription"),$=o.icons&&o.icons.length>0?o.icons.find(w=>!w.theme||w.theme==="light")||o.icons[0]:null;return e.jsxs("div",{className:"hub-card flex flex-col cursor-pointer transition-colors h-full overflow-hidden",onClick:()=>f(s),onMouseEnter:B=>B.currentTarget.style.borderColor="var(--hub-ink-2)",onMouseLeave:B=>B.currentTarget.style.borderColor="var(--hub-line)",children:[e.jsxs("div",{className:"p-3.5 flex-1 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[$?e.jsx("img",{src:$.src,alt:o.title||o.name,className:"rounded-md object-cover flex-shrink-0",style:{width:28,height:28},onError:B=>{B.currentTarget.style.display="none"}}):e.jsx("div",{className:"hub-mono flex-shrink-0",style:{width:28,height:28,borderRadius:7,background:"var(--hub-ink)",color:"var(--hub-bg)",display:"grid",placeItems:"center",fontWeight:600,fontSize:13},children:o.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate",style:{fontSize:14,fontWeight:500,letterSpacing:"-0.01em"},children:o.title||o.name}),a&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 flex-shrink-0",style:{fontSize:10,color:"oklch(0.4 0.13 145)",background:"oklch(0.95 0.05 145)",padding:"0 5px",height:16,borderRadius:3,fontWeight:500},children:[e.jsx(Ne,{size:9,strokeWidth:2.5}),j("registry.latest")]})]}),e.jsxs("div",{className:"hub-mono truncate",style:{fontSize:11,color:"var(--hub-ink-3)"},children:[o.name," · v",o.version]})]})]}),e.jsx("div",{className:"flex-1 line-clamp-2",style:{fontSize:12.5,color:"var(--hub-ink-2)",lineHeight:1.5},children:T})]}),e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)"},children:[e.jsxs("div",{className:"hub-mono flex items-center gap-3",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[P>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Oe,{size:11}),P]}),_>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Qe,{size:11}),_]}),(c||b)&&e.jsx("span",{children:ts(b||c)})]}),e.jsxs("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-accent)"},children:[j("registry.viewDetails")," →"]})]})]})},ns=({serverEntry:s,onBack:f,onInstall:j,installing:o=!1,isInstalled:u=!1,fetchVersions:i})=>{const{t:a}=te(),{server:c,_meta:b}=s,[P,_]=t.useState(c.version),[T,$]=t.useState([]),[D,U]=t.useState(!1),[B,w]=t.useState(!1),[V,L]=t.useState(null),[E,W]=t.useState(null),[q,R]=t.useState(null),[I,z]=t.useState({packages:!0,remotes:!0,repository:!0}),N=b==null?void 0:b["io.modelcontextprotocol.registry/official"];t.useEffect(()=>{(async()=>{if(i){U(!0);try{const m=await i(c.name);$(m)}catch(m){console.error("Failed to load versions:",m)}finally{U(!1)}}})()},[c.name,i]);const Q=c.icons&&c.icons.length>0?c.icons.find(m=>!m.theme||m.theme==="light")||c.icons[0]:null,v=n=>{if(!n)return"";try{return new Date(n).toLocaleDateString()}catch{return""}},h=n=>{z(m=>({...m,[n]:!m[n]}))},C=(n,m)=>{L(n),W(m),R(null),w(!0)},Z=()=>{w(!1),R(null)},g=async n=>{try{if(!j||!E||!V)return;R(null);const m=n.config;j(c,m),w(!1)}catch(m){console.error("Error installing server:",m),R(a("errors.serverInstall"))}},y=()=>{if(!E||!V)return null;if(console.log("Building initial form data for:",E),V==="package"&&"identifier"in E){const n=E,m={};n.environmentVariables&&n.environmentVariables.forEach(M=>{m[M.name]=M.default||""});const d=ls(n.registryType);return{name:xe(c.name),status:"disconnected",config:{type:"stdio",command:d,args:is(d,n),env:Object.keys(m).length>0?m:void 0}}}else if(V==="remote"&&"url"in E){const n=E,m={};n.headers&&n.headers.forEach(M=>{m[M.name]=M.default||M.value||""});const d=n.type==="sse"?"sse":"streamable-http";return{name:xe(c.name),status:"disconnected",config:{type:d,url:n.url,headers:Object.keys(m).length>0?m:void 0}}}return null},p=(n,m)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 mb-3 hover:border-blue-400 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:n.identifier}),n.version&&e.jsxs("p",{className:"text-sm text-gray-500",children:["Version: ",n.version]}),n.runtimeHint&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:n.runtimeHint})]}),e.jsx("button",{onClick:()=>C("package",n),disabled:u||o,className:`px-4 py-2 rounded text-sm font-medium transition-colors ${u?"hub-btn cursor-default":o?"hub-btn cursor-not-allowed opacity-50":"hub-btn primary"}`,children:a(u?"registry.installed":o?"registry.installing":"registry.install")})]}),n.registryType&&e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Registry:"})," ",n.registryType]}),n.transport&&e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Transport:"})," ",n.transport.type,n.transport.url&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["(",n.transport.url,")"]})]}),n.environmentVariables&&n.environmentVariables.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[a("registry.environmentVariables"),":"]}),e.jsx("div",{className:"space-y-2",children:n.environmentVariables.map((d,M)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:d.name}),d.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:a("common.required")}),d.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:a("common.secret")})]}),d.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:d.description}),d.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.default})]})]},M))})]}),n.packageArguments&&n.packageArguments.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[a("registry.packageArguments"),":"]}),e.jsx("div",{className:"space-y-2",children:n.packageArguments.map((d,M)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:d.name}),d.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:a("common.required")}),d.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:a("common.secret")}),d.isRepeated&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300",children:a("common.repeated")})]}),d.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:d.description}),d.type&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.type"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.type})]}),d.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.default})]}),d.value&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.value"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.value})]}),d.valueHint&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.valueHint"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.valueHint})]}),d.choices&&d.choices.length>0&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.choices"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.choices.join(", ")})]})]},M))})]})]},m),S=(n,m)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 mb-3 hover:border-blue-400 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:n.type}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 break-all",children:n.url})]}),e.jsx("button",{onClick:()=>C("remote",n),disabled:u||o,className:`px-4 py-2 rounded text-sm font-medium transition-colors ${u?"hub-btn cursor-default":o?"hub-btn cursor-not-allowed opacity-50":"hub-btn primary"}`,children:a(u?"registry.installed":o?"registry.installing":"registry.install")})]}),n.headers&&n.headers.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[a("registry.headers"),":"]}),e.jsx("div",{className:"space-y-2",children:n.headers.map((d,M)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:d.name}),d.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:a("common.required")}),d.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:a("common.secret")})]}),d.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:d.description}),d.value&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.value"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.value})]}),d.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.default})]})]},M))})]})]},m);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:f,className:"flex items-center text-blue-600 hover:text-blue-800 mb-4 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),a("registry.backToList")]}),e.jsxs("div",{className:"flex items-start space-x-4",children:[Q?e.jsx("img",{src:Q.src,alt:c.title,className:"w-20 h-20 rounded-lg object-cover flex-shrink-0",onError:n=>{n.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-20 h-20 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center text-white text-3xl font-semibold flex-shrink-0",children:"M"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:c.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[(N==null?void 0:N.isLatest)&&e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800",children:a("registry.latest")}),e.jsxs("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:["v",c.version]}),(N==null?void 0:N.status)&&e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gray-100 dark:bg-gray-800 text-gray-800",children:N.status}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4 text-sm text-gray-600",children:[(N==null?void 0:N.publishedAt)&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[a("registry.published"),":"]})," ",v(N.publishedAt)]}),(N==null?void 0:N.updatedAt)&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[a("registry.updated"),":"]})," ",v(N.updatedAt)]})]})]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:a("registry.description")}),e.jsx("p",{className:"text-gray-700 leading-relaxed whitespace-pre-wrap",children:c.description})]}),c.websiteUrl&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:a("registry.website")}),e.jsx("a",{href:c.websiteUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 hover:underline",children:c.websiteUrl})]}),c.packages&&c.packages.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>h("packages"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsxs("span",{children:[a("registry.packages")," (",c.packages.length,")"]}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${I.packages?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I.packages&&e.jsx("div",{className:"space-y-3",children:c.packages.map(p)})]}),c.remotes&&c.remotes.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>h("remotes"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsxs("span",{children:[a("registry.remotes")," (",c.remotes.length,")"]}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${I.remotes?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I.remotes&&e.jsx("div",{className:"space-y-3",children:c.remotes.map(S)})]}),c.repository&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>h("repository"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsx("span",{children:a("registry.repository")}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${I.repository?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I.repository&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[c.repository.url&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"URL:"})," ",e.jsx("a",{href:c.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 hover:underline break-all",children:c.repository.url})]}),c.repository.source&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Source:"})," ",c.repository.source]}),c.repository.subfolder&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Subfolder:"})," ",c.repository.subfolder]}),c.repository.id&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"ID:"})," ",c.repository.id]})]})]}),B&&E&&V&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(je,{onSubmit:g,onCancel:Z,modalTitle:a("registry.installServer",{name:c.title||c.name}),formError:q,initialData:y()})})]})};function ls(s){switch(s.toLowerCase()){case"pypi":case"python":return"uvx";case"npm":case"node":return"npx";case"oci":case"docker":return"docker";default:return""}}function is(s,f){const j=[f.identifier+(f.version?`@${f.version}`:"")],o=[];switch(f.packageArguments&&f.packageArguments.length>0&&f.packageArguments.forEach(u=>{if(u.isRequired||u.default||u.value){const i=`--${u.name}`,a=u.value||u.default||`\${${u.name.toUpperCase()}}`;o.push(i,a)}}),s.toLowerCase()){case"uvx":return[...j,...o];case"npx":return[...j,...o];case"docker":{const u=[];return f.environmentVariables&&f.environmentVariables.forEach(i=>{u.push("-e",`${i.name}`)}),["run","-i","--rm",...u,...j,...o]}default:return[...j,...o]}}const os=({currentPage:s,hasNextPage:f,hasPreviousPage:j,onNextPage:o,onPreviousPage:u})=>e.jsxs("div",{className:"flex items-center justify-center space-x-2 my-6",children:[e.jsxs("button",{onClick:u,disabled:!j,className:`px-4 py-2 rounded transition-all duration-200 ${j?"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 inline-block mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),"Prev"]}),e.jsxs("span",{className:"px-4 py-2 bg-blue-500 text-white rounded btn-primary",children:["Page ",s]}),e.jsxs("button",{onClick:o,disabled:!f,className:`px-4 py-2 rounded transition-all duration-200 ${f?"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:["Next",e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 inline-block ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]}),ps=()=>{const{t:s}=te(),f=De(),{serverName:j}=Ue(),{showToast:o}=We(),[u,i]=He(),a=u.get("tab")==="registry"?"registry":"local",{servers:c,allServers:b,categories:P,loading:_,error:T,setError:$,searchServers:D,filterByCategory:U,filterByTag:B,selectedCategory:w,selectedTag:V,installServer:L,fetchServerByName:E,isServerInstalled:W,currentPage:q,totalPages:R,changePage:I,serversPerPage:z,changeServersPerPage:N}=Ze(),{servers:X,allServers:Q,loading:v,error:h,setError:C,searchServers:Z,clearSearch:g,fetchServerByName:y,fetchServerVersions:p,currentPage:S,totalPages:n,hasNextPage:m,hasPreviousPage:d,changePage:M,goToNextPage:oe,goToPreviousPage:ce,serversPerPage:r,changeServersPerPage:l}=Ke(),[F,K]=t.useState(null),[H,G]=t.useState(null),[Y,ee]=t.useState(""),[de,he]=t.useState(""),[ge,ie]=t.useState(!1),[ke,Se]=t.useState(new Set);t.useEffect(()=>{(async()=>{if(j)if(a==="registry"){const k=await y(j);k?G(k):f("/market?tab=registry")}else{const k=await E(j);k?K(k):f("/market?tab=local")}else K(null),G(null)})()},[j,a,E,y,f]);const we=x=>{const k=new URLSearchParams(u);k.set("tab",x),i(k),j&&f("/market?"+k.toString())},Ce=x=>{x.preventDefault(),a==="local"?D(Y):a==="registry"&&Z(de)},Pe=x=>{a==="local"&&U(x)},Ee=()=>{a==="local"?(ee(""),U(""),B("")):a==="registry"&&(he(""),g())},pe=x=>{var k;if(a==="registry"){const re=(k=x.server)==null?void 0:k.name;re&&f(`/market/${encodeURIComponent(re)}?tab=registry`)}else f(`/market/${x.name}?tab=local`)},fe=()=>f(`/market?tab=${a}`),Re=async(x,k)=>{try{ie(!0),await L(x,k)&&o(s("market.installSuccess",{serverName:x.display_name}),"success")}finally{ie(!1)}},Ie=async(x,k)=>{try{ie(!0);const J={name:xe(x.name),config:k},re=await ve("/servers",J);if(!re.success){o((re==null?void 0:re.message)||s("server.addError"),"error");return}Se(Me=>new Set(Me).add(x.name)),o(s("registry.installSuccess",{name:x.title||x.name}),"success")}catch(J){o(s("registry.installError",{error:J instanceof Error?J.message:String(J)}),"error")}finally{ie(!1)}},Te=x=>{a==="local"?I(x):M(x),window.scrollTo({top:0,behavior:"smooth"})},Le=x=>{const k=parseInt(x.target.value,10);a==="local"?N(k):l(k)};if(F)return e.jsx(rs,{server:F,onBack:fe,onInstall:Re,installing:ge,isInstalled:W(F.name)});if(H)return e.jsx(ns,{serverEntry:H,onBack:fe,onInstall:Ie,installing:ge,isInstalled:ke.has(H.server.name),fetchVersions:p});const A=a==="local",ae=a==="registry",me=A?c:X,ue=A?b:Q,Ae=A?P:[],ze=A?_:v,ye=A?T:h,$e=A?$:C,se=A?w:"",Be=A?V:"",ne=A?q:S,Ve=A?R:n,le=A?z:r,be=[{id:"local",label:s("market.title"),sourceLabel:"MCPM",sourceUrl:"https://mcpm.sh"},{id:"registry",label:s("registry.title"),sourceLabel:s("registry.official"),sourceUrl:"https://registry.modelcontextprotocol.io"}];return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-end justify-between gap-4 mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("nav.market")}),e.jsx("p",{className:"hub-sub",children:be.map(x=>x.label).join(" · ")})]})}),e.jsx("div",{className:"mb-5",children:e.jsx("div",{style:{borderBottom:"1px solid var(--hub-line)"},children:e.jsx("nav",{className:"flex -mb-px gap-1.5",children:be.map(x=>{const k=a===x.id;return e.jsxs("button",{onClick:()=>we(x.id),className:"py-2 px-3 transition-colors text-[14px]",style:{borderBottom:"2px solid "+(k?"var(--hub-ink)":"transparent"),color:k?"var(--hub-ink)":"var(--hub-ink-3)",fontWeight:k?500:400},children:[x.label,e.jsxs("a",{href:x.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"hub-mono ml-1.5",style:{fontSize:11,color:"var(--hub-ink-3)"},onClick:J=>J.stopPropagation(),children:["(",x.sourceLabel,")"]})]},x.id)})})})}),ye&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(qe,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:ye})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>$e(null),children:e.jsx(Ge,{size:13})})]}),(A||ae)&&e.jsxs("form",{onSubmit:Ce,className:"hub-card flex items-center gap-2 px-3 mb-5",style:{padding:6},children:[e.jsx(Je,{size:16,style:{color:"var(--hub-ink-3)",margin:"0 6px 0 6px"}}),e.jsx("input",{type:"text",value:ae?de:Y,onChange:x=>{ae?he(x.target.value):ee(x.target.value)},placeholder:s(ae?"registry.searchPlaceholder":"market.searchPlaceholder"),className:"flex-1 bg-transparent outline-none",style:{height:32,fontSize:14,color:"var(--hub-ink)"}}),e.jsx("button",{type:"submit",className:"hub-btn",children:s("common.search")}),(A&&(Y||se||Be)||ae&&de)&&e.jsx("button",{type:"button",onClick:Ee,className:"hub-btn ghost",children:s("common.clear")})]}),e.jsxs("div",{className:A?"grid gap-5":"",style:A?{gridTemplateColumns:"180px 1fr"}:void 0,children:[A&&e.jsxs("div",{children:[e.jsx("h3",{className:"hub-sect mb-2",children:s("market.categories")}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("button",{onClick:()=>U(""),className:"flex items-center justify-between transition-colors text-[13px]",style:{padding:"6px 10px",borderRadius:6,background:se?"transparent":"var(--hub-surface)",color:se?"var(--hub-ink-2)":"var(--hub-ink)",border:"1px solid "+(se?"transparent":"var(--hub-line)")},children:[e.jsx("span",{children:s("common.all")}),e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:b.length})]}),Ae.map(x=>e.jsx("button",{onClick:()=>Pe(x),className:"flex items-center justify-between transition-colors text-[13px]",style:{padding:"6px 10px",borderRadius:6,background:se===x?"var(--hub-surface)":"transparent",color:se===x?"var(--hub-ink)":"var(--hub-ink-2)",border:"1px solid "+(se===x?"var(--hub-line)":"transparent")},children:e.jsx("span",{className:"truncate",children:x})},x))]})]}),e.jsx("div",{children:ze?e.jsx("div",{className:"hub-card p-6 text-center",style:{color:"var(--hub-ink-3)"},children:s("app.loading")}):me.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:s(A?"market.noServers":"registry.noServers")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:me.map((x,k)=>A?e.jsx(ss,{server:x,onClick:pe},k):e.jsx(as,{serverEntry:x,onClick:pe},k))}),e.jsxs("div",{className:"flex items-center mt-4 text-[12px]",style:{color:"var(--hub-ink-3)"},children:[e.jsx("div",{className:"flex-[2]",children:A?s("market.showing",{from:(ne-1)*le+1,to:Math.min(ne*le,ue.length),total:ue.length}):s("registry.showing",{from:(ne-1)*le+1,to:(ne-1)*le+me.length,total:ue.length+(m?"+":"")})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:ae?e.jsx(os,{currentPage:ne,hasNextPage:m,hasPreviousPage:d,onNextPage:oe,onPreviousPage:ce}):e.jsx(Ye,{currentPage:ne,totalPages:Ve,onPageChange:Te})}),e.jsxs("div",{className:"flex-[2] flex items-center justify-end gap-2",children:[e.jsxs("label",{htmlFor:"perPage",children:[s(A?"market.perPage":"registry.perPage"),":"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{id:"perPage",value:le,onChange:Le,className:"hub-input pr-7",style:{height:26,width:70,padding:"0 6px",fontSize:12},children:[e.jsx("option",{value:"6",children:"6"}),e.jsx("option",{value:"9",children:"9"}),e.jsx("option",{value:"12",children:"12"}),e.jsx("option",{value:"24",children:"24"})]}),e.jsx(Xe,{size:11,className:"absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none",style:{color:"var(--hub-ink-3)"}})]})]})]})]})})]})]})};export{ps as default};
2
- //# sourceMappingURL=MarketPage-BnxAofuO.js.map
1
+ import{r as t,j as e,d as De,b as Ue,i as He}from"./framework-vendor-_YL27Pfc.js";import{e as O,i as ve,j as We}from"./index-DJUr-vo3.js";import{u as te}from"./i18n-vendor-BMaj5qV8.js";import{a as je,d as _e,s as xe}from"./variableDetection-BHrhKDaj.js";import{C as Ne,$ as Fe,a5 as Oe,a7 as Qe,l as qe,X as Ge,G as Je,u as Xe}from"./icons-vendor-CvmEvkQ-.js";import{P as Ye}from"./Pagination-CLUvn47x.js";import"./contextCost-CilWqGWT.js";const Ze=()=>{const{t:s}=te(),[f,j]=t.useState([]),[o,u]=t.useState([]),[i,a]=t.useState([]),[c,b]=t.useState([]),[P,_]=t.useState(""),[T,$]=t.useState(""),[D,U]=t.useState(""),[B,w]=t.useState(!0),[V,L]=t.useState(null),[E,W]=t.useState(null),[q,R]=t.useState([]),[I,z]=t.useState(1),[N,X]=t.useState(9),[Q,v]=t.useState(1),h=t.useCallback(async()=>{try{w(!0);const r=await O("/market/servers");r&&r.success&&Array.isArray(r.data)?(u(r.data),C(r.data,I)):(console.error("Invalid market servers data format",{data:r}),L(s("market.fetchError")))}catch(r){console.error("Error fetching market servers",{err:r}),L(r instanceof Error?r.message:String(r))}finally{w(!1)}},[s]),C=t.useCallback((r,l,F=N)=>{const K=r.length,H=Math.ceil(K/F);v(H);const G=Math.max(1,Math.min(l,H));G!==l&&z(G);const Y=(G-1)*F,ee=r.slice(Y,Y+F);j(ee)},[N]),Z=t.useCallback(r=>{z(r),C(o,r,N)},[o,C,N]),g=t.useCallback(async()=>{try{const r=await O("/market/categories");r&&r.success&&Array.isArray(r.data)?a(r.data):console.error("Invalid categories data format",{data:r})}catch(r){console.error("Error fetching categories",{err:r})}},[]),y=t.useCallback(async()=>{try{const r=await O("/market/tags");r&&r.success&&Array.isArray(r.data)?b(r.data):console.error("Invalid tags data format",{data:r})}catch(r){console.error("Error fetching tags",{err:r})}},[]),p=t.useCallback(async r=>{try{w(!0);const l=await O(`/market/servers/${r}`);return l&&l.success&&l.data?(W(l.data),l.data):(console.error("Invalid market server data format",{name:r,data:l}),L(s("market.serverNotFound")),null)}catch(l){return console.error("Error fetching market server",{name:r,err:l}),L(l instanceof Error?l.message:String(l)),null}finally{w(!1)}},[s]),S=t.useCallback(async r=>{try{if(w(!0),U(r),!r.trim()){h();return}const l=await O(`/market/servers/search?query=${encodeURIComponent(r)}`);l&&l.success&&Array.isArray(l.data)?(u(l.data),z(1),C(l.data,1)):(console.error("Invalid market search results format",{query:r,data:l}),L(s("market.searchError")))}catch(l){console.error("Error searching market servers",{query:r,err:l}),L(l instanceof Error?l.message:String(l))}finally{w(!1)}},[s,o,C,h]),n=t.useCallback(async r=>{try{if(w(!0),_(r),$(""),!r){h();return}const l=await O(`/market/categories/${encodeURIComponent(r)}`);l&&l.success&&Array.isArray(l.data)?(u(l.data),z(1),C(l.data,1)):(console.error("Invalid market category filter results format",{category:r,data:l}),L(s("market.filterError")))}catch(l){console.error("Error filtering market servers by category",{category:r,err:l}),L(l instanceof Error?l.message:String(l))}finally{w(!1)}},[s,h,C]),m=t.useCallback(async r=>{try{if(w(!0),$(r),_(""),!r){h();return}const l=await O(`/market/tags/${encodeURIComponent(r)}`);l&&l.success&&Array.isArray(l.data)?(u(l.data),z(1),C(l.data,1)):(console.error("Invalid market tag filter results format",{tag:r,data:l}),L(s("market.tagFilterError")))}catch(l){console.error("Error filtering market servers by tag",{tag:r,err:l}),L(l instanceof Error?l.message:String(l))}finally{w(!1)}},[s,h,C]),d=t.useCallback(async()=>{try{const r=await O("/servers");if(r&&r.success&&Array.isArray(r.data)){const l=r.data.map(F=>F.name);R(l)}}catch(r){console.error("Error fetching installed servers",{err:r})}},[]),M=t.useCallback(r=>q.includes(r),[q]),oe=t.useCallback(async(r,l)=>{var F,K;try{const H=(F=r.installations)!=null&&F.npm?"npm":Object.keys(r.installations||{}).length>0?Object.keys(r.installations)[0]:null;if(!H||!((K=r.installations)!=null&&K[H]))return L(s("market.noInstallationMethod")),!1;const G=r.installations[H],Y={name:r.name,config:l.type==="stdio"?{command:l.command||G.command||"",args:l.args||G.args||[],env:{...G.env,...l.env}}:l},ee=await ve("/servers",Y);if(!ee.success)throw new Error(ee.message||"Failed to install server");return await d(),!0}catch(H){return console.error("Error installing market server",{serverName:r.name,err:H}),L(H instanceof Error?H.message:String(H)),!1}},[s,d]),ce=t.useCallback(r=>{X(r),z(1),C(o,1,r)},[o,C]);return t.useEffect(()=>{h(),g(),y(),d()},[h,g,y,d]),{servers:f,allServers:o,categories:i,tags:c,selectedCategory:P,selectedTag:T,searchQuery:D,loading:B,error:V,setError:L,currentServer:E,fetchMarketServers:h,fetchServerByName:p,searchServers:S,filterByCategory:n,filterByTag:m,installServer:oe,currentPage:I,totalPages:Q,serversPerPage:N,changePage:Z,changeServersPerPage:ce,isServerInstalled:M}},Ke=()=>{const{t:s}=te(),[f,j]=t.useState([]),[o,u]=t.useState([]),[i,a]=t.useState(!0),[c,b]=t.useState(null),[P,_]=t.useState(""),[T,$]=t.useState(1),[D,U]=t.useState(9),[B,w]=t.useState(null),[V,L]=t.useState(!1),[E,W]=t.useState([]),[q]=t.useState(1),R=t.useCallback(async(g,y)=>{try{a(!0),b(null);const p=new URLSearchParams;p.append("limit",D.toString()),g&&p.append("cursor",g);const S=y!==void 0?y:P;S.trim()&&p.append("search",S.trim());const n=await O(`/registry/servers?${p.toString()}`);if(n&&n.success&&n.data){const m=n.data;if(m.servers&&Array.isArray(m.servers)){j(m.servers);const d=m.metadata.count===D&&!!m.metadata.nextCursor;L(d),w(m.metadata.nextCursor||null),u(g?M=>[...M,...m.servers]:m.servers)}else console.error("Invalid registry servers data format",{data:m}),b(s("registry.fetchError"))}else b(s("registry.fetchError"))}catch(p){console.error("Error fetching registry servers",{cursor:g,search:y,err:p});const S=p instanceof Error?p.message:String(p);b(S)}finally{a(!1)}},[s,D]),I=t.useCallback(async()=>{if(!V||!B)return;const g=E[E.length-1]||"";W(y=>[...y,g]),$(y=>y+1),await R(B,P)},[V,B,E,P,R]),z=t.useCallback(async()=>{if(T<=1)return;const g=[...E];g.pop();const y=g[g.length-1];W(g),$(p=>p-1),await R(y||void 0,P)},[T,E,P,R]),N=t.useCallback(async g=>{g!==T&&(g>T&&V?await I():g<T&&T>1&&await z())},[T,V,I,z]),X=t.useCallback(async g=>{U(g),$(1),W([]),u([]),await R(void 0,P)},[P,R]),Q=t.useCallback(async g=>{try{a(!0),b(null);const y=encodeURIComponent(g),p=await O(`/registry/servers/versions?serverName=${y}`);if(p&&p.success&&p.data){const S=p.data;return S.servers&&Array.isArray(S.servers)&&S.servers.length>0?S.servers[0]:(console.error("Invalid registry server data format",{serverName:g,data:S}),b(s("registry.serverNotFound")),null)}else return b(s("registry.serverNotFound")),null}catch(y){console.error("Error fetching registry server",{serverName:g,err:y});const p=y instanceof Error?y.message:String(y);return b(p),null}finally{a(!1)}},[s]),v=t.useCallback(async g=>{try{b(null);const y=encodeURIComponent(g),p=await O(`/registry/servers/versions?serverName=${y}`);if(p&&p.success&&p.data){const S=p.data;return S.servers&&Array.isArray(S.servers)?S.servers:(console.error("Invalid registry server versions data format",{serverName:g,data:S}),[])}else return[]}catch(y){console.error("Error fetching versions for registry server",{serverName:g,err:y});const p=y instanceof Error?y.message:String(y);return b(p),[]}},[]),h=t.useCallback(async(g,y)=>{try{b(null);const p=encodeURIComponent(g),S=encodeURIComponent(y),n=await O(`/registry/servers/version?serverName=${p}&version=${S}`);if(n&&n.success&&n.data){const m=n.data;return m&&m.server?m:(console.error("Invalid registry server version data format",{serverName:g,version:y,data:m}),null)}else return null}catch(p){console.error("Error fetching specific registry server version",{serverName:g,version:y,err:p});const S=p instanceof Error?p.message:String(p);return b(S),null}},[]),C=t.useCallback(async g=>{console.log("Searching registry servers",{query:g}),_(g),$(1),W([]),u([]),await R(void 0,g)},[R]),Z=t.useCallback(async()=>{_(""),$(1),W([]),u([]),await R(void 0,"")},[R]);return t.useEffect(()=>{R(void 0,P)},[]),{servers:f,allServers:o,loading:i,error:c,setError:b,searchQuery:P,searchServers:C,clearSearch:Z,fetchServerByName:Q,fetchServerVersions:v,fetchServerVersion:h,currentPage:T,totalPages:q,hasNextPage:V,hasPreviousPage:T>1,changePage:N,goToNextPage:I,goToPreviousPage:z,serversPerPage:D,changeServersPerPage:X}},es=s=>s.split(" ").map(f=>f.charAt(0)).join("").toUpperCase().slice(0,2),ss=({server:s,onClick:f})=>{var i,a,c;const{t:j}=te(),o=(s.tags||[]).slice(0,3),u=(i=s.categories)==null?void 0:i[0];return e.jsxs("div",{className:"hub-card flex flex-col cursor-pointer transition-colors h-full overflow-hidden",onClick:()=>f(s),onMouseEnter:b=>b.currentTarget.style.borderColor="var(--hub-ink-2)",onMouseLeave:b=>b.currentTarget.style.borderColor="var(--hub-line)",children:[e.jsxs("div",{className:"p-3.5 flex-1 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"hub-mono",style:{width:28,height:28,borderRadius:7,background:"var(--hub-ink)",color:"var(--hub-bg)",display:"grid",placeItems:"center",fontWeight:600,fontSize:13,flexShrink:0},children:es(s.display_name||s.name)[0]||"?"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate",style:{fontSize:14,fontWeight:500,letterSpacing:"-0.01em"},children:s.display_name}),s.is_official&&e.jsxs("span",{className:"inline-flex items-center gap-0.5",style:{fontSize:10,color:"var(--hub-accent)",background:"var(--hub-accent-soft)",padding:"0 5px",height:16,borderRadius:3,fontWeight:500},children:[e.jsx(Ne,{size:9,strokeWidth:2.5}),j("market.official")]})]}),e.jsxs("div",{className:"hub-mono truncate",style:{fontSize:11,color:"var(--hub-ink-3)"},children:["@",((a=s.author)==null?void 0:a.name)||j("market.unknown")]})]})]}),e.jsx("div",{className:"flex-1 line-clamp-2",style:{fontSize:12.5,color:"var(--hub-ink-2)",lineHeight:1.5},children:s.description}),o.length>0&&e.jsx("div",{className:"flex gap-1 flex-wrap",children:o.map(b=>e.jsxs("span",{className:"hub-tag",style:{background:"oklch(0.96 0.04 145)",color:"oklch(0.4 0.1 145)",border:0},children:["#",b]},b))})]}),e.jsx("div",{className:"flex items-center justify-between px-3.5 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)"},children:e.jsxs("div",{className:"hub-mono flex items-center gap-3",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Fe,{size:11}),((c=s.tools)==null?void 0:c.length)??0," ",j("server.tools").toLowerCase()]}),u&&e.jsx("span",{className:"truncate",children:u})]})})]})},rs=({server:s,onBack:f,onInstall:j,installing:o=!1,isInstalled:u=!1})=>{var N,X,Q;const{t:i}=te(),[a,c]=t.useState(!1),[b,P]=t.useState(null),[_,T]=t.useState(!1),[$,D]=t.useState(null),[U,B]=t.useState([]),w=()=>u?{className:"bg-green-600 cursor-default px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:i("market.installed")}:o?{className:"bg-gray-400 cursor-not-allowed px-4 py-2 rounded text-sm font-medium text-white",disabled:!0,text:i("market.installing")}:{className:"hub-btn primary",disabled:!1,text:i("market.install")},V=()=>{c(!a),P(null),T(!1),D(null)},L=async()=>{$&&(await E($),T(!1),D(null))},E=async v=>{try{P(null),j(s,v.config),c(!1)}catch(h){console.error("Error installing server:",h),P(i("errors.serverInstall"))}},W=()=>{u||V()},q=()=>{if(!s.installations)return;if(s.installations.npm)return s.installations.npm;if(s.installations.uvx)return s.installations.uvx;if(s.installations.default)return s.installations.default;const v=Object.keys(s.installations);if(v.length>0)return s.installations[v[0]]},R=async v=>{try{const h=_e(v);h.length>0?(B(h),D(v),T(!0)):await E(v)}catch(h){console.error("Error processing server installation:",h),P(i("errors.serverInstall"))}},I=w(),z=q();return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md p-6",children:[e.jsx("div",{className:"mb-4",children:e.jsxs("button",{onClick:f,className:"text-gray-600 hover:text-gray-900 flex items-center",children:[e.jsx("svg",{className:"h-5 w-5 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",clipRule:"evenodd"})}),i("market.backToList")]})}),e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("div",{children:e.jsxs("h2",{className:"text-2xl font-bold text-gray-900 flex items-center flex-wrap",children:[s.display_name,e.jsxs("span",{className:"text-sm font-normal text-gray-500 ml-2",children:["(",s.name,")"]}),e.jsxs("span",{className:"text-sm font-normal text-gray-600 ml-4",children:[i("market.author"),": ",((N=s.author)==null?void 0:N.name)||i("market.unknown")," •"," ",i("market.license"),": ",s.license," •",e.jsx("a",{href:s.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:underline ml-1",children:i("market.repository")})]})]})}),e.jsxs("div",{className:"flex items-center",children:[s.is_official&&e.jsx("span",{className:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300 text-sm font-normal px-4 py-2 rounded mr-2 flex items-center label-primary",children:i("market.official")}),e.jsx("button",{onClick:W,disabled:I.disabled,className:I.className,children:I.text})]})]}),e.jsx("p",{className:"text-gray-700 mb-6",children:s.description}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-semibold mb-3",children:[i("market.categories")," & ",i("market.tags")]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(X=s.categories)==null?void 0:X.map((v,h)=>e.jsx("span",{className:"bg-gray-100 dark:bg-gray-800 text-gray-800 px-3 py-1 rounded",children:v},`cat-${h}`)),s.tags&&s.tags.map((v,h)=>e.jsxs("span",{className:"bg-gray-100 dark:bg-gray-800 text-green-700 px-2 py-1 rounded text-sm",children:["#",v]},`tag-${h}`))]})]}),s.arguments&&Object.keys(s.arguments).length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:i("market.arguments")}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.argumentName")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.description")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.required")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider whitespace-nowrap",children:i("market.example")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:Object.entries(s.arguments).map(([v,h],C)=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:v}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-500",children:h.description}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:h.required?e.jsx("span",{className:"text-green-600",children:"✓"}):e.jsx("span",{className:"text-gray-600",children:"✗"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded",children:h.example})})]},C))})]})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:i("market.tools")}),e.jsx("div",{className:"space-y-4",children:(Q=s.tools)==null?void 0:Q.map((v,h)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-4",children:[e.jsxs("h4",{className:"font-medium mb-2",children:[v.name,e.jsx("button",{type:"button",onClick:()=>{const C=document.getElementById(`schema-${h}`);C&&C.classList.toggle("hidden")},className:"text-sm text-blue-500 font-normal hover:underline focus:outline-none ml-2",children:i("market.viewSchema")})]}),e.jsx("p",{className:"text-gray-600 mb-2",children:v.description}),e.jsx("div",{className:"mt-2",children:e.jsx("pre",{id:`schema-${h}`,className:"hidden bg-gray-50 dark:bg-gray-800 p-3 rounded text-sm overflow-auto mt-2",children:JSON.stringify(v.inputSchema,null,2)})})]},h))})]}),s.examples&&s.examples.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:i("market.examples")}),e.jsx("div",{className:"space-y-4",children:s.examples.map((v,h)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:v.title}),e.jsx("p",{className:"text-gray-600 mb-2",children:v.description}),e.jsx("pre",{className:"bg-gray-50 dark:bg-gray-800 p-3 rounded text-sm overflow-auto",children:v.prompt})]},h))})]}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{onClick:W,disabled:I.disabled,className:I.className,children:I.text})}),a&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(je,{onSubmit:R,onCancel:V,modalTitle:i("market.installServer",{name:s.display_name}),formError:b,initialData:{name:s.name,status:"disconnected",config:z?{command:z.command||"",args:z.args||[],env:z.env||{}}:void 0}})}),_&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center p-4",children:e.jsxs("div",{className:"hub-card p-6 w-full max-w-md",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:i("server.confirmVariables")}),e.jsx("p",{className:"text-gray-600 mb-4",children:i("server.variablesDetected")}),e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 rounded p-3 mb-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-yellow-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"ml-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-yellow-800",children:[i("server.detectedVariables"),":"]}),e.jsx("ul",{className:"mt-1 text-sm text-yellow-700",children:U.map((v,h)=>e.jsxs("li",{className:"font-mono",children:["$",`{${v}}`]},h))})]})]})}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:i("market.confirmVariablesMessage")}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{T(!1),D(null)},className:"hub-btn",children:i("common.cancel")}),e.jsx("button",{onClick:L,className:"hub-btn primary",children:i("market.confirmAndInstall")})]})]})})]})},ts=s=>{if(!s)return"";try{const f=new Date(s),j=f.getFullYear(),o=(f.getMonth()+1).toString().padStart(2,"0"),u=f.getDate().toString().padStart(2,"0");return`${j}/${o}/${u}`}catch{return""}},as=({serverEntry:s,onClick:f})=>{var D,U;const{t:j}=te(),{server:o,_meta:u}=s,i=u==null?void 0:u["io.modelcontextprotocol.registry/official"],a=i==null?void 0:i.isLatest,c=i==null?void 0:i.publishedAt,b=i==null?void 0:i.updatedAt,P=((D=o.packages)==null?void 0:D.length)||0,_=((U=o.remotes)==null?void 0:U.length)||0,T=o.description?o.description.length<=150?o.description:o.description.slice(0,150)+"...":j("registry.noDescription"),$=o.icons&&o.icons.length>0?o.icons.find(w=>!w.theme||w.theme==="light")||o.icons[0]:null;return e.jsxs("div",{className:"hub-card flex flex-col cursor-pointer transition-colors h-full overflow-hidden",onClick:()=>f(s),onMouseEnter:B=>B.currentTarget.style.borderColor="var(--hub-ink-2)",onMouseLeave:B=>B.currentTarget.style.borderColor="var(--hub-line)",children:[e.jsxs("div",{className:"p-3.5 flex-1 flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[$?e.jsx("img",{src:$.src,alt:o.title||o.name,className:"rounded-md object-cover flex-shrink-0",style:{width:28,height:28},onError:B=>{B.currentTarget.style.display="none"}}):e.jsx("div",{className:"hub-mono flex-shrink-0",style:{width:28,height:28,borderRadius:7,background:"var(--hub-ink)",color:"var(--hub-bg)",display:"grid",placeItems:"center",fontWeight:600,fontSize:13},children:o.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate",style:{fontSize:14,fontWeight:500,letterSpacing:"-0.01em"},children:o.title||o.name}),a&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 flex-shrink-0",style:{fontSize:10,color:"oklch(0.4 0.13 145)",background:"oklch(0.95 0.05 145)",padding:"0 5px",height:16,borderRadius:3,fontWeight:500},children:[e.jsx(Ne,{size:9,strokeWidth:2.5}),j("registry.latest")]})]}),e.jsxs("div",{className:"hub-mono truncate",style:{fontSize:11,color:"var(--hub-ink-3)"},children:[o.name," · v",o.version]})]})]}),e.jsx("div",{className:"flex-1 line-clamp-2",style:{fontSize:12.5,color:"var(--hub-ink-2)",lineHeight:1.5},children:T})]}),e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2",style:{borderTop:"1px solid var(--hub-line-2)",background:"var(--hub-bg-2)"},children:[e.jsxs("div",{className:"hub-mono flex items-center gap-3",style:{fontSize:11.5,color:"var(--hub-ink-3)"},children:[P>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Oe,{size:11}),P]}),_>0&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Qe,{size:11}),_]}),(c||b)&&e.jsx("span",{children:ts(b||c)})]}),e.jsxs("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-accent)"},children:[j("registry.viewDetails")," →"]})]})]})},ns=({serverEntry:s,onBack:f,onInstall:j,installing:o=!1,isInstalled:u=!1,fetchVersions:i})=>{const{t:a}=te(),{server:c,_meta:b}=s,[P,_]=t.useState(c.version),[T,$]=t.useState([]),[D,U]=t.useState(!1),[B,w]=t.useState(!1),[V,L]=t.useState(null),[E,W]=t.useState(null),[q,R]=t.useState(null),[I,z]=t.useState({packages:!0,remotes:!0,repository:!0}),N=b==null?void 0:b["io.modelcontextprotocol.registry/official"];t.useEffect(()=>{(async()=>{if(i){U(!0);try{const m=await i(c.name);$(m)}catch(m){console.error("Failed to load versions:",m)}finally{U(!1)}}})()},[c.name,i]);const Q=c.icons&&c.icons.length>0?c.icons.find(m=>!m.theme||m.theme==="light")||c.icons[0]:null,v=n=>{if(!n)return"";try{return new Date(n).toLocaleDateString()}catch{return""}},h=n=>{z(m=>({...m,[n]:!m[n]}))},C=(n,m)=>{L(n),W(m),R(null),w(!0)},Z=()=>{w(!1),R(null)},g=async n=>{try{if(!j||!E||!V)return;R(null);const m=n.config;j(c,m),w(!1)}catch(m){console.error("Error installing server:",m),R(a("errors.serverInstall"))}},y=()=>{if(!E||!V)return null;if(console.log("Building initial form data for:",E),V==="package"&&"identifier"in E){const n=E,m={};n.environmentVariables&&n.environmentVariables.forEach(M=>{m[M.name]=M.default||""});const d=ls(n.registryType);return{name:xe(c.name),status:"disconnected",config:{type:"stdio",command:d,args:is(d,n),env:Object.keys(m).length>0?m:void 0}}}else if(V==="remote"&&"url"in E){const n=E,m={};n.headers&&n.headers.forEach(M=>{m[M.name]=M.default||M.value||""});const d=n.type==="sse"?"sse":"streamable-http";return{name:xe(c.name),status:"disconnected",config:{type:d,url:n.url,headers:Object.keys(m).length>0?m:void 0}}}return null},p=(n,m)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 mb-3 hover:border-blue-400 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:n.identifier}),n.version&&e.jsxs("p",{className:"text-sm text-gray-500",children:["Version: ",n.version]}),n.runtimeHint&&e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:n.runtimeHint})]}),e.jsx("button",{onClick:()=>C("package",n),disabled:u||o,className:`px-4 py-2 rounded text-sm font-medium transition-colors ${u?"hub-btn cursor-default":o?"hub-btn cursor-not-allowed opacity-50":"hub-btn primary"}`,children:a(u?"registry.installed":o?"registry.installing":"registry.install")})]}),n.registryType&&e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Registry:"})," ",n.registryType]}),n.transport&&e.jsxs("div",{className:"text-sm text-gray-600 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Transport:"})," ",n.transport.type,n.transport.url&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["(",n.transport.url,")"]})]}),n.environmentVariables&&n.environmentVariables.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[a("registry.environmentVariables"),":"]}),e.jsx("div",{className:"space-y-2",children:n.environmentVariables.map((d,M)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:d.name}),d.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:a("common.required")}),d.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:a("common.secret")})]}),d.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:d.description}),d.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.default})]})]},M))})]}),n.packageArguments&&n.packageArguments.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[a("registry.packageArguments"),":"]}),e.jsx("div",{className:"space-y-2",children:n.packageArguments.map((d,M)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:d.name}),d.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:a("common.required")}),d.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:a("common.secret")}),d.isRepeated&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300",children:a("common.repeated")})]}),d.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:d.description}),d.type&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.type"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.type})]}),d.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.default})]}),d.value&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.value"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.value})]}),d.valueHint&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.valueHint"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.valueHint})]}),d.choices&&d.choices.length>0&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.choices"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.choices.join(", ")})]})]},M))})]})]},m),S=(n,m)=>e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 mb-3 hover:border-blue-400 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900",children:n.type}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 break-all",children:n.url})]}),e.jsx("button",{onClick:()=>C("remote",n),disabled:u||o,className:`px-4 py-2 rounded text-sm font-medium transition-colors ${u?"hub-btn cursor-default":o?"hub-btn cursor-not-allowed opacity-50":"hub-btn primary"}`,children:a(u?"registry.installed":o?"registry.installing":"registry.install")})]}),n.headers&&n.headers.length>0&&e.jsxs("div",{className:"mt-3 border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 mb-2",children:[a("registry.headers"),":"]}),e.jsx("div",{className:"space-y-2",children:n.headers.map((d,M)=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx("span",{className:"font-mono text-gray-900 font-medium",children:d.name}),d.isRequired&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800",children:a("common.required")}),d.isSecret&&e.jsx("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:a("common.secret")})]}),d.description&&e.jsx("p",{className:"text-gray-600 mt-1",children:d.description}),d.value&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.value"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.value})]}),d.default&&e.jsxs("p",{className:"text-gray-500 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[a("common.default"),":"]})," ",e.jsx("span",{className:"font-mono",children:d.default})]})]},M))})]})]},m);return e.jsxs("div",{className:"bg-white dark:bg-gray-800 shadow rounded-lg p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:f,className:"flex items-center text-blue-600 hover:text-blue-800 mb-4 transition-colors",children:[e.jsx("svg",{className:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),a("registry.backToList")]}),e.jsxs("div",{className:"flex items-start space-x-4",children:[Q?e.jsx("img",{src:Q.src,alt:c.title,className:"w-20 h-20 rounded-lg object-cover flex-shrink-0",onError:n=>{n.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-20 h-20 bg-gradient-to-br from-blue-500 to-purple-600 rounded-lg flex items-center justify-center text-white text-3xl font-semibold flex-shrink-0",children:"M"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:c.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[(N==null?void 0:N.isLatest)&&e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800",children:a("registry.latest")}),e.jsxs("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",children:["v",c.version]}),(N==null?void 0:N.status)&&e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-gray-100 dark:bg-gray-800 text-gray-800",children:N.status}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4 text-sm text-gray-600",children:[(N==null?void 0:N.publishedAt)&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[a("registry.published"),":"]})," ",v(N.publishedAt)]}),(N==null?void 0:N.updatedAt)&&e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium",children:[a("registry.updated"),":"]})," ",v(N.updatedAt)]})]})]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:a("registry.description")}),e.jsx("p",{className:"text-gray-700 leading-relaxed whitespace-pre-wrap",children:c.description})]}),c.websiteUrl&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-3",children:a("registry.website")}),e.jsx("a",{href:c.websiteUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 hover:underline",children:c.websiteUrl})]}),c.packages&&c.packages.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>h("packages"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsxs("span",{children:[a("registry.packages")," (",c.packages.length,")"]}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${I.packages?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I.packages&&e.jsx("div",{className:"space-y-3",children:c.packages.map(p)})]}),c.remotes&&c.remotes.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>h("remotes"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsxs("span",{children:[a("registry.remotes")," (",c.remotes.length,")"]}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${I.remotes?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I.remotes&&e.jsx("div",{className:"space-y-3",children:c.remotes.map(S)})]}),c.repository&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("button",{onClick:()=>h("repository"),className:"flex items-center justify-between w-full text-xl font-semibold text-gray-900 mb-3 hover:text-blue-600 transition-colors",children:[e.jsx("span",{children:a("registry.repository")}),e.jsx("svg",{className:`w-5 h-5 transform transition-transform ${I.repository?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I.repository&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[c.repository.url&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"URL:"})," ",e.jsx("a",{href:c.repository.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 hover:underline break-all",children:c.repository.url})]}),c.repository.source&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Source:"})," ",c.repository.source]}),c.repository.subfolder&&e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Subfolder:"})," ",c.repository.subfolder]}),c.repository.id&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"ID:"})," ",c.repository.id]})]})]}),B&&E&&V&&e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsx(je,{onSubmit:g,onCancel:Z,modalTitle:a("registry.installServer",{name:c.title||c.name}),formError:q,initialData:y()})})]})};function ls(s){switch(s.toLowerCase()){case"pypi":case"python":return"uvx";case"npm":case"node":return"npx";case"oci":case"docker":return"docker";default:return""}}function is(s,f){const j=[f.identifier+(f.version?`@${f.version}`:"")],o=[];switch(f.packageArguments&&f.packageArguments.length>0&&f.packageArguments.forEach(u=>{if(u.isRequired||u.default||u.value){const i=`--${u.name}`,a=u.value||u.default||`\${${u.name.toUpperCase()}}`;o.push(i,a)}}),s.toLowerCase()){case"uvx":return[...j,...o];case"npx":return[...j,...o];case"docker":{const u=[];return f.environmentVariables&&f.environmentVariables.forEach(i=>{u.push("-e",`${i.name}`)}),["run","-i","--rm",...u,...j,...o]}default:return[...j,...o]}}const os=({currentPage:s,hasNextPage:f,hasPreviousPage:j,onNextPage:o,onPreviousPage:u})=>e.jsxs("div",{className:"flex items-center justify-center space-x-2 my-6",children:[e.jsxs("button",{onClick:u,disabled:!j,className:`px-4 py-2 rounded transition-all duration-200 ${j?"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 inline-block mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),"Prev"]}),e.jsxs("span",{className:"px-4 py-2 bg-blue-500 text-white rounded btn-primary",children:["Page ",s]}),e.jsxs("button",{onClick:o,disabled:!f,className:`px-4 py-2 rounded transition-all duration-200 ${f?"bg-gray-200 hover:bg-gray-300 text-gray-700 btn-secondary":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:["Next",e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 inline-block ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]}),ps=()=>{const{t:s}=te(),f=De(),{serverName:j}=Ue(),{showToast:o}=We(),[u,i]=He(),a=u.get("tab")==="registry"?"registry":"local",{servers:c,allServers:b,categories:P,loading:_,error:T,setError:$,searchServers:D,filterByCategory:U,filterByTag:B,selectedCategory:w,selectedTag:V,installServer:L,fetchServerByName:E,isServerInstalled:W,currentPage:q,totalPages:R,changePage:I,serversPerPage:z,changeServersPerPage:N}=Ze(),{servers:X,allServers:Q,loading:v,error:h,setError:C,searchServers:Z,clearSearch:g,fetchServerByName:y,fetchServerVersions:p,currentPage:S,totalPages:n,hasNextPage:m,hasPreviousPage:d,changePage:M,goToNextPage:oe,goToPreviousPage:ce,serversPerPage:r,changeServersPerPage:l}=Ke(),[F,K]=t.useState(null),[H,G]=t.useState(null),[Y,ee]=t.useState(""),[de,he]=t.useState(""),[ge,ie]=t.useState(!1),[ke,Se]=t.useState(new Set);t.useEffect(()=>{(async()=>{if(j)if(a==="registry"){const k=await y(j);k?G(k):f("/market?tab=registry")}else{const k=await E(j);k?K(k):f("/market?tab=local")}else K(null),G(null)})()},[j,a,E,y,f]);const we=x=>{const k=new URLSearchParams(u);k.set("tab",x),i(k),j&&f("/market?"+k.toString())},Ce=x=>{x.preventDefault(),a==="local"?D(Y):a==="registry"&&Z(de)},Pe=x=>{a==="local"&&U(x)},Ee=()=>{a==="local"?(ee(""),U(""),B("")):a==="registry"&&(he(""),g())},pe=x=>{var k;if(a==="registry"){const re=(k=x.server)==null?void 0:k.name;re&&f(`/market/${encodeURIComponent(re)}?tab=registry`)}else f(`/market/${x.name}?tab=local`)},fe=()=>f(`/market?tab=${a}`),Re=async(x,k)=>{try{ie(!0),await L(x,k)&&o(s("market.installSuccess",{serverName:x.display_name}),"success")}finally{ie(!1)}},Ie=async(x,k)=>{try{ie(!0);const J={name:xe(x.name),config:k},re=await ve("/servers",J);if(!re.success){o((re==null?void 0:re.message)||s("server.addError"),"error");return}Se(Me=>new Set(Me).add(x.name)),o(s("registry.installSuccess",{name:x.title||x.name}),"success")}catch(J){o(s("registry.installError",{error:J instanceof Error?J.message:String(J)}),"error")}finally{ie(!1)}},Te=x=>{a==="local"?I(x):M(x),window.scrollTo({top:0,behavior:"smooth"})},Le=x=>{const k=parseInt(x.target.value,10);a==="local"?N(k):l(k)};if(F)return e.jsx(rs,{server:F,onBack:fe,onInstall:Re,installing:ge,isInstalled:W(F.name)});if(H)return e.jsx(ns,{serverEntry:H,onBack:fe,onInstall:Ie,installing:ge,isInstalled:ke.has(H.server.name),fetchVersions:p});const A=a==="local",ae=a==="registry",me=A?c:X,ue=A?b:Q,Ae=A?P:[],ze=A?_:v,ye=A?T:h,$e=A?$:C,se=A?w:"",Be=A?V:"",ne=A?q:S,Ve=A?R:n,le=A?z:r,be=[{id:"local",label:s("market.title"),sourceLabel:"MCPM",sourceUrl:"https://mcpm.sh"},{id:"registry",label:s("registry.title"),sourceLabel:s("registry.official"),sourceUrl:"https://registry.modelcontextprotocol.io"}];return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-end justify-between gap-4 mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"hub-h1",children:s("nav.market")}),e.jsx("p",{className:"hub-sub",children:be.map(x=>x.label).join(" · ")})]})}),e.jsx("div",{className:"mb-5",children:e.jsx("div",{style:{borderBottom:"1px solid var(--hub-line)"},children:e.jsx("nav",{className:"flex -mb-px gap-1.5",children:be.map(x=>{const k=a===x.id;return e.jsxs("button",{onClick:()=>we(x.id),className:"py-2 px-3 transition-colors text-[14px]",style:{borderBottom:"2px solid "+(k?"var(--hub-ink)":"transparent"),color:k?"var(--hub-ink)":"var(--hub-ink-3)",fontWeight:k?500:400},children:[x.label,e.jsxs("a",{href:x.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"hub-mono ml-1.5",style:{fontSize:11,color:"var(--hub-ink-3)"},onClick:J=>J.stopPropagation(),children:["(",x.sourceLabel,")"]})]},x.id)})})})}),ye&&e.jsxs("div",{className:"hub-card flex items-center justify-between gap-3 mb-4",style:{padding:"10px 14px",borderColor:"oklch(0.85 0.1 25)",background:"oklch(0.97 0.03 25)",color:"oklch(0.4 0.18 25)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(qe,{size:14,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate text-[13px]",children:ye})]}),e.jsx("button",{className:"hub-icon-btn sm",onClick:()=>$e(null),children:e.jsx(Ge,{size:13})})]}),(A||ae)&&e.jsxs("form",{onSubmit:Ce,className:"hub-card flex items-center gap-2 px-3 mb-5",style:{padding:6},children:[e.jsx(Je,{size:16,style:{color:"var(--hub-ink-3)",margin:"0 6px 0 6px"}}),e.jsx("input",{type:"text",value:ae?de:Y,onChange:x=>{ae?he(x.target.value):ee(x.target.value)},placeholder:s(ae?"registry.searchPlaceholder":"market.searchPlaceholder"),className:"flex-1 bg-transparent outline-none",style:{height:32,fontSize:14,color:"var(--hub-ink)"}}),e.jsx("button",{type:"submit",className:"hub-btn",children:s("common.search")}),(A&&(Y||se||Be)||ae&&de)&&e.jsx("button",{type:"button",onClick:Ee,className:"hub-btn ghost",children:s("common.clear")})]}),e.jsxs("div",{className:A?"grid gap-5":"",style:A?{gridTemplateColumns:"180px 1fr"}:void 0,children:[A&&e.jsxs("div",{children:[e.jsx("h3",{className:"hub-sect mb-2",children:s("market.categories")}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsxs("button",{onClick:()=>U(""),className:"flex items-center justify-between transition-colors text-[13px]",style:{padding:"6px 10px",borderRadius:6,background:se?"transparent":"var(--hub-surface)",color:se?"var(--hub-ink-2)":"var(--hub-ink)",border:"1px solid "+(se?"transparent":"var(--hub-line)")},children:[e.jsx("span",{children:s("common.all")}),e.jsx("span",{className:"hub-mono",style:{fontSize:11,color:"var(--hub-ink-3)"},children:b.length})]}),Ae.map(x=>e.jsx("button",{onClick:()=>Pe(x),className:"flex items-center justify-between transition-colors text-[13px]",style:{padding:"6px 10px",borderRadius:6,background:se===x?"var(--hub-surface)":"transparent",color:se===x?"var(--hub-ink)":"var(--hub-ink-2)",border:"1px solid "+(se===x?"var(--hub-line)":"transparent")},children:e.jsx("span",{className:"truncate",children:x})},x))]})]}),e.jsx("div",{children:ze?e.jsx("div",{className:"hub-card p-6 text-center",style:{color:"var(--hub-ink-3)"},children:s("app.loading")}):me.length===0?e.jsx("div",{className:"hub-card p-10 text-center",style:{color:"var(--hub-ink-3)"},children:s(A?"market.noServers":"registry.noServers")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:me.map((x,k)=>A?e.jsx(ss,{server:x,onClick:pe},k):e.jsx(as,{serverEntry:x,onClick:pe},k))}),e.jsxs("div",{className:"flex items-center mt-4 text-[12px]",style:{color:"var(--hub-ink-3)"},children:[e.jsx("div",{className:"flex-[2]",children:A?s("market.showing",{from:(ne-1)*le+1,to:Math.min(ne*le,ue.length),total:ue.length}):s("registry.showing",{from:(ne-1)*le+1,to:(ne-1)*le+me.length,total:ue.length+(m?"+":"")})}),e.jsx("div",{className:"flex-[4] flex justify-center",children:ae?e.jsx(os,{currentPage:ne,hasNextPage:m,hasPreviousPage:d,onNextPage:oe,onPreviousPage:ce}):e.jsx(Ye,{currentPage:ne,totalPages:Ve,onPageChange:Te})}),e.jsxs("div",{className:"flex-[2] flex items-center justify-end gap-2",children:[e.jsxs("label",{htmlFor:"perPage",children:[s(A?"market.perPage":"registry.perPage"),":"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{id:"perPage",value:le,onChange:Le,className:"hub-input pr-7",style:{height:26,width:70,padding:"0 6px",fontSize:12},children:[e.jsx("option",{value:"6",children:"6"}),e.jsx("option",{value:"9",children:"9"}),e.jsx("option",{value:"12",children:"12"}),e.jsx("option",{value:"24",children:"24"})]}),e.jsx(Xe,{size:11,className:"absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none",style:{color:"var(--hub-ink-3)"}})]})]})]})]})})]})]})};export{ps as default};
2
+ //# sourceMappingURL=MarketPage-D0RXyf6g.js.map