@decocms/mesh 2.64.2 → 2.64.3

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 (135) hide show
  1. package/dist/client/assets/{AlertCircle-CyK0Qw5h.js → AlertCircle-C47UrlAO.js} +1 -1
  2. package/dist/client/assets/{ArrowUp-BzVEz2lB.js → ArrowUp-NpHWyg3u.js} +1 -1
  3. package/dist/client/assets/{Calendar-DtGnvM8B.js → Calendar-B649-aT8.js} +1 -1
  4. package/dist/client/assets/{Check-Dzm8t_lx.js → Check-hF_kXZiK.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-Dq1sA0pv.js → CheckCircle-BIFyDkzk.js} +1 -1
  6. package/dist/client/assets/{ChevronDown-Z3Dyyuvx.js → ChevronDown-CwChLZoe.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-DDdY_PC7.js → ChevronRight-0gQ-Lwyj.js} +1 -1
  8. package/dist/client/assets/{Code01-BWP8EmsE.js → Code01-DSEEeIpb.js} +1 -1
  9. package/dist/client/assets/{Copy01-C6IJYSqu.js → Copy01-BY9LQ_eS.js} +1 -1
  10. package/dist/client/assets/{DotsHorizontal-lop24UEO.js → DotsHorizontal-Bk4oST9u.js} +1 -1
  11. package/dist/client/assets/{DotsVertical-BpzYqYSl.js → DotsVertical-CcQ5Tk1w.js} +1 -1
  12. package/dist/client/assets/{Download01-DkL2eEzP.js → Download01-BY55TLNH.js} +1 -1
  13. package/dist/client/assets/{Edit01-BObRJWWQ.js → Edit01-HUE0OI4J.js} +1 -1
  14. package/dist/client/assets/{File02-D8LncylE.js → File02-DfFeU8B6.js} +1 -1
  15. package/dist/client/assets/{File06-Bwnj0Jvb.js → File06-CV2OmgsQ.js} +1 -1
  16. package/dist/client/assets/{FilterLines-Tzhosng2.js → FilterLines-D6yXcgYG.js} +1 -1
  17. package/dist/client/assets/{Globe02-DudYvjwY.js → Globe02-DqbzCrT0.js} +1 -1
  18. package/dist/client/assets/{Grid01-DB4psHwp.js → Grid01-DshI78vi.js} +1 -1
  19. package/dist/client/assets/{Home02-C9yoONyT.js → Home02-BCiKvL0o.js} +1 -1
  20. package/dist/client/assets/{Image01-BIunU3ME.js → Image01-BR8oz0fK.js} +1 -1
  21. package/dist/client/assets/{Inbox01-Dn_ZLwmj.js → Inbox01-DqHW7WgR.js} +1 -1
  22. package/dist/client/assets/{InfoCircle-p3x1ZyEw.js → InfoCircle-zJUw_W0n.js} +1 -1
  23. package/dist/client/assets/{Key01-Bycaiiyx.js → Key01-Bzha2Tgh.js} +1 -1
  24. package/dist/client/assets/{LinkExternal01-DQ9drSdh.js → LinkExternal01-ybeItDxA.js} +1 -1
  25. package/dist/client/assets/{List-BeVMnZSE.js → List-B7BO0eBJ.js} +1 -1
  26. package/dist/client/assets/{Loading01-DCWQbhnz.js → Loading01-BpkkTLVp.js} +1 -1
  27. package/dist/client/assets/{Lock01-Cnn8kQG1.js → Lock01-D4BGdzZt.js} +1 -1
  28. package/dist/client/assets/{Pin01-WkOPKnTb.js → Pin01-DnWh89mj.js} +1 -1
  29. package/dist/client/assets/{Play-D6BmScpI.js → Play-COkFzcB7.js} +1 -1
  30. package/dist/client/assets/{Plus-CG8dB40n.js → Plus-8ovTaJHc.js} +1 -1
  31. package/dist/client/assets/{SearchMd-BWXZ4bVC.js → SearchMd-SRsVDK9N.js} +1 -1
  32. package/dist/client/assets/{Share07-DSoplUP9.js → Share07-6unHB4nq.js} +1 -1
  33. package/dist/client/assets/{Terminal-CdMAejVo.js → Terminal--fMComVX.js} +1 -1
  34. package/dist/client/assets/{Tool01-BDUyIGto.js → Tool01-BZbzIS2w.js} +1 -1
  35. package/dist/client/assets/{Trash01-C_hJOK44.js → Trash01-BhWwFORM.js} +1 -1
  36. package/dist/client/assets/{Upload01-CnMM-V_T.js → Upload01-B2SsaI_Z.js} +1 -1
  37. package/dist/client/assets/{Users03-DkIVbHWT.js → Users03-8GhqNBdf.js} +1 -1
  38. package/dist/client/assets/{X-8UbCzOSY.js → X-BNK0mLul.js} +1 -1
  39. package/dist/client/assets/{XClose-BDdig6o8.js → XClose-CxBh99Dw.js} +1 -1
  40. package/dist/client/assets/{agent-connections-preview-CC_R-LrZ.js → agent-connections-preview-C9hG7NOc.js} +1 -1
  41. package/dist/client/assets/{agent-detail-yfEWcbsQ.js → agent-detail-2FW7R_Kw.js} +1 -1
  42. package/dist/client/assets/{agents-BLmykWZD.js → agents-DLxYaiBc.js} +1 -1
  43. package/dist/client/assets/{alert-dialog-CHAGlLFb.js → alert-dialog-Cg14vDvh.js} +1 -1
  44. package/dist/client/assets/{auth-catchall-B-Mu7VlE.js → auth-catchall-oZsZy72p.js} +1 -1
  45. package/dist/client/assets/{badge-BMiZ-mom.js → badge-tO1xwt4d.js} +1 -1
  46. package/dist/client/assets/{binder-DC5jbVcK.js → binder-_fA_QfCQ.js} +1 -1
  47. package/dist/client/assets/{breadcrumb-BjHn0dWR.js → breadcrumb-B1KWdwh9.js} +1 -1
  48. package/dist/client/assets/{button-nyR0JH2l.js → button-CWzK0IXA.js} +1 -1
  49. package/dist/client/assets/{card-DVnhjUGd.js → card-uLixd1BQ.js} +1 -1
  50. package/dist/client/assets/{checkbox-TpL0D3NW.js → checkbox-B81riJiI.js} +1 -1
  51. package/dist/client/assets/{circle-alert-D0fEJodr.js → circle-alert-CChO7Clp.js} +1 -1
  52. package/dist/client/assets/{collapsible-DJK4gRv1.js → collapsible-C_w2O0ke.js} +1 -1
  53. package/dist/client/assets/{collection-detail-GbUt_XKS.js → collection-detail-DWdOXH1z.js} +1 -1
  54. package/dist/client/assets/{collection-search-DgJbkAZh.js → collection-search-jBfTOehF.js} +1 -1
  55. package/dist/client/assets/{collection-tab-BTzm3KZ6.js → collection-tab-B_8SPzV6.js} +1 -1
  56. package/dist/client/assets/{collection-table-wrapper-Ad_-F1tG.js → collection-table-wrapper-DtjpsgWF.js} +1 -1
  57. package/dist/client/assets/{collection-tabs-UYd1fkoS.js → collection-tabs-JS9xYoKs.js} +1 -1
  58. package/dist/client/assets/{connect-BCgu89pq.js → connect-qqRP-4pj.js} +1 -1
  59. package/dist/client/assets/{connection-card-ByjFlujM.js → connection-card-CYM4Wn_Y.js} +1 -1
  60. package/dist/client/assets/{connection-detail-CuLe29i_.js → connection-detail-DY6ai_fO.js} +1 -1
  61. package/dist/client/assets/{connections-BKV3JOBI.js → connections-C29FK0Jd.js} +1 -1
  62. package/dist/client/assets/constants-Chp3RuVB.js +1 -0
  63. package/dist/client/assets/constants-DUMQK_Jq.js +1 -0
  64. package/dist/client/assets/{create-organization-dialog-WB_1M15V.js → create-organization-dialog-CNKyQgDY.js} +1 -1
  65. package/dist/client/assets/{dialog-DobMZv-a.js → dialog-BiNw4dY-.js} +1 -1
  66. package/dist/client/assets/{dropdown-menu-BUrC7H_I.js → dropdown-menu-D0wZWcOa.js} +1 -1
  67. package/dist/client/assets/{dynamic-plugin-layout-yJKJv0tx.js → dynamic-plugin-layout-6AKBQQJO.js} +1 -1
  68. package/dist/client/assets/{empty-state-C0f9rz3s.js → empty-state-DrSUCtH7.js} +1 -1
  69. package/dist/client/assets/{empty-state-Z8nGys2S.js → empty-state-yKA0Dnoy.js} +1 -1
  70. package/dist/client/assets/{env-vars-editor-CGiYkoF6.js → env-vars-editor-BXoRftCH.js} +1 -1
  71. package/dist/client/assets/{error-boundary-_n4elsYx.js → error-boundary-DMzArMGc.js} +1 -1
  72. package/dist/client/assets/{extract-connection-data-DS_2GbRy.js → extract-connection-data-Cegvn5cS.js} +1 -1
  73. package/dist/client/assets/{file-browser-BQ5LNDAg.js → file-browser-CJvaY_Ab.js} +2 -2
  74. package/dist/client/assets/{form-8XJyhmpO.js → form-3eNCom8C.js} +1 -1
  75. package/dist/client/assets/{grid-view-D_Aa-emn.js → grid-view-DBknMzh4.js} +1 -1
  76. package/dist/client/assets/{home-uc024wOV.js → home-D-rgYO4-.js} +1 -1
  77. package/dist/client/assets/{index-BQzGssjd.js → index-6SKae0YQ.js} +1 -1
  78. package/dist/client/assets/{index-ZeDSkwHv.js → index-8f9n1Jea.js} +2 -2
  79. package/dist/client/assets/{index-Dl8GoNj7.js → index-BLFsiDnl.js} +1 -1
  80. package/dist/client/assets/{index--OStx8iM.js → index-Bgvel9yL.js} +1 -1
  81. package/dist/client/assets/{index-BAZLm9w0.js → index-DkVMZPZp.js} +2 -2
  82. package/dist/client/assets/{index-Diri8Ct6.js → index-DyvOt7HW.js} +1 -1
  83. package/dist/client/assets/{index-LE1qlbhg.js → index-ssfNqXSw.js} +1 -1
  84. package/dist/client/assets/{infiniteQueryObserver-yv2IwJ75.js → infiniteQueryObserver-BRy8d1pq.js} +1 -1
  85. package/dist/client/assets/{input-DHWQboe4.js → input-BKM3goZw.js} +1 -1
  86. package/dist/client/assets/{layout-DsaX6gcJ.js → layout-B7iU_InR.js} +1 -1
  87. package/dist/client/assets/{localstorage-keys-Ciabbhpd.js → localstorage-keys-DVhuzRr7.js} +1 -1
  88. package/dist/client/assets/{login-BoFTpuW0.js → login-BWXaWv5V.js} +1 -1
  89. package/dist/client/assets/{mcp-oauth-Cik_32Ma.js → mcp-oauth-D7Oz8tNV.js} +1 -1
  90. package/dist/client/assets/{mcp-server-card-C9lXz3j7.js → mcp-server-card-CfIOHPGJ.js} +1 -1
  91. package/dist/client/assets/{mcp-server-detail-CKjLUZ8-.js → mcp-server-detail-C78CCQ6k.js} +2 -2
  92. package/dist/client/assets/{members-B7KaOevg.js → members-duFQ3ptf.js} +1 -1
  93. package/dist/client/assets/{monaco-editor-CyfxpBLo.js → monaco-editor-DcchC01p.js} +1 -1
  94. package/dist/client/assets/{monitoring-71UNkDku.js → monitoring-B7FviaI2.js} +1 -1
  95. package/dist/client/assets/{oauth-callback-B66O8BPw.js → oauth-callback-Cr23Dy5V.js} +1 -1
  96. package/dist/client/assets/{page-CJ03HOIm.js → page-Ad6Sa48d.js} +1 -1
  97. package/dist/client/assets/{page-BTGK2JIy.js → page-D37Vnx0X.js} +1 -1
  98. package/dist/client/assets/{plugin-empty-state-Dn9tQuRR.js → plugin-empty-state-b364WWC7.js} +1 -1
  99. package/dist/client/assets/{plugin-header-CNqlEglT.js → plugin-header-Cf8zeBUs.js} +1 -1
  100. package/dist/client/assets/{plugins-Vjr6K9Js.js → plugins-BH2WU-Ku.js} +1 -1
  101. package/dist/client/assets/{popover-CZsr9YrL.js → popover-C0G-pXcc.js} +1 -1
  102. package/dist/client/assets/{registry-utils-DGqTJkDv.js → registry-utils-DFPURwxl.js} +1 -1
  103. package/dist/client/assets/{resizable-kmnSMXLy.js → resizable-DQrwcKJh.js} +1 -1
  104. package/dist/client/assets/{select-CrjtUXd1.js → select-Df9aMNs1.js} +1 -1
  105. package/dist/client/assets/{settings-BupAfFFs.js → settings-C0Akd5oR.js} +1 -1
  106. package/dist/client/assets/shell-layout-pk6n67Pv.js +12 -0
  107. package/dist/client/assets/{spinner-CQdhmUjg.js → spinner-D8NZVmaU.js} +1 -1
  108. package/dist/client/assets/{store-invite-C-ESgBdT.js → store-invite-B2dM3aW8.js} +1 -1
  109. package/dist/client/assets/{switch-DT-s9pj3.js → switch-Cv7KL0jJ.js} +1 -1
  110. package/dist/client/assets/{table-oiEqEhps.js → table-CWx1lOcJ.js} +1 -1
  111. package/dist/client/assets/{textarea-wjx2NJJH.js → textarea-BQ5-74yh.js} +1 -1
  112. package/dist/client/assets/{tools-list-BIhDDkg5.js → tools-list-BIQssT5E.js} +1 -1
  113. package/dist/client/assets/{typewriter-title-BfWKHlUW.js → typewriter-title-f-tG2rqy.js} +1 -1
  114. package/dist/client/assets/{use-binding-C5bwm3GP.js → use-binding-CDLcDLTQ.js} +1 -1
  115. package/dist/client/assets/{use-connection-k5RUrkjP.js → use-connection-BNgYG_2P.js} +1 -1
  116. package/dist/client/assets/{use-create-virtual-mcp-BfrhVnN1.js → use-create-virtual-mcp-DkV_YHpf.js} +1 -1
  117. package/dist/client/assets/{use-deco-chat-open-BwQGL7z_.js → use-deco-chat-open-LwA291qT.js} +1 -1
  118. package/dist/client/assets/{use-list-state-CCCWL8bD.js → use-list-state-BfUltaaz.js} +1 -1
  119. package/dist/client/assets/{use-mcp-prompts-DeryV1GR.js → use-mcp-prompts-CHXMWYZ1.js} +1 -1
  120. package/dist/client/assets/{use-members-Brv-Zo51.js → use-members-BfS3S-UM.js} +1 -1
  121. package/dist/client/assets/{use-mobile-MoR_lOMO.js → use-mobile-BXQipnb5.js} +1 -1
  122. package/dist/client/assets/{use-organization-settings-DtbIWln6.js → use-organization-settings-DZiQDtex.js} +1 -1
  123. package/dist/client/assets/{use-virtual-mcp-DfnzITXx.js → use-virtual-mcp-CEZ5nKxx.js} +1 -1
  124. package/dist/client/assets/useInfiniteQuery-Do9q2S3P.js +1 -0
  125. package/dist/client/assets/{useMutation-ffySYpQB.js → useMutation-CFQDhqDA.js} +1 -1
  126. package/dist/client/assets/useQuery-BSKCoFrF.js +1 -0
  127. package/dist/client/assets/{view-mode-toggle-DsKf8ZTT.js → view-mode-toggle-Cz9APct2.js} +1 -1
  128. package/dist/client/assets/{workflow-BxPDjOre.js → workflow-CfBvHdI5.js} +1 -1
  129. package/dist/client/index.html +1 -1
  130. package/package.json +1 -1
  131. package/dist/client/assets/constants-CJQnv32m.js +0 -1
  132. package/dist/client/assets/constants-DpsR0LZe.js +0 -1
  133. package/dist/client/assets/shell-layout-Ckg9pQSt.js +0 -12
  134. package/dist/client/assets/useInfiniteQuery-5yIodymH.js +0 -1
  135. package/dist/client/assets/useQuery-Da0DsMDg.js +0 -1
@@ -1 +1 @@
1
- import{r as k,c as T,j as t}from"./index-BAZLm9w0.js";import{c as y,B as L}from"./button-nyR0JH2l.js";import{c as E,a as V,D as B,b as $}from"./dropdown-menu-BUrC7H_I.js";import{i as D}from"./ArrowUp-BzVEz2lB.js";import{i as R}from"./Check-Dzm8t_lx.js";import{c as H}from"./Grid01-DB4psHwp.js";import{i as W}from"./List-BeVMnZSE.js";import{c as I,b as K,T as _,a as A}from"./empty-state-Z8nGys2S.js";import{V as O}from"./view-mode-toggle-DsKf8ZTT.js";import{T as P,a as q,b as z,c as F,d as G,e as J}from"./table-oiEqEhps.js";const S=({size:p=24,color:e="currentColor",...s})=>k.createElement("svg",{viewBox:"0 0 24 24",width:p,height:p,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},k.createElement("path",{d:"M12 5v14m0 0 7-7m-7 7-7-7"}));S.displayName="ArrowDown";const M=({size:p=24,color:e="currentColor",...s})=>k.createElement("svg",{viewBox:"0 0 24 24",width:p,height:p,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},k.createElement("path",{d:"M5 21v-7m0-4V3m7 18v-9m0-4V3m7 18v-5m0-4V3M2 14h6m1-6h6m1 8h6"}));M.displayName="Sliders01";function ie(p){const e=T.c(16),{viewMode:s,onViewModeChange:x,sortKey:u,sortDirection:d,onSort:a,sortOptions:i}=p;let l;e[0]!==i?(l=i===void 0?[]:i,e[0]=i,e[1]=l):l=e[1];const m=l;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(I,{children:t.jsxs(K,{children:[t.jsx(_,{asChild:!0,children:t.jsx(V,{asChild:!0,children:t.jsx(L,{variant:"outline",size:"icon",className:"size-7 border border-input",children:t.jsx(M,{size:16})})})}),t.jsx(A,{children:"Search filters"})]})}),e[2]=h):h=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c={value:"table",icon:t.jsx(W,{})},e[3]=c):c=e[3];let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=[c,{value:"cards",icon:t.jsx(H,{})}],e[4]=r):r=e[4];let o;e[5]!==x||e[6]!==s?(o=t.jsx("div",{className:"p-2 border-b border-border",children:t.jsx(O,{value:s,onValueChange:x,fullWidth:!0,options:r})}),e[5]=x,e[6]=s,e[7]=o):o=e[7];let f;e[8]!==a||e[9]!==d||e[10]!==u||e[11]!==m?(f=m.length>0&&a&&t.jsxs("div",{className:"p-1 flex flex-col gap-0.5",children:[t.jsx("div",{className:"px-2 py-1.5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Sort by"}),m.map(j=>{const w=u===j.id;return t.jsx(E,{onClick:()=>a(j.id),className:y("h-8 px-2 py-0 cursor-pointer",w&&"bg-accent"),children:t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[w&&t.jsx(R,{size:16,className:"text-foreground shrink-0"}),!w&&t.jsx("div",{className:"w-4 shrink-0"}),t.jsx("span",{className:"text-sm text-foreground flex-1",children:j.label}),w&&d&&(d==="asc"?t.jsx(D,{size:16,className:"text-foreground shrink-0"}):t.jsx(S,{size:16,className:"text-foreground shrink-0"}))]})},j.id)})]}),e[8]=a,e[9]=d,e[10]=u,e[11]=m,e[12]=f):f=e[12];let g;return e[13]!==o||e[14]!==f?(g=t.jsxs(B,{children:[h,t.jsxs($,{align:"end",className:"w-[200px] p-0 gap-0",children:[o,f]})]}),e[13]=o,e[14]=f,e[15]=g):g=e[15],g}function Q(p){const e=T.c(29),{columns:s,data:x,sortKey:u,sortDirection:d,onSort:a,onRowClick:i,rowClassName:l}=p;let m;e[0]!==d?(m=function(n,N){return t.jsx("div",{className:"w-4 flex items-center justify-center",children:N&&d&&(d==="asc"?t.jsx(D,{size:16,className:"text-muted-foreground transition-colors"}):t.jsx(S,{size:16,className:"text-muted-foreground transition-colors"}))})},e[0]=d,e[1]=m):m=e[1];const h=m;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=function(n,N){let C="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider";return n===N-1&&(C="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider w-8"),C},e[2]=c):c=e[2];const r=c;let o;if(e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==u){let b;e[8]!==s.length||e[9]!==a||e[10]!==h||e[11]!==u?(b=(n,N)=>{const C=u===n.id;return t.jsx(P,{className:y(r(N,s.length),"group transition-colors select-none",n.sortable&&"hover:bg-accent cursor-pointer",n.rowClassName,n.cellClassName),onClick:n.sortable&&a?()=>a(n.id):void 0,children:t.jsxs("span",{className:"flex items-center gap-1",children:[n.header,n.sortable&&h(n.id,C)]})},n.id)},e[8]=s.length,e[9]=a,e[10]=h,e[11]=u,e[12]=b):b=e[12],o=s.map(b),e[3]=s,e[4]=a,e[5]=h,e[6]=u,e[7]=o}else o=e[7];let f;e[13]!==o?(f=t.jsx(q,{className:"border-b-0",children:t.jsx(z,{className:"h-9 hover:bg-transparent border-b border-border",children:o})}),e[13]=o,e[14]=f):f=e[14];let g;if(e[15]!==s||e[16]!==x||e[17]!==i||e[18]!==l){let b;e[20]!==s||e[21]!==i||e[22]!==l?(b=(n,N)=>{const C=l?.(n);return t.jsx(z,{"data-row-index":N,className:y("group/data-row transition-colors border-b-0 hover:bg-accent/50",i?"cursor-pointer":"",C),onClick:i?()=>i(n):void 0,children:s.map(v=>t.jsx(F,{className:y("px-5 py-4 h-16 align-middle text-sm text-foreground",v.cellClassName,v.wrap?"whitespace-normal wrap-break-word":""),children:t.jsx("div",{className:y(v.wrap?"w-full":"min-w-0 w-full",!v.wrap&&"truncate overflow-hidden whitespace-nowrap"),children:v.render?v.render(n):v.accessor?v.accessor(n):null})},v.id))},N)},e[20]=s,e[21]=i,e[22]=l,e[23]=b):b=e[23],g=x.map(b),e[15]=s,e[16]=x,e[17]=i,e[18]=l,e[19]=g}else g=e[19];let j;e[24]!==g?(j=t.jsx(G,{children:g}),e[24]=g,e[25]=j):j=e[25];let w;return e[26]!==f||e[27]!==j?(w=t.jsxs(J,{className:"w-full border-collapse",children:[f,j]}),e[26]=f,e[27]=j,e[28]=w):w=e[28],w}function ae(p){const e=T.c(12),{columns:s,data:x,isLoading:u,sortKey:d,sortDirection:a,onSort:i,onRowClick:l,emptyState:m}=p;if(u===void 0?!1:u){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}),e[0]=r):r=e[0],r}if(x.length===0){let r;e[1]!==m?(r=m||t.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No items found"}),e[1]=m,e[2]=r):r=e[2];let o;return e[3]!==r?(o=t.jsx("div",{className:"flex items-center justify-center h-full",children:r}),e[3]=r,e[4]=o):o=e[4],o}let c;return e[5]!==s||e[6]!==x||e[7]!==l||e[8]!==i||e[9]!==a||e[10]!==d?(c=t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx(Q,{columns:s,data:x,sortKey:d,sortDirection:a,onSort:i,onRowClick:l})}),e[5]=s,e[6]=x,e[7]=l,e[8]=i,e[9]=a,e[10]=d,e[11]=c):c=e[11],c}export{ie as C,ae as a};
1
+ import{r as k,c as T,j as t}from"./index-DkVMZPZp.js";import{c as y,B as L}from"./button-CWzK0IXA.js";import{c as E,a as V,D as B,b as $}from"./dropdown-menu-D0wZWcOa.js";import{i as D}from"./ArrowUp-NpHWyg3u.js";import{i as R}from"./Check-hF_kXZiK.js";import{c as H}from"./Grid01-DshI78vi.js";import{i as W}from"./List-B7BO0eBJ.js";import{c as I,b as K,T as _,a as A}from"./empty-state-yKA0Dnoy.js";import{V as O}from"./view-mode-toggle-Cz9APct2.js";import{T as P,a as q,b as z,c as F,d as G,e as J}from"./table-CWx1lOcJ.js";const S=({size:p=24,color:e="currentColor",...s})=>k.createElement("svg",{viewBox:"0 0 24 24",width:p,height:p,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},k.createElement("path",{d:"M12 5v14m0 0 7-7m-7 7-7-7"}));S.displayName="ArrowDown";const M=({size:p=24,color:e="currentColor",...s})=>k.createElement("svg",{viewBox:"0 0 24 24",width:p,height:p,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},k.createElement("path",{d:"M5 21v-7m0-4V3m7 18v-9m0-4V3m7 18v-5m0-4V3M2 14h6m1-6h6m1 8h6"}));M.displayName="Sliders01";function ie(p){const e=T.c(16),{viewMode:s,onViewModeChange:x,sortKey:u,sortDirection:d,onSort:a,sortOptions:i}=p;let l;e[0]!==i?(l=i===void 0?[]:i,e[0]=i,e[1]=l):l=e[1];const m=l;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(I,{children:t.jsxs(K,{children:[t.jsx(_,{asChild:!0,children:t.jsx(V,{asChild:!0,children:t.jsx(L,{variant:"outline",size:"icon",className:"size-7 border border-input",children:t.jsx(M,{size:16})})})}),t.jsx(A,{children:"Search filters"})]})}),e[2]=h):h=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c={value:"table",icon:t.jsx(W,{})},e[3]=c):c=e[3];let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=[c,{value:"cards",icon:t.jsx(H,{})}],e[4]=r):r=e[4];let o;e[5]!==x||e[6]!==s?(o=t.jsx("div",{className:"p-2 border-b border-border",children:t.jsx(O,{value:s,onValueChange:x,fullWidth:!0,options:r})}),e[5]=x,e[6]=s,e[7]=o):o=e[7];let f;e[8]!==a||e[9]!==d||e[10]!==u||e[11]!==m?(f=m.length>0&&a&&t.jsxs("div",{className:"p-1 flex flex-col gap-0.5",children:[t.jsx("div",{className:"px-2 py-1.5 text-xs font-mono font-normal text-muted-foreground uppercase tracking-wide",children:"Sort by"}),m.map(j=>{const w=u===j.id;return t.jsx(E,{onClick:()=>a(j.id),className:y("h-8 px-2 py-0 cursor-pointer",w&&"bg-accent"),children:t.jsxs("div",{className:"flex items-center gap-2 w-full",children:[w&&t.jsx(R,{size:16,className:"text-foreground shrink-0"}),!w&&t.jsx("div",{className:"w-4 shrink-0"}),t.jsx("span",{className:"text-sm text-foreground flex-1",children:j.label}),w&&d&&(d==="asc"?t.jsx(D,{size:16,className:"text-foreground shrink-0"}):t.jsx(S,{size:16,className:"text-foreground shrink-0"}))]})},j.id)})]}),e[8]=a,e[9]=d,e[10]=u,e[11]=m,e[12]=f):f=e[12];let g;return e[13]!==o||e[14]!==f?(g=t.jsxs(B,{children:[h,t.jsxs($,{align:"end",className:"w-[200px] p-0 gap-0",children:[o,f]})]}),e[13]=o,e[14]=f,e[15]=g):g=e[15],g}function Q(p){const e=T.c(29),{columns:s,data:x,sortKey:u,sortDirection:d,onSort:a,onRowClick:i,rowClassName:l}=p;let m;e[0]!==d?(m=function(n,N){return t.jsx("div",{className:"w-4 flex items-center justify-center",children:N&&d&&(d==="asc"?t.jsx(D,{size:16,className:"text-muted-foreground transition-colors"}):t.jsx(S,{size:16,className:"text-muted-foreground transition-colors"}))})},e[0]=d,e[1]=m):m=e[1];const h=m;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=function(n,N){let C="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider";return n===N-1&&(C="px-4 py-2 text-left font-mono font-normal text-muted-foreground text-[11px] h-9 uppercase tracking-wider w-8"),C},e[2]=c):c=e[2];const r=c;let o;if(e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==u){let b;e[8]!==s.length||e[9]!==a||e[10]!==h||e[11]!==u?(b=(n,N)=>{const C=u===n.id;return t.jsx(P,{className:y(r(N,s.length),"group transition-colors select-none",n.sortable&&"hover:bg-accent cursor-pointer",n.rowClassName,n.cellClassName),onClick:n.sortable&&a?()=>a(n.id):void 0,children:t.jsxs("span",{className:"flex items-center gap-1",children:[n.header,n.sortable&&h(n.id,C)]})},n.id)},e[8]=s.length,e[9]=a,e[10]=h,e[11]=u,e[12]=b):b=e[12],o=s.map(b),e[3]=s,e[4]=a,e[5]=h,e[6]=u,e[7]=o}else o=e[7];let f;e[13]!==o?(f=t.jsx(q,{className:"border-b-0",children:t.jsx(z,{className:"h-9 hover:bg-transparent border-b border-border",children:o})}),e[13]=o,e[14]=f):f=e[14];let g;if(e[15]!==s||e[16]!==x||e[17]!==i||e[18]!==l){let b;e[20]!==s||e[21]!==i||e[22]!==l?(b=(n,N)=>{const C=l?.(n);return t.jsx(z,{"data-row-index":N,className:y("group/data-row transition-colors border-b-0 hover:bg-accent/50",i?"cursor-pointer":"",C),onClick:i?()=>i(n):void 0,children:s.map(v=>t.jsx(F,{className:y("px-5 py-4 h-16 align-middle text-sm text-foreground",v.cellClassName,v.wrap?"whitespace-normal wrap-break-word":""),children:t.jsx("div",{className:y(v.wrap?"w-full":"min-w-0 w-full",!v.wrap&&"truncate overflow-hidden whitespace-nowrap"),children:v.render?v.render(n):v.accessor?v.accessor(n):null})},v.id))},N)},e[20]=s,e[21]=i,e[22]=l,e[23]=b):b=e[23],g=x.map(b),e[15]=s,e[16]=x,e[17]=i,e[18]=l,e[19]=g}else g=e[19];let j;e[24]!==g?(j=t.jsx(G,{children:g}),e[24]=g,e[25]=j):j=e[25];let w;return e[26]!==f||e[27]!==j?(w=t.jsxs(J,{className:"w-full border-collapse",children:[f,j]}),e[26]=f,e[27]=j,e[28]=w):w=e[28],w}function ae(p){const e=T.c(12),{columns:s,data:x,isLoading:u,sortKey:d,sortDirection:a,onSort:i,onRowClick:l,emptyState:m}=p;if(u===void 0?!1:u){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading..."})}),e[0]=r):r=e[0],r}if(x.length===0){let r;e[1]!==m?(r=m||t.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"No items found"}),e[1]=m,e[2]=r):r=e[2];let o;return e[3]!==r?(o=t.jsx("div",{className:"flex items-center justify-center h-full",children:r}),e[3]=r,e[4]=o):o=e[4],o}let c;return e[5]!==s||e[6]!==x||e[7]!==l||e[8]!==i||e[9]!==a||e[10]!==d?(c=t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx(Q,{columns:s,data:x,sortKey:d,sortDirection:a,onSort:i,onRowClick:l})}),e[5]=s,e[6]=x,e[7]=l,e[8]=i,e[9]=a,e[10]=d,e[11]=c):c=e[11],c}export{ie as C,ae as a};
@@ -1 +1 @@
1
- import{c as x,j as u}from"./index-BAZLm9w0.js";import{c as m}from"./button-nyR0JH2l.js";import{B as g}from"./badge-BMiZ-mom.js";function v(f){const e=x.c(12),{tabs:l,activeTab:n,onTabChange:s,className:a}=f;let t;e[0]!==a?(t=m("flex items-center gap-2 overflow-x-auto no-scrollbar",a),e[0]=a,e[1]=t):t=e[1];let r;if(e[2]!==n||e[3]!==s||e[4]!==l){let c;e[6]!==n||e[7]!==s?(c=o=>{const d=n===o.id;return u.jsxs("button",{type:"button",onClick:()=>s(o.id),className:m("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex gap-1.5 items-center",d&&"bg-accent border-border text-foreground",!d&&"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:[o.label,o.count!==void 0&&u.jsx(g,{variant:"secondary",className:m("h-5 min-w-5 px-1 rounded-full text-[10px] font-mono inline-flex items-center justify-center",d?"bg-background text-foreground":"bg-muted-foreground/10 text-muted-foreground"),children:o.count})]},o.id)},e[6]=n,e[7]=s,e[8]=c):c=e[8],r=l.map(c),e[2]=n,e[3]=s,e[4]=l,e[5]=r}else r=e[5];let i;return e[9]!==t||e[10]!==r?(i=u.jsx("div",{className:t,children:r}),e[9]=t,e[10]=r,e[11]=i):i=e[11],i}export{v as C};
1
+ import{c as x,j as u}from"./index-DkVMZPZp.js";import{c as m}from"./button-CWzK0IXA.js";import{B as g}from"./badge-tO1xwt4d.js";function v(f){const e=x.c(12),{tabs:l,activeTab:n,onTabChange:s,className:a}=f;let t;e[0]!==a?(t=m("flex items-center gap-2 overflow-x-auto no-scrollbar",a),e[0]=a,e[1]=t):t=e[1];let r;if(e[2]!==n||e[3]!==s||e[4]!==l){let c;e[6]!==n||e[7]!==s?(c=o=>{const d=n===o.id;return u.jsxs("button",{type:"button",onClick:()=>s(o.id),className:m("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex gap-1.5 items-center",d&&"bg-accent border-border text-foreground",!d&&"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:[o.label,o.count!==void 0&&u.jsx(g,{variant:"secondary",className:m("h-5 min-w-5 px-1 rounded-full text-[10px] font-mono inline-flex items-center justify-center",d?"bg-background text-foreground":"bg-muted-foreground/10 text-muted-foreground"),children:o.count})]},o.id)},e[6]=n,e[7]=s,e[8]=c):c=e[8],r=l.map(c),e[2]=n,e[3]=s,e[4]=l,e[5]=r}else r=e[5];let i;return e[9]!==t||e[10]!==r?(i=u.jsx("div",{className:t,children:r}),e[9]=t,e[10]=r,e[11]=i):i=e[11],i}export{v as C};
@@ -1 +1 @@
1
- import{c as T,bm as M,j as e,bn as P,F as q,r as R,t as h,a as O}from"./index-BAZLm9w0.js";import{u as A}from"./useQuery-Da0DsMDg.js";import{u as _}from"./useMutation-ffySYpQB.js";import{B as y}from"./button-nyR0JH2l.js";import{C as N,a as v}from"./card-DVnhjUGd.js";import{i as L,a as U}from"./mcp-oauth-Cik_32Ma.js";import{c as C,C as K,a as k}from"./circle-alert-D0fEJodr.js";const Q=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],D=C("external-link",Q);const H=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],w=C("loader-circle",H);const J=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],B=C("refresh-cw",J),Y=t=>{const n=T.c(6);let i;n[0]!==t?({...i}=t,n[0]=t,n[1]=i):i=n[1];const{theme:a}=M(),d=a===void 0?"system":a;let r;n[2]===Symbol.for("react.memo_cache_sentinel")?(r={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},n[2]=r):r=n[2];let m;return n[3]!==i||n[4]!==d?(m=e.jsx(P,{theme:d,className:"toaster group",style:r,...i}),n[3]=i,n[4]=d,n[5]=m):m=n[5],m},b={session:t=>["user-sandbox-session",t]};function V({sessionId:t,onComplete:n,onError:i}){const a=q(),[p,d]=R.useState(null),{data:r,isLoading:m,error:j}=A({queryKey:b.session(t),queryFn:async()=>{const s=await fetch(`/api/user-sandbox/sessions/${t}`);if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to load session")}return s.json()}}),F=_({mutationFn:async({appName:s,connectionId:o})=>{const l=await fetch(`/api/user-sandbox/sessions/${t}/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:s,connection_id:o})});if(!l.ok){const u=await l.json();throw new Error(u.error||"Configuration failed")}return l.json()},onSuccess:()=>{a.invalidateQueries({queryKey:b.session(t)})}}),x=_({mutationFn:async()=>{const s=await fetch(`/api/user-sandbox/sessions/${t}/complete`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to complete")}return s.json()},onSuccess:s=>{s.redirectUrl?window.location.href=s.redirectUrl:(h.success("Setup complete!"),a.invalidateQueries({queryKey:b.session(t)}),n?.({agentId:s.agentId,redirectUrl:s.redirectUrl}))},onError:s=>{const o=s instanceof Error?s:new Error("Failed to complete");h.error(o.message),i?.(o)}}),S=async s=>{d(s.app_name);try{const o=await fetch(`/api/user-sandbox/sessions/${t}/provision`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:s.app_name})});if(!o.ok){const g=await o.json();throw new Error(g.error||"Failed to provision connection")}const u=(await o.json()).connection_id;if(s.connection_type==="HTTP"||s.connection_type==="SSE"||s.connection_type==="Websocket"){const g=`/mcp/${u}`,z=await L({url:g,token:null});if(!z.isAuthenticated&&z.supportsOAuth){h.info("Opening authentication window...");const c=await U({connectionId:u,clientName:s.title,timeout:3e5});if(c.error)throw new Error(c.error);if(c.tokenInfo){const E=await fetch(`/api/connections/${u}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:c.tokenInfo.accessToken,refreshToken:c.tokenInfo.refreshToken,expiresIn:c.tokenInfo.expiresIn,scope:c.tokenInfo.scope,clientId:c.tokenInfo.clientId,clientSecret:c.tokenInfo.clientSecret,tokenEndpoint:c.tokenInfo.tokenEndpoint})});if(!E.ok){const $=await E.json().catch(()=>({}));throw new Error($.error||"Failed to save authentication tokens. Please try again.")}}}}await F.mutateAsync({appName:s.app_name,connectionId:u}),h.success(`${s.title} connected successfully`)}catch(o){console.error("Connection error:",o);const l=o instanceof Error?o:new Error("Failed to connect");h.error(l.message),i?.(l)}finally{d(null)}},I=r?.apps.every(s=>s.status.configured),f=r?.session.status==="completed";return m?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(w,{className:"size-8 animate-spin text-muted-foreground"})}):j?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(N,{className:"max-w-md w-full",children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[e.jsx("div",{className:"size-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(K,{className:"size-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Session Error"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:j instanceof Error?j.message:"Failed to load"})]})]})})})}):r?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Y,{}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-12",children:[e.jsxs("div",{className:"text-center mb-8",children:[r.template.icon&&e.jsx("div",{className:"size-16 mx-auto mb-4 rounded-xl bg-muted flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:r.template.icon,alt:"",className:"size-10 object-contain"})}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:r.template.title}),r.template.description&&e.jsx("p",{className:"text-muted-foreground mt-2",children:r.template.description})]}),f&&e.jsx(N,{className:"mb-6 border-green-500/20 bg-green-500/5",children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(k,{className:"size-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Setup Complete"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your integrations are ready to use."})]})]})})}),e.jsx("div",{className:"space-y-3",children:r.apps.map(s=>e.jsx(N,{children:e.jsx(v,{className:"py-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"size-10 rounded-lg bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:s.icon?e.jsx("img",{src:s.icon,alt:"",className:"size-6 object-contain"}):e.jsx("span",{className:"text-lg",children:"📦"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.status.configured?e.jsxs("span",{className:"text-green-600 dark:text-green-400 flex items-center gap-1",children:[e.jsx(k,{className:"size-3"})," Connected"]}):s.requires_oauth?"Requires authentication":"Ready to connect"})]}),!s.status.configured&&!f&&e.jsx(y,{size:"sm",onClick:()=>S(s),disabled:p!==null||x.isPending,children:p===s.app_name?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"size-4 mr-2 animate-spin"}),"Connecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"size-4 mr-2"}),"Connect"]})}),s.status.configured&&!f&&e.jsxs(y,{size:"sm",variant:"outline",onClick:()=>S(s),disabled:p!==null||x.isPending,children:[e.jsx(B,{className:"size-4 mr-2"}),"Reconnect"]}),f&&e.jsx("div",{className:"size-8 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(k,{className:"size-4 text-green-500"})})]})})},s.app_name))}),I&&!f&&e.jsx("div",{className:"mt-6",children:e.jsx(y,{className:"w-full",size:"lg",onClick:()=>x.mutate(),disabled:x.isPending,children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"size-4 mr-2 animate-spin"}),"Completing..."]}):"Complete Setup"})}),e.jsx("div",{className:"mt-8 pt-6 border-t text-center",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Session expires:"," ",new Date(r.session.expires_at).toLocaleString()]})})]})]}):null}function oe(){const t=T.c(3);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/connect/$sessionId"},t[0]=n):n=t[0];const{sessionId:i}=O(n);let a;return t[1]!==i?(a=e.jsx(V,{sessionId:i}),t[1]=i,t[2]=a):a=t[2],a}export{oe as default};
1
+ import{c as T,bm as M,j as e,bn as P,F as q,r as R,t as h,a as O}from"./index-DkVMZPZp.js";import{u as A}from"./useQuery-BSKCoFrF.js";import{u as _}from"./useMutation-CFQDhqDA.js";import{B as y}from"./button-CWzK0IXA.js";import{C as N,a as v}from"./card-uLixd1BQ.js";import{i as L,a as U}from"./mcp-oauth-D7Oz8tNV.js";import{c as C,C as K,a as k}from"./circle-alert-CChO7Clp.js";const Q=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],D=C("external-link",Q);const H=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],w=C("loader-circle",H);const J=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],B=C("refresh-cw",J),Y=t=>{const n=T.c(6);let i;n[0]!==t?({...i}=t,n[0]=t,n[1]=i):i=n[1];const{theme:a}=M(),d=a===void 0?"system":a;let r;n[2]===Symbol.for("react.memo_cache_sentinel")?(r={"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},n[2]=r):r=n[2];let m;return n[3]!==i||n[4]!==d?(m=e.jsx(P,{theme:d,className:"toaster group",style:r,...i}),n[3]=i,n[4]=d,n[5]=m):m=n[5],m},b={session:t=>["user-sandbox-session",t]};function V({sessionId:t,onComplete:n,onError:i}){const a=q(),[p,d]=R.useState(null),{data:r,isLoading:m,error:j}=A({queryKey:b.session(t),queryFn:async()=>{const s=await fetch(`/api/user-sandbox/sessions/${t}`);if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to load session")}return s.json()}}),F=_({mutationFn:async({appName:s,connectionId:o})=>{const l=await fetch(`/api/user-sandbox/sessions/${t}/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:s,connection_id:o})});if(!l.ok){const u=await l.json();throw new Error(u.error||"Configuration failed")}return l.json()},onSuccess:()=>{a.invalidateQueries({queryKey:b.session(t)})}}),x=_({mutationFn:async()=>{const s=await fetch(`/api/user-sandbox/sessions/${t}/complete`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to complete")}return s.json()},onSuccess:s=>{s.redirectUrl?window.location.href=s.redirectUrl:(h.success("Setup complete!"),a.invalidateQueries({queryKey:b.session(t)}),n?.({agentId:s.agentId,redirectUrl:s.redirectUrl}))},onError:s=>{const o=s instanceof Error?s:new Error("Failed to complete");h.error(o.message),i?.(o)}}),S=async s=>{d(s.app_name);try{const o=await fetch(`/api/user-sandbox/sessions/${t}/provision`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_name:s.app_name})});if(!o.ok){const g=await o.json();throw new Error(g.error||"Failed to provision connection")}const u=(await o.json()).connection_id;if(s.connection_type==="HTTP"||s.connection_type==="SSE"||s.connection_type==="Websocket"){const g=`/mcp/${u}`,z=await L({url:g,token:null});if(!z.isAuthenticated&&z.supportsOAuth){h.info("Opening authentication window...");const c=await U({connectionId:u,clientName:s.title,timeout:3e5});if(c.error)throw new Error(c.error);if(c.tokenInfo){const E=await fetch(`/api/connections/${u}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:c.tokenInfo.accessToken,refreshToken:c.tokenInfo.refreshToken,expiresIn:c.tokenInfo.expiresIn,scope:c.tokenInfo.scope,clientId:c.tokenInfo.clientId,clientSecret:c.tokenInfo.clientSecret,tokenEndpoint:c.tokenInfo.tokenEndpoint})});if(!E.ok){const $=await E.json().catch(()=>({}));throw new Error($.error||"Failed to save authentication tokens. Please try again.")}}}}await F.mutateAsync({appName:s.app_name,connectionId:u}),h.success(`${s.title} connected successfully`)}catch(o){console.error("Connection error:",o);const l=o instanceof Error?o:new Error("Failed to connect");h.error(l.message),i?.(l)}finally{d(null)}},I=r?.apps.every(s=>s.status.configured),f=r?.session.status==="completed";return m?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(w,{className:"size-8 animate-spin text-muted-foreground"})}):j?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(N,{className:"max-w-md w-full",children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[e.jsx("div",{className:"size-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(K,{className:"size-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Session Error"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:j instanceof Error?j.message:"Failed to load"})]})]})})})}):r?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Y,{}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-12",children:[e.jsxs("div",{className:"text-center mb-8",children:[r.template.icon&&e.jsx("div",{className:"size-16 mx-auto mb-4 rounded-xl bg-muted flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:r.template.icon,alt:"",className:"size-10 object-contain"})}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:r.template.title}),r.template.description&&e.jsx("p",{className:"text-muted-foreground mt-2",children:r.template.description})]}),f&&e.jsx(N,{className:"mb-6 border-green-500/20 bg-green-500/5",children:e.jsx(v,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"size-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(k,{className:"size-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Setup Complete"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your integrations are ready to use."})]})]})})}),e.jsx("div",{className:"space-y-3",children:r.apps.map(s=>e.jsx(N,{children:e.jsx(v,{className:"py-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"size-10 rounded-lg bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:s.icon?e.jsx("img",{src:s.icon,alt:"",className:"size-6 object-contain"}):e.jsx("span",{className:"text-lg",children:"📦"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.status.configured?e.jsxs("span",{className:"text-green-600 dark:text-green-400 flex items-center gap-1",children:[e.jsx(k,{className:"size-3"})," Connected"]}):s.requires_oauth?"Requires authentication":"Ready to connect"})]}),!s.status.configured&&!f&&e.jsx(y,{size:"sm",onClick:()=>S(s),disabled:p!==null||x.isPending,children:p===s.app_name?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"size-4 mr-2 animate-spin"}),"Connecting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"size-4 mr-2"}),"Connect"]})}),s.status.configured&&!f&&e.jsxs(y,{size:"sm",variant:"outline",onClick:()=>S(s),disabled:p!==null||x.isPending,children:[e.jsx(B,{className:"size-4 mr-2"}),"Reconnect"]}),f&&e.jsx("div",{className:"size-8 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(k,{className:"size-4 text-green-500"})})]})})},s.app_name))}),I&&!f&&e.jsx("div",{className:"mt-6",children:e.jsx(y,{className:"w-full",size:"lg",onClick:()=>x.mutate(),disabled:x.isPending,children:x.isPending?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"size-4 mr-2 animate-spin"}),"Completing..."]}):"Complete Setup"})}),e.jsx("div",{className:"mt-8 pt-6 border-t text-center",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Session expires:"," ",new Date(r.session.expires_at).toLocaleString()]})})]})]}):null}function oe(){const t=T.c(3);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/connect/$sessionId"},t[0]=n):n=t[0];const{sessionId:i}=O(n);let a;return t[1]!==i?(a=e.jsx(V,{sessionId:i}),t[1]=i,t[2]=a):a=t[2],a}export{oe as default};
@@ -1 +1 @@
1
- import{c as $,j as t}from"./index-BAZLm9w0.js";import{C as q}from"./card-DVnhjUGd.js";import{c as N}from"./button-nyR0JH2l.js";import{I as B}from"./empty-state-Z8nGys2S.js";function L(g){const e=$.c(46),{connection:s,onClick:C,headerActions:b,body:k,footer:y,className:I,size:A,fallbackIcon:w}=g,E=A===void 0?"md":A,i=E==="sm"?"p-4":"p-6",P=E==="sm"?"text-sm":"text-base",R=E==="sm"?"text-xs":"text-sm",S=C&&"hover:bg-muted/50";let l;e[0]!==I||e[1]!==S?(l=N("cursor-pointer transition-colors group overflow-hidden flex flex-col",S,I),e[0]=I,e[1]=S,e[2]=l):l=e[2];let o;e[3]!==i?(o=N("flex flex-col gap-4",i),e[3]=i,e[4]=o):o=e[4];let n;e[5]!==s.icon||e[6]!==s.title||e[7]!==w?(n=t.jsx(B,{icon:s.icon,name:s.title,size:"md",className:"shrink-0 shadow-sm",fallbackIcon:w}),e[5]=s.icon,e[6]=s.title,e[7]=w,e[8]=n):n=e[8];let c;e[9]!==b?(c=b&&t.jsx("div",{className:N("transition-opacity","opacity-0 group-hover:opacity-100"),onClick:F,children:b}),e[9]=b,e[10]=c):c=e[10];let r;e[11]!==c?(r=t.jsx("div",{className:"relative",children:c}),e[11]=c,e[12]=r):r=e[12];let a;e[13]!==n||e[14]!==r?(a=t.jsxs("div",{className:"flex items-start justify-between",children:[n,r]}),e[13]=n,e[14]=r,e[15]=a):a=e[15];let d;e[16]!==P?(d=N("font-medium text-foreground truncate",P),e[16]=P,e[17]=d):d=e[17];let m;e[18]!==s.title||e[19]!==d?(m=t.jsx("h3",{className:d,children:s.title}),e[18]=s.title,e[19]=d,e[20]=m):m=e[20];let f;e[21]!==R?(f=N("text-muted-foreground line-clamp-2",R),e[21]=R,e[22]=f):f=e[22];const _=s.description||"No description";let x;e[23]!==f||e[24]!==_?(x=t.jsx("p",{className:f,children:_}),e[23]=f,e[24]=_,e[25]=x):x=e[25];let p;e[26]!==m||e[27]!==x?(p=t.jsxs("div",{className:"flex flex-col gap-0",children:[m,x]}),e[26]=m,e[27]=x,e[28]=p):p=e[28];let h;e[29]!==k?(h=k&&t.jsx("div",{children:k}),e[29]=k,e[30]=h):h=e[30];let u;e[31]!==p||e[32]!==h||e[33]!==o||e[34]!==a?(u=t.jsxs("div",{className:o,children:[a,p,h]}),e[31]=p,e[32]=h,e[33]=o,e[34]=a,e[35]=u):u=e[35];let j;e[36]!==y||e[37]!==i?(j=y&&t.jsx("div",{className:"border-t border-border mt-auto",children:t.jsx("div",{className:N("h-14 flex items-center",i),onClick:D,children:y})}),e[36]=y,e[37]=i,e[38]=j):j=e[38];let v;e[39]!==u||e[40]!==j?(v=t.jsxs("div",{className:"flex flex-col flex-1",children:[u,j]}),e[39]=u,e[40]=j,e[41]=v):v=e[41];let z;return e[42]!==C||e[43]!==v||e[44]!==l?(z=t.jsx(q,{className:l,onClick:C,children:v}),e[42]=C,e[43]=v,e[44]=l,e[45]=z):z=e[45],z}function D(g){return g.stopPropagation()}function F(g){return g.stopPropagation()}export{L as C};
1
+ import{c as $,j as t}from"./index-DkVMZPZp.js";import{C as q}from"./card-uLixd1BQ.js";import{c as N}from"./button-CWzK0IXA.js";import{I as B}from"./empty-state-yKA0Dnoy.js";function L(g){const e=$.c(46),{connection:s,onClick:C,headerActions:b,body:k,footer:y,className:I,size:A,fallbackIcon:w}=g,E=A===void 0?"md":A,i=E==="sm"?"p-4":"p-6",P=E==="sm"?"text-sm":"text-base",R=E==="sm"?"text-xs":"text-sm",S=C&&"hover:bg-muted/50";let l;e[0]!==I||e[1]!==S?(l=N("cursor-pointer transition-colors group overflow-hidden flex flex-col",S,I),e[0]=I,e[1]=S,e[2]=l):l=e[2];let o;e[3]!==i?(o=N("flex flex-col gap-4",i),e[3]=i,e[4]=o):o=e[4];let n;e[5]!==s.icon||e[6]!==s.title||e[7]!==w?(n=t.jsx(B,{icon:s.icon,name:s.title,size:"md",className:"shrink-0 shadow-sm",fallbackIcon:w}),e[5]=s.icon,e[6]=s.title,e[7]=w,e[8]=n):n=e[8];let c;e[9]!==b?(c=b&&t.jsx("div",{className:N("transition-opacity","opacity-0 group-hover:opacity-100"),onClick:F,children:b}),e[9]=b,e[10]=c):c=e[10];let r;e[11]!==c?(r=t.jsx("div",{className:"relative",children:c}),e[11]=c,e[12]=r):r=e[12];let a;e[13]!==n||e[14]!==r?(a=t.jsxs("div",{className:"flex items-start justify-between",children:[n,r]}),e[13]=n,e[14]=r,e[15]=a):a=e[15];let d;e[16]!==P?(d=N("font-medium text-foreground truncate",P),e[16]=P,e[17]=d):d=e[17];let m;e[18]!==s.title||e[19]!==d?(m=t.jsx("h3",{className:d,children:s.title}),e[18]=s.title,e[19]=d,e[20]=m):m=e[20];let f;e[21]!==R?(f=N("text-muted-foreground line-clamp-2",R),e[21]=R,e[22]=f):f=e[22];const _=s.description||"No description";let x;e[23]!==f||e[24]!==_?(x=t.jsx("p",{className:f,children:_}),e[23]=f,e[24]=_,e[25]=x):x=e[25];let p;e[26]!==m||e[27]!==x?(p=t.jsxs("div",{className:"flex flex-col gap-0",children:[m,x]}),e[26]=m,e[27]=x,e[28]=p):p=e[28];let h;e[29]!==k?(h=k&&t.jsx("div",{children:k}),e[29]=k,e[30]=h):h=e[30];let u;e[31]!==p||e[32]!==h||e[33]!==o||e[34]!==a?(u=t.jsxs("div",{className:o,children:[a,p,h]}),e[31]=p,e[32]=h,e[33]=o,e[34]=a,e[35]=u):u=e[35];let j;e[36]!==y||e[37]!==i?(j=y&&t.jsx("div",{className:"border-t border-border mt-auto",children:t.jsx("div",{className:N("h-14 flex items-center",i),onClick:D,children:y})}),e[36]=y,e[37]=i,e[38]=j):j=e[38];let v;e[39]!==u||e[40]!==j?(v=t.jsxs("div",{className:"flex flex-col flex-1",children:[u,j]}),e[39]=u,e[40]=j,e[41]=v):v=e[41];let z;return e[42]!==C||e[43]!==v||e[44]!==l?(z=t.jsx(q,{className:l,onClick:C,children:v}),e[42]=C,e[43]=v,e[44]=l,e[45]=z):z=e[45],z}function D(g){return g.stopPropagation()}function F(g){return g.stopPropagation()}export{L as C};
@@ -1 +1 @@
1
- import{r as Y,c as U,j as n,w as Re,l as ht,u as pt,bA as tt,ac as Tt,p as Mt,bs as Ye,o as xt,b7 as Dt,bf as It,s as q,ad as nt,ae as At,a as Vt,f as $t,F as Ot,h as Ft,k as Wt,i as Et,t as _e,K as st}from"./index-BAZLm9w0.js";import{I as He,n as Lt,E as ve}from"./empty-state-Z8nGys2S.js";import{E as gt}from"./error-boundary-_n4elsYx.js";import{E as Rt,r as zt,e as bt}from"./env-vars-editor-CGiYkoF6.js";import{P as Ke,S as Xt}from"./index-Dl8GoNj7.js";import{b as Ut,a as Bt}from"./use-binding-C5bwm3GP.js";import{u as qt,S as Yt}from"./index-BQzGssjd.js";import{c as Qe,d as jt,j as Ht}from"./use-connection-k5RUrkjP.js";import{u as Kt}from"./constants-CJQnv32m.js";import{b as Qt,d as Jt}from"./use-mcp-prompts-DeryV1GR.js";import{a as Gt}from"./mcp-oauth-Cik_32Ma.js";import{b as ot,e as Zt,c as en,d as tn,B as nn,a as sn}from"./breadcrumb-BjHn0dWR.js";import{B as Be}from"./button-nyR0JH2l.js";import{C as on}from"./collection-tabs-UYd1fkoS.js";import{i as Le}from"./Loading01-DCWQbhnz.js";import{V as Je,a as rn}from"./layout-DsaX6gcJ.js";import{C as an}from"./collection-tab-BTzm3KZ6.js";import{B as qe}from"./badge-BMiZ-mom.js";import{D as cn,a as ln,b as dn,c as rt}from"./dropdown-menu-BUrC7H_I.js";import{F as J,a as un,b as G,d as K,f as Z,c as ne,e as mn}from"./form-8XJyhmpO.js";import{I as ee}from"./input-DHWQboe4.js";import{S as at,a as it,b as ct,c as lt,d as Q}from"./select-CrjtUXd1.js";import{i as yt}from"./CheckCircle-Dq1sA0pv.js";import{t as fn}from"./ChevronDown-Z3Dyyuvx.js";import{s as Fe}from"./Globe02-DudYvjwY.js";import{i as hn}from"./Terminal-CdMAejVo.js";import{s as pn}from"./Trash01-C_hJOK44.js";import{t as Ge}from"./Users03-DkIVbHWT.js";import{s as xn}from"./XClose-BDdig6o8.js";import{U as gn}from"./use-list-state-CCCWL8bD.js";import{b as bn,a as jn}from"./use-virtual-mcp-DfnzITXx.js";import{i as yn}from"./ChevronRight-DDdY_PC7.js";import{s as vn}from"./Plus-CG8dB40n.js";import{t as Ne,c as vt,d as Nn,m as dt,a as We}from"./differenceInSeconds-NQ4PDo0z.js";import{a as Nt,C as wt}from"./collection-table-wrapper-Ad_-F1tG.js";import{C as St}from"./collection-search-DgJbkAZh.js";import{C as _t}from"./card-DVnhjUGd.js";import{R as wn,T as Sn}from"./tools-list-BIhDDkg5.js";import"./Pin01-WkOPKnTb.js";import"./use-organization-settings-DtbIWln6.js";import"./useMutation-ffySYpQB.js";import"./binder-DC5jbVcK.js";import"./File06-Bwnj0Jvb.js";import"./Key01-Bycaiiyx.js";import"./constants-DpsR0LZe.js";import"./registry-utils-DGqTJkDv.js";import"./extract-connection-data-DS_2GbRy.js";import"./github-icon-Dp3wHhYE.js";import"./generate-id-Dyweu44Y.js";import"./index-Diri8Ct6.js";import"./circle-alert-D0fEJodr.js";import"./index-ZeDSkwHv.js";import"./X-8UbCzOSY.js";import"./collapsible-DJK4gRv1.js";import"./Code01-BWP8EmsE.js";import"./infiniteQueryObserver-yv2IwJ75.js";import"./localstorage-keys-Ciabbhpd.js";import"./useQuery-Da0DsMDg.js";import"./popover-CZsr9YrL.js";import"./Grid01-DB4psHwp.js";import"./Image01-BIunU3ME.js";import"./SearchMd-BWXZ4bVC.js";import"./spinner-CQdhmUjg.js";import"./dialog-DobMZv-a.js";import"./AlertCircle-CyK0Qw5h.js";import"./ArrowUp-BzVEz2lB.js";import"./Edit01-BObRJWWQ.js";import"./Check-Dzm8t_lx.js";import"./Copy01-C6IJYSqu.js";import"./monaco-editor-CyfxpBLo.js";import"./use-create-virtual-mcp-BfrhVnN1.js";import"./index-LE1qlbhg.js";import"./DotsVertical-BpzYqYSl.js";import"./empty-state-C0f9rz3s.js";import"./Inbox01-Dn_ZLwmj.js";import"./alert-dialog-CHAGlLFb.js";import"./use-mobile-MoR_lOMO.js";import"./List-BeVMnZSE.js";import"./view-mode-toggle-DsKf8ZTT.js";import"./table-oiEqEhps.js";const Ct=({size:t=24,color:e="currentColor",...s})=>Y.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},Y.createElement("path",{d:"M2 10s2.005-2.732 3.634-4.362A9 9 0 1 1 12 21a9.004 9.004 0 0 1-8.648-6.5M2 10V4m0 6h6"}));Ct.displayName="RefreshCcw01";let _n={};function Cn(){return _n}function ut(t){const e=Ne(t),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+t-+s}function Ze(t,...e){const s=vt.bind(null,t||e.find(o=>typeof o=="object"));return e.map(s)}function Ee(t,e){const s=+Ne(t)-+Ne(e);return s<0?-1:s>0?1:s}function Pn(t){return vt(t,Date.now())}function kn(t,e,s){const[o,r]=Ze(s?.in,t,e),c=o.getFullYear()-r.getFullYear(),i=o.getMonth()-r.getMonth();return c*12+i}function Tn(t,e){const s=Ne(t);return s.setHours(23,59,59,999),s}function Mn(t,e){const s=Ne(t),o=s.getMonth();return s.setFullYear(s.getFullYear(),o+1,0),s.setHours(23,59,59,999),s}function Dn(t,e){const s=Ne(t);return+Tn(s)==+Mn(s)}function In(t,e,s){const[o,r,c]=Ze(s?.in,t,t,e),i=Ee(r,c),l=Math.abs(kn(r,c));if(l<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-i*l);let m=Ee(r,c)===-i;Dn(o)&&l===1&&Ee(o,c)===1&&(m=!1);const d=i*(l-+m);return d===0?0:d}const An={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Vn=(t,e,s)=>{let o;const r=An[t];return typeof r=="string"?o=r:e===1?o=r.one:o=r.other.replace("{{count}}",e.toString()),s?.addSuffix?s.comparison&&s.comparison>0?"in "+o:o+" ago":o};function Ue(t){return(e={})=>{const s=e.width?String(e.width):t.defaultWidth;return t.formats[s]||t.formats[t.defaultWidth]}}const $n={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},On={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Fn={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wn={date:Ue({formats:$n,defaultWidth:"full"}),time:Ue({formats:On,defaultWidth:"full"}),dateTime:Ue({formats:Fn,defaultWidth:"full"})},En={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ln=(t,e,s,o)=>En[t];function Ce(t){return(e,s)=>{const o=s?.context?String(s.context):"standalone";let r;if(o==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,l=s?.width?String(s.width):i;r=t.formattingValues[l]||t.formattingValues[i]}else{const i=t.defaultWidth,l=s?.width?String(s.width):t.defaultWidth;r=t.values[l]||t.values[i]}const c=t.argumentCallback?t.argumentCallback(e):e;return r[c]}}const Rn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zn={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Xn={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Un={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Bn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},qn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Yn=(t,e)=>{const s=Number(t),o=s%100;if(o>20||o<10)switch(o%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},Hn={ordinalNumber:Yn,era:Ce({values:Rn,defaultWidth:"wide"}),quarter:Ce({values:zn,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Ce({values:Xn,defaultWidth:"wide"}),day:Ce({values:Un,defaultWidth:"wide"}),dayPeriod:Ce({values:Bn,defaultWidth:"wide",formattingValues:qn,defaultFormattingWidth:"wide"})};function Pe(t){return(e,s={})=>{const o=s.width,r=o&&t.matchPatterns[o]||t.matchPatterns[t.defaultMatchWidth],c=e.match(r);if(!c)return null;const i=c[0],l=o&&t.parsePatterns[o]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(l)?Qn(l,p=>p.test(i)):Kn(l,p=>p.test(i));let d;d=t.valueCallback?t.valueCallback(m):m,d=s.valueCallback?s.valueCallback(d):d;const x=e.slice(i.length);return{value:d,rest:x}}}function Kn(t,e){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e(t[s]))return s}function Qn(t,e){for(let s=0;s<t.length;s++)if(e(t[s]))return s}function Jn(t){return(e,s={})=>{const o=e.match(t.matchPattern);if(!o)return null;const r=o[0],c=e.match(t.parsePattern);if(!c)return null;let i=t.valueCallback?t.valueCallback(c[0]):c[0];i=s.valueCallback?s.valueCallback(i):i;const l=e.slice(r.length);return{value:i,rest:l}}}const Gn=/^(\d+)(th|st|nd|rd)?/i,Zn=/\d+/i,es={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ts={any:[/^b/i,/^(a|c)/i]},ns={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ss={any:[/1/i,/2/i,/3/i,/4/i]},os={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},rs={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},as={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},is={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},cs={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ls={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ds={ordinalNumber:Jn({matchPattern:Gn,parsePattern:Zn,valueCallback:t=>parseInt(t,10)}),era:Pe({matchPatterns:es,defaultMatchWidth:"wide",parsePatterns:ts,defaultParseWidth:"any"}),quarter:Pe({matchPatterns:ns,defaultMatchWidth:"wide",parsePatterns:ss,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Pe({matchPatterns:os,defaultMatchWidth:"wide",parsePatterns:rs,defaultParseWidth:"any"}),day:Pe({matchPatterns:as,defaultMatchWidth:"wide",parsePatterns:is,defaultParseWidth:"any"}),dayPeriod:Pe({matchPatterns:cs,defaultMatchWidth:"any",parsePatterns:ls,defaultParseWidth:"any"})},us={code:"en-US",formatDistance:Vn,formatLong:Wn,formatRelative:Ln,localize:Hn,match:ds,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ms(t,e,s){const o=Cn(),r=s?.locale??o.locale??us,c=2520,i=Ee(t,e);if(isNaN(i))throw new RangeError("Invalid time value");const l=Object.assign({},s,{addSuffix:s?.addSuffix,comparison:i}),[m,d]=Ze(s?.in,...i>0?[e,t]:[t,e]),x=Nn(d,m),p=(ut(d)-ut(m))/1e3,a=Math.round((x-p)/60);let g;if(a<2)return s?.includeSeconds?x<5?r.formatDistance("lessThanXSeconds",5,l):x<10?r.formatDistance("lessThanXSeconds",10,l):x<20?r.formatDistance("lessThanXSeconds",20,l):x<40?r.formatDistance("halfAMinute",0,l):x<60?r.formatDistance("lessThanXMinutes",1,l):r.formatDistance("xMinutes",1,l):a===0?r.formatDistance("lessThanXMinutes",1,l):r.formatDistance("xMinutes",a,l);if(a<45)return r.formatDistance("xMinutes",a,l);if(a<90)return r.formatDistance("aboutXHours",1,l);if(a<dt){const u=Math.round(a/60);return r.formatDistance("aboutXHours",u,l)}else{if(a<c)return r.formatDistance("xDays",1,l);if(a<We){const u=Math.round(a/dt);return r.formatDistance("xDays",u,l)}else if(a<We*2)return g=Math.round(a/We),r.formatDistance("aboutXMonths",g,l)}if(g=In(d,m),g<12){const u=Math.round(a/We);return r.formatDistance("xMonths",u,l)}else{const u=g%12,h=Math.trunc(g/12);return u<3?r.formatDistance("aboutXYears",h,l):u<9?r.formatDistance("overXYears",h,l):r.formatDistance("almostXYears",h+1,l)}}function fs(t,e){return ms(t,Pn(t),e)}function hs(t){const e=U.c(13),{virtualMcp:s,org:o}=t;let r;e[0]!==o||e[1]!==s.id?(r={org:o,agentId:s.id},e[0]=o,e[1]=s.id,e[2]=r):r=e[2];let c;e[3]!==s.icon||e[4]!==s.title?(c=s.icon?n.jsx("img",{src:s.icon,alt:s.title,className:"w-5 h-5 rounded-md object-cover shrink-0"}):n.jsx("div",{className:"w-8 h-8 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:n.jsx(Ge,{size:16,className:"text-primary"})}),e[3]=s.icon,e[4]=s.title,e[5]=c):c=e[5];let i;e[6]!==s.title?(i=n.jsx("span",{className:"flex-1 text-sm font-medium text-foreground truncate",children:s.title}),e[6]=s.title,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(yn,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors shrink-0"}),e[8]=l):l=e[8];let m;return e[9]!==r||e[10]!==c||e[11]!==i?(m=n.jsxs(ht,{to:"/$org/agents/$agentId",params:r,className:"flex items-center gap-3 p-2 pr-1 rounded-lg hover:bg-muted/50 transition-colors group",children:[c,i,l]}),e[9]=r,e[10]=c,e[11]=i,e[12]=m):m=e[12],m}function mt(t){const e=U.c(20),{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:l}=t,m=Re(),d=jn();let x;e[0]!==d.create||e[1]!==r||e[2]!==c||e[3]!==s||e[4]!==o||e[5]!==m||e[6]!==i?(x=async()=>{const u=await d.create.mutateAsync({title:`${o} Agent`,description:r??null,icon:c??null,status:"active",connections:[{connection_id:s,selected_tools:null,selected_resources:null,selected_prompts:null}]});m({to:"/$org/agents/$agentId",params:{org:i,agentId:u.id}})},e[0]=d.create,e[1]=r,e[2]=c,e[3]=s,e[4]=o,e[5]=m,e[6]=i,e[7]=x):x=e[7];const p=x;if(l){let u;e[8]!==d.create.isPending?(u=d.create.isPending?n.jsx(Le,{size:16,className:"animate-spin"}):n.jsx(vn,{size:16}),e[8]=d.create.isPending,e[9]=u):u=e[9];let h;return e[10]!==d.create.isPending||e[11]!==p||e[12]!==u?(h=n.jsx(Be,{variant:"ghost",className:"size-6 p-0",onClick:p,disabled:d.create.isPending,children:u}),e[10]=d.create.isPending,e[11]=p,e[12]=u,e[13]=h):h=e[13],h}let a;e[14]!==d.create.isPending?(a=d.create.isPending?n.jsx(Le,{className:"animate-spin text-muted-foreground"}):n.jsx(Ge,{className:"size-3 text-muted-foreground"}),e[14]=d.create.isPending,e[15]=a):a=e[15];let g;return e[16]!==d.create.isPending||e[17]!==p||e[18]!==a?(g=n.jsxs(Be,{variant:"outline",size:"sm",onClick:p,disabled:d.create.isPending,children:[a,"Create an agent"]}),e[16]=d.create.isPending,e[17]=p,e[18]=a,e[19]=g):g=e[19],g}function ps(t){const e=U.c(26),{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i}=t;let l;e[0]!==s?(l={filters:[{column:"connection_id",value:s}]},e[0]=s,e[1]=l):l=e[1];const m=bn(l);if(!(m.length>0)){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("h4",{className:"text-xs text-muted-foreground font-medium",children:"Use in your IDE"}),e[2]=h):h=e[2];let b;return e[3]!==r||e[4]!==c||e[5]!==s||e[6]!==o||e[7]!==i?(b=n.jsxs("div",{className:"p-5 flex items-center justify-between gap-3",children:[h,n.jsx(mt,{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:!1})]}),e[3]=r,e[4]=c,e[5]=s,e[6]=o,e[7]=i,e[8]=b):b=e[8],b}let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h4",{className:"text-xs text-muted-foreground font-medium",children:"Agents"}),e[9]=x):x=e[9];let p;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==o||e[14]!==i?(p=n.jsx("div",{className:"flex flex-col gap-1",children:n.jsxs("div",{className:"flex items-center justify-between",children:[x,n.jsx(mt,{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:!0})]})}),e[10]=r,e[11]=c,e[12]=s,e[13]=o,e[14]=i,e[15]=p):p=e[15];let a;if(e[16]!==i||e[17]!==m){let h;e[19]!==i?(h=b=>n.jsx(hs,{virtualMcp:b,org:i},b.id),e[19]=i,e[20]=h):h=e[20],a=m.map(h),e[16]=i,e[17]=m,e[18]=a}else a=e[18];let g;e[21]!==a?(g=n.jsx("div",{className:"flex flex-col gap-2",children:a}),e[21]=a,e[22]=g):g=e[22];let u;return e[23]!==p||e[24]!==g?(u=n.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[p,g]}),e[23]=p,e[24]=g,e[25]=u):u=e[25],u}function xs({form:t,connection:e,hasOAuthToken:s,onReauthenticate:o,onRemoveOAuth:r}){const c=tt({control:t.control,name:"ui_type"}),i=tt({control:t.control,name:"connection_url"}),{stdioEnabled:l}=Tt(),m=(()=>{if(typeof i!="string"||!i)return!1;try{const a=new URL(i);return a.hostname==="api.githubcopilot.com"&&a.pathname.replace(/\/+$/,"")==="/mcp"}catch{return!1}})(),d=l||e.connection_type==="STDIO",x=e.connection_type==="VIRTUAL",p=x?Mt(e.connection_url):null;return x?n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Type"}),n.jsxs("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:[n.jsx(Ge,{className:"w-4 h-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Virtual MCP"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"This connection references a Virtual MCP. Tools and resources are aggregated dynamically from the Virtual MCP's underlying connections."})]}),p&&n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Virtual MCP ID"}),n.jsx("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:n.jsx("code",{className:"text-sm text-muted-foreground",children:p})})]})]}):n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[n.jsx(J,{control:t.control,name:"ui_type",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Connection"}),c!=="NPX"&&c!=="STDIO"?n.jsxs("div",{className:"flex items-stretch rounded-lg border border-border overflow-hidden",children:[n.jsxs(at,{value:a.value,onValueChange:a.onChange,children:[n.jsx(K,{children:n.jsxs(it,{className:"h-10 w-auto min-w-[90px] border-0 rounded-none bg-muted/50 focus:ring-0 focus:ring-offset-0",children:[n.jsx(Fe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),n.jsx(ct,{})]})}),n.jsxs(lt,{children:[n.jsx(Q,{value:"HTTP",children:"HTTP"}),n.jsx(Q,{value:"SSE",children:"SSE"}),n.jsx(Q,{value:"Websocket",children:"Websocket"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Q,{value:"NPX",children:"NPX Package"}),n.jsx(Q,{value:"STDIO",children:"Custom Command"})]})]})]}),n.jsx("div",{className:"w-px bg-border"}),n.jsx(J,{control:t.control,name:"connection_url",render:({field:g})=>n.jsx(G,{className:"flex-1 min-w-0",children:n.jsx(K,{children:n.jsx(ee,{placeholder:"https://example.com/mcp",...g,value:g.value??"",className:"h-10 border-0 rounded-none focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent"})})})})]}):n.jsxs(at,{value:a.value,onValueChange:a.onChange,children:[n.jsx(K,{children:n.jsx(it,{className:"h-10",children:n.jsx(ct,{})})}),n.jsxs(lt,{children:[n.jsx(Q,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Q,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Q,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"Websocket"]})}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Q,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Lt,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Q,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(hn,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(Z,{})]})}),c==="NPX"&&n.jsx(J,{control:t.control,name:"npx_package",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"NPM Package"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"@perplexity-ai/mcp-server",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})}),c==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(J,{control:t.control,name:"stdio_command",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Command"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"node, bun, python...",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})}),n.jsx(J,{control:t.control,name:"stdio_args",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Arguments"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"arg1 arg2 --flag value",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Space-separated arguments"}),n.jsx(Z,{})]})})]}),n.jsx(J,{control:t.control,name:"stdio_cwd",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Working Directory"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"/path/to/project (optional)",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})})]}),(c==="NPX"||c==="STDIO")&&n.jsx(J,{control:t.control,name:"env_vars",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Environment Variables"}),n.jsx(K,{children:n.jsx(Rt,{value:a.value??[],onChange:a.onChange})}),n.jsx(Z,{})]})}),c!=="NPX"&&c!=="STDIO"&&n.jsx(J,{control:t.control,name:"connection_token",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:m?"GitHub Personal Access Token":"Token"}),s?n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(cn,{children:[n.jsx(ln,{asChild:!0,children:n.jsx("button",{type:"button",className:"inline-flex items-center gap-1.5 cursor-pointer",children:n.jsxs(qe,{variant:"success",className:"gap-1.5",children:[n.jsx(yt,{size:12}),"Authenticated via OAuth",n.jsx(fn,{size:12})]})})}),n.jsxs(dn,{align:"start",children:[n.jsxs(rt,{onClick:o,children:[n.jsx(Ct,{size:16}),"Re-authenticate"]}),n.jsxs(rt,{variant:"destructive",onClick:r,children:[n.jsx(pn,{size:16}),"Remove OAuth"]})]})]})}):e.connection_token&&a.value===null?n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"h-10 px-3 flex items-center rounded-lg border border-border bg-muted/50 text-muted-foreground font-mono text-sm",children:"••••••••••••••••"}),n.jsx("button",{type:"button",onClick:()=>a.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Clear and replace token",children:n.jsx(xn,{size:14,className:"text-muted-foreground"})})]}):n.jsxs(n.Fragment,{children:[n.jsx(K,{children:n.jsx(ee,{type:"password",placeholder:m?"Paste your GitHub PAT":"Enter access token...",...a,value:a.value||"",className:"h-10 rounded-lg"})}),m&&n.jsxs(mn,{children:["Create a PAT at"," ",n.jsx("a",{href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"github.com/settings/personal-access-tokens"})]})]}),n.jsx(Z,{})]})})]})}function gs(t){const e=U.c(43),{form:s,connection:o,isMCPAuthenticated:r,hasOAuthToken:c,onReauthenticate:i,onRemoveOAuth:l}=t,{org:m}=pt();let d;e[0]!==o.icon||e[1]!==o.title?(d=n.jsx(He,{icon:o.icon,name:o.title,size:"lg",className:"shadow-sm"}),e[0]=o.icon,e[1]=o.title,e[2]=d):d=e[2];let x;e[3]!==s.control?(x=n.jsxs("div",{className:"flex flex-col",children:[n.jsx(J,{control:s.control,name:"title",render:js}),n.jsx(J,{control:s.control,name:"description",render:bs})]}),e[3]=s.control,e[4]=x):x=e[4];let p;e[5]!==d||e[6]!==x?(p=n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[d,x]}),e[5]=d,e[6]=x,e[7]=p):p=e[7];let a;e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==i||e[12]!==l?(a=n.jsx(xs,{form:s,connection:o,hasOAuthToken:c,onReauthenticate:i,onRemoveOAuth:l}),e[8]=o,e[9]=s,e[10]=c,e[11]=i,e[12]=l,e[13]=a):a=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Status"}),e[14]=g):g=e[14];let u;e[15]!==r?(u=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[g,r?n.jsxs(qe,{variant:"success",className:"gap-1.5 bg-success-foreground text-success",children:[n.jsx(yt,{size:12}),"Connected"]}):n.jsx(qe,{variant:"outline",className:"text-muted-foreground",children:"Not connected"})]}),e[15]=r,e[16]=u):u=e[16];let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Created by"}),e[17]=h):h=e[17];let b;e[18]!==o.created_by?(b=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[h,n.jsx(gn,{id:o.created_by,size:"2xs"})]}),e[18]=o.created_by,e[19]=b):b=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Updated"}),e[20]=C):C=e[20];let v;e[21]!==o.updated_at?(v=o.updated_at?fs(new Date(o.updated_at),{addSuffix:!0}):"Unknown",e[21]=o.updated_at,e[22]=v):v=e[22];let j;e[23]!==v?(j=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[C,n.jsx("span",{className:"text-sm text-foreground",children:v})]}),e[23]=v,e[24]=j):j=e[24];let w;e[25]!==j||e[26]!==u||e[27]!==b?(w=n.jsxs("div",{className:"flex flex-col gap-2 p-5 border-b border-border",children:[u,b,j]}),e[25]=j,e[26]=u,e[27]=b,e[28]=w):w=e[28];let f;e[29]!==o.description||e[30]!==o.icon||e[31]!==o.id||e[32]!==o.title||e[33]!==m.slug?(f=n.jsx(ps,{connectionId:o.id,connectionTitle:o.title,connectionDescription:o.description,connectionIcon:o.icon,org:m.slug}),e[29]=o.description,e[30]=o.icon,e[31]=o.id,e[32]=o.title,e[33]=m.slug,e[34]=f):f=e[34];let P;e[35]!==w||e[36]!==f||e[37]!==p||e[38]!==a?(P=n.jsxs("div",{className:"flex flex-col h-full overflow-auto",children:[p,a,w,f]}),e[35]=w,e[36]=f,e[37]=p,e[38]=a,e[39]=P):P=e[39];let $;return e[40]!==s||e[41]!==P?($=n.jsx(un,{...s,children:P}),e[40]=s,e[41]=P,e[42]=$):$=e[42],$}function bs(t){const{field:e}=t;return n.jsxs(G,{className:"w-full space-y-0",children:[n.jsx(K,{children:n.jsx(ee,{...e,value:e.value||"",className:"h-auto py-0.5 text-base text-muted-foreground leading-6 px-2 -mx-2 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Add a description..."})}),n.jsx(Z,{})]})}function js(t){const{field:e}=t;return n.jsxs(G,{className:"flex-1 space-y-0",children:[n.jsx(K,{children:n.jsx(ee,{...e,className:"h-auto py-0.5 text-lg! font-medium leading-7 px-2 -mx-2 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Connection Name"})}),n.jsx(Z,{})]})}function ys(t){const e=U.c(42),{prompts:s,connectionId:o,org:r,connectionTitle:c,connectionIcon:i,onPromptClick:l,showToolbar:m,emptyMessage:d}=t,x=m===void 0?!0:m,p=d===void 0?"This connection doesn't have any prompts yet.":d,a=Re(),u=Ye().location.href,[h,b]=Y.useState(""),[C,v]=Y.useState("table"),[j,w]=Y.useState("name"),[f,P]=Y.useState("asc");let $;e[0]!==f||e[1]!==j?($=S=>{j===S?(P(_s),f==="desc"&&w(void 0)):(w(S),P("asc"))},e[0]=f,e[1]=j,e[2]=$):$=e[2];const T=$;let V;e[3]!==o||e[4]!==a||e[5]!==l||e[6]!==r?(V=S=>{l?l(S):o&&r&&a({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:r,connectionId:o,collectionName:"prompts",itemId:encodeURIComponent(S.name)}})},e[3]=o,e[4]=a,e[5]=l,e[6]=r,e[7]=V):V=e[7];const k=V;let O;if(e[8]!==s||e[9]!==h||e[10]!==f||e[11]!==j){const S=!s||s.length===0?[]:h.trim()?(()=>{const H=h.toLowerCase();return s.filter(B=>B.name.toLowerCase().includes(H)||B.description&&B.description.toLowerCase().includes(H))})():s;O=!j||!f?S:[...S].sort((H,B)=>{const se=H[j]||"",we=B[j]||"",te=String(se).localeCompare(String(we));return f==="asc"?te:-te}),e[8]=s,e[9]=h,e[10]=f,e[11]=j,e[12]=O}else O=e[12];const M=O;let X;e[13]===Symbol.for("react.memo_cache_sentinel")?(X=[{id:"name",header:"Name",render:Ss,sortable:!0},{id:"description",header:"Description",render:ws,cellClassName:"flex-1",sortable:!0}],e[13]=X):X=e[13];const N=X;let R;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=N.filter(Ns).map(vs),e[14]=R):R=e[14];const E=R;let I;e[15]!==i||e[16]!==c||e[17]!==T||e[18]!==x||e[19]!==f||e[20]!==j||e[21]!==u||e[22]!==C?(I=x&&n.jsxs(Je,{children:[n.jsx(wt,{viewMode:C,onViewModeChange:v,sortKey:j,sortDirection:f,onSort:T,sortOptions:E}),n.jsx(Ke,{title:c?`${c}: Prompts`:"Prompts",url:u,icon:i??"description"})]}),e[15]=i,e[16]=c,e[17]=T,e[18]=x,e[19]=f,e[20]=j,e[21]=u,e[22]=C,e[23]=I):I=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=S=>{S.key==="Escape"&&(b(""),S.target.blur())},e[24]=A):A=e[24];let D;e[25]!==h?(D=n.jsx(St,{value:h,onChange:b,placeholder:"Search prompts...",onKeyDown:A}),e[25]=h,e[26]=D):D=e[26];let y;e[27]!==p||e[28]!==k||e[29]!==T||e[30]!==h||e[31]!==f||e[32]!==j||e[33]!==M||e[34]!==C?(y=C==="cards"?n.jsx("div",{className:"flex-1 overflow-auto p-5",children:M.length===0?n.jsx(ve,{image:null,title:h?"No prompts found":"No prompts available",description:h?"Try adjusting your search terms":p}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:M.map(S=>n.jsx(_t,{className:"cursor-pointer transition-colors",onClick:()=>k(S),children:n.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[n.jsx(He,{icon:null,name:S.name,size:"md",className:"shrink-0 shadow-sm"}),n.jsxs("div",{className:"flex flex-col gap-0",children:[n.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:S.name}),n.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:S.description||"No description"})]})]})},S.name))})}):n.jsx(Nt,{columns:N,data:M,isLoading:!1,sortKey:j,sortDirection:f,onSort:T,onRowClick:S=>k(S),emptyState:n.jsx(ve,{image:null,title:h?"No prompts found":"No prompts available",description:h?"Try adjusting your search terms":p})}),e[27]=p,e[28]=k,e[29]=T,e[30]=h,e[31]=f,e[32]=j,e[33]=M,e[34]=C,e[35]=y):y=e[35];let F;e[36]!==D||e[37]!==y?(F=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[D,y]}),e[36]=D,e[37]=y,e[38]=F):F=e[38];let z;return e[39]!==F||e[40]!==I?(z=n.jsxs(n.Fragment,{children:[I,F]}),e[39]=F,e[40]=I,e[41]=z):z=e[41],z}function vs(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Ns(t){return t.sortable}function ws(t){return n.jsx("span",{className:"text-sm text-foreground",children:t.description||"—"})}function Ss(t){return n.jsx("span",{className:"text-sm font-medium font-mono text-foreground",children:t.name})}function _s(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Cs(t){const e=U.c(6),{prompts:s,connectionId:o,org:r}=t,c=Qe(o),i=c?.title,l=c?.icon;let m;return e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l?(m=n.jsx(ys,{prompts:s,connectionId:o,org:r,connectionTitle:i,connectionIcon:l}),e[0]=o,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=m):m=e[5],m}function Ps(t){const e=U.c(2),{repository:s}=t;let o;return e[0]!==s?(o=n.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:n.jsx(wn,{repository:s})}),e[0]=s,e[1]=o):o=e[1],o}function ks(t){const e=U.c(39),{resources:s,connectionTitle:o,connectionIcon:r,onResourceClick:c,showToolbar:i,emptyMessage:l}=t,m=i===void 0?!0:i,d=l===void 0?"This connection doesn't have any resources yet.":l,p=Ye().location.href,[a,g]=Y.useState(""),[u,h]=Y.useState("table"),[b,C]=Y.useState("name"),[v,j]=Y.useState("asc");let w;e[0]!==v||e[1]!==b?(w=y=>{b===y?(j($s),v==="desc"&&C(void 0)):(C(y),j("asc"))},e[0]=v,e[1]=b,e[2]=w):w=e[2];const f=w;let P;e[3]!==c?(P=y=>{c&&c(y)},e[3]=c,e[4]=P):P=e[4];const $=P;let T;if(e[5]!==s||e[6]!==a||e[7]!==v||e[8]!==b){const y=!s||s.length===0?[]:a.trim()?(()=>{const F=a.toLowerCase();return s.filter(z=>z.uri.toLowerCase().includes(F)||z.name&&z.name.toLowerCase().includes(F)||z.description&&z.description.toLowerCase().includes(F))})():s;T=!b||!v?y:[...y].sort((F,z)=>{const S=F[b]||"",H=z[b]||"",B=String(S).localeCompare(String(H));return v==="asc"?B:-B}),e[5]=s,e[6]=a,e[7]=v,e[8]=b,e[9]=T}else T=e[9];const V=T;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"name",header:"Name",render:Vs,sortable:!0},{id:"uri",header:"URI",render:As,sortable:!0},{id:"description",header:"Description",render:Is,cellClassName:"flex-1",sortable:!0},{id:"mimeType",header:"Type",render:Ds,sortable:!0}],e[10]=k):k=e[10];const O=k;let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=O.filter(Ms).map(Ts),e[11]=M):M=e[11];const X=M;let N;e[12]!==r||e[13]!==o||e[14]!==f||e[15]!==m||e[16]!==v||e[17]!==b||e[18]!==p||e[19]!==u?(N=m&&n.jsxs(Je,{children:[n.jsx(wt,{viewMode:u,onViewModeChange:h,sortKey:b,sortDirection:v,onSort:f,sortOptions:X}),n.jsx(Ke,{title:o?`${o}: Resources`:"Resources",url:p,icon:r??"folder"})]}),e[12]=r,e[13]=o,e[14]=f,e[15]=m,e[16]=v,e[17]=b,e[18]=p,e[19]=u,e[20]=N):N=e[20];let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=y=>{y.key==="Escape"&&(g(""),y.target.blur())},e[21]=R):R=e[21];let E;e[22]!==a?(E=n.jsx(St,{value:a,onChange:g,placeholder:"Search resources...",onKeyDown:R}),e[22]=a,e[23]=E):E=e[23];let I;e[24]!==d||e[25]!==$||e[26]!==f||e[27]!==a||e[28]!==v||e[29]!==b||e[30]!==V||e[31]!==u?(I=u==="cards"?n.jsx("div",{className:"flex-1 overflow-auto p-5",children:V.length===0?n.jsx(ve,{image:null,title:a?"No resources found":"No resources available",description:a?"Try adjusting your search terms":d}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(y=>n.jsx(_t,{className:"cursor-pointer transition-colors",onClick:()=>$(y),children:n.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[n.jsx(He,{icon:null,name:y.name||y.uri,size:"md",className:"shrink-0 shadow-sm"}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:y.name||y.uri}),n.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:y.uri}),y.description&&n.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:y.description})]})]})},y.uri))})}):n.jsx(Nt,{columns:O,data:V,isLoading:!1,sortKey:b,sortDirection:v,onSort:f,onRowClick:y=>$(y),emptyState:n.jsx(ve,{image:null,title:a?"No resources found":"No resources available",description:a?"Try adjusting your search terms":d})}),e[24]=d,e[25]=$,e[26]=f,e[27]=a,e[28]=v,e[29]=b,e[30]=V,e[31]=u,e[32]=I):I=e[32];let A;e[33]!==E||e[34]!==I?(A=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[E,I]}),e[33]=E,e[34]=I,e[35]=A):A=e[35];let D;return e[36]!==A||e[37]!==N?(D=n.jsxs(n.Fragment,{children:[N,A]}),e[36]=A,e[37]=N,e[38]=D):D=e[38],D}function Ts(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Ms(t){return t.sortable}function Ds(t){return n.jsx("span",{className:"text-sm text-muted-foreground",children:t.mimeType||"—"})}function Is(t){return n.jsx("span",{className:"text-sm text-foreground",children:t.description||"—"})}function As(t){return n.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:t.uri})}function Vs(t){return n.jsx("span",{className:"text-sm font-medium text-foreground",children:t.name||t.uri})}function $s(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Os(t){const e=U.c(6),{resources:s,connectionId:o,org:r}=t,c=Qe(o),i=c?.title,l=c?.icon;let m;return e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l?(m=n.jsx(ks,{resources:s,connectionId:o,org:r,connectionTitle:i,connectionIcon:l}),e[0]=o,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=m):m=e[5],m}const Fs=xt({key:q().min(1,"Key is required"),value:q()}),Ws=xt({title:q().min(1,"Name is required"),description:q().nullable().optional(),ui_type:At(["HTTP","SSE","Websocket","NPX","STDIO"]),connection_url:q().optional(),connection_token:q().nullable().optional(),npx_package:q().optional(),stdio_command:q().optional(),stdio_args:q().optional(),stdio_cwd:q().optional(),env_vars:nt(Fs).optional(),configuration_scopes:nt(q()).nullable().optional(),configuration_state:Dt(q(),It()).nullable().optional()}).refine(t=>t.ui_type==="NPX"?!!t.npx_package?.trim():!0,{message:"NPM package is required",path:["npx_package"]}).refine(t=>t.ui_type==="STDIO"?!!t.stdio_command?.trim():!0,{message:"Command is required",path:["stdio_command"]}).refine(t=>t.ui_type==="HTTP"||t.ui_type==="SSE"||t.ui_type==="Websocket"?!!t.connection_url?.trim():!0,{message:"URL is required",path:["connection_url"]});function Es(t){const e=U.c(5),{tools:s,connectionId:o,org:r,isLoading:c}=t;let i;return e[0]!==o||e[1]!==c||e[2]!==r||e[3]!==s?(i=n.jsx(Sn,{tools:s,connectionId:o,org:r,isLoading:c}),e[0]=o,e[1]=c,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function Ls(t){return t.command==="npx"}function Rs(t){return t.args?.find(e=>!e.startsWith("-"))??""}function zs(t){return{command:t.command,args:t.args?.join(" ")??"",cwd:t.cwd??""}}function Xs(t,e){const s={command:"npx",args:["-y",t]},o=bt(e);return Object.keys(o).length>0&&(s.envVars=o),s}function Us(t,e,s,o){const r={command:t};e.trim()&&(r.args=e.trim().split(/\s+/)),s?.trim()&&(r.cwd=s.trim());const c=bt(o);return Object.keys(c).length>0&&(r.envVars=c),r}function ft(t,e){const s={title:t.title,description:t.description??"",configuration_state:t.configuration_state??{},configuration_scopes:t.configuration_scopes||[]};if(t.connection_type==="STDIO"&&Et(t.connection_headers)){const o=t.connection_headers,r=zt(o.envVars);if(Ls(o)){const i=Rs(o);return{...s,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:i,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:r}}const c=zs(o);return{...s,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:c.command,stdio_args:c.args,stdio_cwd:c.cwd,env_vars:r}}return{...s,ui_type:t.connection_type,connection_url:t.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}function Bs(t){let e,s=null,o=null,r=null;return t.ui_type==="NPX"?(e="STDIO",s="",r=Xs(t.npx_package||"",t.env_vars||[])):t.ui_type==="STDIO"?(e="STDIO",s="",r=Us(t.stdio_command||"",t.stdio_args||"",t.stdio_cwd,t.env_vars||[])):(e=t.ui_type,s=t.connection_url||"",o=t.connection_token||null),{title:t.title,description:t.description||null,connection_type:e,connection_url:s,...o&&{connection_token:o},...r&&{connection_headers:r},configuration_state:t.configuration_state??null,configuration_scopes:t.configuration_scopes??null}}function qs(t){const e=U.c(117),{connection:s,connectionId:o,org:r,requestedTabId:c,collections:i,onUpdate:l,isUpdating:m,prompts:d,resources:x,tools:p,isLoadingTools:a}=t;let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={from:"/$org/mcps/$connectionId"},e[0]=g):g=e[0];const u=Re(g),h=Ot(),C=Ye().location.href,v=jt();let j;e[1]!==o?(j={connectionId:o},e[1]=o,e[2]=j):j=e[2];const w=qt(j),f=w.isAuthenticated;let P;e[3]!==s?(P={connections:[s],binding:"MCP"},e[3]=s,e[4]=P):P=e[4];const T=Bt(P).length>0,V=s?.metadata?.repository,k=!!V?.url;let O;e[5]===Symbol.for("react.memo_cache_sentinel")?(O=Ft(Ws),e[5]=O):O=e[5];let M;e[6]!==s?(M=ft(s),e[6]=s,e[7]=M):M=e[7];let X;e[8]!==M?(X={resolver:O,values:M},e[8]=M,e[9]=X):X=e[9];const N=Wt(X),R=N.formState.isDirty;let E;e[10]!==N||e[11]!==l?(E=async()=>{if(!await N.trigger())return;const L=N.getValues(),ye=Bs(L);await l(ye),N.reset(L)},e[10]=N,e[11]=l,e[12]=E):E=e[12];const I=E;let A;e[13]!==s||e[14]!==N?(A=()=>{N.reset(ft(s))},e[13]=s,e[14]=N,e[15]=A):A=e[15];const D=A;let y;e[16]!==s.id||e[17]!==v||e[18]!==h?(y=async()=>{const{token:_,tokenInfo:L,error:ye}=await Gt({connectionId:s.id});if(ye||!_){_e.error(`Authentication failed: ${ye}`);return}if(L)try{const Oe=await fetch(`/api/connections/${s.id}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})});if(!Oe.ok)console.error("Failed to save OAuth token:",await Oe.text()),await v.update.mutateAsync({id:s.id,data:{connection_token:_}});else try{await v.update.mutateAsync({id:s.id,data:{}})}catch(et){console.warn("Failed to refresh connection tools after OAuth:",et)}}catch(Oe){console.error("Error saving OAuth token:",Oe),await v.update.mutateAsync({id:s.id,data:{connection_token:_}})}else await v.update.mutateAsync({id:s.id,data:{connection_token:_}});const kt=new URL(`/mcp/${s.id}`,window.location.origin);await h.invalidateQueries({queryKey:st.isMCPAuthenticated(kt.href,null)}),_e.success("Authentication successful")},e[16]=s.id,e[17]=v,e[18]=h,e[19]=y):y=e[19];const F=y;let z;e[20]!==s.id||e[21]!==h?(z=async()=>{try{const _=await fetch(`/api/connections/${s.id}/oauth-token`,{method:"DELETE",credentials:"include"});if(!_.ok){const ye=await _.text();_e.error(`Failed to remove OAuth: ${ye}`);return}const L=new URL(`/mcp/${s.id}`,window.location.origin);await h.invalidateQueries({queryKey:st.isMCPAuthenticated(L.href,null)}),_e.success("OAuth removed. You can now re-authenticate with a different account.")}catch(_){console.error("Error removing OAuth token:",_),_e.error("Failed to remove OAuth")}},e[20]=s.id,e[21]=h,e[22]=z):z=e[22];const S=z,H=p.length,B=d.length,se=x.length,we=H>0||a;let te;e[23]===Symbol.for("react.memo_cache_sentinel")?(te={id:"settings",label:"Settings"},e[23]=te):te=e[23];let oe;e[24]!==a||e[25]!==f||e[26]!==we||e[27]!==H?(oe=f&&we?[{id:"tools",label:"Tools",count:a?void 0:H}]:[],e[24]=a,e[25]=f,e[26]=we,e[27]=H,e[28]=oe):oe=e[28];let re;e[29]!==f||e[30]!==B?(re=f&&B>0?[{id:"prompts",label:"Prompts",count:B}]:[],e[29]=f,e[30]=B,e[31]=re):re=e[31];let ae;e[32]!==f||e[33]!==se?(ae=f&&se>0?[{id:"resources",label:"Resources",count:se}]:[],e[32]=f,e[33]=se,e[34]=ae):ae=e[34];let ke;if(e[35]!==i||e[36]!==k||e[37]!==f||e[38]!==oe||e[39]!==re||e[40]!==ae){let _;e[42]!==k?(_=k?[{id:"readme",label:"README"}]:[],e[42]=k,e[43]=_):_=e[43],ke=[te,...oe,...re,...ae,...f?(i||[]).map(Hs):[],..._],e[35]=i,e[36]=k,e[37]=f,e[38]=oe,e[39]=re,e[40]=ae,e[41]=ke}else ke=e[41];const Se=ke,Pt=f&&Se.some(Ys)?"tools":"settings",W=Se.some(_=>_.id===c)?c:Pt;let Te;e[44]!==u?(Te=_=>{u({search:L=>({...L,tab:_}),replace:!0})},e[44]=u,e[45]=Te):Te=e[45];const ie=Te;let ce;e[46]!==i?(ce=i||[],e[46]=i,e[47]=ce):ce=e[47];let Me;if(e[48]!==W||e[49]!==ce){let _;e[51]!==W?(_=L=>L.name===W,e[51]=W,e[52]=_):_=e[52],Me=ce.find(_),e[48]=W,e[49]=ce,e[50]=Me}else Me=e[50];const De=Me;let le;e[53]!==r?(le=n.jsx(ot,{children:n.jsx(en,{asChild:!0,children:n.jsx(ht,{to:"/$org/mcps",params:{org:r},children:"Connections"})})}),e[53]=r,e[54]=le):le=e[54];let Ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(tn,{}),e[55]=Ie):Ie=e[55];let de;e[56]!==s.title?(de=n.jsx(ot,{children:n.jsx(Zt,{children:s.title})}),e[56]=s.title,e[57]=de):de=e[57];let Ae;e[58]!==le||e[59]!==de?(Ae=n.jsx(nn,{children:n.jsxs(sn,{children:[le,Ie,de]})}),e[58]=le,e[59]=de,e[60]=Ae):Ae=e[60];const ze=Ae;let ue;e[61]!==I||e[62]!==D||e[63]!==R||e[64]!==m?(ue=n.jsx(Xt,{onSave:I,onUndo:D,isDirty:R,isSaving:m}),e[61]=I,e[62]=D,e[63]=R,e[64]=m,e[65]=ue):ue=e[65];const Xe=s.icon??"settings";let me;e[66]!==s.title||e[67]!==Xe||e[68]!==C?(me=n.jsx(Ke,{title:s.title,url:C,icon:Xe}),e[66]=s.title,e[67]=Xe,e[68]=C,e[69]=me):me=e[69];let fe;e[70]!==ue||e[71]!==me?(fe=n.jsxs(Je,{children:[ue,me]}),e[70]=ue,e[71]=me,e[72]=fe):fe=e[72];let he;e[73]!==w.hasOAuthToken||e[74]!==s||e[75]!==N||e[76]!==F||e[77]!==S||e[78]!==f?(he=n.jsx("div",{className:"w-100 shrink-0 border-r border-border bg-background",children:n.jsx(gs,{form:N,connection:s,isMCPAuthenticated:f,hasOAuthToken:w.hasOAuthToken,onReauthenticate:F,onRemoveOAuth:S})}),e[73]=w.hasOAuthToken,e[74]=s,e[75]=N,e[76]=F,e[77]=S,e[78]=f,e[79]=he):he=e[79];let pe;e[80]!==W||e[81]!==ie||e[82]!==Se?(pe=n.jsx("div",{className:"shrink-0 flex items-center gap-4 px-5 py-3 border-b border-border",children:n.jsx(on,{tabs:Se,activeTab:W,onTabChange:ie,className:"flex-1"})}),e[80]=W,e[81]=ie,e[82]=Se,e[83]=pe):pe=e[83];let Ve;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ve=n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(Le,{size:32,className:"animate-spin text-muted-foreground"})}),e[84]=Ve):Ve=e[84];let xe;e[85]!==De||e[86]!==W||e[87]!==w.isServerError||e[88]!==w.supportsOAuth||e[89]!==s||e[90]!==o||e[91]!==N||e[92]!==F||e[93]!==ie||e[94]!==T||e[95]!==k||e[96]!==a||e[97]!==f||e[98]!==r||e[99]!==d||e[100]!==V||e[101]!==x||e[102]!==p?(xe=n.jsx(Y.Suspense,{fallback:Ve,children:W==="tools"?n.jsx(Es,{tools:p,connectionId:o,org:r,isLoading:a}):W==="prompts"?n.jsx(Cs,{prompts:d,connectionId:o,org:r}):W==="resources"?n.jsx(Os,{resources:x,connectionId:o,org:r}):W==="settings"?n.jsx(Yt,{connection:s,form:N,hasMcpBinding:T,isMCPAuthenticated:f,supportsOAuth:w.supportsOAuth,isServerError:w.isServerError,onAuthenticate:F,onViewReadme:k?()=>ie("readme"):void 0}):W==="readme"&&k?n.jsx(Ps,{repository:V}):De&&f?n.jsx(an,{connectionId:o,org:r,activeCollection:De},W):n.jsx(ve,{title:"Collection not found",description:"This collection may have been deleted or you may not have access."})}),e[85]=De,e[86]=W,e[87]=w.isServerError,e[88]=w.supportsOAuth,e[89]=s,e[90]=o,e[91]=N,e[92]=F,e[93]=ie,e[94]=T,e[95]=k,e[96]=a,e[97]=f,e[98]=r,e[99]=d,e[100]=V,e[101]=x,e[102]=p,e[103]=xe):xe=e[103];let ge;e[104]!==W||e[105]!==xe?(ge=n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(gt,{children:xe},W)}),e[104]=W,e[105]=xe,e[106]=ge):ge=e[106];let be;e[107]!==pe||e[108]!==ge?(be=n.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:[pe,ge]}),e[107]=pe,e[108]=ge,e[109]=be):be=e[109];let je;e[110]!==he||e[111]!==be?(je=n.jsxs("div",{className:"flex h-full w-full bg-background overflow-hidden",children:[he,be]}),e[110]=he,e[111]=be,e[112]=je):je=e[112];let $e;return e[113]!==ze||e[114]!==fe||e[115]!==je?($e=n.jsxs(rn,{breadcrumb:ze,children:[fe,je]}),e[113]=ze,e[114]=fe,e[115]=je,e[116]=$e):$e=e[116],$e}function Ys(t){return t.id==="tools"}function Hs(t){return{id:t.name,label:t.displayName}}function Ks(){const t=U.c(43);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/mcps/$connectionId"},t[0]=e):e=t[0];const s=Re(e);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={from:"/shell/$org/mcps/$connectionId"},t[1]=o):o=t[1];const{connectionId:r,org:c}=Vt(o),{org:i}=pt();let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={from:"/shell/$org/mcps/$connectionId"},t[2]=l):l=t[2];const d=$t(l).tab??"",x=Qe(r),p=jt(),a=Ut(x??void 0);let g;t[3]!==r||t[4]!==i.id?(g={connectionId:r,orgId:i.id},t[3]=r,t[4]=i.id,t[5]=g):g=t[5];const u=Kt(g);let h;t[6]!==u?(h={client:u},t[6]=u,t[7]=h):h=t[7];const{data:b}=Qt(h);let C;t[8]!==u?(C={client:u},t[8]=u,t[9]=C):C=t[9];const{data:v}=Jt(C),j=x?.tools&&x.tools.length>0,w=!j;let f;t[10]!==u||t[11]!==w?(f={client:u,enabled:w},t[10]=u,t[11]=w,t[12]=f):f=t[12];const{data:P,isLoading:$}=Ht(f);let T;t[13]!==b?.prompts?(T=b?.prompts??[],t[13]=b?.prompts,t[14]=T):T=t[14];let V;t[15]!==T?(V=T.map(Gs),t[15]=T,t[16]=V):V=t[16];const k=V;let O;t[17]!==v?.resources?(O=v?.resources??[],t[17]=v?.resources,t[18]=O):O=t[18];let M;t[19]!==O?(M=O.map(Js),t[19]=O,t[20]=M):M=t[20];const X=M;let N;t[21]!==x||t[22]!==j||t[23]!==P?.tools?(N=j?x.tools??[]:(P?.tools??[]).map(Qs),t[21]=x,t[22]=j,t[23]=P?.tools,t[24]=N):N=t[24];const R=N;let E;t[25]!==p.update||t[26]!==r?(E=async D=>{await p.update.mutateAsync({id:r,data:D})},t[25]=p.update,t[26]=r,t[27]=E):E=t[27];const I=E;if(!x){let D;return t[28]!==s||t[29]!==c?(D=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(ve,{title:"Connection not found",description:"This connection may have been deleted or you may not have access.",actions:n.jsx(Be,{variant:"outline",onClick:()=>s({to:"/$org/mcps",params:{org:c}}),children:"Back to connections"})})}),t[28]=s,t[29]=c,t[30]=D):D=t[30],D}let A;return t[31]!==p.update.isPending||t[32]!==a||t[33]!==x||t[34]!==r||t[35]!==I||t[36]!==$||t[37]!==c||t[38]!==k||t[39]!==d||t[40]!==X||t[41]!==R?(A=n.jsx(qs,{org:c,connection:x,connectionId:r,requestedTabId:d,collections:a,onUpdate:I,isUpdating:p.update.isPending,prompts:k,resources:X,tools:R,isLoadingTools:$}),t[31]=p.update.isPending,t[32]=a,t[33]=x,t[34]=r,t[35]=I,t[36]=$,t[37]=c,t[38]=k,t[39]=d,t[40]=X,t[41]=R,t[42]=A):A=t[42],A}function Qs(t){return{name:t.name,description:t.description,inputSchema:t.inputSchema}}function Js(t){return{uri:t.uri,name:t.name,description:t.description}}function Gs(t){return{name:t.name,description:t.description}}function Zs(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(gt,{children:n.jsx(Y.Suspense,{fallback:n.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:n.jsx(Le,{size:32,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ks,{})})}),t[0]=e):e=t[0],e}function kr(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Zs,{}),t[0]=e):e=t[0],e}export{kr as default};
1
+ import{r as Y,c as U,j as n,w as Re,l as ht,u as pt,bA as tt,ac as Tt,p as Mt,bs as Ye,o as xt,b7 as Dt,bf as It,s as q,ad as nt,ae as At,a as Vt,f as $t,F as Ot,h as Ft,k as Wt,i as Et,t as _e,K as st}from"./index-DkVMZPZp.js";import{I as He,n as Lt,E as ve}from"./empty-state-yKA0Dnoy.js";import{E as gt}from"./error-boundary-DMzArMGc.js";import{E as Rt,r as zt,e as bt}from"./env-vars-editor-BXoRftCH.js";import{P as Ke,S as Xt}from"./index-BLFsiDnl.js";import{b as Ut,a as Bt}from"./use-binding-CDLcDLTQ.js";import{u as qt,S as Yt}from"./index-6SKae0YQ.js";import{c as Qe,d as jt,j as Ht}from"./use-connection-BNgYG_2P.js";import{u as Kt}from"./constants-Chp3RuVB.js";import{b as Qt,d as Jt}from"./use-mcp-prompts-CHXMWYZ1.js";import{a as Gt}from"./mcp-oauth-D7Oz8tNV.js";import{b as ot,e as Zt,c as en,d as tn,B as nn,a as sn}from"./breadcrumb-B1KWdwh9.js";import{B as Be}from"./button-CWzK0IXA.js";import{C as on}from"./collection-tabs-JS9xYoKs.js";import{i as Le}from"./Loading01-BpkkTLVp.js";import{V as Je,a as rn}from"./layout-B7iU_InR.js";import{C as an}from"./collection-tab-B_8SPzV6.js";import{B as qe}from"./badge-tO1xwt4d.js";import{D as cn,a as ln,b as dn,c as rt}from"./dropdown-menu-D0wZWcOa.js";import{F as J,a as un,b as G,d as K,f as Z,c as ne,e as mn}from"./form-3eNCom8C.js";import{I as ee}from"./input-BKM3goZw.js";import{S as at,a as it,b as ct,c as lt,d as Q}from"./select-Df9aMNs1.js";import{i as yt}from"./CheckCircle-BIFyDkzk.js";import{t as fn}from"./ChevronDown-CwChLZoe.js";import{s as Fe}from"./Globe02-DqbzCrT0.js";import{i as hn}from"./Terminal--fMComVX.js";import{s as pn}from"./Trash01-BhWwFORM.js";import{t as Ge}from"./Users03-8GhqNBdf.js";import{s as xn}from"./XClose-CxBh99Dw.js";import{U as gn}from"./use-list-state-BfUltaaz.js";import{b as bn,a as jn}from"./use-virtual-mcp-CEZ5nKxx.js";import{i as yn}from"./ChevronRight-0gQ-Lwyj.js";import{s as vn}from"./Plus-8ovTaJHc.js";import{t as Ne,c as vt,d as Nn,m as dt,a as We}from"./differenceInSeconds-NQ4PDo0z.js";import{a as Nt,C as wt}from"./collection-table-wrapper-DtjpsgWF.js";import{C as St}from"./collection-search-jBfTOehF.js";import{C as _t}from"./card-uLixd1BQ.js";import{R as wn,T as Sn}from"./tools-list-BIQssT5E.js";import"./Pin01-DnWh89mj.js";import"./use-organization-settings-DZiQDtex.js";import"./useMutation-CFQDhqDA.js";import"./binder-_fA_QfCQ.js";import"./File06-CV2OmgsQ.js";import"./Key01-Bzha2Tgh.js";import"./constants-DUMQK_Jq.js";import"./registry-utils-DFPURwxl.js";import"./extract-connection-data-Cegvn5cS.js";import"./github-icon-Dp3wHhYE.js";import"./generate-id-Dyweu44Y.js";import"./index-DyvOt7HW.js";import"./circle-alert-CChO7Clp.js";import"./index-8f9n1Jea.js";import"./X-BNK0mLul.js";import"./collapsible-C_w2O0ke.js";import"./Code01-DSEEeIpb.js";import"./infiniteQueryObserver-BRy8d1pq.js";import"./localstorage-keys-DVhuzRr7.js";import"./useQuery-BSKCoFrF.js";import"./popover-C0G-pXcc.js";import"./Grid01-DshI78vi.js";import"./Image01-BR8oz0fK.js";import"./SearchMd-SRsVDK9N.js";import"./spinner-D8NZVmaU.js";import"./dialog-BiNw4dY-.js";import"./AlertCircle-C47UrlAO.js";import"./ArrowUp-NpHWyg3u.js";import"./Edit01-HUE0OI4J.js";import"./Check-hF_kXZiK.js";import"./Copy01-BY9LQ_eS.js";import"./monaco-editor-DcchC01p.js";import"./use-create-virtual-mcp-DkV_YHpf.js";import"./index-ssfNqXSw.js";import"./DotsVertical-CcQ5Tk1w.js";import"./empty-state-DrSUCtH7.js";import"./Inbox01-DqHW7WgR.js";import"./alert-dialog-Cg14vDvh.js";import"./use-mobile-BXQipnb5.js";import"./List-B7BO0eBJ.js";import"./view-mode-toggle-Cz9APct2.js";import"./table-CWx1lOcJ.js";const Ct=({size:t=24,color:e="currentColor",...s})=>Y.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},Y.createElement("path",{d:"M2 10s2.005-2.732 3.634-4.362A9 9 0 1 1 12 21a9.004 9.004 0 0 1-8.648-6.5M2 10V4m0 6h6"}));Ct.displayName="RefreshCcw01";let _n={};function Cn(){return _n}function ut(t){const e=Ne(t),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+t-+s}function Ze(t,...e){const s=vt.bind(null,t||e.find(o=>typeof o=="object"));return e.map(s)}function Ee(t,e){const s=+Ne(t)-+Ne(e);return s<0?-1:s>0?1:s}function Pn(t){return vt(t,Date.now())}function kn(t,e,s){const[o,r]=Ze(s?.in,t,e),c=o.getFullYear()-r.getFullYear(),i=o.getMonth()-r.getMonth();return c*12+i}function Tn(t,e){const s=Ne(t);return s.setHours(23,59,59,999),s}function Mn(t,e){const s=Ne(t),o=s.getMonth();return s.setFullYear(s.getFullYear(),o+1,0),s.setHours(23,59,59,999),s}function Dn(t,e){const s=Ne(t);return+Tn(s)==+Mn(s)}function In(t,e,s){const[o,r,c]=Ze(s?.in,t,t,e),i=Ee(r,c),l=Math.abs(kn(r,c));if(l<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-i*l);let m=Ee(r,c)===-i;Dn(o)&&l===1&&Ee(o,c)===1&&(m=!1);const d=i*(l-+m);return d===0?0:d}const An={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Vn=(t,e,s)=>{let o;const r=An[t];return typeof r=="string"?o=r:e===1?o=r.one:o=r.other.replace("{{count}}",e.toString()),s?.addSuffix?s.comparison&&s.comparison>0?"in "+o:o+" ago":o};function Ue(t){return(e={})=>{const s=e.width?String(e.width):t.defaultWidth;return t.formats[s]||t.formats[t.defaultWidth]}}const $n={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},On={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Fn={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Wn={date:Ue({formats:$n,defaultWidth:"full"}),time:Ue({formats:On,defaultWidth:"full"}),dateTime:Ue({formats:Fn,defaultWidth:"full"})},En={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ln=(t,e,s,o)=>En[t];function Ce(t){return(e,s)=>{const o=s?.context?String(s.context):"standalone";let r;if(o==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,l=s?.width?String(s.width):i;r=t.formattingValues[l]||t.formattingValues[i]}else{const i=t.defaultWidth,l=s?.width?String(s.width):t.defaultWidth;r=t.values[l]||t.values[i]}const c=t.argumentCallback?t.argumentCallback(e):e;return r[c]}}const Rn={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},zn={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Xn={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Un={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Bn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},qn={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Yn=(t,e)=>{const s=Number(t),o=s%100;if(o>20||o<10)switch(o%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},Hn={ordinalNumber:Yn,era:Ce({values:Rn,defaultWidth:"wide"}),quarter:Ce({values:zn,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Ce({values:Xn,defaultWidth:"wide"}),day:Ce({values:Un,defaultWidth:"wide"}),dayPeriod:Ce({values:Bn,defaultWidth:"wide",formattingValues:qn,defaultFormattingWidth:"wide"})};function Pe(t){return(e,s={})=>{const o=s.width,r=o&&t.matchPatterns[o]||t.matchPatterns[t.defaultMatchWidth],c=e.match(r);if(!c)return null;const i=c[0],l=o&&t.parsePatterns[o]||t.parsePatterns[t.defaultParseWidth],m=Array.isArray(l)?Qn(l,p=>p.test(i)):Kn(l,p=>p.test(i));let d;d=t.valueCallback?t.valueCallback(m):m,d=s.valueCallback?s.valueCallback(d):d;const x=e.slice(i.length);return{value:d,rest:x}}}function Kn(t,e){for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)&&e(t[s]))return s}function Qn(t,e){for(let s=0;s<t.length;s++)if(e(t[s]))return s}function Jn(t){return(e,s={})=>{const o=e.match(t.matchPattern);if(!o)return null;const r=o[0],c=e.match(t.parsePattern);if(!c)return null;let i=t.valueCallback?t.valueCallback(c[0]):c[0];i=s.valueCallback?s.valueCallback(i):i;const l=e.slice(r.length);return{value:i,rest:l}}}const Gn=/^(\d+)(th|st|nd|rd)?/i,Zn=/\d+/i,es={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ts={any:[/^b/i,/^(a|c)/i]},ns={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ss={any:[/1/i,/2/i,/3/i,/4/i]},os={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},rs={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},as={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},is={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},cs={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ls={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ds={ordinalNumber:Jn({matchPattern:Gn,parsePattern:Zn,valueCallback:t=>parseInt(t,10)}),era:Pe({matchPatterns:es,defaultMatchWidth:"wide",parsePatterns:ts,defaultParseWidth:"any"}),quarter:Pe({matchPatterns:ns,defaultMatchWidth:"wide",parsePatterns:ss,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Pe({matchPatterns:os,defaultMatchWidth:"wide",parsePatterns:rs,defaultParseWidth:"any"}),day:Pe({matchPatterns:as,defaultMatchWidth:"wide",parsePatterns:is,defaultParseWidth:"any"}),dayPeriod:Pe({matchPatterns:cs,defaultMatchWidth:"any",parsePatterns:ls,defaultParseWidth:"any"})},us={code:"en-US",formatDistance:Vn,formatLong:Wn,formatRelative:Ln,localize:Hn,match:ds,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ms(t,e,s){const o=Cn(),r=s?.locale??o.locale??us,c=2520,i=Ee(t,e);if(isNaN(i))throw new RangeError("Invalid time value");const l=Object.assign({},s,{addSuffix:s?.addSuffix,comparison:i}),[m,d]=Ze(s?.in,...i>0?[e,t]:[t,e]),x=Nn(d,m),p=(ut(d)-ut(m))/1e3,a=Math.round((x-p)/60);let g;if(a<2)return s?.includeSeconds?x<5?r.formatDistance("lessThanXSeconds",5,l):x<10?r.formatDistance("lessThanXSeconds",10,l):x<20?r.formatDistance("lessThanXSeconds",20,l):x<40?r.formatDistance("halfAMinute",0,l):x<60?r.formatDistance("lessThanXMinutes",1,l):r.formatDistance("xMinutes",1,l):a===0?r.formatDistance("lessThanXMinutes",1,l):r.formatDistance("xMinutes",a,l);if(a<45)return r.formatDistance("xMinutes",a,l);if(a<90)return r.formatDistance("aboutXHours",1,l);if(a<dt){const u=Math.round(a/60);return r.formatDistance("aboutXHours",u,l)}else{if(a<c)return r.formatDistance("xDays",1,l);if(a<We){const u=Math.round(a/dt);return r.formatDistance("xDays",u,l)}else if(a<We*2)return g=Math.round(a/We),r.formatDistance("aboutXMonths",g,l)}if(g=In(d,m),g<12){const u=Math.round(a/We);return r.formatDistance("xMonths",u,l)}else{const u=g%12,h=Math.trunc(g/12);return u<3?r.formatDistance("aboutXYears",h,l):u<9?r.formatDistance("overXYears",h,l):r.formatDistance("almostXYears",h+1,l)}}function fs(t,e){return ms(t,Pn(t),e)}function hs(t){const e=U.c(13),{virtualMcp:s,org:o}=t;let r;e[0]!==o||e[1]!==s.id?(r={org:o,agentId:s.id},e[0]=o,e[1]=s.id,e[2]=r):r=e[2];let c;e[3]!==s.icon||e[4]!==s.title?(c=s.icon?n.jsx("img",{src:s.icon,alt:s.title,className:"w-5 h-5 rounded-md object-cover shrink-0"}):n.jsx("div",{className:"w-8 h-8 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:n.jsx(Ge,{size:16,className:"text-primary"})}),e[3]=s.icon,e[4]=s.title,e[5]=c):c=e[5];let i;e[6]!==s.title?(i=n.jsx("span",{className:"flex-1 text-sm font-medium text-foreground truncate",children:s.title}),e[6]=s.title,e[7]=i):i=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(yn,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors shrink-0"}),e[8]=l):l=e[8];let m;return e[9]!==r||e[10]!==c||e[11]!==i?(m=n.jsxs(ht,{to:"/$org/agents/$agentId",params:r,className:"flex items-center gap-3 p-2 pr-1 rounded-lg hover:bg-muted/50 transition-colors group",children:[c,i,l]}),e[9]=r,e[10]=c,e[11]=i,e[12]=m):m=e[12],m}function mt(t){const e=U.c(20),{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:l}=t,m=Re(),d=jn();let x;e[0]!==d.create||e[1]!==r||e[2]!==c||e[3]!==s||e[4]!==o||e[5]!==m||e[6]!==i?(x=async()=>{const u=await d.create.mutateAsync({title:`${o} Agent`,description:r??null,icon:c??null,status:"active",connections:[{connection_id:s,selected_tools:null,selected_resources:null,selected_prompts:null}]});m({to:"/$org/agents/$agentId",params:{org:i,agentId:u.id}})},e[0]=d.create,e[1]=r,e[2]=c,e[3]=s,e[4]=o,e[5]=m,e[6]=i,e[7]=x):x=e[7];const p=x;if(l){let u;e[8]!==d.create.isPending?(u=d.create.isPending?n.jsx(Le,{size:16,className:"animate-spin"}):n.jsx(vn,{size:16}),e[8]=d.create.isPending,e[9]=u):u=e[9];let h;return e[10]!==d.create.isPending||e[11]!==p||e[12]!==u?(h=n.jsx(Be,{variant:"ghost",className:"size-6 p-0",onClick:p,disabled:d.create.isPending,children:u}),e[10]=d.create.isPending,e[11]=p,e[12]=u,e[13]=h):h=e[13],h}let a;e[14]!==d.create.isPending?(a=d.create.isPending?n.jsx(Le,{className:"animate-spin text-muted-foreground"}):n.jsx(Ge,{className:"size-3 text-muted-foreground"}),e[14]=d.create.isPending,e[15]=a):a=e[15];let g;return e[16]!==d.create.isPending||e[17]!==p||e[18]!==a?(g=n.jsxs(Be,{variant:"outline",size:"sm",onClick:p,disabled:d.create.isPending,children:[a,"Create an agent"]}),e[16]=d.create.isPending,e[17]=p,e[18]=a,e[19]=g):g=e[19],g}function ps(t){const e=U.c(26),{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i}=t;let l;e[0]!==s?(l={filters:[{column:"connection_id",value:s}]},e[0]=s,e[1]=l):l=e[1];const m=bn(l);if(!(m.length>0)){let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("h4",{className:"text-xs text-muted-foreground font-medium",children:"Use in your IDE"}),e[2]=h):h=e[2];let b;return e[3]!==r||e[4]!==c||e[5]!==s||e[6]!==o||e[7]!==i?(b=n.jsxs("div",{className:"p-5 flex items-center justify-between gap-3",children:[h,n.jsx(mt,{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:!1})]}),e[3]=r,e[4]=c,e[5]=s,e[6]=o,e[7]=i,e[8]=b):b=e[8],b}let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h4",{className:"text-xs text-muted-foreground font-medium",children:"Agents"}),e[9]=x):x=e[9];let p;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==o||e[14]!==i?(p=n.jsx("div",{className:"flex flex-col gap-1",children:n.jsxs("div",{className:"flex items-center justify-between",children:[x,n.jsx(mt,{connectionId:s,connectionTitle:o,connectionDescription:r,connectionIcon:c,org:i,hasExistingVirtualMcps:!0})]})}),e[10]=r,e[11]=c,e[12]=s,e[13]=o,e[14]=i,e[15]=p):p=e[15];let a;if(e[16]!==i||e[17]!==m){let h;e[19]!==i?(h=b=>n.jsx(hs,{virtualMcp:b,org:i},b.id),e[19]=i,e[20]=h):h=e[20],a=m.map(h),e[16]=i,e[17]=m,e[18]=a}else a=e[18];let g;e[21]!==a?(g=n.jsx("div",{className:"flex flex-col gap-2",children:a}),e[21]=a,e[22]=g):g=e[22];let u;return e[23]!==p||e[24]!==g?(u=n.jsxs("div",{className:"p-5 flex flex-col gap-3",children:[p,g]}),e[23]=p,e[24]=g,e[25]=u):u=e[25],u}function xs({form:t,connection:e,hasOAuthToken:s,onReauthenticate:o,onRemoveOAuth:r}){const c=tt({control:t.control,name:"ui_type"}),i=tt({control:t.control,name:"connection_url"}),{stdioEnabled:l}=Tt(),m=(()=>{if(typeof i!="string"||!i)return!1;try{const a=new URL(i);return a.hostname==="api.githubcopilot.com"&&a.pathname.replace(/\/+$/,"")==="/mcp"}catch{return!1}})(),d=l||e.connection_type==="STDIO",x=e.connection_type==="VIRTUAL",p=x?Mt(e.connection_url):null;return x?n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Type"}),n.jsxs("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:[n.jsx(Ge,{className:"w-4 h-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Virtual MCP"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"This connection references a Virtual MCP. Tools and resources are aggregated dynamically from the Virtual MCP's underlying connections."})]}),p&&n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Virtual MCP ID"}),n.jsx("div",{className:"flex items-center gap-2 h-10 px-3 border border-border rounded-lg bg-muted/50",children:n.jsx("code",{className:"text-sm text-muted-foreground",children:p})})]})]}):n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[n.jsx(J,{control:t.control,name:"ui_type",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Connection"}),c!=="NPX"&&c!=="STDIO"?n.jsxs("div",{className:"flex items-stretch rounded-lg border border-border overflow-hidden",children:[n.jsxs(at,{value:a.value,onValueChange:a.onChange,children:[n.jsx(K,{children:n.jsxs(it,{className:"h-10 w-auto min-w-[90px] border-0 rounded-none bg-muted/50 focus:ring-0 focus:ring-offset-0",children:[n.jsx(Fe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),n.jsx(ct,{})]})}),n.jsxs(lt,{children:[n.jsx(Q,{value:"HTTP",children:"HTTP"}),n.jsx(Q,{value:"SSE",children:"SSE"}),n.jsx(Q,{value:"Websocket",children:"Websocket"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Q,{value:"NPX",children:"NPX Package"}),n.jsx(Q,{value:"STDIO",children:"Custom Command"})]})]})]}),n.jsx("div",{className:"w-px bg-border"}),n.jsx(J,{control:t.control,name:"connection_url",render:({field:g})=>n.jsx(G,{className:"flex-1 min-w-0",children:n.jsx(K,{children:n.jsx(ee,{placeholder:"https://example.com/mcp",...g,value:g.value??"",className:"h-10 border-0 rounded-none focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent"})})})})]}):n.jsxs(at,{value:a.value,onValueChange:a.onChange,children:[n.jsx(K,{children:n.jsx(it,{className:"h-10",children:n.jsx(ct,{})})}),n.jsxs(lt,{children:[n.jsx(Q,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(Q,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(Q,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Fe,{className:"w-4 h-4"}),"Websocket"]})}),d&&n.jsxs(n.Fragment,{children:[n.jsx(Q,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Lt,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(Q,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(hn,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(Z,{})]})}),c==="NPX"&&n.jsx(J,{control:t.control,name:"npx_package",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"NPM Package"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"@perplexity-ai/mcp-server",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})}),c==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(J,{control:t.control,name:"stdio_command",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Command"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"node, bun, python...",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})}),n.jsx(J,{control:t.control,name:"stdio_args",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Arguments"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"arg1 arg2 --flag value",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Space-separated arguments"}),n.jsx(Z,{})]})})]}),n.jsx(J,{control:t.control,name:"stdio_cwd",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Working Directory"}),n.jsx(K,{children:n.jsx(ee,{placeholder:"/path/to/project (optional)",...a,value:a.value||"",className:"h-10 rounded-lg"})}),n.jsx(Z,{})]})})]}),(c==="NPX"||c==="STDIO")&&n.jsx(J,{control:t.control,name:"env_vars",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:"Environment Variables"}),n.jsx(K,{children:n.jsx(Rt,{value:a.value??[],onChange:a.onChange})}),n.jsx(Z,{})]})}),c!=="NPX"&&c!=="STDIO"&&n.jsx(J,{control:t.control,name:"connection_token",render:({field:a})=>n.jsxs(G,{className:"flex flex-col gap-3",children:[n.jsx(ne,{className:"text-xs text-muted-foreground font-medium",children:m?"GitHub Personal Access Token":"Token"}),s?n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(cn,{children:[n.jsx(ln,{asChild:!0,children:n.jsx("button",{type:"button",className:"inline-flex items-center gap-1.5 cursor-pointer",children:n.jsxs(qe,{variant:"success",className:"gap-1.5",children:[n.jsx(yt,{size:12}),"Authenticated via OAuth",n.jsx(fn,{size:12})]})})}),n.jsxs(dn,{align:"start",children:[n.jsxs(rt,{onClick:o,children:[n.jsx(Ct,{size:16}),"Re-authenticate"]}),n.jsxs(rt,{variant:"destructive",onClick:r,children:[n.jsx(pn,{size:16}),"Remove OAuth"]})]})]})}):e.connection_token&&a.value===null?n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:"h-10 px-3 flex items-center rounded-lg border border-border bg-muted/50 text-muted-foreground font-mono text-sm",children:"••••••••••••••••"}),n.jsx("button",{type:"button",onClick:()=>a.onChange(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Clear and replace token",children:n.jsx(xn,{size:14,className:"text-muted-foreground"})})]}):n.jsxs(n.Fragment,{children:[n.jsx(K,{children:n.jsx(ee,{type:"password",placeholder:m?"Paste your GitHub PAT":"Enter access token...",...a,value:a.value||"",className:"h-10 rounded-lg"})}),m&&n.jsxs(mn,{children:["Create a PAT at"," ",n.jsx("a",{href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"github.com/settings/personal-access-tokens"})]})]}),n.jsx(Z,{})]})})]})}function gs(t){const e=U.c(43),{form:s,connection:o,isMCPAuthenticated:r,hasOAuthToken:c,onReauthenticate:i,onRemoveOAuth:l}=t,{org:m}=pt();let d;e[0]!==o.icon||e[1]!==o.title?(d=n.jsx(He,{icon:o.icon,name:o.title,size:"lg",className:"shadow-sm"}),e[0]=o.icon,e[1]=o.title,e[2]=d):d=e[2];let x;e[3]!==s.control?(x=n.jsxs("div",{className:"flex flex-col",children:[n.jsx(J,{control:s.control,name:"title",render:js}),n.jsx(J,{control:s.control,name:"description",render:bs})]}),e[3]=s.control,e[4]=x):x=e[4];let p;e[5]!==d||e[6]!==x?(p=n.jsxs("div",{className:"flex flex-col gap-4 p-5 border-b border-border",children:[d,x]}),e[5]=d,e[6]=x,e[7]=p):p=e[7];let a;e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==i||e[12]!==l?(a=n.jsx(xs,{form:s,connection:o,hasOAuthToken:c,onReauthenticate:i,onRemoveOAuth:l}),e[8]=o,e[9]=s,e[10]=c,e[11]=i,e[12]=l,e[13]=a):a=e[13];let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Status"}),e[14]=g):g=e[14];let u;e[15]!==r?(u=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[g,r?n.jsxs(qe,{variant:"success",className:"gap-1.5 bg-success-foreground text-success",children:[n.jsx(yt,{size:12}),"Connected"]}):n.jsx(qe,{variant:"outline",className:"text-muted-foreground",children:"Not connected"})]}),e[15]=r,e[16]=u):u=e[16];let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Created by"}),e[17]=h):h=e[17];let b;e[18]!==o.created_by?(b=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[h,n.jsx(gn,{id:o.created_by,size:"2xs"})]}),e[18]=o.created_by,e[19]=b):b=e[19];let C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Updated"}),e[20]=C):C=e[20];let v;e[21]!==o.updated_at?(v=o.updated_at?fs(new Date(o.updated_at),{addSuffix:!0}):"Unknown",e[21]=o.updated_at,e[22]=v):v=e[22];let j;e[23]!==v?(j=n.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[C,n.jsx("span",{className:"text-sm text-foreground",children:v})]}),e[23]=v,e[24]=j):j=e[24];let w;e[25]!==j||e[26]!==u||e[27]!==b?(w=n.jsxs("div",{className:"flex flex-col gap-2 p-5 border-b border-border",children:[u,b,j]}),e[25]=j,e[26]=u,e[27]=b,e[28]=w):w=e[28];let f;e[29]!==o.description||e[30]!==o.icon||e[31]!==o.id||e[32]!==o.title||e[33]!==m.slug?(f=n.jsx(ps,{connectionId:o.id,connectionTitle:o.title,connectionDescription:o.description,connectionIcon:o.icon,org:m.slug}),e[29]=o.description,e[30]=o.icon,e[31]=o.id,e[32]=o.title,e[33]=m.slug,e[34]=f):f=e[34];let P;e[35]!==w||e[36]!==f||e[37]!==p||e[38]!==a?(P=n.jsxs("div",{className:"flex flex-col h-full overflow-auto",children:[p,a,w,f]}),e[35]=w,e[36]=f,e[37]=p,e[38]=a,e[39]=P):P=e[39];let $;return e[40]!==s||e[41]!==P?($=n.jsx(un,{...s,children:P}),e[40]=s,e[41]=P,e[42]=$):$=e[42],$}function bs(t){const{field:e}=t;return n.jsxs(G,{className:"w-full space-y-0",children:[n.jsx(K,{children:n.jsx(ee,{...e,value:e.value||"",className:"h-auto py-0.5 text-base text-muted-foreground leading-6 px-2 -mx-2 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Add a description..."})}),n.jsx(Z,{})]})}function js(t){const{field:e}=t;return n.jsxs(G,{className:"flex-1 space-y-0",children:[n.jsx(K,{children:n.jsx(ee,{...e,className:"h-auto py-0.5 text-lg! font-medium leading-7 px-2 -mx-2 border-transparent hover:bg-input/25 focus:border-input bg-transparent transition-all",placeholder:"Connection Name"})}),n.jsx(Z,{})]})}function ys(t){const e=U.c(42),{prompts:s,connectionId:o,org:r,connectionTitle:c,connectionIcon:i,onPromptClick:l,showToolbar:m,emptyMessage:d}=t,x=m===void 0?!0:m,p=d===void 0?"This connection doesn't have any prompts yet.":d,a=Re(),u=Ye().location.href,[h,b]=Y.useState(""),[C,v]=Y.useState("table"),[j,w]=Y.useState("name"),[f,P]=Y.useState("asc");let $;e[0]!==f||e[1]!==j?($=S=>{j===S?(P(_s),f==="desc"&&w(void 0)):(w(S),P("asc"))},e[0]=f,e[1]=j,e[2]=$):$=e[2];const T=$;let V;e[3]!==o||e[4]!==a||e[5]!==l||e[6]!==r?(V=S=>{l?l(S):o&&r&&a({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:r,connectionId:o,collectionName:"prompts",itemId:encodeURIComponent(S.name)}})},e[3]=o,e[4]=a,e[5]=l,e[6]=r,e[7]=V):V=e[7];const k=V;let O;if(e[8]!==s||e[9]!==h||e[10]!==f||e[11]!==j){const S=!s||s.length===0?[]:h.trim()?(()=>{const H=h.toLowerCase();return s.filter(B=>B.name.toLowerCase().includes(H)||B.description&&B.description.toLowerCase().includes(H))})():s;O=!j||!f?S:[...S].sort((H,B)=>{const se=H[j]||"",we=B[j]||"",te=String(se).localeCompare(String(we));return f==="asc"?te:-te}),e[8]=s,e[9]=h,e[10]=f,e[11]=j,e[12]=O}else O=e[12];const M=O;let X;e[13]===Symbol.for("react.memo_cache_sentinel")?(X=[{id:"name",header:"Name",render:Ss,sortable:!0},{id:"description",header:"Description",render:ws,cellClassName:"flex-1",sortable:!0}],e[13]=X):X=e[13];const N=X;let R;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=N.filter(Ns).map(vs),e[14]=R):R=e[14];const E=R;let I;e[15]!==i||e[16]!==c||e[17]!==T||e[18]!==x||e[19]!==f||e[20]!==j||e[21]!==u||e[22]!==C?(I=x&&n.jsxs(Je,{children:[n.jsx(wt,{viewMode:C,onViewModeChange:v,sortKey:j,sortDirection:f,onSort:T,sortOptions:E}),n.jsx(Ke,{title:c?`${c}: Prompts`:"Prompts",url:u,icon:i??"description"})]}),e[15]=i,e[16]=c,e[17]=T,e[18]=x,e[19]=f,e[20]=j,e[21]=u,e[22]=C,e[23]=I):I=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=S=>{S.key==="Escape"&&(b(""),S.target.blur())},e[24]=A):A=e[24];let D;e[25]!==h?(D=n.jsx(St,{value:h,onChange:b,placeholder:"Search prompts...",onKeyDown:A}),e[25]=h,e[26]=D):D=e[26];let y;e[27]!==p||e[28]!==k||e[29]!==T||e[30]!==h||e[31]!==f||e[32]!==j||e[33]!==M||e[34]!==C?(y=C==="cards"?n.jsx("div",{className:"flex-1 overflow-auto p-5",children:M.length===0?n.jsx(ve,{image:null,title:h?"No prompts found":"No prompts available",description:h?"Try adjusting your search terms":p}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:M.map(S=>n.jsx(_t,{className:"cursor-pointer transition-colors",onClick:()=>k(S),children:n.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[n.jsx(He,{icon:null,name:S.name,size:"md",className:"shrink-0 shadow-sm"}),n.jsxs("div",{className:"flex flex-col gap-0",children:[n.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:S.name}),n.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:S.description||"No description"})]})]})},S.name))})}):n.jsx(Nt,{columns:N,data:M,isLoading:!1,sortKey:j,sortDirection:f,onSort:T,onRowClick:S=>k(S),emptyState:n.jsx(ve,{image:null,title:h?"No prompts found":"No prompts available",description:h?"Try adjusting your search terms":p})}),e[27]=p,e[28]=k,e[29]=T,e[30]=h,e[31]=f,e[32]=j,e[33]=M,e[34]=C,e[35]=y):y=e[35];let F;e[36]!==D||e[37]!==y?(F=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[D,y]}),e[36]=D,e[37]=y,e[38]=F):F=e[38];let z;return e[39]!==F||e[40]!==I?(z=n.jsxs(n.Fragment,{children:[I,F]}),e[39]=F,e[40]=I,e[41]=z):z=e[41],z}function vs(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Ns(t){return t.sortable}function ws(t){return n.jsx("span",{className:"text-sm text-foreground",children:t.description||"—"})}function Ss(t){return n.jsx("span",{className:"text-sm font-medium font-mono text-foreground",children:t.name})}function _s(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Cs(t){const e=U.c(6),{prompts:s,connectionId:o,org:r}=t,c=Qe(o),i=c?.title,l=c?.icon;let m;return e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l?(m=n.jsx(ys,{prompts:s,connectionId:o,org:r,connectionTitle:i,connectionIcon:l}),e[0]=o,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=m):m=e[5],m}function Ps(t){const e=U.c(2),{repository:s}=t;let o;return e[0]!==s?(o=n.jsx("div",{className:"flex-1 overflow-y-auto bg-background",children:n.jsx(wn,{repository:s})}),e[0]=s,e[1]=o):o=e[1],o}function ks(t){const e=U.c(39),{resources:s,connectionTitle:o,connectionIcon:r,onResourceClick:c,showToolbar:i,emptyMessage:l}=t,m=i===void 0?!0:i,d=l===void 0?"This connection doesn't have any resources yet.":l,p=Ye().location.href,[a,g]=Y.useState(""),[u,h]=Y.useState("table"),[b,C]=Y.useState("name"),[v,j]=Y.useState("asc");let w;e[0]!==v||e[1]!==b?(w=y=>{b===y?(j($s),v==="desc"&&C(void 0)):(C(y),j("asc"))},e[0]=v,e[1]=b,e[2]=w):w=e[2];const f=w;let P;e[3]!==c?(P=y=>{c&&c(y)},e[3]=c,e[4]=P):P=e[4];const $=P;let T;if(e[5]!==s||e[6]!==a||e[7]!==v||e[8]!==b){const y=!s||s.length===0?[]:a.trim()?(()=>{const F=a.toLowerCase();return s.filter(z=>z.uri.toLowerCase().includes(F)||z.name&&z.name.toLowerCase().includes(F)||z.description&&z.description.toLowerCase().includes(F))})():s;T=!b||!v?y:[...y].sort((F,z)=>{const S=F[b]||"",H=z[b]||"",B=String(S).localeCompare(String(H));return v==="asc"?B:-B}),e[5]=s,e[6]=a,e[7]=v,e[8]=b,e[9]=T}else T=e[9];const V=T;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=[{id:"name",header:"Name",render:Vs,sortable:!0},{id:"uri",header:"URI",render:As,sortable:!0},{id:"description",header:"Description",render:Is,cellClassName:"flex-1",sortable:!0},{id:"mimeType",header:"Type",render:Ds,sortable:!0}],e[10]=k):k=e[10];const O=k;let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=O.filter(Ms).map(Ts),e[11]=M):M=e[11];const X=M;let N;e[12]!==r||e[13]!==o||e[14]!==f||e[15]!==m||e[16]!==v||e[17]!==b||e[18]!==p||e[19]!==u?(N=m&&n.jsxs(Je,{children:[n.jsx(wt,{viewMode:u,onViewModeChange:h,sortKey:b,sortDirection:v,onSort:f,sortOptions:X}),n.jsx(Ke,{title:o?`${o}: Resources`:"Resources",url:p,icon:r??"folder"})]}),e[12]=r,e[13]=o,e[14]=f,e[15]=m,e[16]=v,e[17]=b,e[18]=p,e[19]=u,e[20]=N):N=e[20];let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=y=>{y.key==="Escape"&&(g(""),y.target.blur())},e[21]=R):R=e[21];let E;e[22]!==a?(E=n.jsx(St,{value:a,onChange:g,placeholder:"Search resources...",onKeyDown:R}),e[22]=a,e[23]=E):E=e[23];let I;e[24]!==d||e[25]!==$||e[26]!==f||e[27]!==a||e[28]!==v||e[29]!==b||e[30]!==V||e[31]!==u?(I=u==="cards"?n.jsx("div",{className:"flex-1 overflow-auto p-5",children:V.length===0?n.jsx(ve,{image:null,title:a?"No resources found":"No resources available",description:a?"Try adjusting your search terms":d}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(y=>n.jsx(_t,{className:"cursor-pointer transition-colors",onClick:()=>$(y),children:n.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[n.jsx(He,{icon:null,name:y.name||y.uri,size:"md",className:"shrink-0 shadow-sm"}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:y.name||y.uri}),n.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:y.uri}),y.description&&n.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:y.description})]})]})},y.uri))})}):n.jsx(Nt,{columns:O,data:V,isLoading:!1,sortKey:b,sortDirection:v,onSort:f,onRowClick:y=>$(y),emptyState:n.jsx(ve,{image:null,title:a?"No resources found":"No resources available",description:a?"Try adjusting your search terms":d})}),e[24]=d,e[25]=$,e[26]=f,e[27]=a,e[28]=v,e[29]=b,e[30]=V,e[31]=u,e[32]=I):I=e[32];let A;e[33]!==E||e[34]!==I?(A=n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[E,I]}),e[33]=E,e[34]=I,e[35]=A):A=e[35];let D;return e[36]!==A||e[37]!==N?(D=n.jsxs(n.Fragment,{children:[N,A]}),e[36]=A,e[37]=N,e[38]=D):D=e[38],D}function Ts(t){return{id:t.id,label:typeof t.header=="string"?t.header:t.id}}function Ms(t){return t.sortable}function Ds(t){return n.jsx("span",{className:"text-sm text-muted-foreground",children:t.mimeType||"—"})}function Is(t){return n.jsx("span",{className:"text-sm text-foreground",children:t.description||"—"})}function As(t){return n.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:t.uri})}function Vs(t){return n.jsx("span",{className:"text-sm font-medium text-foreground",children:t.name||t.uri})}function $s(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Os(t){const e=U.c(6),{resources:s,connectionId:o,org:r}=t,c=Qe(o),i=c?.title,l=c?.icon;let m;return e[0]!==o||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l?(m=n.jsx(ks,{resources:s,connectionId:o,org:r,connectionTitle:i,connectionIcon:l}),e[0]=o,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=m):m=e[5],m}const Fs=xt({key:q().min(1,"Key is required"),value:q()}),Ws=xt({title:q().min(1,"Name is required"),description:q().nullable().optional(),ui_type:At(["HTTP","SSE","Websocket","NPX","STDIO"]),connection_url:q().optional(),connection_token:q().nullable().optional(),npx_package:q().optional(),stdio_command:q().optional(),stdio_args:q().optional(),stdio_cwd:q().optional(),env_vars:nt(Fs).optional(),configuration_scopes:nt(q()).nullable().optional(),configuration_state:Dt(q(),It()).nullable().optional()}).refine(t=>t.ui_type==="NPX"?!!t.npx_package?.trim():!0,{message:"NPM package is required",path:["npx_package"]}).refine(t=>t.ui_type==="STDIO"?!!t.stdio_command?.trim():!0,{message:"Command is required",path:["stdio_command"]}).refine(t=>t.ui_type==="HTTP"||t.ui_type==="SSE"||t.ui_type==="Websocket"?!!t.connection_url?.trim():!0,{message:"URL is required",path:["connection_url"]});function Es(t){const e=U.c(5),{tools:s,connectionId:o,org:r,isLoading:c}=t;let i;return e[0]!==o||e[1]!==c||e[2]!==r||e[3]!==s?(i=n.jsx(Sn,{tools:s,connectionId:o,org:r,isLoading:c}),e[0]=o,e[1]=c,e[2]=r,e[3]=s,e[4]=i):i=e[4],i}function Ls(t){return t.command==="npx"}function Rs(t){return t.args?.find(e=>!e.startsWith("-"))??""}function zs(t){return{command:t.command,args:t.args?.join(" ")??"",cwd:t.cwd??""}}function Xs(t,e){const s={command:"npx",args:["-y",t]},o=bt(e);return Object.keys(o).length>0&&(s.envVars=o),s}function Us(t,e,s,o){const r={command:t};e.trim()&&(r.args=e.trim().split(/\s+/)),s?.trim()&&(r.cwd=s.trim());const c=bt(o);return Object.keys(c).length>0&&(r.envVars=c),r}function ft(t,e){const s={title:t.title,description:t.description??"",configuration_state:t.configuration_state??{},configuration_scopes:t.configuration_scopes||[]};if(t.connection_type==="STDIO"&&Et(t.connection_headers)){const o=t.connection_headers,r=zt(o.envVars);if(Ls(o)){const i=Rs(o);return{...s,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:i,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:r}}const c=zs(o);return{...s,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:c.command,stdio_args:c.args,stdio_cwd:c.cwd,env_vars:r}}return{...s,ui_type:t.connection_type,connection_url:t.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}function Bs(t){let e,s=null,o=null,r=null;return t.ui_type==="NPX"?(e="STDIO",s="",r=Xs(t.npx_package||"",t.env_vars||[])):t.ui_type==="STDIO"?(e="STDIO",s="",r=Us(t.stdio_command||"",t.stdio_args||"",t.stdio_cwd,t.env_vars||[])):(e=t.ui_type,s=t.connection_url||"",o=t.connection_token||null),{title:t.title,description:t.description||null,connection_type:e,connection_url:s,...o&&{connection_token:o},...r&&{connection_headers:r},configuration_state:t.configuration_state??null,configuration_scopes:t.configuration_scopes??null}}function qs(t){const e=U.c(117),{connection:s,connectionId:o,org:r,requestedTabId:c,collections:i,onUpdate:l,isUpdating:m,prompts:d,resources:x,tools:p,isLoadingTools:a}=t;let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={from:"/$org/mcps/$connectionId"},e[0]=g):g=e[0];const u=Re(g),h=Ot(),C=Ye().location.href,v=jt();let j;e[1]!==o?(j={connectionId:o},e[1]=o,e[2]=j):j=e[2];const w=qt(j),f=w.isAuthenticated;let P;e[3]!==s?(P={connections:[s],binding:"MCP"},e[3]=s,e[4]=P):P=e[4];const T=Bt(P).length>0,V=s?.metadata?.repository,k=!!V?.url;let O;e[5]===Symbol.for("react.memo_cache_sentinel")?(O=Ft(Ws),e[5]=O):O=e[5];let M;e[6]!==s?(M=ft(s),e[6]=s,e[7]=M):M=e[7];let X;e[8]!==M?(X={resolver:O,values:M},e[8]=M,e[9]=X):X=e[9];const N=Wt(X),R=N.formState.isDirty;let E;e[10]!==N||e[11]!==l?(E=async()=>{if(!await N.trigger())return;const L=N.getValues(),ye=Bs(L);await l(ye),N.reset(L)},e[10]=N,e[11]=l,e[12]=E):E=e[12];const I=E;let A;e[13]!==s||e[14]!==N?(A=()=>{N.reset(ft(s))},e[13]=s,e[14]=N,e[15]=A):A=e[15];const D=A;let y;e[16]!==s.id||e[17]!==v||e[18]!==h?(y=async()=>{const{token:_,tokenInfo:L,error:ye}=await Gt({connectionId:s.id});if(ye||!_){_e.error(`Authentication failed: ${ye}`);return}if(L)try{const Oe=await fetch(`/api/connections/${s.id}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})});if(!Oe.ok)console.error("Failed to save OAuth token:",await Oe.text()),await v.update.mutateAsync({id:s.id,data:{connection_token:_}});else try{await v.update.mutateAsync({id:s.id,data:{}})}catch(et){console.warn("Failed to refresh connection tools after OAuth:",et)}}catch(Oe){console.error("Error saving OAuth token:",Oe),await v.update.mutateAsync({id:s.id,data:{connection_token:_}})}else await v.update.mutateAsync({id:s.id,data:{connection_token:_}});const kt=new URL(`/mcp/${s.id}`,window.location.origin);await h.invalidateQueries({queryKey:st.isMCPAuthenticated(kt.href,null)}),_e.success("Authentication successful")},e[16]=s.id,e[17]=v,e[18]=h,e[19]=y):y=e[19];const F=y;let z;e[20]!==s.id||e[21]!==h?(z=async()=>{try{const _=await fetch(`/api/connections/${s.id}/oauth-token`,{method:"DELETE",credentials:"include"});if(!_.ok){const ye=await _.text();_e.error(`Failed to remove OAuth: ${ye}`);return}const L=new URL(`/mcp/${s.id}`,window.location.origin);await h.invalidateQueries({queryKey:st.isMCPAuthenticated(L.href,null)}),_e.success("OAuth removed. You can now re-authenticate with a different account.")}catch(_){console.error("Error removing OAuth token:",_),_e.error("Failed to remove OAuth")}},e[20]=s.id,e[21]=h,e[22]=z):z=e[22];const S=z,H=p.length,B=d.length,se=x.length,we=H>0||a;let te;e[23]===Symbol.for("react.memo_cache_sentinel")?(te={id:"settings",label:"Settings"},e[23]=te):te=e[23];let oe;e[24]!==a||e[25]!==f||e[26]!==we||e[27]!==H?(oe=f&&we?[{id:"tools",label:"Tools",count:a?void 0:H}]:[],e[24]=a,e[25]=f,e[26]=we,e[27]=H,e[28]=oe):oe=e[28];let re;e[29]!==f||e[30]!==B?(re=f&&B>0?[{id:"prompts",label:"Prompts",count:B}]:[],e[29]=f,e[30]=B,e[31]=re):re=e[31];let ae;e[32]!==f||e[33]!==se?(ae=f&&se>0?[{id:"resources",label:"Resources",count:se}]:[],e[32]=f,e[33]=se,e[34]=ae):ae=e[34];let ke;if(e[35]!==i||e[36]!==k||e[37]!==f||e[38]!==oe||e[39]!==re||e[40]!==ae){let _;e[42]!==k?(_=k?[{id:"readme",label:"README"}]:[],e[42]=k,e[43]=_):_=e[43],ke=[te,...oe,...re,...ae,...f?(i||[]).map(Hs):[],..._],e[35]=i,e[36]=k,e[37]=f,e[38]=oe,e[39]=re,e[40]=ae,e[41]=ke}else ke=e[41];const Se=ke,Pt=f&&Se.some(Ys)?"tools":"settings",W=Se.some(_=>_.id===c)?c:Pt;let Te;e[44]!==u?(Te=_=>{u({search:L=>({...L,tab:_}),replace:!0})},e[44]=u,e[45]=Te):Te=e[45];const ie=Te;let ce;e[46]!==i?(ce=i||[],e[46]=i,e[47]=ce):ce=e[47];let Me;if(e[48]!==W||e[49]!==ce){let _;e[51]!==W?(_=L=>L.name===W,e[51]=W,e[52]=_):_=e[52],Me=ce.find(_),e[48]=W,e[49]=ce,e[50]=Me}else Me=e[50];const De=Me;let le;e[53]!==r?(le=n.jsx(ot,{children:n.jsx(en,{asChild:!0,children:n.jsx(ht,{to:"/$org/mcps",params:{org:r},children:"Connections"})})}),e[53]=r,e[54]=le):le=e[54];let Ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(tn,{}),e[55]=Ie):Ie=e[55];let de;e[56]!==s.title?(de=n.jsx(ot,{children:n.jsx(Zt,{children:s.title})}),e[56]=s.title,e[57]=de):de=e[57];let Ae;e[58]!==le||e[59]!==de?(Ae=n.jsx(nn,{children:n.jsxs(sn,{children:[le,Ie,de]})}),e[58]=le,e[59]=de,e[60]=Ae):Ae=e[60];const ze=Ae;let ue;e[61]!==I||e[62]!==D||e[63]!==R||e[64]!==m?(ue=n.jsx(Xt,{onSave:I,onUndo:D,isDirty:R,isSaving:m}),e[61]=I,e[62]=D,e[63]=R,e[64]=m,e[65]=ue):ue=e[65];const Xe=s.icon??"settings";let me;e[66]!==s.title||e[67]!==Xe||e[68]!==C?(me=n.jsx(Ke,{title:s.title,url:C,icon:Xe}),e[66]=s.title,e[67]=Xe,e[68]=C,e[69]=me):me=e[69];let fe;e[70]!==ue||e[71]!==me?(fe=n.jsxs(Je,{children:[ue,me]}),e[70]=ue,e[71]=me,e[72]=fe):fe=e[72];let he;e[73]!==w.hasOAuthToken||e[74]!==s||e[75]!==N||e[76]!==F||e[77]!==S||e[78]!==f?(he=n.jsx("div",{className:"w-100 shrink-0 border-r border-border bg-background",children:n.jsx(gs,{form:N,connection:s,isMCPAuthenticated:f,hasOAuthToken:w.hasOAuthToken,onReauthenticate:F,onRemoveOAuth:S})}),e[73]=w.hasOAuthToken,e[74]=s,e[75]=N,e[76]=F,e[77]=S,e[78]=f,e[79]=he):he=e[79];let pe;e[80]!==W||e[81]!==ie||e[82]!==Se?(pe=n.jsx("div",{className:"shrink-0 flex items-center gap-4 px-5 py-3 border-b border-border",children:n.jsx(on,{tabs:Se,activeTab:W,onTabChange:ie,className:"flex-1"})}),e[80]=W,e[81]=ie,e[82]=Se,e[83]=pe):pe=e[83];let Ve;e[84]===Symbol.for("react.memo_cache_sentinel")?(Ve=n.jsx("div",{className:"flex h-full items-center justify-center",children:n.jsx(Le,{size:32,className:"animate-spin text-muted-foreground"})}),e[84]=Ve):Ve=e[84];let xe;e[85]!==De||e[86]!==W||e[87]!==w.isServerError||e[88]!==w.supportsOAuth||e[89]!==s||e[90]!==o||e[91]!==N||e[92]!==F||e[93]!==ie||e[94]!==T||e[95]!==k||e[96]!==a||e[97]!==f||e[98]!==r||e[99]!==d||e[100]!==V||e[101]!==x||e[102]!==p?(xe=n.jsx(Y.Suspense,{fallback:Ve,children:W==="tools"?n.jsx(Es,{tools:p,connectionId:o,org:r,isLoading:a}):W==="prompts"?n.jsx(Cs,{prompts:d,connectionId:o,org:r}):W==="resources"?n.jsx(Os,{resources:x,connectionId:o,org:r}):W==="settings"?n.jsx(Yt,{connection:s,form:N,hasMcpBinding:T,isMCPAuthenticated:f,supportsOAuth:w.supportsOAuth,isServerError:w.isServerError,onAuthenticate:F,onViewReadme:k?()=>ie("readme"):void 0}):W==="readme"&&k?n.jsx(Ps,{repository:V}):De&&f?n.jsx(an,{connectionId:o,org:r,activeCollection:De},W):n.jsx(ve,{title:"Collection not found",description:"This collection may have been deleted or you may not have access."})}),e[85]=De,e[86]=W,e[87]=w.isServerError,e[88]=w.supportsOAuth,e[89]=s,e[90]=o,e[91]=N,e[92]=F,e[93]=ie,e[94]=T,e[95]=k,e[96]=a,e[97]=f,e[98]=r,e[99]=d,e[100]=V,e[101]=x,e[102]=p,e[103]=xe):xe=e[103];let ge;e[104]!==W||e[105]!==xe?(ge=n.jsx("div",{className:"flex-1 overflow-auto",children:n.jsx(gt,{children:xe},W)}),e[104]=W,e[105]=xe,e[106]=ge):ge=e[106];let be;e[107]!==pe||e[108]!==ge?(be=n.jsxs("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:[pe,ge]}),e[107]=pe,e[108]=ge,e[109]=be):be=e[109];let je;e[110]!==he||e[111]!==be?(je=n.jsxs("div",{className:"flex h-full w-full bg-background overflow-hidden",children:[he,be]}),e[110]=he,e[111]=be,e[112]=je):je=e[112];let $e;return e[113]!==ze||e[114]!==fe||e[115]!==je?($e=n.jsxs(rn,{breadcrumb:ze,children:[fe,je]}),e[113]=ze,e[114]=fe,e[115]=je,e[116]=$e):$e=e[116],$e}function Ys(t){return t.id==="tools"}function Hs(t){return{id:t.name,label:t.displayName}}function Ks(){const t=U.c(43);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/$org/mcps/$connectionId"},t[0]=e):e=t[0];const s=Re(e);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={from:"/shell/$org/mcps/$connectionId"},t[1]=o):o=t[1];const{connectionId:r,org:c}=Vt(o),{org:i}=pt();let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l={from:"/shell/$org/mcps/$connectionId"},t[2]=l):l=t[2];const d=$t(l).tab??"",x=Qe(r),p=jt(),a=Ut(x??void 0);let g;t[3]!==r||t[4]!==i.id?(g={connectionId:r,orgId:i.id},t[3]=r,t[4]=i.id,t[5]=g):g=t[5];const u=Kt(g);let h;t[6]!==u?(h={client:u},t[6]=u,t[7]=h):h=t[7];const{data:b}=Qt(h);let C;t[8]!==u?(C={client:u},t[8]=u,t[9]=C):C=t[9];const{data:v}=Jt(C),j=x?.tools&&x.tools.length>0,w=!j;let f;t[10]!==u||t[11]!==w?(f={client:u,enabled:w},t[10]=u,t[11]=w,t[12]=f):f=t[12];const{data:P,isLoading:$}=Ht(f);let T;t[13]!==b?.prompts?(T=b?.prompts??[],t[13]=b?.prompts,t[14]=T):T=t[14];let V;t[15]!==T?(V=T.map(Gs),t[15]=T,t[16]=V):V=t[16];const k=V;let O;t[17]!==v?.resources?(O=v?.resources??[],t[17]=v?.resources,t[18]=O):O=t[18];let M;t[19]!==O?(M=O.map(Js),t[19]=O,t[20]=M):M=t[20];const X=M;let N;t[21]!==x||t[22]!==j||t[23]!==P?.tools?(N=j?x.tools??[]:(P?.tools??[]).map(Qs),t[21]=x,t[22]=j,t[23]=P?.tools,t[24]=N):N=t[24];const R=N;let E;t[25]!==p.update||t[26]!==r?(E=async D=>{await p.update.mutateAsync({id:r,data:D})},t[25]=p.update,t[26]=r,t[27]=E):E=t[27];const I=E;if(!x){let D;return t[28]!==s||t[29]!==c?(D=n.jsx("div",{className:"flex h-full w-full bg-background",children:n.jsx(ve,{title:"Connection not found",description:"This connection may have been deleted or you may not have access.",actions:n.jsx(Be,{variant:"outline",onClick:()=>s({to:"/$org/mcps",params:{org:c}}),children:"Back to connections"})})}),t[28]=s,t[29]=c,t[30]=D):D=t[30],D}let A;return t[31]!==p.update.isPending||t[32]!==a||t[33]!==x||t[34]!==r||t[35]!==I||t[36]!==$||t[37]!==c||t[38]!==k||t[39]!==d||t[40]!==X||t[41]!==R?(A=n.jsx(qs,{org:c,connection:x,connectionId:r,requestedTabId:d,collections:a,onUpdate:I,isUpdating:p.update.isPending,prompts:k,resources:X,tools:R,isLoadingTools:$}),t[31]=p.update.isPending,t[32]=a,t[33]=x,t[34]=r,t[35]=I,t[36]=$,t[37]=c,t[38]=k,t[39]=d,t[40]=X,t[41]=R,t[42]=A):A=t[42],A}function Qs(t){return{name:t.name,description:t.description,inputSchema:t.inputSchema}}function Js(t){return{uri:t.uri,name:t.name,description:t.description}}function Gs(t){return{name:t.name,description:t.description}}function Zs(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(gt,{children:n.jsx(Y.Suspense,{fallback:n.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:n.jsx(Le,{size:32,className:"animate-spin text-muted-foreground"})}),children:n.jsx(Ks,{})})}),t[0]=e):e=t[0],e}function kr(){const t=U.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(Zs,{}),t[0]=e):e=t[0],e}export{kr as default};
@@ -1 +1 @@
1
- import{c as le,j as e,r as U,u as _e,w as Ce,f as be,g as ke,ac as we,k as Ne,h as Se,i as De,o as de,ad as Pe,s as y,ae as Te}from"./index-BAZLm9w0.js";import{g as Ie}from"./generate-id-Dyweu44Y.js";import{C as $e,a as Ve}from"./collection-table-wrapper-Ad_-F1tG.js";import{C as Ae}from"./collection-search-DgJbkAZh.js";import{C as Ee}from"./connection-card-ByjFlujM.js";import{B as F}from"./badge-BMiZ-mom.js";import{i as Me}from"./AlertCircle-CyK0Qw5h.js";import{i as Be}from"./CheckCircle-Dq1sA0pv.js";import{n as H,E as O,I as Fe}from"./empty-state-Z8nGys2S.js";import{E as He}from"./error-boundary-_n4elsYx.js";import{P as T}from"./index-LE1qlbhg.js";import{u as Oe,U as Z,s as ee}from"./use-list-state-CCCWL8bD.js";import{u as ze}from"./use-binding-C5bwm3GP.js";import{f as Ue,e as Re}from"./registry-utils-DGqTJkDv.js";import{f as Xe,a as Le,b as We,c as Ke,d as Ge,e as qe,A as Ye,g as Qe}from"./alert-dialog-CHAGlLFb.js";import{B as Je,a as Ze,b as et,e as tt}from"./breadcrumb-BjHn0dWR.js";import{B as _}from"./button-nyR0JH2l.js";import{D as nt,a as st,b as ot,c as rt,d as it,e as at}from"./dialog-DobMZv-a.js";import{D as te,a as ne,b as se,c as A}from"./dropdown-menu-BUrC7H_I.js";import{a as ct,F as h,b as x,c as g,d as f,f as j}from"./form-8XJyhmpO.js";import{I as b}from"./input-DHWQboe4.js";import{S as lt,a as dt,b as mt,c as ut,d as I}from"./select-CrjtUXd1.js";import{T as pt}from"./textarea-wjx2NJJH.js";import{d as ht,e as xt,h as gt}from"./use-connection-k5RUrkjP.js";import{u as ft}from"./constants-CJQnv32m.js";import{i as oe}from"./DotsVertical-BpzYqYSl.js";import{s as z}from"./Globe02-DudYvjwY.js";import{i as jt}from"./Loading01-DCWQbhnz.js";import{i as yt}from"./Terminal-CdMAejVo.js";import{s as re}from"./Trash01-C_hJOK44.js";import{r as vt,E as _t,e as me}from"./env-vars-editor-CGiYkoF6.js";import{d as Ct}from"./differenceInSeconds-NQ4PDo0z.js";import"./ArrowUp-BzVEz2lB.js";import"./Check-Dzm8t_lx.js";import"./Grid01-DB4psHwp.js";import"./List-BeVMnZSE.js";import"./view-mode-toggle-DsKf8ZTT.js";import"./table-oiEqEhps.js";import"./SearchMd-BWXZ4bVC.js";import"./card-DVnhjUGd.js";import"./useQuery-Da0DsMDg.js";import"./use-mobile-MoR_lOMO.js";import"./binder-DC5jbVcK.js";import"./ChevronRight-DDdY_PC7.js";import"./X-8UbCzOSY.js";import"./ChevronDown-Z3Dyyuvx.js";import"./useMutation-ffySYpQB.js";import"./Plus-CG8dB40n.js";function ie(s){const n=le.c(3),{status:i}=s;if(i==="active"){let c;return n[0]===Symbol.for("react.memo_cache_sentinel")?(c=e.jsxs(F,{variant:"success",className:"gap-1.5 text-success border-success/40 bg-background",children:[e.jsx(Be,{size:12}),"Active"]}),n[0]=c):c=n[0],c}if(i==="error"){let c;return n[1]===Symbol.for("react.memo_cache_sentinel")?(c=e.jsxs(F,{variant:"outline",className:"gap-1.5 text-destructive border-destructive/40 bg-background",children:[e.jsx(Me,{size:12}),"Error"]}),n[1]=c):c=n[1],c}let d;return n[2]===Symbol.for("react.memo_cache_sentinel")?(d=e.jsx(F,{variant:"outline",className:"text-muted-foreground",children:"Inactive"}),n[2]=d):d=n[2],d}function ae(s){const n=Ct(new Date,s);return n<60?"<1m":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<604800?`${Math.floor(n/86400)}d ago`:n<2592e3?`${Math.floor(n/604800)}w ago`:n<31536e3?`${Math.floor(n/2592e3)}mo ago`:`${Math.floor(n/31536e3)}y ago`}const bt=de({key:y(),value:y()}),kt=de({title:y().min(1,"Name is required"),description:y().nullable().optional(),ui_type:Te(["HTTP","SSE","Websocket","NPX","STDIO"]),connection_url:y().optional(),connection_token:y().nullable().optional(),npx_package:y().optional(),stdio_command:y().optional(),stdio_args:y().optional(),stdio_cwd:y().optional(),env_vars:Pe(bt).optional()}).refine(s=>s.ui_type==="NPX"?!!s.npx_package?.trim():!0,{message:"NPM package is required",path:["npx_package"]}).refine(s=>s.ui_type==="STDIO"?!!s.stdio_command?.trim():!0,{message:"Command is required",path:["stdio_command"]}).refine(s=>s.ui_type==="HTTP"||s.ui_type==="SSE"||s.ui_type==="Websocket"?!!s.connection_url?.trim():!0,{message:"URL is required",path:["connection_url"]});function M(s){const n=s.trim();if(!n)return"";try{const i=new URL(n),d=i.pathname.length>1?i.pathname.replace(/\/+$/,""):i.pathname;return`${i.origin}${d}`}catch{return n.replace(/\/+$/,"")}}function wt(s){const n=s.trim().split(/\s+/).filter(Boolean);if(n.length<2)return null;const i=n[0]?.toLowerCase();if(i!=="npx"&&i!=="bunx")return null;const c=n.slice(1).find(a=>!a.startsWith("-"));return c?{packageName:c}:null}function E(s){const{uiType:n}=s,i=M(s.connectionUrl??"");if((n==="HTTP"||n==="SSE"||n==="Websocket")&&i===M("https://api.githubcopilot.com/mcp/"))return{id:"github",title:"GitHub",description:"GitHub Copilot MCP",token:{label:"GitHub PAT",placeholder:"github_pat_…",helperText:"Paste a GitHub Personal Access Token (PAT)"}};const d=(s.npxPackage??"").trim();return n==="NPX"&&d==="@perplexity-ai/mcp-server"?{id:"perplexity",title:"Perplexity",description:"Perplexity MCP Server",envVarKeys:["PERPLEXITY_API_KEY"]}:null}function ce(s){if(s.registryItems.length===0||s.uiType!=="HTTP"&&s.uiType!=="SSE"&&s.uiType!=="Websocket")return null;const n=M(s.connectionUrl??"");if(!n)return null;const i=s.registryItems.find(a=>(a.server?.remotes??[]).some(k=>M(k.url??"")===n));if(!i)return null;const d=i.title||i.name||i.server?.title||i.server?.name||"",c=i.server?.description||i.description||i.summary||null;return d?{id:"registry",title:d,description:c}:null}function Nt(s,n){const i={command:"npx",args:["-y",s]},d=me(n);return Object.keys(d).length>0&&(i.envVars=d),i}function St(s,n,i,d){const c={command:s};n.trim()&&(c.args=n.trim().split(/\s+/)),i?.trim()&&(c.cwd=i.trim());const a=me(d);return Object.keys(a).length>0&&(c.envVars=a),c}function Dt(s){return s.command==="npx"}function Pt(s){return s.args?.find(n=>!n.startsWith("-"))??""}function Tt(s){return{command:s.command,args:s.args?.join(" ")??"",cwd:s.cwd??""}}function It(s,n){switch(n.type){case"edit":return{mode:"editing",connection:n.connection};case"delete":return{mode:"deleting",connection:n.connection};case"close":return{mode:"idle"}}}function $t(){const{org:s}=_e(),n=Ce(),i=be({strict:!1}),{data:d}=ke.useSession(),{stdioEnabled:c}=we(),a=Oe({namespace:s.slug,resource:"connections"}),$=ht(),k=xt(a),[v,w]=U.useReducer(It,{mode:"idle"}),R=ze(k)[0],X=R?.id??"",L=Ue(R?.tools),ue=ft({connectionId:X||null,orgId:s.id}),{data:pe}=gt({client:ue,toolName:L,toolArguments:{limit:200},enabled:!!(X&&L),staleTime:3600*1e3,select:t=>t.structuredContent??t}),W=Re(pe??[]),K=i.action==="create",he=()=>{n({to:"/$org/mcps",params:{org:s.slug},search:{action:"create"}})},G=()=>{n({to:"/$org/mcps",params:{org:s.slug},search:{}})},r=Ne({resolver:Se(kt),defaultValues:{title:"",description:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),u=r.watch("ui_type"),q=r.watch("connection_url"),xe=r.watch("npx_package"),D=E({uiType:u,connectionUrl:q??"",npxPackage:xe??""})??ce({uiType:u,connectionUrl:q??"",registryItems:W}),m=v.mode==="editing"?v.connection:null;U.useEffect(()=>{if(m){const t=De(m.connection_headers)?m.connection_headers:null;if(t&&m.connection_type==="STDIO"){const o=vt(t.envVars);if(Dt(t)){const l=Pt(t);r.reset({title:m.title,description:m.description,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:l,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:o})}else{const l=Tt(t);r.reset({title:m.title,description:m.description,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:l.command,stdio_args:l.args,stdio_cwd:l.cwd,env_vars:o})}}else r.reset({title:m.title,description:m.description,ui_type:m.connection_type,connection_url:m.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})}else r.reset({title:"",description:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})},[m,r]);const ge=async()=>{if(v.mode!=="deleting")return;const t=v.connection.id;w({type:"close"});try{await $.delete.mutateAsync(t)}catch{}},fe=async t=>{let o,l=null,N=null,C=null;if(t.ui_type==="NPX"?(o="STDIO",l="",C=Nt(t.npx_package||"",t.env_vars||[])):t.ui_type==="STDIO"?(o="STDIO",l="",C=St(t.stdio_command||"",t.stdio_args||"",t.stdio_cwd,t.env_vars||[])):(o=t.ui_type,l=t.connection_url||"",N=t.connection_token||null),m){await $.update.mutateAsync({id:m.id,data:{title:t.title,description:t.description||null,connection_type:o,connection_url:l,...N&&{connection_token:N},...C&&{connection_headers:C}}}),w({type:"close"}),r.reset();return}const S=Ie("conn");await $.create.mutateAsync({id:S,title:t.title,description:t.description||null,connection_type:o,connection_url:l,connection_token:N,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:d?.user?.id||"system",organization_id:s.id,icon:null,app_name:null,app_id:null,connection_headers:C,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),G(),r.reset(),n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:S}})},Y=t=>{t||(K?G():w({type:"close"}),r.reset())},V=t=>{const o=t.trim();if(!o)return;const l=!!r.formState.dirtyFields.title,N=!!r.formState.dirtyFields.description,C=!!r.formState.dirtyFields.env_vars,S=p=>{if(p&&(!l&&!r.getValues("title").trim()&&p.title&&r.setValue("title",p.title,{shouldDirty:!1}),!N&&!(r.getValues("description")??"").trim()&&p.description&&r.setValue("description",p.description,{shouldDirty:!1}),!C&&p.envVarKeys?.length)){const Q=r.getValues("env_vars")??[],ve=new Set(Q.map(P=>P.key)),J=p.envVarKeys.filter(P=>!ve.has(P));J.length>0&&r.setValue("env_vars",[...Q,...J.map(P=>({key:P,value:""}))],{shouldDirty:!0})}},B=wt(o);if(B&&c){r.setValue("ui_type","NPX",{shouldDirty:!0}),r.setValue("npx_package",B.packageName,{shouldDirty:!0}),r.setValue("connection_url","",{shouldDirty:!0}),r.setValue("connection_token",null,{shouldDirty:!0}),S(E({uiType:"NPX",npxPackage:B.packageName}));return}if(o.startsWith("http://")||o.startsWith("https://")){const p=u==="HTTP"||u==="SSE"||u==="Websocket"?u:"HTTP";r.setValue("ui_type",p,{shouldDirty:!0}),r.setValue("connection_url",o,{shouldDirty:!0}),S(E({uiType:p,connectionUrl:o})??ce({uiType:p,connectionUrl:o,registryItems:W}));return}u==="NPX"&&S(E({uiType:"NPX",npxPackage:o}))},je=[{id:"title",header:"Name",render:t=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Fe,{icon:t.icon,name:t.title,size:"sm",className:"shrink-0 shadow-sm",fallbackIcon:e.jsx(H,{})}),e.jsx("span",{className:"text-sm font-medium text-foreground truncate block",title:t.title,children:t.title})]}),cellClassName:"w-32 min-w-0 shrink-0",sortable:!0},{id:"description",header:"Description",render:t=>e.jsx("span",{className:"text-sm text-muted-foreground truncate block",title:t.description||"",children:t.description||"—"}),cellClassName:"flex-1 min-w-0 max-w-0",wrap:!1,sortable:!0},{id:"connection_type",header:"Type",accessor:t=>e.jsx("span",{className:"text-xs font-medium",children:t.connection_type}),cellClassName:"w-16 shrink-0",sortable:!0},{id:"status",header:"Status",render:t=>e.jsx(ie,{status:t.status}),cellClassName:"w-28 shrink-0",sortable:!1},{id:"updated_by",header:"Updated by",render:t=>e.jsx(Z,{id:t.updated_by??t.created_by,size:"3xs"}),cellClassName:"w-32 shrink-0",sortable:!0},{id:"updated_at",header:"Updated",render:t=>e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:t.updated_at?ae(new Date(t.updated_at)):"—"}),cellClassName:"max-w-24 w-24 shrink-0",sortable:!0},{id:"actions",header:"",render:t=>e.jsxs(te,{children:[e.jsx(ne,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:o=>o.stopPropagation(),children:e.jsx(oe,{size:20})})}),e.jsxs(se,{align:"end",onClick:o=>o.stopPropagation(),children:[e.jsxs(A,{onClick:o=>{o.stopPropagation(),n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}})},children:[e.jsx(ee,{size:16}),"Open"]}),e.jsxs(A,{variant:"destructive",onClick:o=>{o.stopPropagation(),w({type:"delete",connection:t})},children:[e.jsx(re,{size:16}),"Delete"]})]})]}),cellClassName:"w-12 shrink-0"}],ye=e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",onClick:()=>n({to:"/$org/store",params:{org:s.slug}}),size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:"Browse Store"}),e.jsx(_,{onClick:he,size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:"Custom Connection"})]});return e.jsxs(T,{children:[e.jsx(nt,{open:K||v.mode==="editing",onOpenChange:Y,children:e.jsxs(st,{className:"sm:max-w-[525px]",children:[e.jsxs(ot,{children:[e.jsx(rt,{children:m?"Edit Connection":"Create Connection"}),e.jsx(it,{children:m?"Update the connection details below.":"Create a custom connection in your organization. Fill in the details below."})]}),e.jsx(ct,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(fe),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(h,{control:r.control,name:"ui_type",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Type *"}),e.jsxs(lt,{value:t.value,onValueChange:t.onChange,children:[e.jsx(f,{children:e.jsx(dt,{children:e.jsx(mt,{})})}),e.jsxs(ut,{children:[e.jsx(I,{value:"HTTP",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"HTTP"]})}),e.jsx(I,{value:"SSE",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"SSE"]})}),e.jsx(I,{value:"Websocket",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"Websocket"]})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(I,{value:"NPX",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"NPX Package"]})}),e.jsx(I,{value:"STDIO",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(yt,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),e.jsx(j,{})]})}),u==="NPX"&&e.jsx(e.Fragment,{children:e.jsx(h,{control:r.control,name:"npx_package",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"NPM Package *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"@perplexity-ai/mcp-server",...t,value:t.value??"",onPaste:o=>{const l=o.clipboardData.getData("text");l&&(o.preventDefault(),r.setValue("npx_package",l.trim(),{shouldDirty:!0}),V(l))},onBlur:o=>{V(o.target.value),t.onBlur()}})}),e.jsx(j,{})]})})}),u==="STDIO"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[e.jsx(h,{control:r.control,name:"stdio_command",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Command *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"node, bun, python...",...t,value:t.value??""})}),e.jsx(j,{})]})}),e.jsx(h,{control:r.control,name:"stdio_args",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Arguments"}),e.jsx(f,{children:e.jsx(b,{placeholder:"arg1 arg2 --flag value",...t,value:t.value??""})}),e.jsx(j,{})]})})]}),e.jsx(h,{control:r.control,name:"stdio_cwd",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Working Directory"}),e.jsx(f,{children:e.jsx(b,{placeholder:"/path/to/project (optional)",...t,value:t.value??""})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),e.jsx(j,{})]})})]}),(u==="NPX"||u==="STDIO")&&e.jsx(h,{control:r.control,name:"env_vars",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Environment Variables"}),e.jsx(f,{children:e.jsx(_t,{value:t.value??[],onChange:t.onChange})}),e.jsx(j,{})]})}),u!=="NPX"&&u!=="STDIO"&&e.jsxs(e.Fragment,{children:[e.jsx(h,{control:r.control,name:"connection_url",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"URL *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"https://example.com/mcp",...t,value:t.value??"",onPaste:o=>{const l=o.clipboardData.getData("text");l&&(o.preventDefault(),r.setValue("connection_url",l.trim(),{shouldDirty:!0}),V(l))},onBlur:o=>{V(o.target.value),t.onBlur()}})}),e.jsx(j,{})]})}),e.jsx(h,{control:r.control,name:"connection_token",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:D?.token?.label??"Token (optional)"}),e.jsx(f,{children:e.jsx(b,{type:"password",placeholder:D?.token?.placeholder??"Bearer token or API key",...t,value:t.value??""})}),D?.token?.helperText&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[D.token.helperText,D.id==="github"&&e.jsxs(e.Fragment,{children:[" ","·"," ",e.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),e.jsx(j,{})]})})]}),e.jsx(h,{control:r.control,name:"title",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Name *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"My Connection",...t})}),e.jsx(j,{})]})}),e.jsx(h,{control:r.control,name:"description",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Description"}),e.jsx(f,{children:e.jsx(pt,{placeholder:"A brief description of this connection",rows:3,...t,value:t.value??""})}),e.jsx(j,{})]})})]}),e.jsxs(at,{children:[e.jsx(_,{type:"button",variant:"outline",onClick:()=>Y(!1),children:"Cancel"}),e.jsx(_,{type:"submit",disabled:r.formState.isSubmitting,className:"min-w-40",children:r.formState.isSubmitting?"Saving...":m?"Update Connection":"Create Connection"})]})]})})]})}),e.jsx(Xe,{open:v.mode==="deleting",onOpenChange:t=>!t&&w({type:"close"}),children:e.jsxs(Le,{children:[e.jsxs(We,{children:[e.jsx(Ke,{children:"Delete Connection?"}),e.jsxs(Ge,{children:["This action cannot be undone. This will permanently delete"," ",e.jsx("span",{className:"font-medium text-foreground",children:v.mode==="deleting"&&v.connection.title}),"."]})]}),e.jsxs(qe,{children:[e.jsx(Ye,{children:"Cancel"}),e.jsx(Qe,{onClick:ge,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsxs(T.Header,{children:[e.jsx(T.Header.Left,{children:e.jsx(Je,{children:e.jsx(Ze,{children:e.jsx(et,{children:e.jsx(tt,{children:"Connections"})})})})}),e.jsxs(T.Header.Right,{children:[e.jsx($e,{viewMode:a.viewMode,onViewModeChange:a.setViewMode,sortKey:a.sortKey,sortDirection:a.sortDirection,onSort:a.handleSort,sortOptions:[{id:"title",label:"Name"},{id:"description",label:"Description"},{id:"connection_type",label:"Type"},{id:"updated_by",label:"Updated by"},{id:"updated_at",label:"Updated"}]}),ye]})]}),e.jsx(Ae,{value:a.search,onChange:a.setSearch,placeholder:"Search for a Connection...",onKeyDown:t=>{t.key==="Escape"&&(a.setSearch(""),t.target.blur())}}),e.jsx(T.Content,{children:a.viewMode==="cards"?e.jsx("div",{className:"flex-1 overflow-auto p-5",children:k.length===0?e.jsx(O,{image:e.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:336,height:320,"aria-hidden":"true"}),title:(a.search,"No Connections found"),description:a.search?`No Connections match "${a.search}"`:"Create a connection to get started.",actions:!a.search&&e.jsx(_,{variant:"outline",onClick:()=>n({to:"/$org/store",params:{org:s.slug}}),children:"Browse Store"})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:k.map(t=>e.jsx(Ee,{connection:t,fallbackIcon:e.jsx(H,{}),onClick:()=>n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}}),headerActions:e.jsxs(te,{children:[e.jsx(ne,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:o=>o.stopPropagation(),children:e.jsx(oe,{size:20})})}),e.jsxs(se,{align:"end",onClick:o=>o.stopPropagation(),children:[e.jsxs(A,{onClick:o=>{o.stopPropagation(),n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}})},children:[e.jsx(ee,{size:16}),"Open"]}),e.jsxs(A,{variant:"destructive",onClick:o=>{o.stopPropagation(),w({type:"delete",connection:t})},children:[e.jsx(re,{size:16}),"Delete"]})]})]}),body:e.jsx(ie,{status:t.status}),footer:e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground w-full min-w-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(Z,{id:t.updated_by??t.created_by,size:"3xs"})}),e.jsx("span",{className:"shrink-0 ml-2",children:t.updated_at?ae(new Date(t.updated_at)):"—"})]})},t.id))})}):e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto min-w-0",children:e.jsx("div",{className:"min-w-[1000px]",children:e.jsx(Ve,{columns:je,data:k,isLoading:!1,sortKey:a.sortKey,sortDirection:a.sortDirection,onSort:a.handleSort,onRowClick:t=>n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}}),emptyState:a.search?e.jsx(O,{image:e.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:400,height:178,"aria-hidden":"true"}),title:"No Connections found",description:`No Connections match "${a.search}"`}):e.jsx(O,{image:e.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:400,height:178,"aria-hidden":"true"}),title:"No Connections found",description:"Create a connection to get started.",actions:e.jsx(_,{variant:"outline",onClick:()=>n({to:"/$org/store",params:{org:s.slug}}),children:"Browse Store"})})})})})})})]})}function Dn(){const s=le.c(1);let n;return s[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsx(He,{children:e.jsx(U.Suspense,{fallback:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(jt,{size:32,className:"animate-spin text-muted-foreground"})}),children:e.jsx($t,{})})}),s[0]=n):n=s[0],n}export{Dn as default};
1
+ import{c as le,j as e,r as U,u as _e,w as Ce,f as be,g as ke,ac as we,k as Ne,h as Se,i as De,o as de,ad as Pe,s as y,ae as Te}from"./index-DkVMZPZp.js";import{g as Ie}from"./generate-id-Dyweu44Y.js";import{C as $e,a as Ve}from"./collection-table-wrapper-DtjpsgWF.js";import{C as Ae}from"./collection-search-jBfTOehF.js";import{C as Ee}from"./connection-card-CYM4Wn_Y.js";import{B as F}from"./badge-tO1xwt4d.js";import{i as Me}from"./AlertCircle-C47UrlAO.js";import{i as Be}from"./CheckCircle-BIFyDkzk.js";import{n as H,E as O,I as Fe}from"./empty-state-yKA0Dnoy.js";import{E as He}from"./error-boundary-DMzArMGc.js";import{P as T}from"./index-ssfNqXSw.js";import{u as Oe,U as Z,s as ee}from"./use-list-state-BfUltaaz.js";import{u as ze}from"./use-binding-CDLcDLTQ.js";import{f as Ue,e as Re}from"./registry-utils-DFPURwxl.js";import{f as Xe,a as Le,b as We,c as Ke,d as Ge,e as qe,A as Ye,g as Qe}from"./alert-dialog-Cg14vDvh.js";import{B as Je,a as Ze,b as et,e as tt}from"./breadcrumb-B1KWdwh9.js";import{B as _}from"./button-CWzK0IXA.js";import{D as nt,a as st,b as ot,c as rt,d as it,e as at}from"./dialog-BiNw4dY-.js";import{D as te,a as ne,b as se,c as A}from"./dropdown-menu-D0wZWcOa.js";import{a as ct,F as h,b as x,c as g,d as f,f as j}from"./form-3eNCom8C.js";import{I as b}from"./input-BKM3goZw.js";import{S as lt,a as dt,b as mt,c as ut,d as I}from"./select-Df9aMNs1.js";import{T as pt}from"./textarea-BQ5-74yh.js";import{d as ht,e as xt,h as gt}from"./use-connection-BNgYG_2P.js";import{u as ft}from"./constants-Chp3RuVB.js";import{i as oe}from"./DotsVertical-CcQ5Tk1w.js";import{s as z}from"./Globe02-DqbzCrT0.js";import{i as jt}from"./Loading01-BpkkTLVp.js";import{i as yt}from"./Terminal--fMComVX.js";import{s as re}from"./Trash01-BhWwFORM.js";import{r as vt,E as _t,e as me}from"./env-vars-editor-BXoRftCH.js";import{d as Ct}from"./differenceInSeconds-NQ4PDo0z.js";import"./ArrowUp-NpHWyg3u.js";import"./Check-hF_kXZiK.js";import"./Grid01-DshI78vi.js";import"./List-B7BO0eBJ.js";import"./view-mode-toggle-Cz9APct2.js";import"./table-CWx1lOcJ.js";import"./SearchMd-SRsVDK9N.js";import"./card-uLixd1BQ.js";import"./useQuery-BSKCoFrF.js";import"./use-mobile-BXQipnb5.js";import"./binder-_fA_QfCQ.js";import"./ChevronRight-0gQ-Lwyj.js";import"./X-BNK0mLul.js";import"./ChevronDown-CwChLZoe.js";import"./useMutation-CFQDhqDA.js";import"./Plus-8ovTaJHc.js";function ie(s){const n=le.c(3),{status:i}=s;if(i==="active"){let c;return n[0]===Symbol.for("react.memo_cache_sentinel")?(c=e.jsxs(F,{variant:"success",className:"gap-1.5 text-success border-success/40 bg-background",children:[e.jsx(Be,{size:12}),"Active"]}),n[0]=c):c=n[0],c}if(i==="error"){let c;return n[1]===Symbol.for("react.memo_cache_sentinel")?(c=e.jsxs(F,{variant:"outline",className:"gap-1.5 text-destructive border-destructive/40 bg-background",children:[e.jsx(Me,{size:12}),"Error"]}),n[1]=c):c=n[1],c}let d;return n[2]===Symbol.for("react.memo_cache_sentinel")?(d=e.jsx(F,{variant:"outline",className:"text-muted-foreground",children:"Inactive"}),n[2]=d):d=n[2],d}function ae(s){const n=Ct(new Date,s);return n<60?"<1m":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<604800?`${Math.floor(n/86400)}d ago`:n<2592e3?`${Math.floor(n/604800)}w ago`:n<31536e3?`${Math.floor(n/2592e3)}mo ago`:`${Math.floor(n/31536e3)}y ago`}const bt=de({key:y(),value:y()}),kt=de({title:y().min(1,"Name is required"),description:y().nullable().optional(),ui_type:Te(["HTTP","SSE","Websocket","NPX","STDIO"]),connection_url:y().optional(),connection_token:y().nullable().optional(),npx_package:y().optional(),stdio_command:y().optional(),stdio_args:y().optional(),stdio_cwd:y().optional(),env_vars:Pe(bt).optional()}).refine(s=>s.ui_type==="NPX"?!!s.npx_package?.trim():!0,{message:"NPM package is required",path:["npx_package"]}).refine(s=>s.ui_type==="STDIO"?!!s.stdio_command?.trim():!0,{message:"Command is required",path:["stdio_command"]}).refine(s=>s.ui_type==="HTTP"||s.ui_type==="SSE"||s.ui_type==="Websocket"?!!s.connection_url?.trim():!0,{message:"URL is required",path:["connection_url"]});function M(s){const n=s.trim();if(!n)return"";try{const i=new URL(n),d=i.pathname.length>1?i.pathname.replace(/\/+$/,""):i.pathname;return`${i.origin}${d}`}catch{return n.replace(/\/+$/,"")}}function wt(s){const n=s.trim().split(/\s+/).filter(Boolean);if(n.length<2)return null;const i=n[0]?.toLowerCase();if(i!=="npx"&&i!=="bunx")return null;const c=n.slice(1).find(a=>!a.startsWith("-"));return c?{packageName:c}:null}function E(s){const{uiType:n}=s,i=M(s.connectionUrl??"");if((n==="HTTP"||n==="SSE"||n==="Websocket")&&i===M("https://api.githubcopilot.com/mcp/"))return{id:"github",title:"GitHub",description:"GitHub Copilot MCP",token:{label:"GitHub PAT",placeholder:"github_pat_…",helperText:"Paste a GitHub Personal Access Token (PAT)"}};const d=(s.npxPackage??"").trim();return n==="NPX"&&d==="@perplexity-ai/mcp-server"?{id:"perplexity",title:"Perplexity",description:"Perplexity MCP Server",envVarKeys:["PERPLEXITY_API_KEY"]}:null}function ce(s){if(s.registryItems.length===0||s.uiType!=="HTTP"&&s.uiType!=="SSE"&&s.uiType!=="Websocket")return null;const n=M(s.connectionUrl??"");if(!n)return null;const i=s.registryItems.find(a=>(a.server?.remotes??[]).some(k=>M(k.url??"")===n));if(!i)return null;const d=i.title||i.name||i.server?.title||i.server?.name||"",c=i.server?.description||i.description||i.summary||null;return d?{id:"registry",title:d,description:c}:null}function Nt(s,n){const i={command:"npx",args:["-y",s]},d=me(n);return Object.keys(d).length>0&&(i.envVars=d),i}function St(s,n,i,d){const c={command:s};n.trim()&&(c.args=n.trim().split(/\s+/)),i?.trim()&&(c.cwd=i.trim());const a=me(d);return Object.keys(a).length>0&&(c.envVars=a),c}function Dt(s){return s.command==="npx"}function Pt(s){return s.args?.find(n=>!n.startsWith("-"))??""}function Tt(s){return{command:s.command,args:s.args?.join(" ")??"",cwd:s.cwd??""}}function It(s,n){switch(n.type){case"edit":return{mode:"editing",connection:n.connection};case"delete":return{mode:"deleting",connection:n.connection};case"close":return{mode:"idle"}}}function $t(){const{org:s}=_e(),n=Ce(),i=be({strict:!1}),{data:d}=ke.useSession(),{stdioEnabled:c}=we(),a=Oe({namespace:s.slug,resource:"connections"}),$=ht(),k=xt(a),[v,w]=U.useReducer(It,{mode:"idle"}),R=ze(k)[0],X=R?.id??"",L=Ue(R?.tools),ue=ft({connectionId:X||null,orgId:s.id}),{data:pe}=gt({client:ue,toolName:L,toolArguments:{limit:200},enabled:!!(X&&L),staleTime:3600*1e3,select:t=>t.structuredContent??t}),W=Re(pe??[]),K=i.action==="create",he=()=>{n({to:"/$org/mcps",params:{org:s.slug},search:{action:"create"}})},G=()=>{n({to:"/$org/mcps",params:{org:s.slug},search:{}})},r=Ne({resolver:Se(kt),defaultValues:{title:"",description:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),u=r.watch("ui_type"),q=r.watch("connection_url"),xe=r.watch("npx_package"),D=E({uiType:u,connectionUrl:q??"",npxPackage:xe??""})??ce({uiType:u,connectionUrl:q??"",registryItems:W}),m=v.mode==="editing"?v.connection:null;U.useEffect(()=>{if(m){const t=De(m.connection_headers)?m.connection_headers:null;if(t&&m.connection_type==="STDIO"){const o=vt(t.envVars);if(Dt(t)){const l=Pt(t);r.reset({title:m.title,description:m.description,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:l,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:o})}else{const l=Tt(t);r.reset({title:m.title,description:m.description,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:l.command,stdio_args:l.args,stdio_cwd:l.cwd,env_vars:o})}}else r.reset({title:m.title,description:m.description,ui_type:m.connection_type,connection_url:m.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})}else r.reset({title:"",description:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})},[m,r]);const ge=async()=>{if(v.mode!=="deleting")return;const t=v.connection.id;w({type:"close"});try{await $.delete.mutateAsync(t)}catch{}},fe=async t=>{let o,l=null,N=null,C=null;if(t.ui_type==="NPX"?(o="STDIO",l="",C=Nt(t.npx_package||"",t.env_vars||[])):t.ui_type==="STDIO"?(o="STDIO",l="",C=St(t.stdio_command||"",t.stdio_args||"",t.stdio_cwd,t.env_vars||[])):(o=t.ui_type,l=t.connection_url||"",N=t.connection_token||null),m){await $.update.mutateAsync({id:m.id,data:{title:t.title,description:t.description||null,connection_type:o,connection_url:l,...N&&{connection_token:N},...C&&{connection_headers:C}}}),w({type:"close"}),r.reset();return}const S=Ie("conn");await $.create.mutateAsync({id:S,title:t.title,description:t.description||null,connection_type:o,connection_url:l,connection_token:N,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:d?.user?.id||"system",organization_id:s.id,icon:null,app_name:null,app_id:null,connection_headers:C,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),G(),r.reset(),n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:S}})},Y=t=>{t||(K?G():w({type:"close"}),r.reset())},V=t=>{const o=t.trim();if(!o)return;const l=!!r.formState.dirtyFields.title,N=!!r.formState.dirtyFields.description,C=!!r.formState.dirtyFields.env_vars,S=p=>{if(p&&(!l&&!r.getValues("title").trim()&&p.title&&r.setValue("title",p.title,{shouldDirty:!1}),!N&&!(r.getValues("description")??"").trim()&&p.description&&r.setValue("description",p.description,{shouldDirty:!1}),!C&&p.envVarKeys?.length)){const Q=r.getValues("env_vars")??[],ve=new Set(Q.map(P=>P.key)),J=p.envVarKeys.filter(P=>!ve.has(P));J.length>0&&r.setValue("env_vars",[...Q,...J.map(P=>({key:P,value:""}))],{shouldDirty:!0})}},B=wt(o);if(B&&c){r.setValue("ui_type","NPX",{shouldDirty:!0}),r.setValue("npx_package",B.packageName,{shouldDirty:!0}),r.setValue("connection_url","",{shouldDirty:!0}),r.setValue("connection_token",null,{shouldDirty:!0}),S(E({uiType:"NPX",npxPackage:B.packageName}));return}if(o.startsWith("http://")||o.startsWith("https://")){const p=u==="HTTP"||u==="SSE"||u==="Websocket"?u:"HTTP";r.setValue("ui_type",p,{shouldDirty:!0}),r.setValue("connection_url",o,{shouldDirty:!0}),S(E({uiType:p,connectionUrl:o})??ce({uiType:p,connectionUrl:o,registryItems:W}));return}u==="NPX"&&S(E({uiType:"NPX",npxPackage:o}))},je=[{id:"title",header:"Name",render:t=>e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Fe,{icon:t.icon,name:t.title,size:"sm",className:"shrink-0 shadow-sm",fallbackIcon:e.jsx(H,{})}),e.jsx("span",{className:"text-sm font-medium text-foreground truncate block",title:t.title,children:t.title})]}),cellClassName:"w-32 min-w-0 shrink-0",sortable:!0},{id:"description",header:"Description",render:t=>e.jsx("span",{className:"text-sm text-muted-foreground truncate block",title:t.description||"",children:t.description||"—"}),cellClassName:"flex-1 min-w-0 max-w-0",wrap:!1,sortable:!0},{id:"connection_type",header:"Type",accessor:t=>e.jsx("span",{className:"text-xs font-medium",children:t.connection_type}),cellClassName:"w-16 shrink-0",sortable:!0},{id:"status",header:"Status",render:t=>e.jsx(ie,{status:t.status}),cellClassName:"w-28 shrink-0",sortable:!1},{id:"updated_by",header:"Updated by",render:t=>e.jsx(Z,{id:t.updated_by??t.created_by,size:"3xs"}),cellClassName:"w-32 shrink-0",sortable:!0},{id:"updated_at",header:"Updated",render:t=>e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:t.updated_at?ae(new Date(t.updated_at)):"—"}),cellClassName:"max-w-24 w-24 shrink-0",sortable:!0},{id:"actions",header:"",render:t=>e.jsxs(te,{children:[e.jsx(ne,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:o=>o.stopPropagation(),children:e.jsx(oe,{size:20})})}),e.jsxs(se,{align:"end",onClick:o=>o.stopPropagation(),children:[e.jsxs(A,{onClick:o=>{o.stopPropagation(),n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}})},children:[e.jsx(ee,{size:16}),"Open"]}),e.jsxs(A,{variant:"destructive",onClick:o=>{o.stopPropagation(),w({type:"delete",connection:t})},children:[e.jsx(re,{size:16}),"Delete"]})]})]}),cellClassName:"w-12 shrink-0"}],ye=e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",onClick:()=>n({to:"/$org/store",params:{org:s.slug}}),size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:"Browse Store"}),e.jsx(_,{onClick:he,size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:"Custom Connection"})]});return e.jsxs(T,{children:[e.jsx(nt,{open:K||v.mode==="editing",onOpenChange:Y,children:e.jsxs(st,{className:"sm:max-w-[525px]",children:[e.jsxs(ot,{children:[e.jsx(rt,{children:m?"Edit Connection":"Create Connection"}),e.jsx(it,{children:m?"Update the connection details below.":"Create a custom connection in your organization. Fill in the details below."})]}),e.jsx(ct,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(fe),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(h,{control:r.control,name:"ui_type",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Type *"}),e.jsxs(lt,{value:t.value,onValueChange:t.onChange,children:[e.jsx(f,{children:e.jsx(dt,{children:e.jsx(mt,{})})}),e.jsxs(ut,{children:[e.jsx(I,{value:"HTTP",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"HTTP"]})}),e.jsx(I,{value:"SSE",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"SSE"]})}),e.jsx(I,{value:"Websocket",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4"}),"Websocket"]})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(I,{value:"NPX",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"NPX Package"]})}),e.jsx(I,{value:"STDIO",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(yt,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),e.jsx(j,{})]})}),u==="NPX"&&e.jsx(e.Fragment,{children:e.jsx(h,{control:r.control,name:"npx_package",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"NPM Package *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"@perplexity-ai/mcp-server",...t,value:t.value??"",onPaste:o=>{const l=o.clipboardData.getData("text");l&&(o.preventDefault(),r.setValue("npx_package",l.trim(),{shouldDirty:!0}),V(l))},onBlur:o=>{V(o.target.value),t.onBlur()}})}),e.jsx(j,{})]})})}),u==="STDIO"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[e.jsx(h,{control:r.control,name:"stdio_command",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Command *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"node, bun, python...",...t,value:t.value??""})}),e.jsx(j,{})]})}),e.jsx(h,{control:r.control,name:"stdio_args",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Arguments"}),e.jsx(f,{children:e.jsx(b,{placeholder:"arg1 arg2 --flag value",...t,value:t.value??""})}),e.jsx(j,{})]})})]}),e.jsx(h,{control:r.control,name:"stdio_cwd",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Working Directory"}),e.jsx(f,{children:e.jsx(b,{placeholder:"/path/to/project (optional)",...t,value:t.value??""})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),e.jsx(j,{})]})})]}),(u==="NPX"||u==="STDIO")&&e.jsx(h,{control:r.control,name:"env_vars",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Environment Variables"}),e.jsx(f,{children:e.jsx(_t,{value:t.value??[],onChange:t.onChange})}),e.jsx(j,{})]})}),u!=="NPX"&&u!=="STDIO"&&e.jsxs(e.Fragment,{children:[e.jsx(h,{control:r.control,name:"connection_url",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"URL *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"https://example.com/mcp",...t,value:t.value??"",onPaste:o=>{const l=o.clipboardData.getData("text");l&&(o.preventDefault(),r.setValue("connection_url",l.trim(),{shouldDirty:!0}),V(l))},onBlur:o=>{V(o.target.value),t.onBlur()}})}),e.jsx(j,{})]})}),e.jsx(h,{control:r.control,name:"connection_token",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:D?.token?.label??"Token (optional)"}),e.jsx(f,{children:e.jsx(b,{type:"password",placeholder:D?.token?.placeholder??"Bearer token or API key",...t,value:t.value??""})}),D?.token?.helperText&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[D.token.helperText,D.id==="github"&&e.jsxs(e.Fragment,{children:[" ","·"," ",e.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),e.jsx(j,{})]})})]}),e.jsx(h,{control:r.control,name:"title",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Name *"}),e.jsx(f,{children:e.jsx(b,{placeholder:"My Connection",...t})}),e.jsx(j,{})]})}),e.jsx(h,{control:r.control,name:"description",render:({field:t})=>e.jsxs(x,{children:[e.jsx(g,{children:"Description"}),e.jsx(f,{children:e.jsx(pt,{placeholder:"A brief description of this connection",rows:3,...t,value:t.value??""})}),e.jsx(j,{})]})})]}),e.jsxs(at,{children:[e.jsx(_,{type:"button",variant:"outline",onClick:()=>Y(!1),children:"Cancel"}),e.jsx(_,{type:"submit",disabled:r.formState.isSubmitting,className:"min-w-40",children:r.formState.isSubmitting?"Saving...":m?"Update Connection":"Create Connection"})]})]})})]})}),e.jsx(Xe,{open:v.mode==="deleting",onOpenChange:t=>!t&&w({type:"close"}),children:e.jsxs(Le,{children:[e.jsxs(We,{children:[e.jsx(Ke,{children:"Delete Connection?"}),e.jsxs(Ge,{children:["This action cannot be undone. This will permanently delete"," ",e.jsx("span",{className:"font-medium text-foreground",children:v.mode==="deleting"&&v.connection.title}),"."]})]}),e.jsxs(qe,{children:[e.jsx(Ye,{children:"Cancel"}),e.jsx(Qe,{onClick:ge,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsxs(T.Header,{children:[e.jsx(T.Header.Left,{children:e.jsx(Je,{children:e.jsx(Ze,{children:e.jsx(et,{children:e.jsx(tt,{children:"Connections"})})})})}),e.jsxs(T.Header.Right,{children:[e.jsx($e,{viewMode:a.viewMode,onViewModeChange:a.setViewMode,sortKey:a.sortKey,sortDirection:a.sortDirection,onSort:a.handleSort,sortOptions:[{id:"title",label:"Name"},{id:"description",label:"Description"},{id:"connection_type",label:"Type"},{id:"updated_by",label:"Updated by"},{id:"updated_at",label:"Updated"}]}),ye]})]}),e.jsx(Ae,{value:a.search,onChange:a.setSearch,placeholder:"Search for a Connection...",onKeyDown:t=>{t.key==="Escape"&&(a.setSearch(""),t.target.blur())}}),e.jsx(T.Content,{children:a.viewMode==="cards"?e.jsx("div",{className:"flex-1 overflow-auto p-5",children:k.length===0?e.jsx(O,{image:e.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:336,height:320,"aria-hidden":"true"}),title:(a.search,"No Connections found"),description:a.search?`No Connections match "${a.search}"`:"Create a connection to get started.",actions:!a.search&&e.jsx(_,{variant:"outline",onClick:()=>n({to:"/$org/store",params:{org:s.slug}}),children:"Browse Store"})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:k.map(t=>e.jsx(Ee,{connection:t,fallbackIcon:e.jsx(H,{}),onClick:()=>n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}}),headerActions:e.jsxs(te,{children:[e.jsx(ne,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:o=>o.stopPropagation(),children:e.jsx(oe,{size:20})})}),e.jsxs(se,{align:"end",onClick:o=>o.stopPropagation(),children:[e.jsxs(A,{onClick:o=>{o.stopPropagation(),n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}})},children:[e.jsx(ee,{size:16}),"Open"]}),e.jsxs(A,{variant:"destructive",onClick:o=>{o.stopPropagation(),w({type:"delete",connection:t})},children:[e.jsx(re,{size:16}),"Delete"]})]})]}),body:e.jsx(ie,{status:t.status}),footer:e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground w-full min-w-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(Z,{id:t.updated_by??t.created_by,size:"3xs"})}),e.jsx("span",{className:"shrink-0 ml-2",children:t.updated_at?ae(new Date(t.updated_at)):"—"})]})},t.id))})}):e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 overflow-auto min-w-0",children:e.jsx("div",{className:"min-w-[1000px]",children:e.jsx(Ve,{columns:je,data:k,isLoading:!1,sortKey:a.sortKey,sortDirection:a.sortDirection,onSort:a.handleSort,onRowClick:t=>n({to:"/$org/mcps/$connectionId",params:{org:s.slug,connectionId:t.id}}),emptyState:a.search?e.jsx(O,{image:e.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:400,height:178,"aria-hidden":"true"}),title:"No Connections found",description:`No Connections match "${a.search}"`}):e.jsx(O,{image:e.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:400,height:178,"aria-hidden":"true"}),title:"No Connections found",description:"Create a connection to get started.",actions:e.jsx(_,{variant:"outline",onClick:()=>n({to:"/$org/store",params:{org:s.slug}}),children:"Browse Store"})})})})})})})]})}function Dn(){const s=le.c(1);let n;return s[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsx(He,{children:e.jsx(U.Suspense,{fallback:e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(jt,{size:32,className:"animate-spin text-muted-foreground"})}),children:e.jsx($t,{})})}),s[0]=n):n=s[0],n}export{Dn as default};
@@ -0,0 +1 @@
1
+ import{b1 as d,c as g,q as f,b2 as h}from"./index-DkVMZPZp.js";const u={authConfig:()=>["authConfig"],threads:e=>["threads",e],virtualMcpThreads:(e,t)=>["threads",e,"virtual-mcp",t],thread:(e,t)=>["thread",e,t],threadMessages:(e,t)=>["thread-messages",e,t],messages:e=>["messages",e],organizations:()=>["organizations"],members:e=>[e,"members"],invitations:e=>[e,"invitations"],organizationRoles:e=>[e,"organization-roles"],connections:e=>[e,"connections"],connectionsByBinding:(e,t)=>[e,"connections",`binding:${t}`],connection:(e,t)=>[e,"connection",t],isMCPAuthenticated:(e,t)=>["is-mcp-authenticated",e,t],mcpTools:(e,t)=>["mcp","tools",e,t],mcpClient:(e,t,n,o)=>["mcp","client",e,t,n,o],mcpToolsList:e=>["mcp","client",e,"tools"],mcpResourcesList:e=>["mcp","client",e,"resources"],mcpPromptsList:e=>["mcp","client",e,"prompts"],mcpReadResource:(e,t)=>["mcp","client",e,"resource",t],mcpGetPrompt:(e,t,n)=>["mcp","client",e,"prompt",t,n],mcpToolCall:(e,t,n)=>["mcp","client",e,"tool-call",t,n],organizationSettings:e=>["organization-settings",e],activeOrganization:e=>["activeOrganization",e],modelsList:e=>["models-list",e],connectionCollections:e=>[e,"collections","discovery"],toolCall:(e,t,n)=>["tool-call",e,t,n],collectionItems:(e,t)=>["collection",e,t],collection:(e,t,n)=>[e,t,"collection",n],collectionItem:(e,t,n,o,i)=>[e,t,n,"collection",o,i],collectionList:(e,t,n,o,i)=>[e,t,n,"collection",o,"list",i],collectionListInfinite:(e,t,n,o,i)=>[e,t,n,"collection",o,"list-infinite",i],githubReadme:(e,t)=>["github-readme",e,t],monitoringStats:()=>["monitoring","stats"],monitoringLogs:e=>["monitoring","logs",e],monitoringLogsInfinite:(e,t)=>["monitoring","logs-infinite",e,t],virtualMcpPrompts:e=>["virtual-mcp",e,"prompts"],connectionPrompts:e=>["connection",e,"prompts"],connectionResources:e=>["connection",e,"resources"],user:e=>["user",e]};class _ extends d{constructor(t,n){super(t,n)}send(t,n){const o=y(t);return o?.type==="emit"?(this.onmessage?.(o.message),Promise.resolve()):o?.type==="suppress"?Promise.resolve():super.send(t,n)}}function y(e){const t=e;if(!t||typeof t!="object"||!("method"in t))return null;switch(t.method){case"initialize":{const n=t?.params?.protocolVersion;return n?{type:"emit",message:{result:{protocolVersion:n,capabilities:{tools:{},resources:{},prompts:{},tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}},serverInfo:{name:"mesh-virtual-mcp",version:"1.0.0"}},jsonrpc:t.jsonrpc??"2.0",id:t.id}}:null}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}const b={name:"mesh-sdk",version:"1.0.0"};function C(e,t){const n=t??(typeof window<"u"?window.location.origin:void 0);if(!n)throw new Error("MCP client requires either meshUrl option or a browser environment.");const o=e?`/mcp/${e}`:"/mcp";return new URL(o,n).href}async function T({connectionId:e,orgId:t,token:n,meshUrl:o}){const i=C(e,o),c=new h(b,{capabilities:{tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}}}),s=new _(new URL(i),{requestInit:{headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","x-org-id":t,...n?{Authorization:`Bearer ${n}`}:{}}}});await c.connect(s);const r=u.mcpClient(t,e??"self",n??"",o??"");return c.toJSON=()=>`mcp-client:${r.join(":")}`,c}function v(e){const t=g.c(13),{connectionId:n,orgId:o,token:i,meshUrl:c}=e;let s;t[0]!==n||t[1]!==c||t[2]!==o||t[3]!==i?(s=u.mcpClient(o,n??"",i??"",c??""),t[0]=n,t[1]=c,t[2]=o,t[3]=i,t[4]=s):s=t[4];const r=s;let a;t[5]!==n||t[6]!==c||t[7]!==o||t[8]!==i?(a=()=>T({connectionId:n,orgId:o,token:i,meshUrl:c}),t[5]=n,t[6]=c,t[7]=o,t[8]=i,t[9]=a):a=t[9];let l;t[10]!==r||t[11]!==a?(l={queryKey:r,queryFn:a,staleTime:1/0,gcTime:0},t[10]=r,t[11]=a,t[12]=l):l=t[12];const{data:m}=f(l);return m}const P={SELF:e=>`${e}_self`,REGISTRY:e=>`${e}_registry`,COMMUNITY_REGISTRY:e=>`${e}_community-registry`,DEV_ASSETS:e=>`${e}_dev-assets`},M="self";function R(e){return{id:P.REGISTRY(e),title:"Deco Store",description:"Official deco MCP registry with curated integrations",connection_type:"HTTP",connection_url:"https://api.decocms.com/mcp/registry",icon:"https://assets.decocache.com/decocms/00ccf6c3-9e13-4517-83b0-75ab84554bb9/596364c63320075ca58483660156b6d9de9b526e.png",app_name:"deco-registry",app_id:null,connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:{isDefault:!0,type:"registry"}}}function I(){return{id:"community-registry",title:"MCP Registry",description:"Community MCP registry with thousands of handy MCPs",connection_type:"HTTP",connection_url:"https://sites-registry.decocache.com/mcp",icon:"https://assets.decocache.com/decocms/cd7ca472-0f72-463a-b0de-6e44bdd0f9b4/mcp.png",app_name:"mcp-registry",app_id:null,connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:{isDefault:!0,type:"registry"}}}function L(e={}){return{id:e.id,title:"OpenRouter",description:"Access hundreds of LLM models from a single API",icon:"https://assets.decocache.com/decocms/b2e2f64f-6025-45f7-9e8c-3b3ebdd073d8/openrouter_logojpg.jpg",app_name:"openrouter",app_id:"openrouter",connection_type:"HTTP",connection_url:"https://sites-openrouter.decocache.com/mcp",connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:{source:"chat",verified:!1,scopeName:"deco",toolsCount:0,publishedAt:null,repository:null}}}function D(){return{title:"MCP Studio",description:"An app that allows you to create and manage MCPs",icon:"https://assets.decocache.com/mcp/09e44283-f47d-4046-955f-816d227c626f/app.png",app_name:"mcp-studio",app_id:"65a1b407-b6af-41e2-a89f-ce9450c05bbc",connection_type:"HTTP",connection_url:"https://sites-vibemcp.decocache.com/mcp",connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:{isDefault:!1,type:"mcp-studio"}}}function E(e){return{id:w(e),organization_id:e,title:"Decopilot",description:"Default agent that aggregates all organization connections",icon:"https://assets.decocache.com/decocms/fd07a578-6b1c-40f1-bc05-88a3b981695d/f7fc4ffa81aec04e37ae670c3cd4936643a7b269.png",status:"active",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:"system",updated_by:void 0,metadata:{instructions:null},connections:[]}}const p="decopilot_";function A(e){return!e||!e.startsWith(p)?null:e.slice(p.length)||null}function w(e){return`${p}${e}`}export{u as K,_ as S,P as W,M as a,I as b,T as c,E as d,D as e,L as f,w as g,R as h,A as i,v as u};
@@ -0,0 +1 @@
1
+ import{H as t,I as a}from"./index-DkVMZPZp.js";const e=t(a,{target:"draft-7"});export{e as B};
@@ -1 +1 @@
1
- import{o as A,s as D,c as O,h as v,k as E,j as r,g as N}from"./index-BAZLm9w0.js";import{A as I,a as M,b as L,c as R,d as T,e as $,f as k}from"./alert-dialog-CHAGlLFb.js";import{B}from"./button-nyR0JH2l.js";import{F as V,a as q,b as H,c as U,d as G,e as J,f as K}from"./form-8XJyhmpO.js";import{I as P}from"./input-DHWQboe4.js";import{S as Q}from"./spinner-CQdhmUjg.js";import{u as W}from"./useMutation-ffySYpQB.js";function _(o){return o.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const X=A({name:D().min(2,"Organization name is required")});function ne(o){const e=O.c(41),{open:a,onOpenChange:s}=o;let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={resolver:v(X),defaultValues:{name:""}},e[0]=j):j=e[0];const t=E(j);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={mutationFn:Z,onSuccess:Y},e[1]=w):w=e[1];const i=W(w),z=i.error instanceof Error?i.error.message:i.error?"Failed to create organization.":null;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsxs(L,{children:[r.jsx(R,{children:"Create a new organization"}),r.jsx(T,{children:"Set up a new organization to collaborate with others."})]}),e[2]=F):F=e[2];let n;if(e[3]!==i||e[4]!==t){let x;e[6]!==i?(x=b=>i.mutateAsync(b),e[6]=i,e[7]=x):x=e[7],n=t.handleSubmit(x),e[3]=i,e[4]=t,e[5]=n}else n=e[5];let l;e[8]!==t.formState.isSubmitting?(l=x=>{const{field:b}=x;return r.jsxs(H,{children:[r.jsx(U,{children:"Organization Name"}),r.jsx(G,{children:r.jsx(P,{...b,placeholder:"Acme Inc.",disabled:t.formState.isSubmitting})}),r.jsx(J,{children:"The name of your company or organization"}),b.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",_(b.value)]})]}),r.jsx(K,{})]})},e[8]=t.formState.isSubmitting,e[9]=l):l=e[9];let m;e[10]!==t.control||e[11]!==l?(m=r.jsx(V,{control:t.control,name:"name",render:l}),e[10]=t.control,e[11]=l,e[12]=m):m=e[12];let c;e[13]!==z?(c=z&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:z}),e[13]=z,e[14]=c):c=e[14];let f;e[15]!==i||e[16]!==t?(f=()=>{i.reset(),t.reset()},e[15]=i,e[16]=t,e[17]=f):f=e[17];let g;e[18]!==t.formState.isSubmitting||e[19]!==f?(g=r.jsx(I,{disabled:t.formState.isSubmitting,onClick:f,children:"Cancel"}),e[18]=t.formState.isSubmitting,e[19]=f,e[20]=g):g=e[20];const y=!t.formState.isValid||t.formState.isSubmitting;let u;e[21]!==t.formState.isSubmitting?(u=t.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Q,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=t.formState.isSubmitting,e[22]=u):u=e[22];let d;e[23]!==y||e[24]!==u?(d=r.jsx(B,{type:"submit",variant:"default",disabled:y,children:u}),e[23]=y,e[24]=u,e[25]=d):d=e[25];let h;e[26]!==d||e[27]!==g?(h=r.jsxs($,{children:[g,d]}),e[26]=d,e[27]=g,e[28]=h):h=e[28];let S;e[29]!==h||e[30]!==n||e[31]!==m||e[32]!==c?(S=r.jsxs("form",{className:"space-y-6",onSubmit:n,autoComplete:"off",children:[m,c,h]}),e[29]=h,e[30]=n,e[31]=m,e[32]=c,e[33]=S):S=e[33];let p;e[34]!==t||e[35]!==S?(p=r.jsxs(M,{children:[F,r.jsx(q,{...t,children:S})]}),e[34]=t,e[35]=S,e[36]=p):p=e[36];let C;return e[37]!==s||e[38]!==a||e[39]!==p?(C=r.jsx(k,{open:a,onOpenChange:s,children:p}),e[37]=s,e[38]=a,e[39]=p,e[40]=C):C=e[40],C}function Y(o){const{orgSlug:e}=o;window.location.href=`/${e}`}async function Z(o){const e=_(o.name);if(!e)throw new Error("Organization slug is invalid");const a=await N.organization.create({name:o.name,slug:e});if(a?.error)throw new Error(a.error.message||"Failed to create organization");const s=a?.data?.slug??e;if(!s)throw new Error("Failed to create organization");return{orgSlug:s}}export{ne as C};
1
+ import{o as A,s as D,c as O,h as v,k as E,j as r,g as N}from"./index-DkVMZPZp.js";import{A as I,a as M,b as L,c as R,d as T,e as $,f as k}from"./alert-dialog-Cg14vDvh.js";import{B}from"./button-CWzK0IXA.js";import{F as V,a as q,b as H,c as U,d as G,e as J,f as K}from"./form-3eNCom8C.js";import{I as P}from"./input-BKM3goZw.js";import{S as Q}from"./spinner-D8NZVmaU.js";import{u as W}from"./useMutation-CFQDhqDA.js";function _(o){return o.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const X=A({name:D().min(2,"Organization name is required")});function ne(o){const e=O.c(41),{open:a,onOpenChange:s}=o;let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={resolver:v(X),defaultValues:{name:""}},e[0]=j):j=e[0];const t=E(j);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={mutationFn:Z,onSuccess:Y},e[1]=w):w=e[1];const i=W(w),z=i.error instanceof Error?i.error.message:i.error?"Failed to create organization.":null;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsxs(L,{children:[r.jsx(R,{children:"Create a new organization"}),r.jsx(T,{children:"Set up a new organization to collaborate with others."})]}),e[2]=F):F=e[2];let n;if(e[3]!==i||e[4]!==t){let x;e[6]!==i?(x=b=>i.mutateAsync(b),e[6]=i,e[7]=x):x=e[7],n=t.handleSubmit(x),e[3]=i,e[4]=t,e[5]=n}else n=e[5];let l;e[8]!==t.formState.isSubmitting?(l=x=>{const{field:b}=x;return r.jsxs(H,{children:[r.jsx(U,{children:"Organization Name"}),r.jsx(G,{children:r.jsx(P,{...b,placeholder:"Acme Inc.",disabled:t.formState.isSubmitting})}),r.jsx(J,{children:"The name of your company or organization"}),b.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",_(b.value)]})]}),r.jsx(K,{})]})},e[8]=t.formState.isSubmitting,e[9]=l):l=e[9];let m;e[10]!==t.control||e[11]!==l?(m=r.jsx(V,{control:t.control,name:"name",render:l}),e[10]=t.control,e[11]=l,e[12]=m):m=e[12];let c;e[13]!==z?(c=z&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:z}),e[13]=z,e[14]=c):c=e[14];let f;e[15]!==i||e[16]!==t?(f=()=>{i.reset(),t.reset()},e[15]=i,e[16]=t,e[17]=f):f=e[17];let g;e[18]!==t.formState.isSubmitting||e[19]!==f?(g=r.jsx(I,{disabled:t.formState.isSubmitting,onClick:f,children:"Cancel"}),e[18]=t.formState.isSubmitting,e[19]=f,e[20]=g):g=e[20];const y=!t.formState.isValid||t.formState.isSubmitting;let u;e[21]!==t.formState.isSubmitting?(u=t.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Q,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=t.formState.isSubmitting,e[22]=u):u=e[22];let d;e[23]!==y||e[24]!==u?(d=r.jsx(B,{type:"submit",variant:"default",disabled:y,children:u}),e[23]=y,e[24]=u,e[25]=d):d=e[25];let h;e[26]!==d||e[27]!==g?(h=r.jsxs($,{children:[g,d]}),e[26]=d,e[27]=g,e[28]=h):h=e[28];let S;e[29]!==h||e[30]!==n||e[31]!==m||e[32]!==c?(S=r.jsxs("form",{className:"space-y-6",onSubmit:n,autoComplete:"off",children:[m,c,h]}),e[29]=h,e[30]=n,e[31]=m,e[32]=c,e[33]=S):S=e[33];let p;e[34]!==t||e[35]!==S?(p=r.jsxs(M,{children:[F,r.jsx(q,{...t,children:S})]}),e[34]=t,e[35]=S,e[36]=p):p=e[36];let C;return e[37]!==s||e[38]!==a||e[39]!==p?(C=r.jsx(k,{open:a,onOpenChange:s,children:p}),e[37]=s,e[38]=a,e[39]=p,e[40]=C):C=e[40],C}function Y(o){const{orgSlug:e}=o;window.location.href=`/${e}`}async function Z(o){const e=_(o.name);if(!e)throw new Error("Organization slug is invalid");const a=await N.organization.create({name:o.name,slug:e});if(a?.error)throw new Error(a.error.message||"Failed to create organization");const s=a?.data?.slug??e;if(!s)throw new Error("Failed to create organization");return{orgSlug:s}}export{ne as C};