decocms 2.306.13 → 2.306.15

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 (186) hide show
  1. package/dist/client/assets/{AlertCircle-UghQPlAa.js → AlertCircle-CIkkTlF7.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-1BfkUm85.js → ArrowNarrowLeft-Cdap_AHq.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-1rqShrTM.js → ArrowUpRight-DISZ90vG.js} +1 -1
  4. package/dist/client/assets/{Check-DBWnyOFJ.js → Check-CrFTsmMd.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-CBMgXE-F.js → CheckCircle-CpClZbOK.js} +1 -1
  6. package/dist/client/assets/{ChevronDown-D452dgSU.js → ChevronDown-vyFW7nWm.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-DoY3rcf9.js → ChevronRight-B1QR9mxi.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-BlZFoG59.js → ChevronUp-B_8XT1h5.js} +1 -1
  9. package/dist/client/assets/{Container-BQVUd9tN.js → Container-BSuhE8C0.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CAgAGLKz.js → DotsVertical-D5hdBGsZ.js} +1 -1
  11. package/dist/client/assets/{LinkExternal01-CGcDVdEi.js → LinkExternal01-D8USnatR.js} +1 -1
  12. package/dist/client/assets/{Lock01-FiMk9Cv6.js → Lock01-BMc0QX1N.js} +1 -1
  13. package/dist/client/assets/{Palette-DXyBGBQu.js → Palette-DWWtOVzo.js} +1 -1
  14. package/dist/client/assets/{Play-CDjH79to.js → Play-MH92fE32.js} +1 -1
  15. package/dist/client/assets/{Plus-FC_C8qkl.js → Plus-DAOphtXP.js} +1 -1
  16. package/dist/client/assets/{RefreshCcw01-Cd8Km121.js → RefreshCcw01-DN4ew4Kc.js} +1 -1
  17. package/dist/client/assets/{SearchMd-B780aQOS.js → SearchMd-MizqCBM1.js} +1 -1
  18. package/dist/client/assets/{Settings02--XuHa5eI.js → Settings02-2PiOkYtI.js} +1 -1
  19. package/dist/client/assets/{Shield01-Bg1T1EGa.js → Shield01-oTE-LfH6.js} +1 -1
  20. package/dist/client/assets/{Star01-DRidtrYn.js → Star01-D8dlu5Yy.js} +1 -1
  21. package/dist/client/assets/{Sun-Bpli4t2N.js → Sun-OhlBKjKD.js} +1 -1
  22. package/dist/client/assets/{Tool01-NWIcFn9q.js → Tool01-C9QYl8tu.js} +1 -1
  23. package/dist/client/assets/{Trash01-4w6_aW9X.js → Trash01-Cn1Fmdwd.js} +1 -1
  24. package/dist/client/assets/{User01-CxpWRrdM.js → User01-D9nCHLW_.js} +1 -1
  25. package/dist/client/assets/{Users03-CK1Aa1HI.js → Users03-C8vM077j.js} +1 -1
  26. package/dist/client/assets/{X-BGh8G2l7.js → X-DcV2kx7g.js} +1 -1
  27. package/dist/client/assets/{XCircle-CYGTZyzW.js → XCircle-VFtGBzwy.js} +1 -1
  28. package/dist/client/assets/{XClose-Dz5yGfpm.js → XClose-DfIvwfxS.js} +1 -1
  29. package/dist/client/assets/{Zap-Druw6RpX.js → Zap-CLvz7RTE.js} +1 -1
  30. package/dist/client/assets/{ZapSquare-BLhBRchY.js → ZapSquare-BtHPjvWF.js} +1 -1
  31. package/dist/client/assets/{accordion-DdQd4o33.js → accordion-BpppHrXX.js} +1 -1
  32. package/dist/client/assets/{agent-icon-CznXZlOI.js → agent-icon-B77lAtfk.js} +1 -1
  33. package/dist/client/assets/{agents-list-CaQhK_9Q.js → agents-list-DcUtsjo0.js} +1 -1
  34. package/dist/client/assets/ai-providers-Bai6F1w9.js +1 -0
  35. package/dist/client/assets/{alert-dialog-BiN56dOX.js → alert-dialog-ffhzv4m-.js} +1 -1
  36. package/dist/client/assets/{auth-catchall-6Av77aQi.js → auth-catchall-CTKap3mM.js} +1 -1
  37. package/dist/client/assets/{automation-list-row-DdlSuO-v.js → automation-list-row-DCpw1HBv.js} +1 -1
  38. package/dist/client/assets/{automations-BMuo3AXx.js → automations-BMIHIrMi.js} +1 -1
  39. package/dist/client/assets/{avatar-Z1wN1pq-.js → avatar-CMxH2q_w.js} +1 -1
  40. package/dist/client/assets/{badge-CTmf2TW8.js → badge-CgoHsUkF.js} +1 -1
  41. package/dist/client/assets/{brand-context-CUDRGuTh.js → brand-context-NnPmYyFo.js} +1 -1
  42. package/dist/client/assets/{card-Bd8klEwI.js → card-BiS_R1xQ.js} +1 -1
  43. package/dist/client/assets/{chat-context-DGU47jw7.js → chat-context-Rq_Iuvf4.js} +1 -1
  44. package/dist/client/assets/{checkbox-B3EwrxkO.js → checkbox-yg1I1N9G.js} +1 -1
  45. package/dist/client/assets/{collection-detail-Cgmw3RVY.js → collection-detail-_OUZ1nCa.js} +1 -1
  46. package/dist/client/assets/{collection-display-button-DMmbKfya.js → collection-display-button-DeSxG6UB.js} +1 -1
  47. package/dist/client/assets/{collection-search-D-x3SJ1z.js → collection-search-7y-wgnCT.js} +1 -1
  48. package/dist/client/assets/{collection-search-Do2r8Bif.js → collection-search-Dll2Lk9F.js} +1 -1
  49. package/dist/client/assets/{collection-table-wrapper-CtvRahI-.js → collection-table-wrapper-xdclfmzd.js} +1 -1
  50. package/dist/client/assets/{collection-tabs-BKqleLTU.js → collection-tabs-Dj_k95te.js} +1 -1
  51. package/dist/client/assets/{collections-67ZnQ_LS.js → collections-DnZgyzTW.js} +1 -1
  52. package/dist/client/assets/{command-BAMG06m5.js → command-BdLpLF4Y.js} +1 -1
  53. package/dist/client/assets/{connection-card-DQm8aezN.js → connection-card-DKYOuda_.js} +1 -1
  54. package/dist/client/assets/{connection-detail-BhxCMY6j.js → connection-detail-ZeLVtXEt.js} +1 -1
  55. package/dist/client/assets/{connection-form-helpers--6zqXj9i.js → connection-form-helpers-BASCNONd.js} +1 -1
  56. package/dist/client/assets/{connections-C0gQbHBs.js → connections-BMSc7-Es.js} +1 -1
  57. package/dist/client/assets/{constants-DXQgV2hu.js → constants-ChKBx8P9.js} +1 -1
  58. package/dist/client/assets/{constants-BDk5hb7z.js → constants-CjyyPkqB.js} +1 -1
  59. package/dist/client/assets/{dialog-DUgfuVrb.js → dialog-DWzrMeko.js} +1 -1
  60. package/dist/client/assets/{domain-settings-DpONcUPd.js → domain-settings-CgLUbjrq.js} +1 -1
  61. package/dist/client/assets/{drawer-DeyjQQc7.js → drawer-CVaGMEnC.js} +1 -1
  62. package/dist/client/assets/{dropdown-menu-Cbx_bdO_.js → dropdown-menu-D9UMjJNs.js} +1 -1
  63. package/dist/client/assets/{dynamic-plugin-layout-D7HG8B_t.js → dynamic-plugin-layout-DUGZplob.js} +1 -1
  64. package/dist/client/assets/{empty-state-BnjbbhBR.js → empty-state-CEv_S9NU.js} +1 -1
  65. package/dist/client/assets/{empty-state-BIAZXmQO.js → empty-state-DHmS7AZ6.js} +1 -1
  66. package/dist/client/assets/{extract-connection-data-Dgw7Sgd3.js → extract-connection-data-OE0lRTFA.js} +1 -1
  67. package/dist/client/assets/{features-De6GvAAs.js → features-BxUdFWas.js} +1 -1
  68. package/dist/client/assets/{form-O0xus6j8.js → form-x_GA0lGZ.js} +1 -1
  69. package/dist/client/assets/{general-tEcdYerZ.js → general-xbPvQEW6.js} +1 -1
  70. package/dist/client/assets/{index-DPM8__xA.js → index-B79QPuhQ.js} +1 -1
  71. package/dist/client/assets/{index-CqFBXkjQ.js → index-BFkfPy7u.js} +1 -1
  72. package/dist/client/assets/{index-EV8zcDnc.js → index-BH3y0deM.js} +1 -1
  73. package/dist/client/assets/{index-XGdWuQyL.js → index-Bu3Wy6vF.js} +1 -1
  74. package/dist/client/assets/{index-CG3ceZHc.js → index-C6p1UU5y.js} +1 -1
  75. package/dist/client/assets/{index-CuVn0uMY.js → index-CopHENRs.js} +1 -1
  76. package/dist/client/assets/{index-i68m5nvc.js → index-D9bqveRt.js} +1 -1
  77. package/dist/client/assets/{index-Dcg8Qevd.js → index-DGBhnElr.js} +2 -2
  78. package/dist/client/assets/index-DMmG8Xta.js +1 -0
  79. package/dist/client/assets/{index-DZjKh5eS.js → index-DZx6AUWL.js} +3 -3
  80. package/dist/client/assets/{index-CdFJkiAN.js → index-Df3GOSYm.js} +1 -1
  81. package/dist/client/assets/{index-DdsW868M.js → index-FaOXDjGC.js} +1 -1
  82. package/dist/client/assets/{index-CZLTTN-z.js → index-bLj_vX-5.js} +1 -1
  83. package/dist/client/assets/{index-DtUGvIts.js → index-eAGChOCR.js} +1 -1
  84. package/dist/client/assets/{index-DJiWK6lj.js → index-qLhngyMj.js} +1 -1
  85. package/dist/client/assets/{index-DV-VioVg.js → index-ua9QmBu2.js} +1 -1
  86. package/dist/client/assets/{infiniteQueryObserver-D9yYekai.js → infiniteQueryObserver-Cy5fWNus.js} +1 -1
  87. package/dist/client/assets/{input-Cvo2jJQf.js → input-DzxFi8fX.js} +1 -1
  88. package/dist/client/assets/{integration-icon-DTJ2wb4X.js → integration-icon-BgHtBrFn.js} +1 -1
  89. package/dist/client/assets/{label-_jNQo8Ll.js → label-DuKyp2cN.js} +1 -1
  90. package/dist/client/assets/{layout-DbwGS2qx.js → layout-CoMLDyJ-.js} +1 -1
  91. package/dist/client/assets/{lean-canvas-recruit-modal-tP8fRQib.js → lean-canvas-recruit-modal-C23fbv3U.js} +1 -1
  92. package/dist/client/assets/{login-DehPjhCM.js → login-wbePE4N0.js} +1 -1
  93. package/dist/client/assets/{members-BMPf1BpS.js → members-B9Pm3wRi.js} +1 -1
  94. package/dist/client/assets/{monaco-editor-BVARKKWN.js → monaco-editor-DlP04BYU.js} +1 -1
  95. package/dist/client/assets/{monitoring-stats-row-D7tWgW-Q.js → monitoring-stats-row-CfKC9LMN.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-l4PY6t1A.js → oauth-callback-BaeEpHuZ.js} +1 -1
  97. package/dist/client/assets/{oauth-callback-ai-provider-DC-UED8v.js → oauth-callback-ai-provider-B9fuYOAk.js} +1 -1
  98. package/dist/client/assets/{onboarding-Bd6pQbk3.js → onboarding-MdpKvsCc.js} +1 -1
  99. package/dist/client/assets/{org-layout-COoj2PVG.js → org-layout-DZtjtaSY.js} +1 -1
  100. package/dist/client/assets/{org-plugin-layout-DGnpwRtk.js → org-plugin-layout-CFNQJjnL.js} +1 -1
  101. package/dist/client/assets/{pair-_253DGSq.js → pair-Cb9wMKkp.js} +1 -1
  102. package/dist/client/assets/{plugin-empty-state-CakFVZ2i.js → plugin-empty-state-DNa6nsoW.js} +1 -1
  103. package/dist/client/assets/{plugin-header-6TMFE3Ls.js → plugin-header-CYn2IE4X.js} +1 -1
  104. package/dist/client/assets/{plugin-layout-3m9okTPI.js → plugin-layout-j4_UYQDV.js} +1 -1
  105. package/dist/client/assets/{popover-DNu8C4Ll.js → popover-Le9pRw8B.js} +1 -1
  106. package/dist/client/assets/{profile-CLBWN3L8.js → profile-CPWscNWi.js} +1 -1
  107. package/dist/client/assets/{project-app-view-5ZnU4fo7.js → project-app-view-BHz8L-HQ.js} +1 -1
  108. package/dist/client/assets/registry-CQ7pl1Pr.js +2 -0
  109. package/dist/client/assets/{registry-layout-Hazgpecz.js → registry-layout-dRWbjORf.js} +1 -1
  110. package/dist/client/assets/{required-auth-layout-Cg8CZTlk.js → required-auth-layout-Pt0Rd8Fm.js} +1 -1
  111. package/dist/client/assets/{reset-password-CzwUFBho.js → reset-password-CAwZsKpJ.js} +1 -1
  112. package/dist/client/assets/{roles-DUtgWupV.js → roles-BUCmGiTb.js} +1 -1
  113. package/dist/client/assets/{scroll-area-DGEAK3pH.js → scroll-area-DBQm7zmF.js} +1 -1
  114. package/dist/client/assets/{search-input-C50ImRzg.js → search-input-B6qLYIdC.js} +1 -1
  115. package/dist/client/assets/{select-DkBE5ypj.js → select-C4bCQJgN.js} +1 -1
  116. package/dist/client/assets/{select-model-B9xghDV8.js → select-model-CFqPJ1H2.js} +1 -1
  117. package/dist/client/assets/{settings-layout-u6gOtHmU.js → settings-layout-CQak8li2.js} +1 -1
  118. package/dist/client/assets/{settings-section-DeAx6MsQ.js → settings-section-jTaVlfku.js} +1 -1
  119. package/dist/client/assets/{shell-layout-xLg1cKrj.js → shell-layout-B681S4cR.js} +1 -1
  120. package/dist/client/assets/{skeleton-BL7idETO.js → skeleton-BHVCGCRI.js} +1 -1
  121. package/dist/client/assets/{sso-UHrPOY4-.js → sso-CjHHDhyD.js} +1 -1
  122. package/dist/client/assets/{store-CCrp-zDu.js → store-10Y2VMNT.js} +1 -1
  123. package/dist/client/assets/store-registry-BBjFRrS9.js +2 -0
  124. package/dist/client/assets/{switch-Ba2DX0J8.js → switch-BAJJzbRq.js} +1 -1
  125. package/dist/client/assets/{table-Dpjp6sno.js → table-DUHnOueh.js} +1 -1
  126. package/dist/client/assets/{tabs-CUXWIghp.js → tabs-DZ-UigIt.js} +1 -1
  127. package/dist/client/assets/{task-status-D6HaLDfU.js → task-status-UkB7MCMT.js} +1 -1
  128. package/dist/client/assets/{textarea-e7WVG0Uq.js → textarea-DTBlkTwn.js} +1 -1
  129. package/dist/client/assets/{toggle-group-Bzjy8IQq.js → toggle-group-WQKfLs2t.js} +1 -1
  130. package/dist/client/assets/{tools-list-ddVo-6Vs.js → tools-list-DpkqKld0.js} +1 -1
  131. package/dist/client/assets/{tooltip-sn7TXXXA.js → tooltip-CkuZjpG2.js} +1 -1
  132. package/dist/client/assets/{types-ClFDwb3j.js → types-g30HZ1cH.js} +1 -1
  133. package/dist/client/assets/{use-ai-providers-D1ZzNZfi.js → use-ai-providers-CEyFLQmS.js} +1 -1
  134. package/dist/client/assets/{use-collections-DDocavcC.js → use-collections-isYyFolY.js} +1 -1
  135. package/dist/client/assets/{use-connection-wzOJDB7e.js → use-connection-2nfGp1Tw.js} +1 -1
  136. package/dist/client/assets/{use-copy-D0VCYdzD.js → use-copy-DVLXao5Z.js} +1 -1
  137. package/dist/client/assets/{use-create-virtual-mcp-BQ9UAVGc.js → use-create-virtual-mcp-ChfF1BUq.js} +1 -1
  138. package/dist/client/assets/{use-debounced-autosave-vxXjJ2-V.js → use-debounced-autosave-DucmaD2V.js} +1 -1
  139. package/dist/client/assets/{use-decopilot-events-CQn9-0iO.js → use-decopilot-events-DCwMJhMc.js} +1 -1
  140. package/dist/client/assets/{use-delete-connection-C1mV-M2x.js → use-delete-connection-mWOjFFGp.js} +1 -1
  141. package/dist/client/assets/{use-infinite-scroll-CyUixfAd.js → use-infinite-scroll-BPX0CawW.js} +1 -1
  142. package/dist/client/assets/{use-list-state-BkqBgDIi.js → use-list-state-Ajk41_oq.js} +1 -1
  143. package/dist/client/assets/{use-mcp-tools-Cu2GPPjO.js → use-mcp-tools-DsJCeK5Y.js} +1 -1
  144. package/dist/client/assets/{use-members-Bw_9meIY.js → use-members-B9Eyug-z.js} +1 -1
  145. package/dist/client/assets/{use-navigate-to-agent-BvnJAyr6.js → use-navigate-to-agent-Cz3ZvHb6.js} +1 -1
  146. package/dist/client/assets/{use-org-auth-client-uXh4lV5h.js → use-org-auth-client-CC9Iglye.js} +1 -1
  147. package/dist/client/assets/{use-org-sso-Co0XjU-j.js → use-org-sso-Bd6T193E.js} +1 -1
  148. package/dist/client/assets/{use-organization-roles-CXi0dKrO.js → use-organization-roles-BAYYxXBp.js} +1 -1
  149. package/dist/client/assets/{use-organization-settings-OER3kM7D.js → use-organization-settings-CCpba_eF.js} +1 -1
  150. package/dist/client/assets/{use-registry-connections-LYUFCGgQ.js → use-registry-connections-CbKI0pjB.js} +1 -1
  151. package/dist/client/assets/{use-status-sounds-CQVr-jwf.js → use-status-sounds-rQljUDDi.js} +1 -1
  152. package/dist/client/assets/{use-tasks-B8ZzLgVK.js → use-tasks-Cq912bSr.js} +1 -1
  153. package/dist/client/assets/{use-view-mode-ti5AMLDX.js → use-view-mode-CQCwdxiq.js} +1 -1
  154. package/dist/client/assets/{use-virtual-mcp-Cvy2Xx_N.js → use-virtual-mcp-BlZvOWuE.js} +1 -1
  155. package/dist/client/assets/useInfiniteQuery-DGAowBb5.js +1 -0
  156. package/dist/client/assets/useSuspenseInfiniteQuery-sUHx2ilf.js +1 -0
  157. package/dist/client/assets/{user-Dst4Prvf.js → user-CLrbzmGW.js} +1 -1
  158. package/dist/client/assets/{view-mode-toggle-Ca3EQ8LL.js → view-mode-toggle-yG7ozqz2.js} +1 -1
  159. package/dist/client/assets/{workflow-BUQXpyzH.js → workflow-D8BZX_5_.js} +1 -1
  160. package/dist/client/assets/workflow-detail--H2ZMjSK.js +1 -0
  161. package/dist/client/index.html +1 -1
  162. package/dist/server/cli.js +6 -1
  163. package/dist/server/server.js +5 -0
  164. package/package.json +1 -1
  165. package/dist/client/assets/ai-providers-C_QaV2LV.js +0 -1
  166. package/dist/client/assets/index-BZ6nkz4a.js +0 -1
  167. package/dist/client/assets/registry-D_jmaKr2.js +0 -2
  168. package/dist/client/assets/store-registry-dlSCWL84.js +0 -2
  169. package/dist/client/assets/useInfiniteQuery-eCacXMD5.js +0 -1
  170. package/dist/client/assets/useSuspenseInfiniteQuery-Ck-t1SMi.js +0 -1
  171. package/dist/client/assets/workflow-detail-DLo-hD09.js +0 -1
  172. package/dist/server/node_modules/ansi-styles/index.d.ts +0 -236
  173. package/dist/server/node_modules/ansi-styles/index.js +0 -223
  174. package/dist/server/node_modules/ansi-styles/license +0 -9
  175. package/dist/server/node_modules/ansi-styles/package.json +0 -54
  176. package/dist/server/node_modules/ansi-styles/readme.md +0 -173
  177. package/dist/server/node_modules/mimic-fn/index.d.ts +0 -54
  178. package/dist/server/node_modules/mimic-fn/index.js +0 -13
  179. package/dist/server/node_modules/mimic-fn/license +0 -9
  180. package/dist/server/node_modules/mimic-fn/package.json +0 -42
  181. package/dist/server/node_modules/mimic-fn/readme.md +0 -69
  182. package/dist/server/node_modules/onetime/index.d.ts +0 -64
  183. package/dist/server/node_modules/onetime/index.js +0 -44
  184. package/dist/server/node_modules/onetime/license +0 -9
  185. package/dist/server/node_modules/onetime/package.json +0 -43
  186. package/dist/server/node_modules/onetime/readme.md +0 -94
@@ -1,4 +1,4 @@
1
- import{cp as Fe,bn as Os,J as oe,I as ge,a_ as ti,bS as _i,aK as Ie,bl as mt,a$ as qe,ap as mr,cq as rn,H as _e,cr as Ii,cs as ws,ct as ec,bQ as tc,cu as ia,cv as nc,cw as rc,cx as ic,cy as fn,cz as Tr,cA as xs,bL as sa,bD as sc,aJ as ze,bR as oc,aI as On,bb as Ci,cB as ac,r as N,j as w,cC as oa,cD as lc}from"./index-Dcg8Qevd.js";import{f as cc,h as uc,n as fc,j as dc,C as hc,A as pc}from"./constants-DXQgV2hu.js";import{B as Ti,c as Pi}from"./collections-67ZnQ_LS.js";import{R as Es}from"./index-CqFBXkjQ.js";var mc=class{apply(e,t){if(!t.type)return;const n=Array.isArray(t.type)?t.type:[t.type],r=new Set(n);if(r.has("string")||(e.string=!1),!r.has("number")&&!r.has("integer")&&(e.number=!1),r.has("boolean")||(e.boolean=!1),r.has("null")||(e.null=!1),r.has("array")||(e.array=!1),r.has("object")||(e.object=!1),r.has("integer")&&e.number!==!1){const i=e.number||ge();i instanceof rn&&(e.number=i.int())}}},yc=class{apply(e,t){if(t.const===void 0)return;const n=t.const;e.string=!1,e.number=!1,e.boolean=!1,e.null=!1,e.array=!1,e.object=!1,typeof n=="string"?e.string=qe(n):typeof n=="number"?e.number=qe(n):typeof n=="boolean"?e.boolean=qe(n):n===null?e.null=_i():Array.isArray(n)?e.array=void 0:typeof n=="object"&&(e.object=void 0)}},gc=class{apply(e,t){if(!t.enum)return;if(t.enum.length===0){t.type||(e.string=!1,e.number=!1,e.boolean=!1,e.null=!1,e.array=!1,e.object=!1);return}const n={string:t.enum.filter(r=>typeof r=="string"),number:t.enum.filter(r=>typeof r=="number"),boolean:t.enum.filter(r=>typeof r=="boolean"),null:t.enum.filter(r=>r===null),array:t.enum.filter(r=>Array.isArray(r)),object:t.enum.filter(r=>typeof r=="object"&&r!==null&&!Array.isArray(r))};e.string=this.createTypeSchema(n.string,"string"),e.number=this.createTypeSchema(n.number,"number"),e.boolean=this.createTypeSchema(n.boolean,"boolean"),e.null=n.null.length>0?_i():!1,e.array=n.array.length>0?void 0:!1,e.object=n.object.length>0?void 0:!1}createTypeSchema(e,t){if(e.length===0)return!1;if(e.length===1)return qe(e[0]);if(t==="string")return mr(e);if(t==="number"){const[n,r,...i]=e;return mt([qe(n),qe(r),...i.map(s=>qe(s))])}return t==="boolean"?mt([qe(!0),qe(!1)]):!1}},bc=class{apply(e,t){const n=t;if(n.type==="string"&&n.format==="binary"&&n.contentEncoding==="binary"){let r=ic();n.minLength!==void 0&&(r=r.min(n.minLength)),n.maxLength!==void 0&&(r=r.max(n.maxLength)),n.contentMediaType!==void 0&&(r=r.mime(n.contentMediaType)),e.file=r,e.string=!1}}},Sc=class{apply(e,t){const n=t;t.type===void 0&&(n.minLength!==void 0||n.maxLength!==void 0||n.pattern!==void 0)&&e.string===void 0&&(e.string=oe())}},vc=class{apply(e,t){const n=t;if(n.minLength!==void 0&&e.string!==!1){const r=e.string||oe();r instanceof Ii&&(e.string=r.refine(i=>Array.from(i).length>=n.minLength,{message:`String must be at least ${n.minLength} characters long`}))}}},Oc=class{apply(e,t){const n=t;if(n.maxLength!==void 0&&e.string!==!1){const r=e.string||oe();r instanceof Ii&&(e.string=r.refine(i=>Array.from(i).length<=n.maxLength,{message:`String must be at most ${n.maxLength} characters long`}))}}},wc=class{apply(e,t){const n=t;if(n.pattern&&e.string!==!1){const r=e.string||oe();if(r instanceof Ii){const i=new RegExp(n.pattern);e.string=r.regex(i)}}}},xc=class{apply(e,t){const n=t;if(n.minimum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(e.number=r.min(n.minimum))}}},Ec=class{apply(e,t){const n=t;if(n.maximum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(e.number=r.max(n.maximum))}}},Ac=class{apply(e,t){const n=t;if(n.exclusiveMinimum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(typeof n.exclusiveMinimum=="number"?e.number=r.gt(n.exclusiveMinimum):e.number=!1)}}},_c=class{apply(e,t){const n=t;if(n.exclusiveMaximum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(typeof n.exclusiveMaximum=="number"?e.number=r.lt(n.exclusiveMaximum):e.number=!1)}}},Ic=class{apply(e,t){const n=t;if(n.multipleOf!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(e.number=r.refine(i=>{if(n.multipleOf===0)return!1;const s=i/n.multipleOf,o=Math.round(s),a=Math.min(Math.abs(i)*Number.EPSILON*10,Math.abs(n.multipleOf)*Number.EPSILON*10);return Math.abs(s-o)<=a/Math.abs(n.multipleOf)},{message:`Must be a multiple of ${n.multipleOf}`}))}}},Cc=class{apply(e,t){const n=t;t.type===void 0&&(n.minItems!==void 0||n.maxItems!==void 0||n.items!==void 0||n.prefixItems!==void 0)&&e.array===void 0&&(e.array=Ie(Fe()))}},Tc=class{apply(e,t){const n=t;n.minItems!==void 0&&e.array!==!1&&(e.array=(e.array||Ie(Fe())).min(n.minItems))}},Pc=class{apply(e,t){const n=t;n.maxItems!==void 0&&e.array!==!1&&(e.array=(e.array||Ie(Fe())).max(n.maxItems))}},Fc=class{apply(e,t){const n=t;if(e.array!==!1)if(Array.isArray(n.items))e.array=e.array||Ie(Fe());else if(n.items&&typeof n.items!="boolean"&&!n.prefixItems){const r=Ae(n.items);let i=Ie(r);if(e.array&&e.array instanceof ec){const s=e.array._def;s.checks&&s.checks.forEach(o=>{if(o._zod&&o._zod.def){const a=o._zod.def;a.check==="min_length"&&a.minimum!==void 0?i=i.min(a.minimum):a.check==="max_length"&&a.maximum!==void 0&&(i=i.max(a.maximum))}})}e.array=i}else typeof n.items=="boolean"&&n.items===!1?n.prefixItems?e.array=e.array||Ie(Fe()):e.array=Ie(Fe()).max(0):typeof n.items=="boolean"&&n.items===!0?e.array=e.array||Ie(Fe()):n.prefixItems&&(e.array=e.array||Ie(Fe()))}},jc=class{apply(e,t){if(t.type!=="array")return;const n=t;if(!Array.isArray(n.items)||e.array===!1)return;const r=n.items.map(s=>Ae(s));let i;r.length===0?i=ws([]):i=ws(r),n.minItems!==void 0&&n.minItems>r.length&&(i=!1),n.maxItems!==void 0&&n.maxItems<r.length&&(i=!1),e.tuple=i,e.array=!1}},$c=class{apply(e,t){const n=t;e.object!==!1&&(n.properties||n.required||n.additionalProperties!==void 0)&&(e.object=e.object||_e({}).passthrough())}},Dc=class{apply(e,t){const n=t;t.type===void 0&&(n.maxProperties!==void 0||n.minProperties!==void 0)&&e.object===void 0&&(e.object=_e({}).passthrough())}},Nc=class{apply(e,t){const n=t;if(n.maxProperties!==void 0&&e.object!==!1){const r=e.object||_e({}).passthrough();e.object=r.refine(i=>Object.keys(i).length<=n.maxProperties,{message:`Object must have at most ${n.maxProperties} properties`})}}},Rc=class{apply(e,t){const n=t;if(n.minProperties!==void 0&&e.object!==!1){const r=e.object||_e({}).passthrough();e.object=r.refine(i=>Object.keys(i).length>=n.minProperties,{message:`Object must have at least ${n.minProperties} properties`})}}};function Tn(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((n,r)=>Tn(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>r.includes(i)&&Tn(e[i],t[i]))}return!1}function Mc(){return e=>{if(!Array.isArray(e))return!0;const t=[];return e.every(n=>t.some(i=>Tn(n,i))?!1:(t.push(n),!0))}}function cr(e,t){return e.safeParse(t).success}var Uc=class{apply(e,t){if(!t.not)return e;const n=Ae(t.not);return e.refine(r=>!cr(n,r),{message:"Value must not match the 'not' schema"})}},kc=class{apply(e,t){return t.uniqueItems!==!0?e:e.refine(Mc(),{message:"Array items must be unique"})}},Lc=class{apply(e,t){return!t.allOf||t.allOf.length===0?e:t.allOf.map(r=>Ae(r)).reduce((r,i)=>ia(r,i),e)}},Bc=class{apply(e,t){if(!t.anyOf||t.anyOf.length===0)return e;const n=t.anyOf.length===1?Ae(t.anyOf[0]):mt([Ae(t.anyOf[0]),Ae(t.anyOf[1]),...t.anyOf.slice(2).map(r=>Ae(r))]);return ia(e,n)}},Wc=class{apply(e,t){if(!t.oneOf||t.oneOf.length===0)return e;const n=t.oneOf.map(r=>Ae(r));return e.refine(r=>{let i=0;for(const s of n)if(s.safeParse(r).success&&(i++,i>1))return!1;return i===1},{message:"Value must match exactly one of the oneOf schemas"})}},qc=class{apply(e,t){const n=t;if(n.prefixItems&&Array.isArray(n.prefixItems)){const i=n.prefixItems.map(s=>Ae(s));return e.refine(s=>{if(!Array.isArray(s))return!0;for(let o=0;o<Math.min(s.length,i.length);o++)if(!cr(i[o],s[o]))return!1;if(s.length>i.length){if(typeof n.items=="boolean"&&n.items===!1)return!1;if(n.items&&typeof n.items=="object"&&!Array.isArray(n.items)){const o=Ae(n.items);for(let a=i.length;a<s.length;a++)if(!cr(o,s[a]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return e}},Vc=class{apply(e,t){const n=t;if(!n.properties&&!n.required&&n.additionalProperties!==!1)return e;if(e instanceof nc||e instanceof rc){const r={};if(n.properties)for(const[i,s]of Object.entries(n.properties))s!==void 0&&(r[i]=Ae(s));if(n.required&&Array.isArray(n.required)){const i=new Set(n.required);for(const s of Object.keys(r))i.has(s)||(r[s]=r[s].optional())}else for(const i of Object.keys(r))r[i]=r[i].optional();return n.additionalProperties===!1?_e(r):_e(r).passthrough()}return e.refine(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return!0;if(n.properties){for(const[i,s]of Object.entries(n.properties))if(s!==void 0&&Object.getOwnPropertyDescriptor(r,i)!==void 0&&!Ae(s).safeParse(r[i]).success)return!1}if(n.required&&Array.isArray(n.required)){for(const i of n.required)if(!(Object.getOwnPropertyDescriptor(r,i)!==void 0))return!1}if(n.additionalProperties===!1&&n.properties){const i=new Set(Object.keys(n.properties));for(const s in r)if(!i.has(s))return!1}return!0},{message:"Object constraints validation failed"})}},Hc=class{apply(e,t){if(!t.enum||t.enum.length===0)return e;const n=t.enum.filter(r=>Array.isArray(r)||typeof r=="object"&&r!==null);return n.length===0?e:e.refine(r=>typeof r!="object"||r===null?!0:n.some(i=>Tn(r,i)),{message:"Value must match one of the enum values"})}},Kc=class{apply(e,t){if(t.const===void 0)return e;const n=t.const;return typeof n!="object"||n===null?e:e.refine(r=>Tn(r,n),{message:"Value must equal the const value"})}},Gc=class{apply(e,t){return t.description&&(e=e.describe(t.description)),e}},zc=class{apply(e,t){var n;const r=t;return!((n=r.required)!=null&&n.includes("__proto__"))||t.type!==void 0?e:Fe().refine(i=>this.validateRequired(i,r.required),{message:"Missing required properties"})}validateRequired(e,t){return typeof e!="object"||e===null||Array.isArray(e)?!0:t.every(n=>Object.prototype.hasOwnProperty.call(e,n))}},Yc=class{apply(e,t){var n;const r=t;if(r.contains===void 0)return e;const i=Ae(r.contains),s=(n=r.minContains)!=null?n:1,o=r.maxContains;return e.refine(a=>{if(!Array.isArray(a))return!0;let l=0;for(const c of a)cr(i,c)&&l++;return!(l<s||o!==void 0&&l>o)},{message:"Array must contain required items matching the schema"})}},Jc=class{apply(e,t){const{default:n}=t;return n===void 0||!e.safeParse(n).success?e:e.default(n)}},Zc=[new yc,new gc,new mc,new bc,new Sc,new Cc,new Dc,new vc,new Oc,new wc,new xc,new Ec,new Ac,new _c,new Ic,new jc,new Tc,new Pc,new Fc,new Nc,new Rc,new $c],Xc=[new zc,new Hc,new Kc,new Lc,new Bc,new Wc,new qc,new Vc,new Yc,new Uc,new kc,new Jc,new Gc];function Ae(e){if(typeof e=="boolean")return e?Fe():Os();const t={};for(const i of Zc)i.apply(t,e);const n=[];if(t.string!==!1&&n.push(t.string||oe()),t.number!==!1&&n.push(t.number||ge()),t.boolean!==!1&&n.push(t.boolean||ti()),t.null!==!1&&n.push(t.null||_i()),t.array!==!1&&n.push(t.array||Ie(Fe())),t.tuple!==!1&&t.tuple!==void 0&&n.push(t.tuple),t.object!==!1)if(t.object)n.push(t.object);else{const i=tc(s=>typeof s=="object"&&s!==null&&!Array.isArray(s),"Must be an object, not an array");n.push(i)}t.file!==!1&&t.file!==void 0&&n.push(t.file);let r;n.length===0?r=Os():n.length===1?r=n[0]:Object.keys(e).some(s=>s!=="$schema"&&s!=="title"&&s!=="description")?r=mt(n):r=Fe();for(const i of Xc)r=i.apply(r,e);return r}class As extends Event{constructor(t,n){var r,i;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(i=n?.message)!=null?i:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(_s(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(_s(this),n)}}function Qc(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function ni(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(ni).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${ni(e.cause)}`:e.message:`${e}`}function _s(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var aa=e=>{throw TypeError(e)},Fi=(e,t,n)=>t.has(e)||aa("Cannot "+n),G=(e,t,n)=>(Fi(e,t,"read from private field"),n?n.call(e):t.get(e)),Se=(e,t,n)=>t.has(e)?aa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),he=(e,t,n,r)=>(Fi(e,t,"write to private field"),t.set(e,n),n),Qe=(e,t,n)=>(Fi(e,t,"access private method"),n),Ce,Et,kt,Qn,ur,wn,qt,xn,ct,Lt,Gt,Bt,mn,Re,ri,ii,si,Is,oi,ai,yn,li,ci;class er extends EventTarget{constructor(t,n){var r,i;super(),Se(this,Re),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Se(this,Ce),Se(this,Et),Se(this,kt),Se(this,Qn),Se(this,ur),Se(this,wn),Se(this,qt),Se(this,xn,null),Se(this,ct),Se(this,Lt),Se(this,Gt,null),Se(this,Bt,null),Se(this,mn,null),Se(this,ii,async s=>{var o;G(this,Lt).reset();const{body:a,redirected:l,status:c,headers:u}=s;if(c===204){Qe(this,Re,yn).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?he(this,kt,new URL(s.url)):he(this,kt,void 0),c!==200){Qe(this,Re,yn).call(this,`Non-200 status code (${c})`,c);return}if(!(u.get("content-type")||"").startsWith("text/event-stream")){Qe(this,Re,yn).call(this,'Invalid content type, expected "text/event-stream"',c);return}if(G(this,Ce)===this.CLOSED)return;he(this,Ce,this.OPEN);const f=new Event("open");if((o=G(this,mn))==null||o.call(this,f),this.dispatchEvent(f),typeof a!="object"||!a||!("getReader"in a)){Qe(this,Re,yn).call(this,"Invalid response body, expected a web ReadableStream",c),this.close();return}const h=new TextDecoder,m=a.getReader();let d=!0;do{const{done:p,value:y}=await m.read();y&&G(this,Lt).feed(h.decode(y,{stream:!p})),p&&(d=!1,G(this,Lt).reset(),Qe(this,Re,li).call(this))}while(d)}),Se(this,si,s=>{he(this,ct,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Qe(this,Re,li).call(this,ni(s))}),Se(this,oi,s=>{typeof s.id=="string"&&he(this,xn,s.id);const o=new MessageEvent(s.event||"message",{data:s.data,origin:G(this,kt)?G(this,kt).origin:G(this,Et).origin,lastEventId:s.id||""});G(this,Bt)&&(!s.event||s.event==="message")&&G(this,Bt).call(this,o),this.dispatchEvent(o)}),Se(this,ai,s=>{he(this,wn,s)}),Se(this,ci,()=>{he(this,qt,void 0),G(this,Ce)===this.CONNECTING&&Qe(this,Re,ri).call(this)});try{if(t instanceof URL)he(this,Et,t);else if(typeof t=="string")he(this,Et,new URL(t,eu()));else throw new Error("Invalid URL")}catch{throw Qc("An invalid or illegal string was specified")}he(this,Lt,cc({onEvent:G(this,oi),onRetry:G(this,ai)})),he(this,Ce,this.CONNECTING),he(this,wn,3e3),he(this,ur,(r=n?.fetch)!=null?r:globalThis.fetch),he(this,Qn,(i=n?.withCredentials)!=null?i:!1),Qe(this,Re,ri).call(this)}get readyState(){return G(this,Ce)}get url(){return G(this,Et).href}get withCredentials(){return G(this,Qn)}get onerror(){return G(this,Gt)}set onerror(t){he(this,Gt,t)}get onmessage(){return G(this,Bt)}set onmessage(t){he(this,Bt,t)}get onopen(){return G(this,mn)}set onopen(t){he(this,mn,t)}addEventListener(t,n,r){const i=n;super.addEventListener(t,i,r)}removeEventListener(t,n,r){const i=n;super.removeEventListener(t,i,r)}close(){G(this,qt)&&clearTimeout(G(this,qt)),G(this,Ce)!==this.CLOSED&&(G(this,ct)&&G(this,ct).abort(),he(this,Ce,this.CLOSED),he(this,ct,void 0))}}Ce=new WeakMap,Et=new WeakMap,kt=new WeakMap,Qn=new WeakMap,ur=new WeakMap,wn=new WeakMap,qt=new WeakMap,xn=new WeakMap,ct=new WeakMap,Lt=new WeakMap,Gt=new WeakMap,Bt=new WeakMap,mn=new WeakMap,Re=new WeakSet,ri=function(){he(this,Ce,this.CONNECTING),he(this,ct,new AbortController),G(this,ur)(G(this,Et),Qe(this,Re,Is).call(this)).then(G(this,ii)).catch(G(this,si))},ii=new WeakMap,si=new WeakMap,Is=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...G(this,xn)?{"Last-Event-ID":G(this,xn)}:void 0},cache:"no-store",signal:(e=G(this,ct))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},oi=new WeakMap,ai=new WeakMap,yn=function(e,t){var n;G(this,Ce)!==this.CLOSED&&he(this,Ce,this.CLOSED);const r=new As("error",{code:t,message:e});(n=G(this,Gt))==null||n.call(this,r),this.dispatchEvent(r)},li=function(e,t){var n;if(G(this,Ce)===this.CLOSED)return;he(this,Ce,this.CONNECTING);const r=new As("error",{code:t,message:e});(n=G(this,Gt))==null||n.call(this,r),this.dispatchEvent(r),he(this,qt,setTimeout(G(this,ci),G(this,wn)))},ci=new WeakMap,er.CONNECTING=0,er.OPEN=1,er.CLOSED=2;function eu(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}class tu extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class nu{constructor(t,n){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=n?.eventSourceInit,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=uc(n?.fetch,n?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new fn("No auth provider");let t;try{t=await Tr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new fn;return await this._startOrAuth()}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=fc(this._requestInit?.headers);return new Headers({...t,...n})}_startOrAuth(){const t=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((n,r)=>{this._eventSource=new er(this._url.href,{...this._eventSourceInit,fetch:async(i,s)=>{const o=await this._commonHeaders();o.set("Accept","text/event-stream");const a=await t(i,{...s,headers:o});if(a.status===401&&a.headers.has("www-authenticate")){const{resourceMetadataUrl:l,scope:c}=xs(a);this._resourceMetadataUrl=l,this._scope=c}return a}}),this._abortController=new AbortController,this._eventSource.onerror=i=>{if(i.code===401&&this._authProvider){this._authThenStart().then(n,r);return}const s=new tu(i.code,i.message,i);r(s),this.onerror?.(s)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",i=>{const s=i;try{if(this._endpoint=new URL(s.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(o){r(o),this.onerror?.(o),this.close();return}n()}),this._eventSource.onmessage=i=>{const s=i;let o;try{o=sa.parse(JSON.parse(s.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(o)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new fn("No auth provider");if(await Tr(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new fn("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{const n=await this._commonHeaders();n.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(t),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._endpoint,r);if(!i.ok){const s=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){const{resourceMetadataUrl:o,scope:a}=xs(i);if(this._resourceMetadataUrl=o,this._scope=a,await Tr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new fn;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${i.status}): ${s}`)}await i.body?.cancel()}catch(n){throw this.onerror?.(n),n}}setProtocolVersion(t){this._protocolVersion=t}}const ru="mcp";class iu{constructor(t){this._url=t}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((t,n)=>{this._socket=new WebSocket(this._url,ru),this._socket.onerror=r=>{const i="error"in r?r.error:new Error(`WebSocket error: ${JSON.stringify(r)}`);n(i),this.onerror?.(i)},this._socket.onopen=()=>{t()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=r=>{let i;try{i=sa.parse(JSON.parse(r.data))}catch(s){this.onerror?.(s);return}this.onmessage?.(i)}})}async close(){this._socket?.close()}send(t){return new Promise((n,r)=>{if(!this._socket){r(new Error("Not connected"));return}this._socket?.send(JSON.stringify(t)),n()})}}class su extends dc{constructor(t,n){super(t,n)}send(t,n){const r=ou(t);return r?.type==="emit"?(this.onmessage?.(r.message),Promise.resolve()):r?.type==="suppress"?Promise.resolve():super.send(t,n)}}function ou(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:{}},serverInfo:{name:"deco-chat-server",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}}class au extends hc{constructor(t,n){super(t,n)}async listTools(t,n){return await this.request({method:"tools/list",params:t},sc,n)}}const lu=async(e,t,n)=>{const r=cu(e.connection,t,n);if(!r)throw new Error("Unknown MCP connection type");const i=new au({name:e?.name??"MCP Client",version:"1.0.0"});return await i.connect(r),{client:i}},cu=(e,t,n)=>{if(e.type==="Websocket")return new iu(new URL(e.url));if(e.type!=="SSE"&&e.type!=="HTTP")return null;const i={...e.token?{authorization:`Bearer ${e.token}`}:{},...n??{},..."headers"in e?e.headers||{}:{}};if(e.type==="SSE"){const s={requestInit:{headers:i,signal:t}};return e.token&&(s.eventSourceInit={fetch:(o,a)=>fetch(o,{...a,headers:{...i,Accept:"text/event-stream"},signal:t})}),new nu(new URL(e.url),s)}return new su(new URL(e.url),{requestInit:{headers:i,signal:t,credentials:"include"}})},Cs=e=>{try{return JSON.parse(e)}catch{return e}},zn=new Map,Ts=(e,t)=>({...e,id:e.name,inputSchema:e.inputSchema?Ae(e.inputSchema):void 0,outputSchema:e.outputSchema?Ae(e.outputSchema):void 0,execute:n=>t(n.context,e.name)});function uu(e){const t=n=>"connection"in e?lu({connection:e.connection},void 0,n):e.client;return new Proxy({},{get(n,r){if(r==="toJSON")return null;if(typeof r!="string")throw new Error("Name must be a string");if(r==="listTools")return a;async function i(l,c=r){const u=e?.debugId?.(),f=u?{"x-trace-debug-id":u}:void 0,{client:h}=await t(f),{structuredContent:m,isError:d,content:p}=await h.callTool({name:String(c),arguments:l});if(d){const S=p?.[0]?.text,O=typeof S=="string"?Cs(S):null,E=O?.code&&typeof e?.getErrorByStatusCode=="function"?e.getErrorByStatusCode(O.code,O.message,O.traceId):null;throw E||new Error(`Tool ${String(c)} returned an error: ${JSON.stringify(m??p)}`)}if(m!==void 0)return m;const y=p?.[0]?.text;return typeof y=="string"?Cs(y):void 0}async function s(){const{client:l}=await t(),{tools:c}=await l.listTools();return c}async function o(){if(!("connection"in e))return s();const l=e.connection,c=JSON.stringify(l);try{return zn.has(c)||zn.set(c,s()),await zn.get(c)}catch(u){console.error("Failed to list tools",u),zn.delete(c);return}}async function a(){return(await o()??[]).map(c=>Ts(c,i))}return i.asTool=async()=>{const c=(await o()??[]).find(u=>u.name===r);if(!c)throw new Error(`Tool ${r} not found`);return Ts(c,i)},i}})}new Proxy({},{get(e,t){return t==="toJSON"?null:t==="forConnection"?n=>fu({connection:n}):global[t]}});function fu(e){return uu(e)}const du=_e({toolName:oe().describe("Name of the tool to invoke on that connection"),transformCode:oe().optional().describe("Pure TypeScript function for data transformation of the tool call result. Must be a TypeScript file that declares the Output interface and exports a default function: `interface Output { ... } export default async function(stepInput): Output { ... }`\n The stepInput will match with the tool call outputSchema. If transformCode is not provided, the tool call result will be used as the step output.\n Providing an transformCode is recommended because it both allows you to transform the data and validate it against a JSON Schema - tools are ephemeral and may return unexpected data.")}),hu=_e({code:oe().describe(`Pure TypeScript function for data transformation. Useful to merge data from multiple steps and transform it. Must be a TypeScript file that declares the Output interface and exports a default function: \`interface Output { ... } export default async function(stepInput): Output { ... }\`
1
+ import{cp as Fe,bn as Os,J as oe,I as ge,a_ as ti,bS as _i,aK as Ie,bl as mt,a$ as qe,ap as mr,cq as rn,H as _e,cr as Ii,cs as ws,ct as ec,bQ as tc,cu as ia,cv as nc,cw as rc,cx as ic,cy as fn,cz as Tr,cA as xs,bL as sa,bD as sc,aJ as ze,bR as oc,aI as On,bb as Ci,cB as ac,r as N,j as w,cC as oa,cD as lc}from"./index-DGBhnElr.js";import{f as cc,h as uc,n as fc,j as dc,C as hc,A as pc}from"./constants-ChKBx8P9.js";import{B as Ti,c as Pi}from"./collections-DnZgyzTW.js";import{R as Es}from"./index-BFkfPy7u.js";var mc=class{apply(e,t){if(!t.type)return;const n=Array.isArray(t.type)?t.type:[t.type],r=new Set(n);if(r.has("string")||(e.string=!1),!r.has("number")&&!r.has("integer")&&(e.number=!1),r.has("boolean")||(e.boolean=!1),r.has("null")||(e.null=!1),r.has("array")||(e.array=!1),r.has("object")||(e.object=!1),r.has("integer")&&e.number!==!1){const i=e.number||ge();i instanceof rn&&(e.number=i.int())}}},yc=class{apply(e,t){if(t.const===void 0)return;const n=t.const;e.string=!1,e.number=!1,e.boolean=!1,e.null=!1,e.array=!1,e.object=!1,typeof n=="string"?e.string=qe(n):typeof n=="number"?e.number=qe(n):typeof n=="boolean"?e.boolean=qe(n):n===null?e.null=_i():Array.isArray(n)?e.array=void 0:typeof n=="object"&&(e.object=void 0)}},gc=class{apply(e,t){if(!t.enum)return;if(t.enum.length===0){t.type||(e.string=!1,e.number=!1,e.boolean=!1,e.null=!1,e.array=!1,e.object=!1);return}const n={string:t.enum.filter(r=>typeof r=="string"),number:t.enum.filter(r=>typeof r=="number"),boolean:t.enum.filter(r=>typeof r=="boolean"),null:t.enum.filter(r=>r===null),array:t.enum.filter(r=>Array.isArray(r)),object:t.enum.filter(r=>typeof r=="object"&&r!==null&&!Array.isArray(r))};e.string=this.createTypeSchema(n.string,"string"),e.number=this.createTypeSchema(n.number,"number"),e.boolean=this.createTypeSchema(n.boolean,"boolean"),e.null=n.null.length>0?_i():!1,e.array=n.array.length>0?void 0:!1,e.object=n.object.length>0?void 0:!1}createTypeSchema(e,t){if(e.length===0)return!1;if(e.length===1)return qe(e[0]);if(t==="string")return mr(e);if(t==="number"){const[n,r,...i]=e;return mt([qe(n),qe(r),...i.map(s=>qe(s))])}return t==="boolean"?mt([qe(!0),qe(!1)]):!1}},bc=class{apply(e,t){const n=t;if(n.type==="string"&&n.format==="binary"&&n.contentEncoding==="binary"){let r=ic();n.minLength!==void 0&&(r=r.min(n.minLength)),n.maxLength!==void 0&&(r=r.max(n.maxLength)),n.contentMediaType!==void 0&&(r=r.mime(n.contentMediaType)),e.file=r,e.string=!1}}},Sc=class{apply(e,t){const n=t;t.type===void 0&&(n.minLength!==void 0||n.maxLength!==void 0||n.pattern!==void 0)&&e.string===void 0&&(e.string=oe())}},vc=class{apply(e,t){const n=t;if(n.minLength!==void 0&&e.string!==!1){const r=e.string||oe();r instanceof Ii&&(e.string=r.refine(i=>Array.from(i).length>=n.minLength,{message:`String must be at least ${n.minLength} characters long`}))}}},Oc=class{apply(e,t){const n=t;if(n.maxLength!==void 0&&e.string!==!1){const r=e.string||oe();r instanceof Ii&&(e.string=r.refine(i=>Array.from(i).length<=n.maxLength,{message:`String must be at most ${n.maxLength} characters long`}))}}},wc=class{apply(e,t){const n=t;if(n.pattern&&e.string!==!1){const r=e.string||oe();if(r instanceof Ii){const i=new RegExp(n.pattern);e.string=r.regex(i)}}}},xc=class{apply(e,t){const n=t;if(n.minimum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(e.number=r.min(n.minimum))}}},Ec=class{apply(e,t){const n=t;if(n.maximum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(e.number=r.max(n.maximum))}}},Ac=class{apply(e,t){const n=t;if(n.exclusiveMinimum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(typeof n.exclusiveMinimum=="number"?e.number=r.gt(n.exclusiveMinimum):e.number=!1)}}},_c=class{apply(e,t){const n=t;if(n.exclusiveMaximum!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(typeof n.exclusiveMaximum=="number"?e.number=r.lt(n.exclusiveMaximum):e.number=!1)}}},Ic=class{apply(e,t){const n=t;if(n.multipleOf!==void 0&&e.number!==!1){const r=e.number||ge();r instanceof rn&&(e.number=r.refine(i=>{if(n.multipleOf===0)return!1;const s=i/n.multipleOf,o=Math.round(s),a=Math.min(Math.abs(i)*Number.EPSILON*10,Math.abs(n.multipleOf)*Number.EPSILON*10);return Math.abs(s-o)<=a/Math.abs(n.multipleOf)},{message:`Must be a multiple of ${n.multipleOf}`}))}}},Cc=class{apply(e,t){const n=t;t.type===void 0&&(n.minItems!==void 0||n.maxItems!==void 0||n.items!==void 0||n.prefixItems!==void 0)&&e.array===void 0&&(e.array=Ie(Fe()))}},Tc=class{apply(e,t){const n=t;n.minItems!==void 0&&e.array!==!1&&(e.array=(e.array||Ie(Fe())).min(n.minItems))}},Pc=class{apply(e,t){const n=t;n.maxItems!==void 0&&e.array!==!1&&(e.array=(e.array||Ie(Fe())).max(n.maxItems))}},Fc=class{apply(e,t){const n=t;if(e.array!==!1)if(Array.isArray(n.items))e.array=e.array||Ie(Fe());else if(n.items&&typeof n.items!="boolean"&&!n.prefixItems){const r=Ae(n.items);let i=Ie(r);if(e.array&&e.array instanceof ec){const s=e.array._def;s.checks&&s.checks.forEach(o=>{if(o._zod&&o._zod.def){const a=o._zod.def;a.check==="min_length"&&a.minimum!==void 0?i=i.min(a.minimum):a.check==="max_length"&&a.maximum!==void 0&&(i=i.max(a.maximum))}})}e.array=i}else typeof n.items=="boolean"&&n.items===!1?n.prefixItems?e.array=e.array||Ie(Fe()):e.array=Ie(Fe()).max(0):typeof n.items=="boolean"&&n.items===!0?e.array=e.array||Ie(Fe()):n.prefixItems&&(e.array=e.array||Ie(Fe()))}},jc=class{apply(e,t){if(t.type!=="array")return;const n=t;if(!Array.isArray(n.items)||e.array===!1)return;const r=n.items.map(s=>Ae(s));let i;r.length===0?i=ws([]):i=ws(r),n.minItems!==void 0&&n.minItems>r.length&&(i=!1),n.maxItems!==void 0&&n.maxItems<r.length&&(i=!1),e.tuple=i,e.array=!1}},$c=class{apply(e,t){const n=t;e.object!==!1&&(n.properties||n.required||n.additionalProperties!==void 0)&&(e.object=e.object||_e({}).passthrough())}},Dc=class{apply(e,t){const n=t;t.type===void 0&&(n.maxProperties!==void 0||n.minProperties!==void 0)&&e.object===void 0&&(e.object=_e({}).passthrough())}},Nc=class{apply(e,t){const n=t;if(n.maxProperties!==void 0&&e.object!==!1){const r=e.object||_e({}).passthrough();e.object=r.refine(i=>Object.keys(i).length<=n.maxProperties,{message:`Object must have at most ${n.maxProperties} properties`})}}},Rc=class{apply(e,t){const n=t;if(n.minProperties!==void 0&&e.object!==!1){const r=e.object||_e({}).passthrough();e.object=r.refine(i=>Object.keys(i).length>=n.minProperties,{message:`Object must have at least ${n.minProperties} properties`})}}};function Tn(e,t){if(e===t)return!0;if(e==null||t==null)return e===t;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((n,r)=>Tn(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>r.includes(i)&&Tn(e[i],t[i]))}return!1}function Mc(){return e=>{if(!Array.isArray(e))return!0;const t=[];return e.every(n=>t.some(i=>Tn(n,i))?!1:(t.push(n),!0))}}function cr(e,t){return e.safeParse(t).success}var Uc=class{apply(e,t){if(!t.not)return e;const n=Ae(t.not);return e.refine(r=>!cr(n,r),{message:"Value must not match the 'not' schema"})}},kc=class{apply(e,t){return t.uniqueItems!==!0?e:e.refine(Mc(),{message:"Array items must be unique"})}},Lc=class{apply(e,t){return!t.allOf||t.allOf.length===0?e:t.allOf.map(r=>Ae(r)).reduce((r,i)=>ia(r,i),e)}},Bc=class{apply(e,t){if(!t.anyOf||t.anyOf.length===0)return e;const n=t.anyOf.length===1?Ae(t.anyOf[0]):mt([Ae(t.anyOf[0]),Ae(t.anyOf[1]),...t.anyOf.slice(2).map(r=>Ae(r))]);return ia(e,n)}},Wc=class{apply(e,t){if(!t.oneOf||t.oneOf.length===0)return e;const n=t.oneOf.map(r=>Ae(r));return e.refine(r=>{let i=0;for(const s of n)if(s.safeParse(r).success&&(i++,i>1))return!1;return i===1},{message:"Value must match exactly one of the oneOf schemas"})}},qc=class{apply(e,t){const n=t;if(n.prefixItems&&Array.isArray(n.prefixItems)){const i=n.prefixItems.map(s=>Ae(s));return e.refine(s=>{if(!Array.isArray(s))return!0;for(let o=0;o<Math.min(s.length,i.length);o++)if(!cr(i[o],s[o]))return!1;if(s.length>i.length){if(typeof n.items=="boolean"&&n.items===!1)return!1;if(n.items&&typeof n.items=="object"&&!Array.isArray(n.items)){const o=Ae(n.items);for(let a=i.length;a<s.length;a++)if(!cr(o,s[a]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return e}},Vc=class{apply(e,t){const n=t;if(!n.properties&&!n.required&&n.additionalProperties!==!1)return e;if(e instanceof nc||e instanceof rc){const r={};if(n.properties)for(const[i,s]of Object.entries(n.properties))s!==void 0&&(r[i]=Ae(s));if(n.required&&Array.isArray(n.required)){const i=new Set(n.required);for(const s of Object.keys(r))i.has(s)||(r[s]=r[s].optional())}else for(const i of Object.keys(r))r[i]=r[i].optional();return n.additionalProperties===!1?_e(r):_e(r).passthrough()}return e.refine(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return!0;if(n.properties){for(const[i,s]of Object.entries(n.properties))if(s!==void 0&&Object.getOwnPropertyDescriptor(r,i)!==void 0&&!Ae(s).safeParse(r[i]).success)return!1}if(n.required&&Array.isArray(n.required)){for(const i of n.required)if(!(Object.getOwnPropertyDescriptor(r,i)!==void 0))return!1}if(n.additionalProperties===!1&&n.properties){const i=new Set(Object.keys(n.properties));for(const s in r)if(!i.has(s))return!1}return!0},{message:"Object constraints validation failed"})}},Hc=class{apply(e,t){if(!t.enum||t.enum.length===0)return e;const n=t.enum.filter(r=>Array.isArray(r)||typeof r=="object"&&r!==null);return n.length===0?e:e.refine(r=>typeof r!="object"||r===null?!0:n.some(i=>Tn(r,i)),{message:"Value must match one of the enum values"})}},Kc=class{apply(e,t){if(t.const===void 0)return e;const n=t.const;return typeof n!="object"||n===null?e:e.refine(r=>Tn(r,n),{message:"Value must equal the const value"})}},Gc=class{apply(e,t){return t.description&&(e=e.describe(t.description)),e}},zc=class{apply(e,t){var n;const r=t;return!((n=r.required)!=null&&n.includes("__proto__"))||t.type!==void 0?e:Fe().refine(i=>this.validateRequired(i,r.required),{message:"Missing required properties"})}validateRequired(e,t){return typeof e!="object"||e===null||Array.isArray(e)?!0:t.every(n=>Object.prototype.hasOwnProperty.call(e,n))}},Yc=class{apply(e,t){var n;const r=t;if(r.contains===void 0)return e;const i=Ae(r.contains),s=(n=r.minContains)!=null?n:1,o=r.maxContains;return e.refine(a=>{if(!Array.isArray(a))return!0;let l=0;for(const c of a)cr(i,c)&&l++;return!(l<s||o!==void 0&&l>o)},{message:"Array must contain required items matching the schema"})}},Jc=class{apply(e,t){const{default:n}=t;return n===void 0||!e.safeParse(n).success?e:e.default(n)}},Zc=[new yc,new gc,new mc,new bc,new Sc,new Cc,new Dc,new vc,new Oc,new wc,new xc,new Ec,new Ac,new _c,new Ic,new jc,new Tc,new Pc,new Fc,new Nc,new Rc,new $c],Xc=[new zc,new Hc,new Kc,new Lc,new Bc,new Wc,new qc,new Vc,new Yc,new Uc,new kc,new Jc,new Gc];function Ae(e){if(typeof e=="boolean")return e?Fe():Os();const t={};for(const i of Zc)i.apply(t,e);const n=[];if(t.string!==!1&&n.push(t.string||oe()),t.number!==!1&&n.push(t.number||ge()),t.boolean!==!1&&n.push(t.boolean||ti()),t.null!==!1&&n.push(t.null||_i()),t.array!==!1&&n.push(t.array||Ie(Fe())),t.tuple!==!1&&t.tuple!==void 0&&n.push(t.tuple),t.object!==!1)if(t.object)n.push(t.object);else{const i=tc(s=>typeof s=="object"&&s!==null&&!Array.isArray(s),"Must be an object, not an array");n.push(i)}t.file!==!1&&t.file!==void 0&&n.push(t.file);let r;n.length===0?r=Os():n.length===1?r=n[0]:Object.keys(e).some(s=>s!=="$schema"&&s!=="title"&&s!=="description")?r=mt(n):r=Fe();for(const i of Xc)r=i.apply(r,e);return r}class As extends Event{constructor(t,n){var r,i;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(i=n?.message)!=null?i:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(_s(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(_s(this),n)}}function Qc(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function ni(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(ni).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${ni(e.cause)}`:e.message:`${e}`}function _s(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var aa=e=>{throw TypeError(e)},Fi=(e,t,n)=>t.has(e)||aa("Cannot "+n),G=(e,t,n)=>(Fi(e,t,"read from private field"),n?n.call(e):t.get(e)),Se=(e,t,n)=>t.has(e)?aa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),he=(e,t,n,r)=>(Fi(e,t,"write to private field"),t.set(e,n),n),Qe=(e,t,n)=>(Fi(e,t,"access private method"),n),Ce,Et,kt,Qn,ur,wn,qt,xn,ct,Lt,Gt,Bt,mn,Re,ri,ii,si,Is,oi,ai,yn,li,ci;class er extends EventTarget{constructor(t,n){var r,i;super(),Se(this,Re),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Se(this,Ce),Se(this,Et),Se(this,kt),Se(this,Qn),Se(this,ur),Se(this,wn),Se(this,qt),Se(this,xn,null),Se(this,ct),Se(this,Lt),Se(this,Gt,null),Se(this,Bt,null),Se(this,mn,null),Se(this,ii,async s=>{var o;G(this,Lt).reset();const{body:a,redirected:l,status:c,headers:u}=s;if(c===204){Qe(this,Re,yn).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(l?he(this,kt,new URL(s.url)):he(this,kt,void 0),c!==200){Qe(this,Re,yn).call(this,`Non-200 status code (${c})`,c);return}if(!(u.get("content-type")||"").startsWith("text/event-stream")){Qe(this,Re,yn).call(this,'Invalid content type, expected "text/event-stream"',c);return}if(G(this,Ce)===this.CLOSED)return;he(this,Ce,this.OPEN);const f=new Event("open");if((o=G(this,mn))==null||o.call(this,f),this.dispatchEvent(f),typeof a!="object"||!a||!("getReader"in a)){Qe(this,Re,yn).call(this,"Invalid response body, expected a web ReadableStream",c),this.close();return}const h=new TextDecoder,m=a.getReader();let d=!0;do{const{done:p,value:y}=await m.read();y&&G(this,Lt).feed(h.decode(y,{stream:!p})),p&&(d=!1,G(this,Lt).reset(),Qe(this,Re,li).call(this))}while(d)}),Se(this,si,s=>{he(this,ct,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Qe(this,Re,li).call(this,ni(s))}),Se(this,oi,s=>{typeof s.id=="string"&&he(this,xn,s.id);const o=new MessageEvent(s.event||"message",{data:s.data,origin:G(this,kt)?G(this,kt).origin:G(this,Et).origin,lastEventId:s.id||""});G(this,Bt)&&(!s.event||s.event==="message")&&G(this,Bt).call(this,o),this.dispatchEvent(o)}),Se(this,ai,s=>{he(this,wn,s)}),Se(this,ci,()=>{he(this,qt,void 0),G(this,Ce)===this.CONNECTING&&Qe(this,Re,ri).call(this)});try{if(t instanceof URL)he(this,Et,t);else if(typeof t=="string")he(this,Et,new URL(t,eu()));else throw new Error("Invalid URL")}catch{throw Qc("An invalid or illegal string was specified")}he(this,Lt,cc({onEvent:G(this,oi),onRetry:G(this,ai)})),he(this,Ce,this.CONNECTING),he(this,wn,3e3),he(this,ur,(r=n?.fetch)!=null?r:globalThis.fetch),he(this,Qn,(i=n?.withCredentials)!=null?i:!1),Qe(this,Re,ri).call(this)}get readyState(){return G(this,Ce)}get url(){return G(this,Et).href}get withCredentials(){return G(this,Qn)}get onerror(){return G(this,Gt)}set onerror(t){he(this,Gt,t)}get onmessage(){return G(this,Bt)}set onmessage(t){he(this,Bt,t)}get onopen(){return G(this,mn)}set onopen(t){he(this,mn,t)}addEventListener(t,n,r){const i=n;super.addEventListener(t,i,r)}removeEventListener(t,n,r){const i=n;super.removeEventListener(t,i,r)}close(){G(this,qt)&&clearTimeout(G(this,qt)),G(this,Ce)!==this.CLOSED&&(G(this,ct)&&G(this,ct).abort(),he(this,Ce,this.CLOSED),he(this,ct,void 0))}}Ce=new WeakMap,Et=new WeakMap,kt=new WeakMap,Qn=new WeakMap,ur=new WeakMap,wn=new WeakMap,qt=new WeakMap,xn=new WeakMap,ct=new WeakMap,Lt=new WeakMap,Gt=new WeakMap,Bt=new WeakMap,mn=new WeakMap,Re=new WeakSet,ri=function(){he(this,Ce,this.CONNECTING),he(this,ct,new AbortController),G(this,ur)(G(this,Et),Qe(this,Re,Is).call(this)).then(G(this,ii)).catch(G(this,si))},ii=new WeakMap,si=new WeakMap,Is=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...G(this,xn)?{"Last-Event-ID":G(this,xn)}:void 0},cache:"no-store",signal:(e=G(this,ct))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},oi=new WeakMap,ai=new WeakMap,yn=function(e,t){var n;G(this,Ce)!==this.CLOSED&&he(this,Ce,this.CLOSED);const r=new As("error",{code:t,message:e});(n=G(this,Gt))==null||n.call(this,r),this.dispatchEvent(r)},li=function(e,t){var n;if(G(this,Ce)===this.CLOSED)return;he(this,Ce,this.CONNECTING);const r=new As("error",{code:t,message:e});(n=G(this,Gt))==null||n.call(this,r),this.dispatchEvent(r),he(this,qt,setTimeout(G(this,ci),G(this,wn)))},ci=new WeakMap,er.CONNECTING=0,er.OPEN=1,er.CLOSED=2;function eu(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}class tu extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class nu{constructor(t,n){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=n?.eventSourceInit,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=uc(n?.fetch,n?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new fn("No auth provider");let t;try{t=await Tr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new fn;return await this._startOrAuth()}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=fc(this._requestInit?.headers);return new Headers({...t,...n})}_startOrAuth(){const t=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((n,r)=>{this._eventSource=new er(this._url.href,{...this._eventSourceInit,fetch:async(i,s)=>{const o=await this._commonHeaders();o.set("Accept","text/event-stream");const a=await t(i,{...s,headers:o});if(a.status===401&&a.headers.has("www-authenticate")){const{resourceMetadataUrl:l,scope:c}=xs(a);this._resourceMetadataUrl=l,this._scope=c}return a}}),this._abortController=new AbortController,this._eventSource.onerror=i=>{if(i.code===401&&this._authProvider){this._authThenStart().then(n,r);return}const s=new tu(i.code,i.message,i);r(s),this.onerror?.(s)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",i=>{const s=i;try{if(this._endpoint=new URL(s.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(o){r(o),this.onerror?.(o),this.close();return}n()}),this._eventSource.onmessage=i=>{const s=i;let o;try{o=sa.parse(JSON.parse(s.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(o)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new fn("No auth provider");if(await Tr(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new fn("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{const n=await this._commonHeaders();n.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(t),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._endpoint,r);if(!i.ok){const s=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){const{resourceMetadataUrl:o,scope:a}=xs(i);if(this._resourceMetadataUrl=o,this._scope=a,await Tr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new fn;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${i.status}): ${s}`)}await i.body?.cancel()}catch(n){throw this.onerror?.(n),n}}setProtocolVersion(t){this._protocolVersion=t}}const ru="mcp";class iu{constructor(t){this._url=t}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((t,n)=>{this._socket=new WebSocket(this._url,ru),this._socket.onerror=r=>{const i="error"in r?r.error:new Error(`WebSocket error: ${JSON.stringify(r)}`);n(i),this.onerror?.(i)},this._socket.onopen=()=>{t()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=r=>{let i;try{i=sa.parse(JSON.parse(r.data))}catch(s){this.onerror?.(s);return}this.onmessage?.(i)}})}async close(){this._socket?.close()}send(t){return new Promise((n,r)=>{if(!this._socket){r(new Error("Not connected"));return}this._socket?.send(JSON.stringify(t)),n()})}}class su extends dc{constructor(t,n){super(t,n)}send(t,n){const r=ou(t);return r?.type==="emit"?(this.onmessage?.(r.message),Promise.resolve()):r?.type==="suppress"?Promise.resolve():super.send(t,n)}}function ou(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:{}},serverInfo:{name:"deco-chat-server",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}}class au extends hc{constructor(t,n){super(t,n)}async listTools(t,n){return await this.request({method:"tools/list",params:t},sc,n)}}const lu=async(e,t,n)=>{const r=cu(e.connection,t,n);if(!r)throw new Error("Unknown MCP connection type");const i=new au({name:e?.name??"MCP Client",version:"1.0.0"});return await i.connect(r),{client:i}},cu=(e,t,n)=>{if(e.type==="Websocket")return new iu(new URL(e.url));if(e.type!=="SSE"&&e.type!=="HTTP")return null;const i={...e.token?{authorization:`Bearer ${e.token}`}:{},...n??{},..."headers"in e?e.headers||{}:{}};if(e.type==="SSE"){const s={requestInit:{headers:i,signal:t}};return e.token&&(s.eventSourceInit={fetch:(o,a)=>fetch(o,{...a,headers:{...i,Accept:"text/event-stream"},signal:t})}),new nu(new URL(e.url),s)}return new su(new URL(e.url),{requestInit:{headers:i,signal:t,credentials:"include"}})},Cs=e=>{try{return JSON.parse(e)}catch{return e}},zn=new Map,Ts=(e,t)=>({...e,id:e.name,inputSchema:e.inputSchema?Ae(e.inputSchema):void 0,outputSchema:e.outputSchema?Ae(e.outputSchema):void 0,execute:n=>t(n.context,e.name)});function uu(e){const t=n=>"connection"in e?lu({connection:e.connection},void 0,n):e.client;return new Proxy({},{get(n,r){if(r==="toJSON")return null;if(typeof r!="string")throw new Error("Name must be a string");if(r==="listTools")return a;async function i(l,c=r){const u=e?.debugId?.(),f=u?{"x-trace-debug-id":u}:void 0,{client:h}=await t(f),{structuredContent:m,isError:d,content:p}=await h.callTool({name:String(c),arguments:l});if(d){const S=p?.[0]?.text,O=typeof S=="string"?Cs(S):null,E=O?.code&&typeof e?.getErrorByStatusCode=="function"?e.getErrorByStatusCode(O.code,O.message,O.traceId):null;throw E||new Error(`Tool ${String(c)} returned an error: ${JSON.stringify(m??p)}`)}if(m!==void 0)return m;const y=p?.[0]?.text;return typeof y=="string"?Cs(y):void 0}async function s(){const{client:l}=await t(),{tools:c}=await l.listTools();return c}async function o(){if(!("connection"in e))return s();const l=e.connection,c=JSON.stringify(l);try{return zn.has(c)||zn.set(c,s()),await zn.get(c)}catch(u){console.error("Failed to list tools",u),zn.delete(c);return}}async function a(){return(await o()??[]).map(c=>Ts(c,i))}return i.asTool=async()=>{const c=(await o()??[]).find(u=>u.name===r);if(!c)throw new Error(`Tool ${r} not found`);return Ts(c,i)},i}})}new Proxy({},{get(e,t){return t==="toJSON"?null:t==="forConnection"?n=>fu({connection:n}):global[t]}});function fu(e){return uu(e)}const du=_e({toolName:oe().describe("Name of the tool to invoke on that connection"),transformCode:oe().optional().describe("Pure TypeScript function for data transformation of the tool call result. Must be a TypeScript file that declares the Output interface and exports a default function: `interface Output { ... } export default async function(stepInput): Output { ... }`\n The stepInput will match with the tool call outputSchema. If transformCode is not provided, the tool call result will be used as the step output.\n Providing an transformCode is recommended because it both allows you to transform the data and validate it against a JSON Schema - tools are ephemeral and may return unexpected data.")}),hu=_e({code:oe().describe(`Pure TypeScript function for data transformation. Useful to merge data from multiple steps and transform it. Must be a TypeScript file that declares the Output interface and exports a default function: \`interface Output { ... } export default async function(stepInput): Output { ... }\`
2
2
  The stepInput is the resolved value of the references in the input field. Example:
3
3
  {
4
4
  "input": {
@@ -1 +1 @@
1
- import{dw as d,dx as f,dy as v,dz as x}from"./index-Dcg8Qevd.js";var N=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:f()})}getOptimisticResult(e){return e.behavior=f(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:P,isError:c,isRefetchError:g}=i,r=s.fetchMeta?.fetchMore?.direction,h=c&&r==="forward",o=a&&r==="forward",n=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:x(t,s.data),hasPreviousPage:v(t,s.data),isFetchNextPageError:h,isFetchingNextPage:o,isFetchPreviousPageError:n,isFetchingPreviousPage:u,isRefetchError:g&&!h&&!n,isRefetching:P&&!o&&!u}}};export{N as I};
1
+ import{dw as d,dx as f,dy as v,dz as x}from"./index-DGBhnElr.js";var N=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:f()})}getOptimisticResult(e){return e.behavior=f(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:P,isError:c,isRefetchError:g}=i,r=s.fetchMeta?.fetchMore?.direction,h=c&&r==="forward",o=a&&r==="forward",n=c&&r==="backward",u=a&&r==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:x(t,s.data),hasPreviousPage:v(t,s.data),isFetchNextPageError:h,isFetchingNextPage:o,isFetchPreviousPageError:n,isFetchingPreviousPage:u,isRefetchError:g&&!h&&!n,isRefetching:P&&!o&&!u}}};export{N as I};
@@ -1 +1 @@
1
- import{e as s,c as a,j as d}from"./index-Dcg8Qevd.js";function f(l){const e=s.c(10);let i,t,r;e[0]!==l?({className:i,type:r,...t}=l,e[0]=l,e[1]=i,e[2]=t,e[3]=r):(i=e[1],t=e[2],r=e[3]);let n;e[4]!==i?(n=a("file:text-foreground text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-9 w-full min-w-0 rounded-lg bg-background dark:bg-input/30 px-3 py-1 text-sm transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:opacity-50 card-shadow","focus-visible:border-ring focus-visible:ring-ring/20 focus-visible:ring-[2px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),e[4]=i,e[5]=n):n=e[5];let o;return e[6]!==t||e[7]!==n||e[8]!==r?(o=d.jsx("input",{type:r,"data-slot":"input",className:n,...t}),e[6]=t,e[7]=n,e[8]=r,e[9]=o):o=e[9],o}export{f as I};
1
+ import{e as s,c as a,j as d}from"./index-DGBhnElr.js";function f(l){const e=s.c(10);let i,t,r;e[0]!==l?({className:i,type:r,...t}=l,e[0]=l,e[1]=i,e[2]=t,e[3]=r):(i=e[1],t=e[2],r=e[3]);let n;e[4]!==i?(n=a("file:text-foreground text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-9 w-full min-w-0 rounded-lg bg-background dark:bg-input/30 px-3 py-1 text-sm transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:opacity-50 card-shadow","focus-visible:border-ring focus-visible:ring-ring/20 focus-visible:ring-[2px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",i),e[4]=i,e[5]=n):n=e[5];let o;return e[6]!==t||e[7]!==n||e[8]!==r?(o=d.jsx("input",{type:r,"data-slot":"input",className:n,...t}),e[6]=t,e[7]=n,e[8]=r,e[9]=o):o=e[9],o}export{f as I};
@@ -1 +1 @@
1
- import{e as A,j as h,r as z,c as _}from"./index-Dcg8Qevd.js";import{n as L}from"./Container-BQVUd9tN.js";import{A as k}from"./agent-icon-CznXZlOI.js";const C={"2xs":"h-4 w-4",xs:"h-6 w-6",sm:"h-9 w-9",md:"h-12 w-12",lg:"h-16 w-16",xl:"h-14 w-14"},Z={"2xs":"min-w-4",xs:"min-w-6",sm:"min-w-9",md:"min-w-12",lg:"min-w-16",xl:"min-w-14"},y={"2xs":8,xs:12,sm:16,md:24,lg:32,xl:28},M={"2xs":"xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"lg"};function q(E){const e=A.c(12),{icon:t,name:s,size:w,className:o,fallbackIcon:c}=E,n=w===void 0?"md":w;if(t?.startsWith("icon://")||t?.includes("#agentcolor=")){const r=M[n];let l;return e[0]!==o||e[1]!==t||e[2]!==s||e[3]!==r?(l=h.jsx(k,{icon:t,name:s,size:r,className:o}),e[0]=o,e[1]=t,e[2]=s,e[3]=r,e[4]=l):l=e[4],l}const g=t??"no-icon";let i;return e[5]!==o||e[6]!==c||e[7]!==t||e[8]!==s||e[9]!==n||e[10]!==g?(i=h.jsx(R,{icon:t,name:s,size:n,className:o,fallbackIcon:c},g),e[5]=o,e[6]=c,e[7]=t,e[8]=s,e[9]=n,e[10]=g,e[11]=i):i=e[11],i}function R(E){const e=A.c(24),{icon:t,name:s,size:w,className:o,fallbackIcon:c}=E,n=w===void 0?"md":w,[g,i]=z.useState(!1),r=!!t&&g,l=C[n],b=Z[n];let a;e[0]!==o||e[1]!==l||e[2]!==b?(a=_("rounded-lg border border-border shrink-0 overflow-hidden aspect-square bg-white",l,b,o),e[0]=o,e[1]=l,e[2]=b,e[3]=a):a=e[3];const p=t||void 0,N=!r&&"hidden";let m;e[4]!==N?(m=_("h-full w-full object-cover",N),e[4]=N,e[5]=m):m=e[5];let I,S;e[6]===Symbol.for("react.memo_cache_sentinel")?(I=()=>i(!1),S=()=>i(!0),e[6]=I,e[7]=S):(I=e[6],S=e[7]);let d;e[8]!==s||e[9]!==p||e[10]!==m?(d=h.jsx("img",{src:p,alt:s,className:m,onError:I,onLoad:S}),e[8]=s,e[9]=p,e[10]=m,e[11]=d):d=e[11];const v=r&&"hidden";let f;e[12]!==v?(f=_("h-full w-full flex items-center justify-center bg-muted/20",v),e[12]=v,e[13]=f):f=e[13];let x;e[14]!==c||e[15]!==n?(x=c??h.jsx(L,{size:y[n],className:"text-muted-foreground"}),e[14]=c,e[15]=n,e[16]=x):x=e[16];let u;e[17]!==f||e[18]!==x?(u=h.jsx("div",{className:f,children:x}),e[17]=f,e[18]=x,e[19]=u):u=e[19];let j;return e[20]!==d||e[21]!==u||e[22]!==a?(j=h.jsxs("div",{className:a,children:[d,u]}),e[20]=d,e[21]=u,e[22]=a,e[23]=j):j=e[23],j}export{q as I};
1
+ import{e as A,j as h,r as z,c as _}from"./index-DGBhnElr.js";import{n as L}from"./Container-BSuhE8C0.js";import{A as k}from"./agent-icon-B77lAtfk.js";const C={"2xs":"h-4 w-4",xs:"h-6 w-6",sm:"h-9 w-9",md:"h-12 w-12",lg:"h-16 w-16",xl:"h-14 w-14"},Z={"2xs":"min-w-4",xs:"min-w-6",sm:"min-w-9",md:"min-w-12",lg:"min-w-16",xl:"min-w-14"},y={"2xs":8,xs:12,sm:16,md:24,lg:32,xl:28},M={"2xs":"xs",xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"lg"};function q(E){const e=A.c(12),{icon:t,name:s,size:w,className:o,fallbackIcon:c}=E,n=w===void 0?"md":w;if(t?.startsWith("icon://")||t?.includes("#agentcolor=")){const r=M[n];let l;return e[0]!==o||e[1]!==t||e[2]!==s||e[3]!==r?(l=h.jsx(k,{icon:t,name:s,size:r,className:o}),e[0]=o,e[1]=t,e[2]=s,e[3]=r,e[4]=l):l=e[4],l}const g=t??"no-icon";let i;return e[5]!==o||e[6]!==c||e[7]!==t||e[8]!==s||e[9]!==n||e[10]!==g?(i=h.jsx(R,{icon:t,name:s,size:n,className:o,fallbackIcon:c},g),e[5]=o,e[6]=c,e[7]=t,e[8]=s,e[9]=n,e[10]=g,e[11]=i):i=e[11],i}function R(E){const e=A.c(24),{icon:t,name:s,size:w,className:o,fallbackIcon:c}=E,n=w===void 0?"md":w,[g,i]=z.useState(!1),r=!!t&&g,l=C[n],b=Z[n];let a;e[0]!==o||e[1]!==l||e[2]!==b?(a=_("rounded-lg border border-border shrink-0 overflow-hidden aspect-square bg-white",l,b,o),e[0]=o,e[1]=l,e[2]=b,e[3]=a):a=e[3];const p=t||void 0,N=!r&&"hidden";let m;e[4]!==N?(m=_("h-full w-full object-cover",N),e[4]=N,e[5]=m):m=e[5];let I,S;e[6]===Symbol.for("react.memo_cache_sentinel")?(I=()=>i(!1),S=()=>i(!0),e[6]=I,e[7]=S):(I=e[6],S=e[7]);let d;e[8]!==s||e[9]!==p||e[10]!==m?(d=h.jsx("img",{src:p,alt:s,className:m,onError:I,onLoad:S}),e[8]=s,e[9]=p,e[10]=m,e[11]=d):d=e[11];const v=r&&"hidden";let f;e[12]!==v?(f=_("h-full w-full flex items-center justify-center bg-muted/20",v),e[12]=v,e[13]=f):f=e[13];let x;e[14]!==c||e[15]!==n?(x=c??h.jsx(L,{size:y[n],className:"text-muted-foreground"}),e[14]=c,e[15]=n,e[16]=x):x=e[16];let u;e[17]!==f||e[18]!==x?(u=h.jsx("div",{className:f,children:x}),e[17]=f,e[18]=x,e[19]=u):u=e[19];let j;return e[20]!==d||e[21]!==u||e[22]!==a?(j=h.jsxs("div",{className:a,children:[d,u]}),e[20]=d,e[21]=u,e[22]=a,e[23]=j):j=e[23],j}export{q as I};
@@ -1 +1 @@
1
- import{e as n,c as r,j as i,b5 as p}from"./index-Dcg8Qevd.js";function c(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=r("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx(p,{"data-slot":"label",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}export{c as L};
1
+ import{e as n,c as r,j as i,b5 as p}from"./index-DGBhnElr.js";function c(l){const e=n.c(8);let t,s;e[0]!==l?({className:t,...s}=l,e[0]=l,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let a;e[3]!==t?(a=r("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),e[3]=t,e[4]=a):a=e[4];let o;return e[5]!==s||e[6]!==a?(o=i.jsx(p,{"data-slot":"label",className:a,...s}),e[5]=s,e[6]=a,e[7]=o):o=e[7],o}export{c as L};
@@ -1 +1 @@
1
- import{e as C,r as i,c as A,j as a,ao as V}from"./index-Dcg8Qevd.js";import{P as E}from"./index-DtUGvIts.js";const H=i.createContext(null);function z(x){const e=C.c(3),{children:l}=x,s=i.useContext(H);if(!s?.tabsEl)return null;let c;return e[0]!==l||e[1]!==s.tabsEl?(c=V.createPortal(l,s.tabsEl),e[0]=l,e[1]=s.tabsEl,e[2]=c):c=e[2],c}function D(x){const e=C.c(3),{children:l}=x,s=i.useContext(H);if(!s?.actionsEl)return null;let c;return e[0]!==l||e[1]!==s.actionsEl?(c=V.createPortal(l,s.actionsEl),e[0]=l,e[1]=s.actionsEl,e[2]=c):c=e[2],c}const B=D;function F(x){const e=C.c(21),{children:l,breadcrumb:s,hideHeader:c}=x;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={leftEl:null,tabsEl:null,actionsEl:null},e[0]=b):b=e[0];const[w,g]=i.useState(b),N=i.useRef(null),P=i.useRef(null),L=i.useRef(null);let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=t=>{N.current=t,t&&g(n=>n.leftEl===t?n:{...n,leftEl:t})},e[1]=h):h=e[1];const $=h;let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R=t=>{P.current=t,t&&g(n=>n.tabsEl===t?n:{...n,tabsEl:t})},e[2]=R):R=e[2];const _=R;let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t=>{L.current=t,t&&g(n=>n.actionsEl===t?n:{...n,actionsEl:t})},e[3]=d):d=e[3];const k=d,p=c&&"hidden";let o;e[4]!==p?(o=A(p),e[4]=p,e[5]=o):o=e[5];let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{ref:$,className:"flex items-center gap-2 min-w-0"}),e[6]=j):j=e[6];let r;e[7]!==s?(r=a.jsxs(E.Header.Left,{children:[s,j]}),e[7]=s,e[8]=r):r=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsxs(E.Header.Right,{children:[a.jsx("div",{ref:_,className:"flex items-center gap-2 overflow-x-auto min-w-0"}),a.jsx("div",{ref:k,className:"flex items-center gap-2 shrink-0"})]}),e[9]=y):y=e[9];let f;e[10]!==o||e[11]!==r?(f=a.jsxs(E.Header,{className:o,children:[r,y]}),e[10]=o,e[11]=r,e[12]=f):f=e[12];let m;e[13]!==l?(m=a.jsx(E.Content,{children:l}),e[13]=l,e[14]=m):m=e[14];let u;e[15]!==f||e[16]!==m?(u=a.jsxs(E,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=u):u=e[17];let S;return e[18]!==w||e[19]!==u?(S=a.jsx(H,{value:w,children:u}),e[18]=w,e[19]=u,e[20]=S):S=e[20],S}export{F as V,B as a,z as b};
1
+ import{e as C,r as i,c as A,j as a,ao as V}from"./index-DGBhnElr.js";import{P as E}from"./index-eAGChOCR.js";const H=i.createContext(null);function z(x){const e=C.c(3),{children:l}=x,s=i.useContext(H);if(!s?.tabsEl)return null;let c;return e[0]!==l||e[1]!==s.tabsEl?(c=V.createPortal(l,s.tabsEl),e[0]=l,e[1]=s.tabsEl,e[2]=c):c=e[2],c}function D(x){const e=C.c(3),{children:l}=x,s=i.useContext(H);if(!s?.actionsEl)return null;let c;return e[0]!==l||e[1]!==s.actionsEl?(c=V.createPortal(l,s.actionsEl),e[0]=l,e[1]=s.actionsEl,e[2]=c):c=e[2],c}const B=D;function F(x){const e=C.c(21),{children:l,breadcrumb:s,hideHeader:c}=x;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={leftEl:null,tabsEl:null,actionsEl:null},e[0]=b):b=e[0];const[w,g]=i.useState(b),N=i.useRef(null),P=i.useRef(null),L=i.useRef(null);let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=t=>{N.current=t,t&&g(n=>n.leftEl===t?n:{...n,leftEl:t})},e[1]=h):h=e[1];const $=h;let R;e[2]===Symbol.for("react.memo_cache_sentinel")?(R=t=>{P.current=t,t&&g(n=>n.tabsEl===t?n:{...n,tabsEl:t})},e[2]=R):R=e[2];const _=R;let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t=>{L.current=t,t&&g(n=>n.actionsEl===t?n:{...n,actionsEl:t})},e[3]=d):d=e[3];const k=d,p=c&&"hidden";let o;e[4]!==p?(o=A(p),e[4]=p,e[5]=o):o=e[5];let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=a.jsx("div",{ref:$,className:"flex items-center gap-2 min-w-0"}),e[6]=j):j=e[6];let r;e[7]!==s?(r=a.jsxs(E.Header.Left,{children:[s,j]}),e[7]=s,e[8]=r):r=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=a.jsxs(E.Header.Right,{children:[a.jsx("div",{ref:_,className:"flex items-center gap-2 overflow-x-auto min-w-0"}),a.jsx("div",{ref:k,className:"flex items-center gap-2 shrink-0"})]}),e[9]=y):y=e[9];let f;e[10]!==o||e[11]!==r?(f=a.jsxs(E.Header,{className:o,children:[r,y]}),e[10]=o,e[11]=r,e[12]=f):f=e[12];let m;e[13]!==l?(m=a.jsx(E.Content,{children:l}),e[13]=l,e[14]=m):m=e[14];let u;e[15]!==f||e[16]!==m?(u=a.jsxs(E,{children:[f,m]}),e[15]=f,e[16]=m,e[17]=u):u=e[17];let S;return e[18]!==w||e[19]!==u?(S=a.jsx(H,{value:w,children:u}),e[18]=w,e[19]=u,e[20]=S):S=e[20],S}export{F as V,B as a,z as b};
@@ -1,4 +1,4 @@
1
- import{e as k,j as t,s as $,o as je,b as Fe,r as O,K as ne,n as He,a as Be,c as xe,B as ae,t as D,x as oe,G as Xe,F as Ze,v as ve,P as et,l as Ne,w as tt,f as nt}from"./index-Dcg8Qevd.js";import{S as ce,u as V,d as Ae,W as qe,a as be}from"./constants-DXQgV2hu.js";import{a as _e}from"./use-navigate-to-agent-BvnJAyr6.js";import{a as le,b as de,c as ue,d as me,D as st}from"./dialog-DUgfuVrb.js";import{i as Ee}from"./RefreshCcw01-Cd8Km121.js";import{C as Qe}from"./collection-search-D-x3SJ1z.js";import{C as it}from"./checkbox-B3EwrxkO.js";import{b as Se,u as ot}from"./use-connection-wzOJDB7e.js";import{i as at}from"./Lock01-FiMk9Cv6.js";import{n as rt}from"./agent-icon-CznXZlOI.js";import{e as ct}from"./extract-connection-data-Dgw7Sgd3.js";import{b as Oe,a as Le,c as Re,D as Me}from"./drawer-DeyjQQc7.js";import{u as ke}from"./tooltip-sn7TXXXA.js";import{I as Ue}from"./integration-icon-DTJ2wb4X.js";import{u as lt,d as Ke}from"./use-mcp-tools-Cu2GPPjO.js";import{a as Pe,b as dt}from"./use-virtual-mcp-Cvy2Xx_N.js";function re(i){const e=k.c(4),{size:s,className:a}=i;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z"}),e[0]=l):l=e[0];let n;return e[1]!==a||e[2]!==s?(n=t.jsx("svg",{width:s,height:s,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:a,children:l}),e[1]=a,e[2]=s,e[3]=n):n=e[3],n}function ut(i){return i.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function mt(i){const e=await fetch(`/api/${i}/deco-sites`);if(!e.ok){const s=await e.json().catch(()=>({}));throw new Error(s.error??`Failed to load sites (${e.status})`)}return e.json()}function Xt(i){const e=k.c(70),{open:s,onOpenChange:a,onBack:l}=i,{org:n}=$(),r=_e(),u=je(),{data:d}=Fe.useSession(),[_,c]=O.useState(null),[h,C]=O.useState("");let f;e[0]!==n.id||e[1]!==n.slug?(f={connectionId:ce,orgId:n.id,orgSlug:n.slug},e[0]=n.id,e[1]=n.slug,e[2]=f):f=e[2];const p=V(f);let m;e[3]!==d?.user?.email?(m=ne.decoSites(d?.user?.email),e[3]=d?.user?.email,e[4]=m):m=e[4];let g;e[5]!==n.slug?(g=()=>mt(n.slug),e[5]=n.slug,e[6]=g):g=e[6];const x=s&&!!d?.user?.email;let I;e[7]!==m||e[8]!==g||e[9]!==x?(I={queryKey:m,queryFn:g,enabled:x,staleTime:6e4,retry:!1},e[7]=m,e[8]=g,e[9]=x,e[10]=I):I=e[10];const{data:b,isLoading:N,error:y}=He(I),o=b?.sites??[];let T;e[11]!==a?(T=j=>{j||(c(null),C("")),a(j)},e[11]=a,e[12]=T):T=e[12];const w=T;let v;e[13]!==h?(v=j=>j.name.toLowerCase().includes(h.toLowerCase())||j.domains?.[0]?.domain.toLowerCase().includes(h.toLowerCase()),e[13]=h,e[14]=v):v=e[14];const A=o.filter(v),E=!_||A.some(j=>j.name===_);let S;e[15]!==p||e[16]!==n.id||e[17]!==n.slug?(S=async j=>{D("deco_site_import_started",{site_name:j});const P=await fetch(`/api/${n.slug}/deco-sites/connection`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:j,orgId:n.id})}),G=await P.json().catch(pt);if(!P.ok)throw new Error(G.error??`Failed to create connection (${P.status})`);const M=G.connId;if(!M)throw new Error("Server did not return a connection ID");const he=G.icon??null,te=ut(j),Ge=await p.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:j,description:"Imported from deco.cx",pinned:!0,icon:he??null,subtype:"project",metadata:{instructions:null,enabled_plugins:[],ui:{banner:null,bannerColor:"#22C55E",icon:he,themeColor:"#22C55E",slug:te,pinnedViews:[{connectionId:M,toolName:"file_explorer",label:"Preview",icon:null},{connectionId:M,toolName:"fetch_assets",label:"Assets",icon:null},{connectionId:M,toolName:"get_monitor_data",label:"Monitor",icon:null},{connectionId:M,toolName:"list_pull_requests",label:"Pull Requests",icon:null},{connectionId:M,toolName:"list_releases",label:"Releases",icon:null}],layout:{defaultMainView:{type:"ext-apps",id:M,toolName:"file_explorer"}}}},connections:[{connection_id:M}]}}}),De=Ge.structuredContent??Ge;return{slug:te,virtualMcpId:De.item.id,connId:M,item:De.item}},e[15]=p,e[16]=n.id,e[17]=n.slug,e[18]=S):S=e[18];let R;e[19]!==p||e[20]!==w||e[21]!==r||e[22]!==n.id||e[23]!==u?(R=j=>{const{slug:P,virtualMcpId:G,item:M}=j;D("deco_site_import_succeeded",{site_name:M.title,virtual_mcp_id:G,slug:P}),u.setQueryData(ne.collectionItem(p,n.id,"","VIRTUAL_MCP",G),{item:M}),u.invalidateQueries({predicate:he=>{const te=he.queryKey;return te[1]===n.id&&te[3]==="collection"&&te[4]==="VIRTUAL_MCP"}}),u.invalidateQueries({queryKey:ne.projects(n.id)}),oe.success(`Imported ${P} from deco.cx`),w(!1),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),r(G)},e[19]=p,e[20]=w,e[21]=r,e[22]=n.id,e[23]=u,e[24]=R):R=e[24];let z;e[25]!==S||e[26]!==R?(z={mutationFn:S,onSuccess:R,onError:gt},e[25]=S,e[26]=R,e[27]=z):z=e[27];const U=Be(z),se=de,L=le,ie="sm:max-w-[900px] p-0 gap-0 overflow-hidden";let F;e[28]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(ue,{className:"sr-only",children:t.jsx(me,{children:"Import from deco.cx"})}),e[28]=F):F=e[28];let H;e[29]!==l?(H=l&&t.jsx("button",{type:"button",onClick:l,className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors","aria-label":"Go back",children:t.jsx(Ee,{size:18})}),e[29]=l,e[30]=H):H=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Import from deco.cx"}),e[31]=fe):fe=e[31];let B;e[32]!==H?(B=t.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3",children:[H,fe]}),e[32]=H,e[33]=B):B=e[33];let ge;e[34]===Symbol.for("react.memo_cache_sentinel")?(ge=j=>{j.key==="Escape"&&C("")},e[34]=ge):ge=e[34];let q;e[35]!==h?(q=t.jsx("div",{children:t.jsx(Qe,{value:h,onChange:C,placeholder:"Search sites...",onKeyDown:ge})}),e[35]=h,e[36]=q):q=e[36];const Je="pb-0 min-h-[300px]";let Q;e[37]!==N?(Q=N&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"Loading sites..."}),e[37]=N,e[38]=Q):Q=e[38];const Ce=!N&&!y&&o.length===0&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"No sites found for this account."}),Te=!N&&o.length>0&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 max-h-[420px] overflow-y-auto py-4 px-8 [scrollbar-gutter:stable]",children:[A.length===0&&t.jsxs("p",{className:"col-span-3 text-sm text-muted-foreground text-center py-8",children:["No sites match “",h,"”"]}),A.map(j=>{const P=j.domains?.find(ft)?.domain??j.domains?.[0]?.domain,G=_===j.name;return t.jsxs("button",{type:"button",onClick:()=>c(j.name),className:xe("flex flex-col rounded-xl border overflow-hidden text-left transition-all cursor-pointer",G?"border-primary ring-1 ring-primary":"border-border hover:border-muted-foreground/40"),children:[t.jsx("div",{className:"w-full aspect-video bg-muted overflow-hidden",children:j.thumb_url?t.jsx("img",{src:j.thumb_url,alt:j.name,className:"w-full h-full object-cover",loading:"lazy"}):t.jsx("div",{className:"w-full h-full bg-muted"})}),t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:j.name}),P&&t.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:P})]})]},j.name)})]});let K;e[39]!==Q||e[40]!==Ce||e[41]!==Te?(K=t.jsxs("div",{className:Je,children:[Q,Ce,Te]}),e[39]=Q,e[40]=Ce,e[41]=Te,e[42]=K):K=e[42];let Y;e[43]!==w?(Y=()=>w(!1),e[43]=w,e[44]=Y):Y=e[44];let W;e[45]!==U.isPending||e[46]!==Y?(W=t.jsx(ae,{variant:"outline",onClick:Y,disabled:U.isPending,children:"Cancel"}),e[45]=U.isPending,e[46]=Y,e[47]=W):W=e[47];const Ie=!_||!E||U.isPending||N;let J;e[48]!==U||e[49]!==_?(J=()=>_&&U.mutate(_),e[48]=U,e[49]=_,e[50]=J):J=e[50];const ye=U.isPending?"Importing...":"Import";let X;e[51]!==Ie||e[52]!==J||e[53]!==ye?(X=t.jsx(ae,{disabled:Ie,onClick:J,children:ye}),e[51]=Ie,e[52]=J,e[53]=ye,e[54]=X):X=e[54];let Z;e[55]!==W||e[56]!==X?(Z=t.jsxs(st,{className:"px-8 py-5 border-t border-border",children:[W,X]}),e[55]=W,e[56]=X,e[57]=Z):Z=e[57];let ee;e[58]!==L||e[59]!==F||e[60]!==B||e[61]!==q||e[62]!==K||e[63]!==Z?(ee=t.jsxs(L,{className:ie,children:[F,B,q,K,Z]}),e[58]=L,e[59]=F,e[60]=B,e[61]=q,e[62]=K,e[63]=Z,e[64]=ee):ee=e[64];let pe;return e[65]!==se||e[66]!==w||e[67]!==s||e[68]!==ee?(pe=t.jsx(se,{open:s,onOpenChange:w,children:ee}),e[65]=se,e[66]=w,e[67]=s,e[68]=ee,e[69]=pe):pe=e[69],pe}function ft(i){return i.production}function gt(i){D("deco_site_import_failed",{error:i instanceof Error?i.message:"Unknown error"}),oe.error("Import failed: "+(i instanceof Error?i.message:"Unknown error"))}function pt(){return{}}function Ye(i,e){const s=k.c(12),{org:a}=$();let l;s[0]!==a.id?(l=Ae.REGISTRY(a.id),s[0]=a.id,s[1]=l):l=s[1];const n=l;let r;s[2]!==a.id||s[3]!==a.slug||s[4]!==n?(r={connectionId:n,orgId:a.id,orgSlug:a.slug},s[2]=a.id,s[3]=a.slug,s[4]=n,s[5]=r):r=s[5];const u=V(r);let d;s[6]!==i?(d={name:i},s[6]=i,s[7]=d):d=s[7];const _=e?.enabled??!0;let c;return s[8]!==u||s[9]!==d||s[10]!==_?(c={client:u,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:d,enabled:_,staleTime:3e5,select:ht},s[8]=u,s[9]=d,s[10]=_,s[11]=c):c=s[11],lt(c)}function ht(i){return i.structuredContent?.item??null}const xt="deco/mcp-github";function Nt(i){const{org:e}=$(),{data:s}=Fe.useSession(),a=Se(),l=je(),[n,r]=O.useState("idle"),[u,d]=O.useState(null),[_,c]=O.useState(null),{data:h,isLoading:C}=Ye(xt,{enabled:i.enabled}),f=O.useRef(!1);i.enabled&&h&&!C&&!f.current&&s?.user?.id&&n==="idle"&&(f.current=!0,p());async function p(){if(!(!h||!s?.user?.id||!e))try{r("installing"),d(null);const g=ct(h,e.id,s.user.id,{remoteIndex:0});if(!g.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:I}=await a.create.mutateAsync(g);r("authenticating");const b=new URL(`/api/${e.slug}/mcp/${I}`,window.location.origin),N=await Xe({url:b.href,token:null,orgId:e.id});if(N.supportsOAuth&&!N.isAuthenticated){const{token:y,tokenInfo:o,error:T}=await Ze({connectionId:I,orgSlug:e.slug,scope:"offline_access"});if(T||!y){try{await a.delete.mutateAsync(I)}catch{}throw new Error(T??"No token received from GitHub")}if(o)try{(await fetch(`/api/${e.slug}/connections/${I}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:o.accessToken,refreshToken:o.refreshToken,expiresIn:o.expiresIn,scope:o.scope,clientId:o.clientId,clientSecret:o.clientSecret,tokenEndpoint:o.tokenEndpoint})})).ok||await a.update.mutateAsync({id:I,data:{connection_token:y}})}catch{await a.update.mutateAsync({id:I,data:{connection_token:y}})}}ve(l,e.id),c(g),r("ready")}catch(g){d(g instanceof Error?g.message:String(g)),r("error")}}function m(){r("idle"),d(null),c(null),f.current=!1}return i.enabled&&C&&n==="idle"?{status:"installing",error:null,connection:null,retry:m}:{status:n,error:u,connection:_,retry:m}}function Zt(i){const e=k.c(21),{open:s,onOpenChange:a,title:l,hideAutoRespondCheckbox:n,onImportComplete:r}=i,u=l===void 0?"Import from GitHub":l,d=n===void 0?!1:n,[_]=et(),[c,h]=O.useState(null);if(!_.experimental_vibecode)return null;let C;e[0]!==u?(C=t.jsx(ue,{className:"sr-only",children:t.jsx(me,{children:u})}),e[0]=u,e[1]=C):C=e[1];let f;e[2]!==c||e[3]!==u?(f=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:c?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>h(null),className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors shrink-0","aria-label":"Back to accounts",children:t.jsx(Ee,{size:16})}),t.jsx("img",{src:c.avatarUrl,alt:c.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:c.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:u})]})}),e[2]=c,e[3]=u,e[4]=f):f=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ne,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=p):p=e[5];let m;e[6]!==a?(m=()=>a(!1),e[6]=a,e[7]=m):m=e[7];let g;e[8]!==d||e[9]!==r||e[10]!==c||e[11]!==m?(g=t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:t.jsx(O.Suspense,{fallback:p,children:t.jsx(_t,{onComplete:m,selectedInstallation:c,onSelectInstallation:h,hideAutoRespondCheckbox:d,onImportComplete:r})})}),e[8]=d,e[9]=r,e[10]=c,e[11]=m,e[12]=g):g=e[12];let x;e[13]!==C||e[14]!==f||e[15]!==g?(x=t.jsxs(le,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[C,f,g]}),e[13]=C,e[14]=f,e[15]=g,e[16]=x):x=e[16];let I;return e[17]!==a||e[18]!==s||e[19]!==x?(I=t.jsx(de,{open:s,onOpenChange:a,children:x}),e[17]=a,e[18]=s,e[19]=x,e[20]=I):I=e[20],I}function _t({onComplete:i,selectedInstallation:e,onSelectInstallation:s,hideAutoRespondCheckbox:a,onImportComplete:l}){const{org:n}=$(),r=je(),u=_e(),[d,_]=O.useState(null),[c,h]=O.useState(!0),C=a?!0:c,f=ot({slug:"mcp-github"}),p=Nt({enabled:f.length===0}),m=f.length===1?f[0]??null:d,g=V({connectionId:m?.id??"",orgId:n.id,orgSlug:n.slug}),x=V({connectionId:ce,orgId:n.id,orgSlug:n.slug}),I=async(o,T)=>{try{const v=await g.callTool({name:"get_file_contents",arguments:{owner:o.owner,repo:o.name,path:T}});if(v.isError)return null;const E=v.content?.find(S=>S.type==="resource")?.resource?.text;if(!E)return null;try{const S=JSON.parse(E);return typeof S=="string"?S:JSON.stringify(S)}catch{return E}}catch{return null}},b=(o,T)=>{Promise.all([I(T,"AGENTS.md"),I(T,"CLAUDE.md")]).then(async([w,v])=>{const A=w??v??null;A&&(await x.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:o,data:{metadata:{instructions:A}}}}),ve(r,n.id))}).catch(w=>{console.error("GitHub instructions fetch failed:",w)})},N=async({virtualMcpId:o,repo:T,connectionId:w})=>{const v=await g.callTool({name:"TRIGGER_LIST",arguments:{}}),A=v.structuredContent??v,E=A.triggers?.find(L=>L.type==="github.issues.opened")??A.triggers?.find(L=>{const ie=L.type.toLowerCase();return/\bissues?\./.test(ie)&&(ie.endsWith(".opened")||ie.endsWith(".created"))});if(!E)throw new Error("No issue-created trigger exposed by GitHub connection");const S=new Set;if(Array.isArray(E.params))for(const L of E.params)S.add(L.name);else if(E.params&&typeof E.params=="object")for(const L of Object.keys(E.params))S.add(L);if(E.paramsSchema)for(const L of Object.keys(E.paramsSchema))S.add(L);const R={};S.has("repo")?R.repo=`${T.owner}/${T.name}`:(S.has("owner")&&(R.owner=T.owner),S.has("name")&&(R.name=T.name),S.has("repository")&&(R.repository=`${T.owner}/${T.name}`));const z=`A new GitHub issue has been opened in ${T.owner}/${T.name}. Read the issue details, explore the relevant code in the repository, create a new branch, implement the fix or feature requested, and open a pull request that resolves the issue. Reference the issue number in the PR description.`,U=await x.callTool({name:"AUTOMATION_CREATE",arguments:{name:`${T.name}: auto-respond to issues`,virtual_mcp_id:o,messages:z,active:!0}}),se=U.structuredContent??U;await x.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:se.id,type:"event",connection_id:w,event_type:E.type,params:R}})},y=Be({mutationFn:async o=>{if(!m||!e)throw new Error("No GitHub connection or installation");const T=m.id,w=await x.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:o.name,description:o.description||"Imported from GitHub",pinned:!0,icon:null,metadata:{githubRepo:{owner:o.owner,name:o.name,url:o.url,installationId:e.installationId,connectionId:T},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"}}}},connections:[{connection_id:T}]}}}),v=w.structuredContent??w,A=v.item.id;return C&&await N({virtualMcpId:A,repo:o,connectionId:T}).catch(E=>{console.error("Failed to set up issue automation:",E),oe.warning("Imported repo, but failed to set up issue auto-response. You can add the trigger manually from the automations view.")}),{virtualMcpId:A,repo:o,connectionId:T,item:v.item}},onSuccess:({virtualMcpId:o,repo:T,connectionId:w,item:v})=>{if(r.setQueryData(ne.collectionItem(x,n.id,"","VIRTUAL_MCP",o),{item:v}),ve(r,n.id),b(o,T),l){l({virtualMcpId:o,repo:T,connectionId:w});return}oe.success(`Imported ${T.name} from GitHub`),i(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),u(o)},onError:o=>{oe.error("Failed to import repo: "+(o instanceof Error?o.message:"Unknown error"))}});return p.status==="installing"||p.status==="authenticating"?t.jsx(we,{status:p.status,error:null,retry:p.retry}):p.status==="error"?t.jsx(we,{status:"error",error:p.error,retry:p.retry}):f.length===0&&p.status==="idle"?t.jsx(we,{status:"installing",error:null,retry:p.retry}):f.length>1&&!m?t.jsxs("div",{className:"flex flex-col py-2",children:[t.jsx("div",{className:"px-4 py-2",children:t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Select a connection"})}),f.map(o=>t.jsxs("button",{type:"button",onClick:()=>_(o),className:"flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left",children:[o.icon?t.jsx("img",{src:o.icon,alt:o.title,className:"size-7 rounded-full shrink-0"}):t.jsx("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center shrink-0",children:t.jsx(re,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:o.title})]},o.id))]}):m?e?t.jsx(Tt,{connectionId:m.id,orgId:n.id,orgSlug:n.slug,installation:e,onSelectRepo:o=>y.mutate(o),isSaving:y.isPending,autoRespondToIssues:c,onAutoRespondChange:h,hideAutoRespondCheckbox:a}):t.jsx(Ct,{connectionId:m.id,orgId:n.id,orgSlug:n.slug,onSelect:s,showBackButton:f.length>1,onBack:()=>_(null)}):null}function Ct(i){const e=k.c(31),{connectionId:s,orgId:a,orgSlug:l,onSelect:n,showBackButton:r,onBack:u}=i;let d;e[0]!==a||e[1]!==l?(d={connectionId:ce,orgId:a,orgSlug:l},e[0]=a,e[1]=l,e[2]=d):d=e[2];const _=V(d);let c;e[3]!==s||e[4]!==a?(c=ne.githubUserOrgs(a,s),e[3]=s,e[4]=a,e[5]=c):c=e[5];let h;e[6]!==s||e[7]!==_?(h=async()=>{const T=(await _.callTool({name:"GITHUB_LIST_USER_ORGS",arguments:{connectionId:s}})).content?.[0]?.text;if(!T)throw new Error("No response from GITHUB_LIST_USER_ORGS");return JSON.parse(T)},e[6]=s,e[7]=_,e[8]=h):h=e[8];let C;e[9]!==c||e[10]!==h?(C={queryKey:c,queryFn:h},e[9]=c,e[10]=h,e[11]=C):C=e[11];const f=He(C);if(f.isLoading){let o;return e[12]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ne,{size:18,className:"animate-spin text-muted-foreground"})}),e[12]=o):o=e[12],o}if(f.isError){let o;return e[13]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("p",{className:"text-sm text-destructive",children:"Failed to load GitHub accounts"})}),e[13]=o):o=e[13],o}const p=f.data;if(!p)return null;let m;e[14]!==u||e[15]!==r?(m=r&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(Ee,{size:12}),"Change connection"]})}),e[14]=u,e[15]=r,e[16]=m):m=e[16];let g;if(e[17]!==p.installations||e[18]!==n){let o;e[20]!==n?(o=T=>t.jsxs("button",{type:"button",onClick:()=>n(T),className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left group",children:[t.jsx("img",{src:T.avatarUrl,alt:T.login,className:"size-7 rounded-full shrink-0 ring-1 ring-border"}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium leading-none",children:T.login}),T.type==="User"&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Personal account"})]}),t.jsx("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:"Select →"})]},T.installationId),e[20]=n,e[21]=o):o=e[21],g=p.installations.map(o),e[17]=p.installations,e[18]=n,e[19]=g}else g=e[19];let x;e[22]!==g?(x=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:g}),e[22]=g,e[23]=x):x=e[23];const I=p.appSlug?`https://github.com/apps/${p.appSlug}/installations/new`:"https://github.com/settings/installations";let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("span",{className:"underline underline-offset-2",children:"Install the GitHub App"}),e[24]=b):b=e[24];let N;e[25]!==I?(N=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:["Account not listed?"," ",b]})}),e[25]=I,e[26]=N):N=e[26];let y;return e[27]!==N||e[28]!==m||e[29]!==x?(y=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m,x,N]}),e[27]=N,e[28]=m,e[29]=x,e[30]=y):y=e[30],y}function Tt(i){const e=k.c(25),{connectionId:s,orgId:a,orgSlug:l,installation:n,onSelectRepo:r,isSaving:u,autoRespondToIssues:d,onAutoRespondChange:_,hideAutoRespondCheckbox:c}=i,[h,C]=O.useState(""),f=O.useDeferredValue(h),p=h!==f;let m;e[0]!==p||e[1]!==h?(m=t.jsx(Qe,{placeholder:"Search repositories...",value:h,onChange:C,isSearching:p}),e[0]=p,e[1]=h,e[2]=m):m=e[2];const g=p?"opacity-40":"opacity-100";let x;e[3]!==g?(x=xe("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",g),e[3]=g,e[4]=x):x=e[4];let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ne,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=I):I=e[5];let b;e[6]!==s||e[7]!==f||e[8]!==n||e[9]!==u||e[10]!==r||e[11]!==a||e[12]!==l?(b=t.jsx(O.Suspense,{fallback:I,children:t.jsx(It,{connectionId:s,orgId:a,orgSlug:l,installation:n,query:f,onSelectRepo:r,isSaving:u})}),e[6]=s,e[7]=f,e[8]=n,e[9]=u,e[10]=r,e[11]=a,e[12]=l,e[13]=b):b=e[13];let N;e[14]!==x||e[15]!==b?(N=t.jsx("div",{className:x,children:b}),e[14]=x,e[15]=b,e[16]=N):N=e[16];let y;e[17]!==d||e[18]!==c||e[19]!==_?(y=!c&&t.jsxs("label",{className:"flex items-center gap-2 px-4 py-3 border-t border-border shrink-0 cursor-pointer select-none",children:[t.jsx(it,{checked:d,onCheckedChange:T=>_(T===!0)}),t.jsx("span",{className:"text-xs text-foreground",children:"Auto-respond to new issues with a PR"})]}),e[17]=d,e[18]=c,e[19]=_,e[20]=y):y=e[20];let o;return e[21]!==m||e[22]!==N||e[23]!==y?(o=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m,N,y]}),e[21]=m,e[22]=N,e[23]=y,e[24]=o):o=e[24],o}function It(i){const e=k.c(29),{connectionId:s,orgId:a,orgSlug:l,installation:n,query:r,onSelectRepo:u,isSaving:d}=i;let _;e[0]!==s||e[1]!==a||e[2]!==l?(_={connectionId:s,orgId:a,orgSlug:l},e[0]=s,e[1]=a,e[2]=l,e[3]=_):_=e[3];const c=V(_),h=n.type==="User"?"user":"org",C=r?`${h}:${n.login} ${r} in:name`:`${h}:${n.login}`;let f;e[4]!==s||e[5]!==n.login||e[6]!==a||e[7]!==r?(f=ne.githubOrgRepos(a,s,n.login,r),e[4]=s,e[5]=n.login,e[6]=a,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==c||e[10]!==C?(p=async()=>{const N=(await c.callTool({name:"search_repositories",arguments:{query:C,page:1,perPage:30}})).content?.[0]?.text;if(!N)throw new Error("No response from search_repositories");return(JSON.parse(N).items??[]).map(yt)},e[9]=c,e[10]=C,e[11]=p):p=e[11];let m;e[12]!==f||e[13]!==p?(m={queryKey:f,queryFn:p},e[12]=f,e[13]=p,e[14]=m):m=e[14];const{data:g}=tt(m);if(g.length===0){let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("p",{className:"text-sm text-muted-foreground",children:"No repositories found"}),e[15]=b):b=e[15];let N;e[16]!==r?(N=r&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Try a different search term"}),e[16]=r,e[17]=N):N=e[17];let y;return e[18]!==N?(y=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[b,N]}),e[18]=N,e[19]=y):y=e[19],y}let x;if(e[20]!==d||e[21]!==u||e[22]!==g){let b;e[24]!==d||e[25]!==u?(b=N=>t.jsxs("button",{type:"button",onClick:()=>u(N),disabled:d,className:"flex items-start gap-3 px-4 py-3 hover:bg-accent transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(re,{className:"size-4 text-muted-foreground mt-0.5 shrink-0"}),t.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:t.jsx("span",{className:"text-sm font-medium truncate",children:N.name})}),t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:[N.private?t.jsx(at,{size:10}):t.jsx(rt,{size:10}),N.private?"Private":"Public"]})]},N.fullName),e[24]=d,e[25]=u,e[26]=b):b=e[26],x=g.map(b),e[20]=d,e[21]=u,e[22]=g,e[23]=x}else x=e[23];let I;return e[27]!==x?(I=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:x}),e[27]=x,e[28]=I):I=e[28],I}function yt(i){return{name:i.name,fullName:i.full_name,owner:i.full_name.split("/")[0]??"",url:i.html_url,private:i.private,description:i.description,updatedAt:i.updated_at}}function we(i){const e=k.c(33),{status:s,error:a,retry:l}=i;if(s==="error"){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"size-10 rounded-full bg-destructive/10 flex items-center justify-center",children:t.jsx(re,{className:"size-5 text-destructive"})}),e[0]=o):o=e[0];let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("p",{className:"text-sm font-medium",children:"Connection failed"}),e[1]=T):T=e[1];const w=a??"Something went wrong while connecting to GitHub.";let v;e[2]!==w?(v=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[T,t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:w})]}),e[2]=w,e[3]=v):v=e[3];let A;e[4]!==l?(A=t.jsx("button",{type:"button",onClick:l,className:"text-xs font-medium text-foreground border border-border rounded-md px-3 py-1.5 hover:bg-accent transition-colors",children:"Try again"}),e[4]=l,e[5]=A):A=e[5];let E;return e[6]!==v||e[7]!==A?(E=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[o,v,A]}),e[6]=v,e[7]=A,e[8]=E):E=e[8],E}const n=s==="authenticating";let r;e[9]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(re,{className:"size-5 text-foreground"})}),e[9]=r):r=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsxs("div",{className:"relative size-10",children:[r,t.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-background flex items-center justify-center",children:t.jsx(Ne,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[10]=u):u=e[10];const d=n?"Authenticating with GitHub":"Setting up GitHub";let _;e[11]!==d?(_=t.jsx("p",{className:"text-sm font-medium",children:d}),e[11]=d,e[12]=_):_=e[12];const c=n?"Complete the OAuth flow in your browser":"Installing the GitHub connection...";let h;e[13]!==c?(h=t.jsx("p",{className:"text-xs text-muted-foreground",children:c}),e[13]=c,e[14]=h):h=e[14];let C;e[15]!==_||e[16]!==h?(C=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[_,h]}),e[15]=_,e[16]=h,e[17]=C):C=e[17];const f=n?"bg-muted-foreground/30":"bg-foreground animate-pulse";let p;e[18]!==f?(p=xe("size-1.5 rounded-full",f),e[18]=f,e[19]=p):p=e[19];let m;e[20]!==p?(m=t.jsx("span",{className:p}),e[20]=p,e[21]=m):m=e[21];const g=n?"bg-foreground animate-pulse":"bg-muted-foreground/30";let x;e[22]!==g?(x=xe("size-1.5 rounded-full",g),e[22]=g,e[23]=x):x=e[23];let I;e[24]!==x?(I=t.jsx("span",{className:x}),e[24]=x,e[25]=I):I=e[25];let b;e[26]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[26]=b):b=e[26];let N;e[27]!==m||e[28]!==I?(N=t.jsxs("div",{className:"flex items-center gap-1.5",children:[m,I,b]}),e[27]=m,e[28]=I,e[29]=N):N=e[29];let y;return e[30]!==N||e[31]!==C?(y=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[u,C,N]}),e[30]=N,e[31]=C,e[32]=y):y=e[32],y}const bt=["Full HAR capture with cache, TTFB, and request analysis","Screenshot capture for visual inspection","Page discovery via sitemap, navigation, and link crawling","SEO audit — meta tags, structured data, robots.txt","Third-party script inventory and size analysis","Dead link detection across the entire site","Deco-specific diagnostics (?__d debug mode)"];function Ve(i){const e=k.c(7),{onRecruit:s,isRecruiting:a,isLoading:l}=i;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a blackbox diagnostics agent that tests your storefront from the outside — no internal access needed. Give it a URL and it produces a detailed performance and health report."}),e[0]=n):n=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=r):r=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsxs("div",{className:"space-y-2",children:[r,t.jsx("ul",{className:"space-y-1.5",children:bt.map(wt)})]}),e[2]=u):u=e[2];const d=a||l,_=a?"Setting up...":"Add Site Diagnostics";let c;return e[3]!==s||e[4]!==d||e[5]!==_?(c=t.jsxs("div",{className:"flex flex-col gap-6",children:[n,u,t.jsx(ae,{onClick:s,disabled:d,className:"w-full cursor-pointer",children:_})]}),e[3]=s,e[4]=d,e[5]=_,e[6]=c):c=e[6],c}function wt(i){return t.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[t.jsx("span",{className:"text-emerald-500 mt-0.5 shrink-0",children:"+"}),i]},i)}function en({open:i,onOpenChange:e,existingAgent:s}){const a=ke(),{org:l}=$(),n=_e(),r=Se(),u=Pe(),d=V({connectionId:ce,orgId:l.id,orgSlug:l.slug}),_=Ke({client:d}),[c,h]=O.useState(!1),C=qe.find(y=>y.id==="site-diagnostics"),{data:f,isLoading:p}=Ye(C.appId,{enabled:i}),m=f?.title||f?.server?.title||f?.server?.name||C.title,g=f?.server?.icons?.[0]?.src??C.icon,x=f?.server?.description??null,I=t.jsx(Ue,{icon:g,name:m,size:"sm"}),b=async()=>{if(f){if(s){e(!1),n(s.id);return}h(!0);try{const y=await _.mutateAsync({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:C.appId},limit:1,offset:0}});let o;const w=y?.structuredContent?.items?.find(A=>A.app_id===C.appId);if(w)o=w.id;else{const A=f.server?.remotes?.[0]?.url;if(!A)throw new Error("Registry item is missing a remote URL for site-diagnostics");o=(await r.create.mutateAsync({title:m,description:x,icon:f.server?.icons?.[0]?.src??C.icon,connection_type:"HTTP",connection_url:A,app_name:f.server?.name??"site-diagnostics",app_id:C.appId,metadata:{type:"site-diagnostics",source:"store",registry_item_id:C.appId,verified:!0}})).id}const v=await u.create.mutateAsync({title:m,description:x,icon:g,status:"active",connections:[{connection_id:o,selected_tools:null,selected_resources:null,selected_prompts:null}],metadata:{type:"site-diagnostics",instructions:null,ui:{pinnedViews:[{connectionId:o,toolName:"diagnose",label:"diagnose",icon:null}],layout:{defaultMainView:{type:"ext-apps",id:o,toolName:"diagnose"}}}}});D("agent_recruit_confirmed",{template_id:"site-diagnostics",agent_id:v.id}),e(!1),n(v.id)}catch(y){D("agent_recruit_failed",{template_id:"site-diagnostics",error:y instanceof Error?y.message:String(y)}),console.error("Failed to create Site Diagnostics agent:",y)}finally{h(!1)}}},N=`Add ${m}`;return a?t.jsx(Oe,{open:i,onOpenChange:e,children:t.jsxs(Le,{className:"h-[70dvh]",children:[t.jsx(Re,{className:"px-4 pt-4 pb-4 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-3",children:[I,t.jsx(Me,{className:"text-xl font-semibold",children:N})]})}),t.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:t.jsx(Ve,{onRecruit:b,isRecruiting:c,isLoading:p})})]})}):t.jsx(de,{open:i,onOpenChange:e,children:t.jsxs(le,{className:"sm:max-w-[500px] p-8",children:[t.jsx(ue,{className:"mb-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[I,t.jsx(me,{className:"text-xl font-semibold",children:N})]})}),t.jsx(Ve,{onRecruit:b,isRecruiting:c,isLoading:p})]})})}const vt=`<role>
1
+ import{e as k,j as t,s as $,o as je,b as Fe,r as O,K as ne,n as He,a as Be,c as xe,B as ae,t as D,x as oe,G as Xe,F as Ze,v as ve,P as et,l as Ne,w as tt,f as nt}from"./index-DGBhnElr.js";import{S as ce,u as V,d as Ae,W as qe,a as be}from"./constants-ChKBx8P9.js";import{a as _e}from"./use-navigate-to-agent-Cz3ZvHb6.js";import{a as le,b as de,c as ue,d as me,D as st}from"./dialog-DWzrMeko.js";import{i as Ee}from"./RefreshCcw01-DN4ew4Kc.js";import{C as Qe}from"./collection-search-7y-wgnCT.js";import{C as it}from"./checkbox-yg1I1N9G.js";import{b as Se,u as ot}from"./use-connection-2nfGp1Tw.js";import{i as at}from"./Lock01-BMc0QX1N.js";import{n as rt}from"./agent-icon-B77lAtfk.js";import{e as ct}from"./extract-connection-data-OE0lRTFA.js";import{b as Oe,a as Le,c as Re,D as Me}from"./drawer-CVaGMEnC.js";import{u as ke}from"./tooltip-CkuZjpG2.js";import{I as Ue}from"./integration-icon-BgHtBrFn.js";import{u as lt,d as Ke}from"./use-mcp-tools-DsJCeK5Y.js";import{a as Pe,b as dt}from"./use-virtual-mcp-BlZvOWuE.js";function re(i){const e=k.c(4),{size:s,className:a}=i;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z"}),e[0]=l):l=e[0];let n;return e[1]!==a||e[2]!==s?(n=t.jsx("svg",{width:s,height:s,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:a,children:l}),e[1]=a,e[2]=s,e[3]=n):n=e[3],n}function ut(i){return i.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function mt(i){const e=await fetch(`/api/${i}/deco-sites`);if(!e.ok){const s=await e.json().catch(()=>({}));throw new Error(s.error??`Failed to load sites (${e.status})`)}return e.json()}function Xt(i){const e=k.c(70),{open:s,onOpenChange:a,onBack:l}=i,{org:n}=$(),r=_e(),u=je(),{data:d}=Fe.useSession(),[_,c]=O.useState(null),[h,C]=O.useState("");let f;e[0]!==n.id||e[1]!==n.slug?(f={connectionId:ce,orgId:n.id,orgSlug:n.slug},e[0]=n.id,e[1]=n.slug,e[2]=f):f=e[2];const p=V(f);let m;e[3]!==d?.user?.email?(m=ne.decoSites(d?.user?.email),e[3]=d?.user?.email,e[4]=m):m=e[4];let g;e[5]!==n.slug?(g=()=>mt(n.slug),e[5]=n.slug,e[6]=g):g=e[6];const x=s&&!!d?.user?.email;let I;e[7]!==m||e[8]!==g||e[9]!==x?(I={queryKey:m,queryFn:g,enabled:x,staleTime:6e4,retry:!1},e[7]=m,e[8]=g,e[9]=x,e[10]=I):I=e[10];const{data:b,isLoading:N,error:y}=He(I),o=b?.sites??[];let T;e[11]!==a?(T=j=>{j||(c(null),C("")),a(j)},e[11]=a,e[12]=T):T=e[12];const w=T;let v;e[13]!==h?(v=j=>j.name.toLowerCase().includes(h.toLowerCase())||j.domains?.[0]?.domain.toLowerCase().includes(h.toLowerCase()),e[13]=h,e[14]=v):v=e[14];const A=o.filter(v),E=!_||A.some(j=>j.name===_);let S;e[15]!==p||e[16]!==n.id||e[17]!==n.slug?(S=async j=>{D("deco_site_import_started",{site_name:j});const P=await fetch(`/api/${n.slug}/deco-sites/connection`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:j,orgId:n.id})}),G=await P.json().catch(pt);if(!P.ok)throw new Error(G.error??`Failed to create connection (${P.status})`);const M=G.connId;if(!M)throw new Error("Server did not return a connection ID");const he=G.icon??null,te=ut(j),Ge=await p.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:j,description:"Imported from deco.cx",pinned:!0,icon:he??null,subtype:"project",metadata:{instructions:null,enabled_plugins:[],ui:{banner:null,bannerColor:"#22C55E",icon:he,themeColor:"#22C55E",slug:te,pinnedViews:[{connectionId:M,toolName:"file_explorer",label:"Preview",icon:null},{connectionId:M,toolName:"fetch_assets",label:"Assets",icon:null},{connectionId:M,toolName:"get_monitor_data",label:"Monitor",icon:null},{connectionId:M,toolName:"list_pull_requests",label:"Pull Requests",icon:null},{connectionId:M,toolName:"list_releases",label:"Releases",icon:null}],layout:{defaultMainView:{type:"ext-apps",id:M,toolName:"file_explorer"}}}},connections:[{connection_id:M}]}}}),De=Ge.structuredContent??Ge;return{slug:te,virtualMcpId:De.item.id,connId:M,item:De.item}},e[15]=p,e[16]=n.id,e[17]=n.slug,e[18]=S):S=e[18];let R;e[19]!==p||e[20]!==w||e[21]!==r||e[22]!==n.id||e[23]!==u?(R=j=>{const{slug:P,virtualMcpId:G,item:M}=j;D("deco_site_import_succeeded",{site_name:M.title,virtual_mcp_id:G,slug:P}),u.setQueryData(ne.collectionItem(p,n.id,"","VIRTUAL_MCP",G),{item:M}),u.invalidateQueries({predicate:he=>{const te=he.queryKey;return te[1]===n.id&&te[3]==="collection"&&te[4]==="VIRTUAL_MCP"}}),u.invalidateQueries({queryKey:ne.projects(n.id)}),oe.success(`Imported ${P} from deco.cx`),w(!1),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),r(G)},e[19]=p,e[20]=w,e[21]=r,e[22]=n.id,e[23]=u,e[24]=R):R=e[24];let z;e[25]!==S||e[26]!==R?(z={mutationFn:S,onSuccess:R,onError:gt},e[25]=S,e[26]=R,e[27]=z):z=e[27];const U=Be(z),se=de,L=le,ie="sm:max-w-[900px] p-0 gap-0 overflow-hidden";let F;e[28]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(ue,{className:"sr-only",children:t.jsx(me,{children:"Import from deco.cx"})}),e[28]=F):F=e[28];let H;e[29]!==l?(H=l&&t.jsx("button",{type:"button",onClick:l,className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors","aria-label":"Go back",children:t.jsx(Ee,{size:18})}),e[29]=l,e[30]=H):H=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Import from deco.cx"}),e[31]=fe):fe=e[31];let B;e[32]!==H?(B=t.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3",children:[H,fe]}),e[32]=H,e[33]=B):B=e[33];let ge;e[34]===Symbol.for("react.memo_cache_sentinel")?(ge=j=>{j.key==="Escape"&&C("")},e[34]=ge):ge=e[34];let q;e[35]!==h?(q=t.jsx("div",{children:t.jsx(Qe,{value:h,onChange:C,placeholder:"Search sites...",onKeyDown:ge})}),e[35]=h,e[36]=q):q=e[36];const Je="pb-0 min-h-[300px]";let Q;e[37]!==N?(Q=N&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"Loading sites..."}),e[37]=N,e[38]=Q):Q=e[38];const Ce=!N&&!y&&o.length===0&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"No sites found for this account."}),Te=!N&&o.length>0&&t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 max-h-[420px] overflow-y-auto py-4 px-8 [scrollbar-gutter:stable]",children:[A.length===0&&t.jsxs("p",{className:"col-span-3 text-sm text-muted-foreground text-center py-8",children:["No sites match “",h,"”"]}),A.map(j=>{const P=j.domains?.find(ft)?.domain??j.domains?.[0]?.domain,G=_===j.name;return t.jsxs("button",{type:"button",onClick:()=>c(j.name),className:xe("flex flex-col rounded-xl border overflow-hidden text-left transition-all cursor-pointer",G?"border-primary ring-1 ring-primary":"border-border hover:border-muted-foreground/40"),children:[t.jsx("div",{className:"w-full aspect-video bg-muted overflow-hidden",children:j.thumb_url?t.jsx("img",{src:j.thumb_url,alt:j.name,className:"w-full h-full object-cover",loading:"lazy"}):t.jsx("div",{className:"w-full h-full bg-muted"})}),t.jsxs("div",{className:"px-4 py-3",children:[t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:j.name}),P&&t.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:P})]})]},j.name)})]});let K;e[39]!==Q||e[40]!==Ce||e[41]!==Te?(K=t.jsxs("div",{className:Je,children:[Q,Ce,Te]}),e[39]=Q,e[40]=Ce,e[41]=Te,e[42]=K):K=e[42];let Y;e[43]!==w?(Y=()=>w(!1),e[43]=w,e[44]=Y):Y=e[44];let W;e[45]!==U.isPending||e[46]!==Y?(W=t.jsx(ae,{variant:"outline",onClick:Y,disabled:U.isPending,children:"Cancel"}),e[45]=U.isPending,e[46]=Y,e[47]=W):W=e[47];const Ie=!_||!E||U.isPending||N;let J;e[48]!==U||e[49]!==_?(J=()=>_&&U.mutate(_),e[48]=U,e[49]=_,e[50]=J):J=e[50];const ye=U.isPending?"Importing...":"Import";let X;e[51]!==Ie||e[52]!==J||e[53]!==ye?(X=t.jsx(ae,{disabled:Ie,onClick:J,children:ye}),e[51]=Ie,e[52]=J,e[53]=ye,e[54]=X):X=e[54];let Z;e[55]!==W||e[56]!==X?(Z=t.jsxs(st,{className:"px-8 py-5 border-t border-border",children:[W,X]}),e[55]=W,e[56]=X,e[57]=Z):Z=e[57];let ee;e[58]!==L||e[59]!==F||e[60]!==B||e[61]!==q||e[62]!==K||e[63]!==Z?(ee=t.jsxs(L,{className:ie,children:[F,B,q,K,Z]}),e[58]=L,e[59]=F,e[60]=B,e[61]=q,e[62]=K,e[63]=Z,e[64]=ee):ee=e[64];let pe;return e[65]!==se||e[66]!==w||e[67]!==s||e[68]!==ee?(pe=t.jsx(se,{open:s,onOpenChange:w,children:ee}),e[65]=se,e[66]=w,e[67]=s,e[68]=ee,e[69]=pe):pe=e[69],pe}function ft(i){return i.production}function gt(i){D("deco_site_import_failed",{error:i instanceof Error?i.message:"Unknown error"}),oe.error("Import failed: "+(i instanceof Error?i.message:"Unknown error"))}function pt(){return{}}function Ye(i,e){const s=k.c(12),{org:a}=$();let l;s[0]!==a.id?(l=Ae.REGISTRY(a.id),s[0]=a.id,s[1]=l):l=s[1];const n=l;let r;s[2]!==a.id||s[3]!==a.slug||s[4]!==n?(r={connectionId:n,orgId:a.id,orgSlug:a.slug},s[2]=a.id,s[3]=a.slug,s[4]=n,s[5]=r):r=s[5];const u=V(r);let d;s[6]!==i?(d={name:i},s[6]=i,s[7]=d):d=s[7];const _=e?.enabled??!0;let c;return s[8]!==u||s[9]!==d||s[10]!==_?(c={client:u,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:d,enabled:_,staleTime:3e5,select:ht},s[8]=u,s[9]=d,s[10]=_,s[11]=c):c=s[11],lt(c)}function ht(i){return i.structuredContent?.item??null}const xt="deco/mcp-github";function Nt(i){const{org:e}=$(),{data:s}=Fe.useSession(),a=Se(),l=je(),[n,r]=O.useState("idle"),[u,d]=O.useState(null),[_,c]=O.useState(null),{data:h,isLoading:C}=Ye(xt,{enabled:i.enabled}),f=O.useRef(!1);i.enabled&&h&&!C&&!f.current&&s?.user?.id&&n==="idle"&&(f.current=!0,p());async function p(){if(!(!h||!s?.user?.id||!e))try{r("installing"),d(null);const g=ct(h,e.id,s.user.id,{remoteIndex:0});if(!g.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:I}=await a.create.mutateAsync(g);r("authenticating");const b=new URL(`/api/${e.slug}/mcp/${I}`,window.location.origin),N=await Xe({url:b.href,token:null,orgId:e.id});if(N.supportsOAuth&&!N.isAuthenticated){const{token:y,tokenInfo:o,error:T}=await Ze({connectionId:I,orgSlug:e.slug,scope:"offline_access"});if(T||!y){try{await a.delete.mutateAsync(I)}catch{}throw new Error(T??"No token received from GitHub")}if(o)try{(await fetch(`/api/${e.slug}/connections/${I}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:o.accessToken,refreshToken:o.refreshToken,expiresIn:o.expiresIn,scope:o.scope,clientId:o.clientId,clientSecret:o.clientSecret,tokenEndpoint:o.tokenEndpoint})})).ok||await a.update.mutateAsync({id:I,data:{connection_token:y}})}catch{await a.update.mutateAsync({id:I,data:{connection_token:y}})}}ve(l,e.id),c(g),r("ready")}catch(g){d(g instanceof Error?g.message:String(g)),r("error")}}function m(){r("idle"),d(null),c(null),f.current=!1}return i.enabled&&C&&n==="idle"?{status:"installing",error:null,connection:null,retry:m}:{status:n,error:u,connection:_,retry:m}}function Zt(i){const e=k.c(21),{open:s,onOpenChange:a,title:l,hideAutoRespondCheckbox:n,onImportComplete:r}=i,u=l===void 0?"Import from GitHub":l,d=n===void 0?!1:n,[_]=et(),[c,h]=O.useState(null);if(!_.experimental_vibecode)return null;let C;e[0]!==u?(C=t.jsx(ue,{className:"sr-only",children:t.jsx(me,{children:u})}),e[0]=u,e[1]=C):C=e[1];let f;e[2]!==c||e[3]!==u?(f=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:c?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>h(null),className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors shrink-0","aria-label":"Back to accounts",children:t.jsx(Ee,{size:16})}),t.jsx("img",{src:c.avatarUrl,alt:c.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:c.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:u})]})}),e[2]=c,e[3]=u,e[4]=f):f=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ne,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=p):p=e[5];let m;e[6]!==a?(m=()=>a(!1),e[6]=a,e[7]=m):m=e[7];let g;e[8]!==d||e[9]!==r||e[10]!==c||e[11]!==m?(g=t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:t.jsx(O.Suspense,{fallback:p,children:t.jsx(_t,{onComplete:m,selectedInstallation:c,onSelectInstallation:h,hideAutoRespondCheckbox:d,onImportComplete:r})})}),e[8]=d,e[9]=r,e[10]=c,e[11]=m,e[12]=g):g=e[12];let x;e[13]!==C||e[14]!==f||e[15]!==g?(x=t.jsxs(le,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[C,f,g]}),e[13]=C,e[14]=f,e[15]=g,e[16]=x):x=e[16];let I;return e[17]!==a||e[18]!==s||e[19]!==x?(I=t.jsx(de,{open:s,onOpenChange:a,children:x}),e[17]=a,e[18]=s,e[19]=x,e[20]=I):I=e[20],I}function _t({onComplete:i,selectedInstallation:e,onSelectInstallation:s,hideAutoRespondCheckbox:a,onImportComplete:l}){const{org:n}=$(),r=je(),u=_e(),[d,_]=O.useState(null),[c,h]=O.useState(!0),C=a?!0:c,f=ot({slug:"mcp-github"}),p=Nt({enabled:f.length===0}),m=f.length===1?f[0]??null:d,g=V({connectionId:m?.id??"",orgId:n.id,orgSlug:n.slug}),x=V({connectionId:ce,orgId:n.id,orgSlug:n.slug}),I=async(o,T)=>{try{const v=await g.callTool({name:"get_file_contents",arguments:{owner:o.owner,repo:o.name,path:T}});if(v.isError)return null;const E=v.content?.find(S=>S.type==="resource")?.resource?.text;if(!E)return null;try{const S=JSON.parse(E);return typeof S=="string"?S:JSON.stringify(S)}catch{return E}}catch{return null}},b=(o,T)=>{Promise.all([I(T,"AGENTS.md"),I(T,"CLAUDE.md")]).then(async([w,v])=>{const A=w??v??null;A&&(await x.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:o,data:{metadata:{instructions:A}}}}),ve(r,n.id))}).catch(w=>{console.error("GitHub instructions fetch failed:",w)})},N=async({virtualMcpId:o,repo:T,connectionId:w})=>{const v=await g.callTool({name:"TRIGGER_LIST",arguments:{}}),A=v.structuredContent??v,E=A.triggers?.find(L=>L.type==="github.issues.opened")??A.triggers?.find(L=>{const ie=L.type.toLowerCase();return/\bissues?\./.test(ie)&&(ie.endsWith(".opened")||ie.endsWith(".created"))});if(!E)throw new Error("No issue-created trigger exposed by GitHub connection");const S=new Set;if(Array.isArray(E.params))for(const L of E.params)S.add(L.name);else if(E.params&&typeof E.params=="object")for(const L of Object.keys(E.params))S.add(L);if(E.paramsSchema)for(const L of Object.keys(E.paramsSchema))S.add(L);const R={};S.has("repo")?R.repo=`${T.owner}/${T.name}`:(S.has("owner")&&(R.owner=T.owner),S.has("name")&&(R.name=T.name),S.has("repository")&&(R.repository=`${T.owner}/${T.name}`));const z=`A new GitHub issue has been opened in ${T.owner}/${T.name}. Read the issue details, explore the relevant code in the repository, create a new branch, implement the fix or feature requested, and open a pull request that resolves the issue. Reference the issue number in the PR description.`,U=await x.callTool({name:"AUTOMATION_CREATE",arguments:{name:`${T.name}: auto-respond to issues`,virtual_mcp_id:o,messages:z,active:!0}}),se=U.structuredContent??U;await x.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:se.id,type:"event",connection_id:w,event_type:E.type,params:R}})},y=Be({mutationFn:async o=>{if(!m||!e)throw new Error("No GitHub connection or installation");const T=m.id,w=await x.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:o.name,description:o.description||"Imported from GitHub",pinned:!0,icon:null,metadata:{githubRepo:{owner:o.owner,name:o.name,url:o.url,installationId:e.installationId,connectionId:T},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"}}}},connections:[{connection_id:T}]}}}),v=w.structuredContent??w,A=v.item.id;return C&&await N({virtualMcpId:A,repo:o,connectionId:T}).catch(E=>{console.error("Failed to set up issue automation:",E),oe.warning("Imported repo, but failed to set up issue auto-response. You can add the trigger manually from the automations view.")}),{virtualMcpId:A,repo:o,connectionId:T,item:v.item}},onSuccess:({virtualMcpId:o,repo:T,connectionId:w,item:v})=>{if(r.setQueryData(ne.collectionItem(x,n.id,"","VIRTUAL_MCP",o),{item:v}),ve(r,n.id),b(o,T),l){l({virtualMcpId:o,repo:T,connectionId:w});return}oe.success(`Imported ${T.name} from GitHub`),i(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),u(o)},onError:o=>{oe.error("Failed to import repo: "+(o instanceof Error?o.message:"Unknown error"))}});return p.status==="installing"||p.status==="authenticating"?t.jsx(we,{status:p.status,error:null,retry:p.retry}):p.status==="error"?t.jsx(we,{status:"error",error:p.error,retry:p.retry}):f.length===0&&p.status==="idle"?t.jsx(we,{status:"installing",error:null,retry:p.retry}):f.length>1&&!m?t.jsxs("div",{className:"flex flex-col py-2",children:[t.jsx("div",{className:"px-4 py-2",children:t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Select a connection"})}),f.map(o=>t.jsxs("button",{type:"button",onClick:()=>_(o),className:"flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left",children:[o.icon?t.jsx("img",{src:o.icon,alt:o.title,className:"size-7 rounded-full shrink-0"}):t.jsx("div",{className:"size-7 rounded-full bg-muted flex items-center justify-center shrink-0",children:t.jsx(re,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:o.title})]},o.id))]}):m?e?t.jsx(Tt,{connectionId:m.id,orgId:n.id,orgSlug:n.slug,installation:e,onSelectRepo:o=>y.mutate(o),isSaving:y.isPending,autoRespondToIssues:c,onAutoRespondChange:h,hideAutoRespondCheckbox:a}):t.jsx(Ct,{connectionId:m.id,orgId:n.id,orgSlug:n.slug,onSelect:s,showBackButton:f.length>1,onBack:()=>_(null)}):null}function Ct(i){const e=k.c(31),{connectionId:s,orgId:a,orgSlug:l,onSelect:n,showBackButton:r,onBack:u}=i;let d;e[0]!==a||e[1]!==l?(d={connectionId:ce,orgId:a,orgSlug:l},e[0]=a,e[1]=l,e[2]=d):d=e[2];const _=V(d);let c;e[3]!==s||e[4]!==a?(c=ne.githubUserOrgs(a,s),e[3]=s,e[4]=a,e[5]=c):c=e[5];let h;e[6]!==s||e[7]!==_?(h=async()=>{const T=(await _.callTool({name:"GITHUB_LIST_USER_ORGS",arguments:{connectionId:s}})).content?.[0]?.text;if(!T)throw new Error("No response from GITHUB_LIST_USER_ORGS");return JSON.parse(T)},e[6]=s,e[7]=_,e[8]=h):h=e[8];let C;e[9]!==c||e[10]!==h?(C={queryKey:c,queryFn:h},e[9]=c,e[10]=h,e[11]=C):C=e[11];const f=He(C);if(f.isLoading){let o;return e[12]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ne,{size:18,className:"animate-spin text-muted-foreground"})}),e[12]=o):o=e[12],o}if(f.isError){let o;return e[13]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("p",{className:"text-sm text-destructive",children:"Failed to load GitHub accounts"})}),e[13]=o):o=e[13],o}const p=f.data;if(!p)return null;let m;e[14]!==u||e[15]!==r?(m=r&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(Ee,{size:12}),"Change connection"]})}),e[14]=u,e[15]=r,e[16]=m):m=e[16];let g;if(e[17]!==p.installations||e[18]!==n){let o;e[20]!==n?(o=T=>t.jsxs("button",{type:"button",onClick:()=>n(T),className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-accent transition-colors text-left group",children:[t.jsx("img",{src:T.avatarUrl,alt:T.login,className:"size-7 rounded-full shrink-0 ring-1 ring-border"}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("span",{className:"text-sm font-medium leading-none",children:T.login}),T.type==="User"&&t.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Personal account"})]}),t.jsx("span",{className:"text-xs text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:"Select →"})]},T.installationId),e[20]=n,e[21]=o):o=e[21],g=p.installations.map(o),e[17]=p.installations,e[18]=n,e[19]=g}else g=e[19];let x;e[22]!==g?(x=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:g}),e[22]=g,e[23]=x):x=e[23];const I=p.appSlug?`https://github.com/apps/${p.appSlug}/installations/new`:"https://github.com/settings/installations";let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("span",{className:"underline underline-offset-2",children:"Install the GitHub App"}),e[24]=b):b=e[24];let N;e[25]!==I?(N=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:["Account not listed?"," ",b]})}),e[25]=I,e[26]=N):N=e[26];let y;return e[27]!==N||e[28]!==m||e[29]!==x?(y=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m,x,N]}),e[27]=N,e[28]=m,e[29]=x,e[30]=y):y=e[30],y}function Tt(i){const e=k.c(25),{connectionId:s,orgId:a,orgSlug:l,installation:n,onSelectRepo:r,isSaving:u,autoRespondToIssues:d,onAutoRespondChange:_,hideAutoRespondCheckbox:c}=i,[h,C]=O.useState(""),f=O.useDeferredValue(h),p=h!==f;let m;e[0]!==p||e[1]!==h?(m=t.jsx(Qe,{placeholder:"Search repositories...",value:h,onChange:C,isSearching:p}),e[0]=p,e[1]=h,e[2]=m):m=e[2];const g=p?"opacity-40":"opacity-100";let x;e[3]!==g?(x=xe("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",g),e[3]=g,e[4]=x):x=e[4];let I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ne,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=I):I=e[5];let b;e[6]!==s||e[7]!==f||e[8]!==n||e[9]!==u||e[10]!==r||e[11]!==a||e[12]!==l?(b=t.jsx(O.Suspense,{fallback:I,children:t.jsx(It,{connectionId:s,orgId:a,orgSlug:l,installation:n,query:f,onSelectRepo:r,isSaving:u})}),e[6]=s,e[7]=f,e[8]=n,e[9]=u,e[10]=r,e[11]=a,e[12]=l,e[13]=b):b=e[13];let N;e[14]!==x||e[15]!==b?(N=t.jsx("div",{className:x,children:b}),e[14]=x,e[15]=b,e[16]=N):N=e[16];let y;e[17]!==d||e[18]!==c||e[19]!==_?(y=!c&&t.jsxs("label",{className:"flex items-center gap-2 px-4 py-3 border-t border-border shrink-0 cursor-pointer select-none",children:[t.jsx(it,{checked:d,onCheckedChange:T=>_(T===!0)}),t.jsx("span",{className:"text-xs text-foreground",children:"Auto-respond to new issues with a PR"})]}),e[17]=d,e[18]=c,e[19]=_,e[20]=y):y=e[20];let o;return e[21]!==m||e[22]!==N||e[23]!==y?(o=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[m,N,y]}),e[21]=m,e[22]=N,e[23]=y,e[24]=o):o=e[24],o}function It(i){const e=k.c(29),{connectionId:s,orgId:a,orgSlug:l,installation:n,query:r,onSelectRepo:u,isSaving:d}=i;let _;e[0]!==s||e[1]!==a||e[2]!==l?(_={connectionId:s,orgId:a,orgSlug:l},e[0]=s,e[1]=a,e[2]=l,e[3]=_):_=e[3];const c=V(_),h=n.type==="User"?"user":"org",C=r?`${h}:${n.login} ${r} in:name`:`${h}:${n.login}`;let f;e[4]!==s||e[5]!==n.login||e[6]!==a||e[7]!==r?(f=ne.githubOrgRepos(a,s,n.login,r),e[4]=s,e[5]=n.login,e[6]=a,e[7]=r,e[8]=f):f=e[8];let p;e[9]!==c||e[10]!==C?(p=async()=>{const N=(await c.callTool({name:"search_repositories",arguments:{query:C,page:1,perPage:30}})).content?.[0]?.text;if(!N)throw new Error("No response from search_repositories");return(JSON.parse(N).items??[]).map(yt)},e[9]=c,e[10]=C,e[11]=p):p=e[11];let m;e[12]!==f||e[13]!==p?(m={queryKey:f,queryFn:p},e[12]=f,e[13]=p,e[14]=m):m=e[14];const{data:g}=tt(m);if(g.length===0){let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("p",{className:"text-sm text-muted-foreground",children:"No repositories found"}),e[15]=b):b=e[15];let N;e[16]!==r?(N=r&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Try a different search term"}),e[16]=r,e[17]=N):N=e[17];let y;return e[18]!==N?(y=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[b,N]}),e[18]=N,e[19]=y):y=e[19],y}let x;if(e[20]!==d||e[21]!==u||e[22]!==g){let b;e[24]!==d||e[25]!==u?(b=N=>t.jsxs("button",{type:"button",onClick:()=>u(N),disabled:d,className:"flex items-start gap-3 px-4 py-3 hover:bg-accent transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[t.jsx(re,{className:"size-4 text-muted-foreground mt-0.5 shrink-0"}),t.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:t.jsx("span",{className:"text-sm font-medium truncate",children:N.name})}),t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground border border-border rounded px-1.5 py-0.5 shrink-0 leading-none",children:[N.private?t.jsx(at,{size:10}):t.jsx(rt,{size:10}),N.private?"Private":"Public"]})]},N.fullName),e[24]=d,e[25]=u,e[26]=b):b=e[26],x=g.map(b),e[20]=d,e[21]=u,e[22]=g,e[23]=x}else x=e[23];let I;return e[27]!==x?(I=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:x}),e[27]=x,e[28]=I):I=e[28],I}function yt(i){return{name:i.name,fullName:i.full_name,owner:i.full_name.split("/")[0]??"",url:i.html_url,private:i.private,description:i.description,updatedAt:i.updated_at}}function we(i){const e=k.c(33),{status:s,error:a,retry:l}=i;if(s==="error"){let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("div",{className:"size-10 rounded-full bg-destructive/10 flex items-center justify-center",children:t.jsx(re,{className:"size-5 text-destructive"})}),e[0]=o):o=e[0];let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("p",{className:"text-sm font-medium",children:"Connection failed"}),e[1]=T):T=e[1];const w=a??"Something went wrong while connecting to GitHub.";let v;e[2]!==w?(v=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[T,t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:w})]}),e[2]=w,e[3]=v):v=e[3];let A;e[4]!==l?(A=t.jsx("button",{type:"button",onClick:l,className:"text-xs font-medium text-foreground border border-border rounded-md px-3 py-1.5 hover:bg-accent transition-colors",children:"Try again"}),e[4]=l,e[5]=A):A=e[5];let E;return e[6]!==v||e[7]!==A?(E=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[o,v,A]}),e[6]=v,e[7]=A,e[8]=E):E=e[8],E}const n=s==="authenticating";let r;e[9]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(re,{className:"size-5 text-foreground"})}),e[9]=r):r=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsxs("div",{className:"relative size-10",children:[r,t.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 size-4 rounded-full bg-background flex items-center justify-center",children:t.jsx(Ne,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[10]=u):u=e[10];const d=n?"Authenticating with GitHub":"Setting up GitHub";let _;e[11]!==d?(_=t.jsx("p",{className:"text-sm font-medium",children:d}),e[11]=d,e[12]=_):_=e[12];const c=n?"Complete the OAuth flow in your browser":"Installing the GitHub connection...";let h;e[13]!==c?(h=t.jsx("p",{className:"text-xs text-muted-foreground",children:c}),e[13]=c,e[14]=h):h=e[14];let C;e[15]!==_||e[16]!==h?(C=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[_,h]}),e[15]=_,e[16]=h,e[17]=C):C=e[17];const f=n?"bg-muted-foreground/30":"bg-foreground animate-pulse";let p;e[18]!==f?(p=xe("size-1.5 rounded-full",f),e[18]=f,e[19]=p):p=e[19];let m;e[20]!==p?(m=t.jsx("span",{className:p}),e[20]=p,e[21]=m):m=e[21];const g=n?"bg-foreground animate-pulse":"bg-muted-foreground/30";let x;e[22]!==g?(x=xe("size-1.5 rounded-full",g),e[22]=g,e[23]=x):x=e[23];let I;e[24]!==x?(I=t.jsx("span",{className:x}),e[24]=x,e[25]=I):I=e[25];let b;e[26]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[26]=b):b=e[26];let N;e[27]!==m||e[28]!==I?(N=t.jsxs("div",{className:"flex items-center gap-1.5",children:[m,I,b]}),e[27]=m,e[28]=I,e[29]=N):N=e[29];let y;return e[30]!==N||e[31]!==C?(y=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[u,C,N]}),e[30]=N,e[31]=C,e[32]=y):y=e[32],y}const bt=["Full HAR capture with cache, TTFB, and request analysis","Screenshot capture for visual inspection","Page discovery via sitemap, navigation, and link crawling","SEO audit — meta tags, structured data, robots.txt","Third-party script inventory and size analysis","Dead link detection across the entire site","Deco-specific diagnostics (?__d debug mode)"];function Ve(i){const e=k.c(7),{onRecruit:s,isRecruiting:a,isLoading:l}=i;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a blackbox diagnostics agent that tests your storefront from the outside — no internal access needed. Give it a URL and it produces a detailed performance and health report."}),e[0]=n):n=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=r):r=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsxs("div",{className:"space-y-2",children:[r,t.jsx("ul",{className:"space-y-1.5",children:bt.map(wt)})]}),e[2]=u):u=e[2];const d=a||l,_=a?"Setting up...":"Add Site Diagnostics";let c;return e[3]!==s||e[4]!==d||e[5]!==_?(c=t.jsxs("div",{className:"flex flex-col gap-6",children:[n,u,t.jsx(ae,{onClick:s,disabled:d,className:"w-full cursor-pointer",children:_})]}),e[3]=s,e[4]=d,e[5]=_,e[6]=c):c=e[6],c}function wt(i){return t.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[t.jsx("span",{className:"text-emerald-500 mt-0.5 shrink-0",children:"+"}),i]},i)}function en({open:i,onOpenChange:e,existingAgent:s}){const a=ke(),{org:l}=$(),n=_e(),r=Se(),u=Pe(),d=V({connectionId:ce,orgId:l.id,orgSlug:l.slug}),_=Ke({client:d}),[c,h]=O.useState(!1),C=qe.find(y=>y.id==="site-diagnostics"),{data:f,isLoading:p}=Ye(C.appId,{enabled:i}),m=f?.title||f?.server?.title||f?.server?.name||C.title,g=f?.server?.icons?.[0]?.src??C.icon,x=f?.server?.description??null,I=t.jsx(Ue,{icon:g,name:m,size:"sm"}),b=async()=>{if(f){if(s){e(!1),n(s.id);return}h(!0);try{const y=await _.mutateAsync({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:C.appId},limit:1,offset:0}});let o;const w=y?.structuredContent?.items?.find(A=>A.app_id===C.appId);if(w)o=w.id;else{const A=f.server?.remotes?.[0]?.url;if(!A)throw new Error("Registry item is missing a remote URL for site-diagnostics");o=(await r.create.mutateAsync({title:m,description:x,icon:f.server?.icons?.[0]?.src??C.icon,connection_type:"HTTP",connection_url:A,app_name:f.server?.name??"site-diagnostics",app_id:C.appId,metadata:{type:"site-diagnostics",source:"store",registry_item_id:C.appId,verified:!0}})).id}const v=await u.create.mutateAsync({title:m,description:x,icon:g,status:"active",connections:[{connection_id:o,selected_tools:null,selected_resources:null,selected_prompts:null}],metadata:{type:"site-diagnostics",instructions:null,ui:{pinnedViews:[{connectionId:o,toolName:"diagnose",label:"diagnose",icon:null}],layout:{defaultMainView:{type:"ext-apps",id:o,toolName:"diagnose"}}}}});D("agent_recruit_confirmed",{template_id:"site-diagnostics",agent_id:v.id}),e(!1),n(v.id)}catch(y){D("agent_recruit_failed",{template_id:"site-diagnostics",error:y instanceof Error?y.message:String(y)}),console.error("Failed to create Site Diagnostics agent:",y)}finally{h(!1)}}},N=`Add ${m}`;return a?t.jsx(Oe,{open:i,onOpenChange:e,children:t.jsxs(Le,{className:"h-[70dvh]",children:[t.jsx(Re,{className:"px-4 pt-4 pb-4 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-3",children:[I,t.jsx(Me,{className:"text-xl font-semibold",children:N})]})}),t.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:t.jsx(Ve,{onRecruit:b,isRecruiting:c,isLoading:p})})]})}):t.jsx(de,{open:i,onOpenChange:e,children:t.jsxs(le,{className:"sm:max-w-[500px] p-8",children:[t.jsx(ue,{className:"mb-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[I,t.jsx(me,{className:"text-xl font-semibold",children:N})]})}),t.jsx(Ve,{onRecruit:b,isRecruiting:c,isLoading:p})]})})}const vt=`<role>
2
2
  You are the Agent Manager. You create, configure, and maintain agents (Virtual MCPs) in this workspace.
3
3
  </role>
4
4
 
@@ -1 +1 @@
1
- import{u as X,r as x,a as V,t as P,b as p,j as e,B as f,c as T,d as ae,S as $,N as ie,e as oe}from"./index-Dcg8Qevd.js";import{I}from"./input-Cvo2jJQf.js";function le({redirectUrl:s,callbackUrl:r="/"}){const{emailAndPassword:l,resetPassword:u,emailOtp:i,socialProviders:d}=X(),[n,j]=x.useState(""),[y,D]=x.useState(""),[b,C]=x.useState(""),[O,A]=x.useState(""),[L,R]=x.useState(!1),[z,N]=x.useState(()=>!l.enabled&&i.enabled?"emailOtp":globalThis.localStorage?.getItem("hasLoggedIn")!=="true"?"signUp":"signIn"),[c,S]=x.useState(""),[Y,G]=x.useState(!1),m=z==="signUp",h=z==="forgotPassword",w=z==="emailOtp",F=V({mutationFn:async({email:t,password:a,name:q})=>{try{if(m){const g=await p.signUp.email({email:t,password:a,name:q||""});if(g.error)throw new Error(g.error.message||"Sign up failed");return g}else{const g=await p.signIn.email({email:t,password:a});if(g.error)throw new Error(g.error.message||"Sign in failed");return g}}catch(g){throw g instanceof Error?g:new Error("Authentication failed")}},onSuccess:()=>{globalThis.localStorage?.setItem("hasLoggedIn","true"),window.location.href=s??r},onError:t=>{P(m?"user_signup_failed":"user_signin_failed",{error:t instanceof Error?t.message:String(t)})}}),U=V({mutationFn:async({email:t})=>{const a=await p.requestPasswordReset({email:t,redirectTo:"/reset-password"});if(a.error)throw new Error(a.error.message||"Failed to send reset email");return a},onSuccess:()=>{P("password_reset_requested"),G(!0)},onError:t=>{P("password_reset_request_failed",{error:t instanceof Error?t.message:String(t)})}}),E=V({mutationFn:async({email:t})=>{const a=await p.emailOtp.sendVerificationOtp({email:t,type:"sign-in"});if(a.error)throw new Error(a.error.message||"Failed to send code");return a},onSuccess:()=>{P("email_otp_sent"),R(!0)},onError:t=>{P("email_otp_send_failed",{error:t instanceof Error?t.message:String(t)})}}),_=V({mutationFn:async({email:t,otp:a})=>{const q=await p.signIn.emailOtp({email:t,otp:a});if(q.error)throw new Error(q.error.message||"Invalid code");return q},onSuccess:()=>{globalThis.localStorage?.setItem("hasLoggedIn","true"),window.location.href=s??r},onError:t=>{P("email_otp_verify_failed",{error:t instanceof Error?t.message:String(t)})}}),B=t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t),W=()=>{n.trim()&&!B(n)&&S("Invalid email address")},Z=t=>{if(t.preventDefault(),!B(n)){S("Invalid email address");return}F.mutate({email:n,password:y,name:b})},ee=t=>{if(t.preventDefault(),!B(n)){S("Invalid email address");return}U.mutate({email:n})},te=t=>{if(t.preventDefault(),!B(n)){S("Invalid email address");return}E.mutate({email:n})},se=t=>{t.preventDefault(),_.mutate({email:n,otp:O})},k=t=>a=>{t(a.target.value),H&&F.reset(),J&&U.reset(),K&&(E.reset(),_.reset()),t===j&&c&&S("")},M=t=>{N(t),C(""),A(""),R(!1),S(""),G(!1),F.reset(),U.reset(),E.reset(),_.reset()},o=F.isPending||U.isPending||E.isPending||_.isPending,H=F.error,J=U.error,K=E.error||_.error,v=m?n.trim()&&y.trim()&&b.trim():h?n.trim():w?L?O.trim():n.trim():n.trim()&&y.trim(),re=t=>{if(!t)return null;const a=t.message.toLowerCase();return a.includes("unauthorized")||a.includes("401")?"Invalid email or password. Please try again.":a.includes("already exists")||a.includes("409")?"An account with this email already exists. Try signing in instead.":a.includes("network")||a.includes("fetch")?"Network error. Please check your connection and try again.":a.includes("rate limit")||a.includes("429")?"Too many attempts. Please wait a moment and try again.":a.includes("invalid")&&a.includes("otp")?"Invalid or expired code. Please try again.":t.message||"An error occurred. Please try again."},Q=H||J||K,ne=h?"Reset your password":w?L?"Enter verification code":"Sign in with email code":m?"Create your account":"Login or signup below";return e.jsxs("div",{className:"mx-auto w-full min-h-full md:min-h-0 md:min-w-[400px] max-w-md grid gap-6 content-center bg-card p-6 md:p-10 border border-primary-foreground/20",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"h-12 w-12"})}),e.jsx("div",{className:"text-center space-y-1",children:e.jsx("p",{className:"text-sm text-foreground/70",children:ne})}),Q&&e.jsx("div",{className:"rounded-xl bg-destructive/10 p-3 text-sm text-destructive text-center",children:re(Q)}),Y&&e.jsx("div",{className:"rounded-xl bg-emerald-500/10 p-3 text-sm text-emerald-600 dark:text-emerald-400 text-center",children:"Check your email for a password reset link."}),!h&&d.enabled&&e.jsx("div",{className:"grid gap-3",children:d.providers.map(t=>e.jsxs(f,{type:"button",variant:"outline",size:"lg",className:"w-full font-medium",disabled:o,onClick:()=>{p.signIn.social({provider:t.name,callbackURL:s??r})},children:[t.icon&&e.jsx("img",{src:t.icon,alt:"",className:"h-5 w-5","aria-hidden":"true"}),"Continue with"," ",t.name.charAt(0).toUpperCase()+t.name.slice(1)]},t.name))}),!h&&d.enabled&&(l.enabled||i.enabled)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),w&&i.enabled&&e.jsx(e.Fragment,{children:L?e.jsxs("form",{onSubmit:se,className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-muted/50 p-3 text-sm text-muted-foreground text-center",children:["Code sent to ",n]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Verification code"}),e.jsx(I,{type:"text",placeholder:"Enter code",value:O,onChange:k(A),required:!0,disabled:o,autoFocus:!0,inputMode:"numeric",autoComplete:"one-time-code"})]}),e.jsx(f,{type:"submit",disabled:o||!v,className:"w-full font-semibold",size:"lg",children:o?"Verifying...":"Verify"}),e.jsx(f,{type:"button",variant:"ghost",onClick:()=>{R(!1),A(""),E.reset(),_.reset()},disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Use a different email"})]}):e.jsxs("form",{onSubmit:te,className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),e.jsx(I,{type:"email",placeholder:"you@example.com",value:n,onChange:k(j),onBlur:W,required:!0,disabled:o,"aria-invalid":!!c}),c&&e.jsx("p",{className:"text-xs text-destructive mt-1.5",children:c})]}),e.jsx(f,{type:"submit",disabled:o||!v,className:"w-full font-semibold",size:"lg",children:o?"Sending...":"Send code"})]})}),h&&l.enabled&&!Y&&e.jsxs("form",{onSubmit:ee,className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),e.jsx(I,{type:"email",placeholder:"you@example.com",value:n,onChange:k(j),onBlur:W,required:!0,disabled:o,"aria-invalid":!!c}),c&&e.jsx("p",{className:"text-xs text-destructive mt-1.5",children:c})]}),e.jsx(f,{type:"submit",disabled:o||!v,className:"w-full font-semibold",size:"lg",children:o?"Sending...":"Send reset link"})]}),!h&&!w&&l.enabled&&e.jsxs("form",{onSubmit:Z,className:"grid gap-4",children:[e.jsx("div",{className:T("overflow-hidden transition-all duration-300 ease-[cubic-bezier(0.075,0.82,0.165,1)]",m?"max-h-[200px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2"),children:e.jsxs("div",{className:T("p-1",!m&&"pointer-events-none"),children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Name"}),e.jsx(I,{type:"text",placeholder:"Your name",value:b,onChange:k(C),required:!0,disabled:o||!m,"aria-hidden":!m})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),e.jsx(I,{type:"email",placeholder:"you@example.com",value:n,onChange:k(j),onBlur:W,required:!0,disabled:o,"aria-invalid":!!c}),c&&e.jsx("p",{className:"text-xs text-destructive mt-1.5",children:c})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground",children:"Password"}),!m&&u.enabled&&e.jsx("button",{type:"button",onClick:()=>M("forgotPassword"),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Forgot password?"})]}),e.jsx(I,{type:"password",placeholder:"••••••••",value:y,onChange:k(D),required:!0,disabled:o})]}),e.jsx("div",{className:T("overflow-hidden transition-all duration-300 ease-[cubic-bezier(0.075,0.82,0.165,1)]",v?"max-h-[100px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2"),children:e.jsx("div",{className:T("p-1",!v&&"pointer-events-none"),children:e.jsx(f,{type:"submit",disabled:o||!v,className:T("w-full font-semibold"),size:"lg","aria-hidden":!v,children:o?m?"Creating account...":"Signing in...":"Continue"})})})]}),!h&&i.enabled&&l.enabled&&!w&&e.jsx("div",{className:"text-center",children:e.jsx(f,{type:"button",variant:"link",onClick:()=>M("emailOtp"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Sign in with email code instead"})}),w&&l.enabled&&e.jsx("div",{className:"text-center",children:e.jsx(f,{type:"button",variant:"link",onClick:()=>M("signIn"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Sign in with password instead"})}),e.jsx("div",{className:"text-center",children:h?e.jsx(f,{type:"button",variant:"link",onClick:()=>M("signIn"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Back to sign in"}):!w&&l.enabled?e.jsx(f,{type:"button",variant:"link",onClick:()=>M(m?"signIn":"signUp"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:m?"Already have an account? Sign in":"Don't have an account? Sign up"}):null}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground pt-4",children:[e.jsx("a",{href:"https://www.decocms.com/terms-of-use",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground transition-colors",children:"Terms of Service"}),e.jsx("a",{href:"https://www.decocms.com/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground transition-colors",children:"Privacy Policy"})]})]})}function de({redirectTo:s}){const[r,l]=x.useState(null);return x.useEffect(()=>{let u=!1;return(async()=>{try{let i;for(let d=0;d<5&&(i=await fetch("/api/auth/custom/local-session",{method:"POST",credentials:"include"}),!(i.ok||i.status<500));d++)await new Promise(n=>setTimeout(n,Math.min(1e3*2**d,1e4)));if(!i?.ok){const d=await i?.json().catch(()=>({}));throw new Error(d?.error||"Auto-login failed")}if(!u){const d=s.startsWith("/")&&!s.startsWith("//")?s:"/";window.location.href=d}}catch(i){u||l(i instanceof Error?i.message:"Auto-login failed")}})(),()=>{u=!0}},[s]),r?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-destructive mb-2",children:["Auto-login failed: ",r]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try restarting the server."})]})}):e.jsx($,{})}function ce(s){if(!s.client_id||s.response_type!=="code")return null;const r=new URLSearchParams;return s.client_id&&r.set("client_id",s.client_id),s.redirect_uri&&r.set("redirect_uri",s.redirect_uri),s.response_type&&r.set("response_type",s.response_type),s.state&&r.set("state",s.state),s.scope&&r.set("scope",s.scope),s.code_challenge&&r.set("code_challenge",s.code_challenge),s.code_challenge_method&&r.set("code_challenge_method",s.code_challenge_method),`/api/auth/mcp/authorize?${r.toString()}`}function ue(s){const r=oe.c(5),{callbackURL:l,providerId:u}=s;let i,d;r[0]!==l||r[1]!==u?(i=()=>{(async()=>await p.signIn.sso({providerId:u,callbackURL:l}))()},d=[u,l],r[0]=l,r[1]=u,r[2]=i,r[3]=d):(i=r[2],d=r[3]),x.useEffect(i,d);let n;return r[4]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsx($,{}),r[4]=n):n=r[4],n}function ge(){const s=p.useSession(),r=ae({from:"/login"}),{next:l="/",client_id:u,redirect_uri:i,response_type:d,state:n,scope:j,code_challenge:y,code_challenge_method:D}=r,b=l.startsWith("/")&&!l.startsWith("//")?l:"/",{sso:C,emailAndPassword:O,magicLink:A,emailOtp:L,socialProviders:R,localMode:z}=X(),N=ce({client_id:u,redirect_uri:i,response_type:d,state:n,scope:j,code_challenge:y,code_challenge_method:D}),c=N||b;return s.data?N?(window.location.href=N,e.jsx($,{})):e.jsx(ie,{to:b}):z?e.jsx(de,{redirectTo:c}):C.enabled?e.jsx(ue,{callbackURL:c,providerId:C.providerId}):O.enabled||A.enabled||L.enabled||R.enabled?e.jsxs("main",{className:"relative flex min-h-screen items-stretch md:items-center justify-center bg-gradient-to-br from-brand to-brand/75 p-1 md:p-4",children:[e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, var(--brand-foreground) 1px, transparent 1px)",backgroundSize:"16px 16px",opacity:.15}}),e.jsxs("div",{className:"relative z-10 w-full md:w-auto",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-screen h-px bg-brand-foreground/15"}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-screen h-px bg-brand-foreground/15"}),e.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-px h-screen bg-brand-foreground/15"}),e.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 w-px h-screen bg-brand-foreground/15"}),e.jsx(le,{redirectUrl:N,callbackUrl:b})]})]}):e.jsx("div",{children:"No login options available"})}export{ge as default};
1
+ import{u as X,r as x,a as V,t as P,b as p,j as e,B as f,c as T,d as ae,S as $,N as ie,e as oe}from"./index-DGBhnElr.js";import{I}from"./input-DzxFi8fX.js";function le({redirectUrl:s,callbackUrl:r="/"}){const{emailAndPassword:l,resetPassword:u,emailOtp:i,socialProviders:d}=X(),[n,j]=x.useState(""),[y,D]=x.useState(""),[b,C]=x.useState(""),[O,A]=x.useState(""),[L,R]=x.useState(!1),[z,N]=x.useState(()=>!l.enabled&&i.enabled?"emailOtp":globalThis.localStorage?.getItem("hasLoggedIn")!=="true"?"signUp":"signIn"),[c,S]=x.useState(""),[Y,G]=x.useState(!1),m=z==="signUp",h=z==="forgotPassword",w=z==="emailOtp",F=V({mutationFn:async({email:t,password:a,name:q})=>{try{if(m){const g=await p.signUp.email({email:t,password:a,name:q||""});if(g.error)throw new Error(g.error.message||"Sign up failed");return g}else{const g=await p.signIn.email({email:t,password:a});if(g.error)throw new Error(g.error.message||"Sign in failed");return g}}catch(g){throw g instanceof Error?g:new Error("Authentication failed")}},onSuccess:()=>{globalThis.localStorage?.setItem("hasLoggedIn","true"),window.location.href=s??r},onError:t=>{P(m?"user_signup_failed":"user_signin_failed",{error:t instanceof Error?t.message:String(t)})}}),U=V({mutationFn:async({email:t})=>{const a=await p.requestPasswordReset({email:t,redirectTo:"/reset-password"});if(a.error)throw new Error(a.error.message||"Failed to send reset email");return a},onSuccess:()=>{P("password_reset_requested"),G(!0)},onError:t=>{P("password_reset_request_failed",{error:t instanceof Error?t.message:String(t)})}}),E=V({mutationFn:async({email:t})=>{const a=await p.emailOtp.sendVerificationOtp({email:t,type:"sign-in"});if(a.error)throw new Error(a.error.message||"Failed to send code");return a},onSuccess:()=>{P("email_otp_sent"),R(!0)},onError:t=>{P("email_otp_send_failed",{error:t instanceof Error?t.message:String(t)})}}),_=V({mutationFn:async({email:t,otp:a})=>{const q=await p.signIn.emailOtp({email:t,otp:a});if(q.error)throw new Error(q.error.message||"Invalid code");return q},onSuccess:()=>{globalThis.localStorage?.setItem("hasLoggedIn","true"),window.location.href=s??r},onError:t=>{P("email_otp_verify_failed",{error:t instanceof Error?t.message:String(t)})}}),B=t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t),W=()=>{n.trim()&&!B(n)&&S("Invalid email address")},Z=t=>{if(t.preventDefault(),!B(n)){S("Invalid email address");return}F.mutate({email:n,password:y,name:b})},ee=t=>{if(t.preventDefault(),!B(n)){S("Invalid email address");return}U.mutate({email:n})},te=t=>{if(t.preventDefault(),!B(n)){S("Invalid email address");return}E.mutate({email:n})},se=t=>{t.preventDefault(),_.mutate({email:n,otp:O})},k=t=>a=>{t(a.target.value),H&&F.reset(),J&&U.reset(),K&&(E.reset(),_.reset()),t===j&&c&&S("")},M=t=>{N(t),C(""),A(""),R(!1),S(""),G(!1),F.reset(),U.reset(),E.reset(),_.reset()},o=F.isPending||U.isPending||E.isPending||_.isPending,H=F.error,J=U.error,K=E.error||_.error,v=m?n.trim()&&y.trim()&&b.trim():h?n.trim():w?L?O.trim():n.trim():n.trim()&&y.trim(),re=t=>{if(!t)return null;const a=t.message.toLowerCase();return a.includes("unauthorized")||a.includes("401")?"Invalid email or password. Please try again.":a.includes("already exists")||a.includes("409")?"An account with this email already exists. Try signing in instead.":a.includes("network")||a.includes("fetch")?"Network error. Please check your connection and try again.":a.includes("rate limit")||a.includes("429")?"Too many attempts. Please wait a moment and try again.":a.includes("invalid")&&a.includes("otp")?"Invalid or expired code. Please try again.":t.message||"An error occurred. Please try again."},Q=H||J||K,ne=h?"Reset your password":w?L?"Enter verification code":"Sign in with email code":m?"Create your account":"Login or signup below";return e.jsxs("div",{className:"mx-auto w-full min-h-full md:min-h-0 md:min-w-[400px] max-w-md grid gap-6 content-center bg-card p-6 md:p-10 border border-primary-foreground/20",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"h-12 w-12"})}),e.jsx("div",{className:"text-center space-y-1",children:e.jsx("p",{className:"text-sm text-foreground/70",children:ne})}),Q&&e.jsx("div",{className:"rounded-xl bg-destructive/10 p-3 text-sm text-destructive text-center",children:re(Q)}),Y&&e.jsx("div",{className:"rounded-xl bg-emerald-500/10 p-3 text-sm text-emerald-600 dark:text-emerald-400 text-center",children:"Check your email for a password reset link."}),!h&&d.enabled&&e.jsx("div",{className:"grid gap-3",children:d.providers.map(t=>e.jsxs(f,{type:"button",variant:"outline",size:"lg",className:"w-full font-medium",disabled:o,onClick:()=>{p.signIn.social({provider:t.name,callbackURL:s??r})},children:[t.icon&&e.jsx("img",{src:t.icon,alt:"",className:"h-5 w-5","aria-hidden":"true"}),"Continue with"," ",t.name.charAt(0).toUpperCase()+t.name.slice(1)]},t.name))}),!h&&d.enabled&&(l.enabled||i.enabled)&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),w&&i.enabled&&e.jsx(e.Fragment,{children:L?e.jsxs("form",{onSubmit:se,className:"grid gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-muted/50 p-3 text-sm text-muted-foreground text-center",children:["Code sent to ",n]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Verification code"}),e.jsx(I,{type:"text",placeholder:"Enter code",value:O,onChange:k(A),required:!0,disabled:o,autoFocus:!0,inputMode:"numeric",autoComplete:"one-time-code"})]}),e.jsx(f,{type:"submit",disabled:o||!v,className:"w-full font-semibold",size:"lg",children:o?"Verifying...":"Verify"}),e.jsx(f,{type:"button",variant:"ghost",onClick:()=>{R(!1),A(""),E.reset(),_.reset()},disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Use a different email"})]}):e.jsxs("form",{onSubmit:te,className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),e.jsx(I,{type:"email",placeholder:"you@example.com",value:n,onChange:k(j),onBlur:W,required:!0,disabled:o,"aria-invalid":!!c}),c&&e.jsx("p",{className:"text-xs text-destructive mt-1.5",children:c})]}),e.jsx(f,{type:"submit",disabled:o||!v,className:"w-full font-semibold",size:"lg",children:o?"Sending...":"Send code"})]})}),h&&l.enabled&&!Y&&e.jsxs("form",{onSubmit:ee,className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),e.jsx(I,{type:"email",placeholder:"you@example.com",value:n,onChange:k(j),onBlur:W,required:!0,disabled:o,"aria-invalid":!!c}),c&&e.jsx("p",{className:"text-xs text-destructive mt-1.5",children:c})]}),e.jsx(f,{type:"submit",disabled:o||!v,className:"w-full font-semibold",size:"lg",children:o?"Sending...":"Send reset link"})]}),!h&&!w&&l.enabled&&e.jsxs("form",{onSubmit:Z,className:"grid gap-4",children:[e.jsx("div",{className:T("overflow-hidden transition-all duration-300 ease-[cubic-bezier(0.075,0.82,0.165,1)]",m?"max-h-[200px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2"),children:e.jsxs("div",{className:T("p-1",!m&&"pointer-events-none"),children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Name"}),e.jsx(I,{type:"text",placeholder:"Your name",value:b,onChange:k(C),required:!0,disabled:o||!m,"aria-hidden":!m})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),e.jsx(I,{type:"email",placeholder:"you@example.com",value:n,onChange:k(j),onBlur:W,required:!0,disabled:o,"aria-invalid":!!c}),c&&e.jsx("p",{className:"text-xs text-destructive mt-1.5",children:c})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground",children:"Password"}),!m&&u.enabled&&e.jsx("button",{type:"button",onClick:()=>M("forgotPassword"),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Forgot password?"})]}),e.jsx(I,{type:"password",placeholder:"••••••••",value:y,onChange:k(D),required:!0,disabled:o})]}),e.jsx("div",{className:T("overflow-hidden transition-all duration-300 ease-[cubic-bezier(0.075,0.82,0.165,1)]",v?"max-h-[100px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2"),children:e.jsx("div",{className:T("p-1",!v&&"pointer-events-none"),children:e.jsx(f,{type:"submit",disabled:o||!v,className:T("w-full font-semibold"),size:"lg","aria-hidden":!v,children:o?m?"Creating account...":"Signing in...":"Continue"})})})]}),!h&&i.enabled&&l.enabled&&!w&&e.jsx("div",{className:"text-center",children:e.jsx(f,{type:"button",variant:"link",onClick:()=>M("emailOtp"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Sign in with email code instead"})}),w&&l.enabled&&e.jsx("div",{className:"text-center",children:e.jsx(f,{type:"button",variant:"link",onClick:()=>M("signIn"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Sign in with password instead"})}),e.jsx("div",{className:"text-center",children:h?e.jsx(f,{type:"button",variant:"link",onClick:()=>M("signIn"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:"Back to sign in"}):!w&&l.enabled?e.jsx(f,{type:"button",variant:"link",onClick:()=>M(m?"signIn":"signUp"),disabled:o,className:"text-sm text-muted-foreground hover:text-foreground",children:m?"Already have an account? Sign in":"Don't have an account? Sign up"}):null}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground pt-4",children:[e.jsx("a",{href:"https://www.decocms.com/terms-of-use",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground transition-colors",children:"Terms of Service"}),e.jsx("a",{href:"https://www.decocms.com/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground transition-colors",children:"Privacy Policy"})]})]})}function de({redirectTo:s}){const[r,l]=x.useState(null);return x.useEffect(()=>{let u=!1;return(async()=>{try{let i;for(let d=0;d<5&&(i=await fetch("/api/auth/custom/local-session",{method:"POST",credentials:"include"}),!(i.ok||i.status<500));d++)await new Promise(n=>setTimeout(n,Math.min(1e3*2**d,1e4)));if(!i?.ok){const d=await i?.json().catch(()=>({}));throw new Error(d?.error||"Auto-login failed")}if(!u){const d=s.startsWith("/")&&!s.startsWith("//")?s:"/";window.location.href=d}}catch(i){u||l(i instanceof Error?i.message:"Auto-login failed")}})(),()=>{u=!0}},[s]),r?e.jsx("div",{className:"flex min-h-screen items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-destructive mb-2",children:["Auto-login failed: ",r]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try restarting the server."})]})}):e.jsx($,{})}function ce(s){if(!s.client_id||s.response_type!=="code")return null;const r=new URLSearchParams;return s.client_id&&r.set("client_id",s.client_id),s.redirect_uri&&r.set("redirect_uri",s.redirect_uri),s.response_type&&r.set("response_type",s.response_type),s.state&&r.set("state",s.state),s.scope&&r.set("scope",s.scope),s.code_challenge&&r.set("code_challenge",s.code_challenge),s.code_challenge_method&&r.set("code_challenge_method",s.code_challenge_method),`/api/auth/mcp/authorize?${r.toString()}`}function ue(s){const r=oe.c(5),{callbackURL:l,providerId:u}=s;let i,d;r[0]!==l||r[1]!==u?(i=()=>{(async()=>await p.signIn.sso({providerId:u,callbackURL:l}))()},d=[u,l],r[0]=l,r[1]=u,r[2]=i,r[3]=d):(i=r[2],d=r[3]),x.useEffect(i,d);let n;return r[4]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsx($,{}),r[4]=n):n=r[4],n}function ge(){const s=p.useSession(),r=ae({from:"/login"}),{next:l="/",client_id:u,redirect_uri:i,response_type:d,state:n,scope:j,code_challenge:y,code_challenge_method:D}=r,b=l.startsWith("/")&&!l.startsWith("//")?l:"/",{sso:C,emailAndPassword:O,magicLink:A,emailOtp:L,socialProviders:R,localMode:z}=X(),N=ce({client_id:u,redirect_uri:i,response_type:d,state:n,scope:j,code_challenge:y,code_challenge_method:D}),c=N||b;return s.data?N?(window.location.href=N,e.jsx($,{})):e.jsx(ie,{to:b}):z?e.jsx(de,{redirectTo:c}):C.enabled?e.jsx(ue,{callbackURL:c,providerId:C.providerId}):O.enabled||A.enabled||L.enabled||R.enabled?e.jsxs("main",{className:"relative flex min-h-screen items-stretch md:items-center justify-center bg-gradient-to-br from-brand to-brand/75 p-1 md:p-4",children:[e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, var(--brand-foreground) 1px, transparent 1px)",backgroundSize:"16px 16px",opacity:.15}}),e.jsxs("div",{className:"relative z-10 w-full md:w-auto",children:[e.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-screen h-px bg-brand-foreground/15"}),e.jsx("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 w-screen h-px bg-brand-foreground/15"}),e.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-px h-screen bg-brand-foreground/15"}),e.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 w-px h-screen bg-brand-foreground/15"}),e.jsx(le,{redirectUrl:N,callbackUrl:b})]})]}):e.jsx("div",{children:"No login options available"})}export{ge as default};
@@ -1,3 +1,3 @@
1
- import{J as Dt,r as ce,s as fe,o as De,b as $t,z as kt,a as pe,t as ue,x as G,K as ie,j as s,B as Pe,e as Y,w as Ft,n as Tt,c as ze,l as Xe,E as Lt}from"./index-Dcg8Qevd.js";import{C as Ot}from"./collection-display-button-DMmbKfya.js";import{S as qt}from"./search-input-C50ImRzg.js";import{P as Ee}from"./index-DtUGvIts.js";import{C as Bt}from"./collection-table-wrapper-CtvRahI-.js";import{E as We}from"./empty-state-BnjbbhBR.js";import{b as Kt,h as Vt,a as Qt,c as Ut,d as Gt,D as Jt}from"./dialog-DUgfuVrb.js";import{a as Ht,F as rt,b as ct,c as Wt,d as mt,f as dt}from"./form-O0xus6j8.js";import{S as et,a as tt,b as st,c as nt,d as it}from"./select-DkBE5ypj.js";import{T as Yt}from"./textarea-e7WVG0Uq.js";import{u as at}from"./use-org-auth-client-uXh4lV5h.js";import{u as It}from"./use-organization-roles-CXi0dKrO.js";import{u as Zt}from"./use-members-Bw_9meIY.js";import{S as $e,u as ke}from"./constants-DXQgV2hu.js";import{a as Xt,b as es,c as ts,T as ss}from"./tooltip-sn7TXXXA.js";import{a as ut,e as ft,g as gt,b as ht,c as pt,d as xt,f as bt,A as jt}from"./alert-dialog-BiN56dOX.js";import{A as Ve}from"./avatar-Z1wN1pq-.js";import{B as Ue}from"./badge-CTmf2TW8.js";import{C as vt}from"./card-Bd8klEwI.js";import{D as At,a as Mt,b as Et,e as ns,d as is,f as ls,c as lt,i as as}from"./dropdown-menu-Cbx_bdO_.js";import{i as Pt}from"./DotsVertical-CAgAGLKz.js";import{a as os}from"./SearchMd-B780aQOS.js";import{i as rs}from"./Shield01-Bg1T1EGa.js";import{s as _t,a as cs}from"./XClose-Dz5yGfpm.js";import{s as ms}from"./Trash01-4w6_aW9X.js";import{C as Ct}from"./checkbox-B3EwrxkO.js";import{a as Ye,b as Ze,c as yt,C as ds,e as us,f as fs,d as gs}from"./command-BAMG06m5.js";import{a as hs,b as ps,P as xs}from"./popover-DNu8C4Ll.js";import{t as bs}from"./ChevronDown-D452dgSU.js";import{s as js}from"./Plus-FC_C8qkl.js";import"./Check-DBWnyOFJ.js";import"./view-mode-toggle-Ca3EQ8LL.js";import"./X-BGh8G2l7.js";import"./table-Dpjp6sno.js";import"./label-_jNQo8Ll.js";import"./ChevronUp-BlZFoG59.js";import"./User01-CxpWRrdM.js";import"./ChevronRight-DoY3rcf9.js";import"./index-CuVn0uMY.js";const vs=Dt().email("Invalid email address");function Cs(t){if(!t.trim())return[];const e=t.split(/[,;\n]/).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(e))}function ys({trigger:t}){const[e,n]=ce.useState(!1),{locator:o}=fe(),r=at(),l=De(),{data:i}=$t.useSession(),a=i?.user?.email,{roles:m,isLoading:g}=It(),h=m.filter(d=>d.role!=="owner"),p=kt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),j=p.watch("emailsText"),I=p.watch("role"),v=Cs(j).filter(d=>{const c=vs.safeParse(d).success,x=!a||d!==a.toLowerCase();return c&&x}),N=pe({mutationFn:async({emails:d,role:c})=>{if(!c)throw new Error("Please select a role");const x=await Promise.allSettled(d.map(async w=>{const M=await r.organization.inviteMember({email:w,role:c});if(M.error)throw new Error(M.error.message);return M.data})),A=x.filter(w=>w.status==="rejected");if(A.length>0)throw new Error(`Failed to invite ${A.length} member${A.length>1?"s":""}`);return x},onSuccess:(d,{emails:c,role:x})=>{ue("member_invited",{count:c.length,role:x}),l.invalidateQueries({queryKey:ie.members(o)}),l.invalidateQueries({queryKey:ie.invitations(o)}),G.success(c.length===1?"Member invited successfully!":`${c.length} members invited successfully!`),p.reset({emailsText:"",role:"user"}),n(!1)},onError:(d,{emails:c,role:x})=>{ue("member_invite_failed",{count:c.length,role:x,error:d instanceof Error?d.message:String(d)}),G.error(d instanceof Error?d.message:"Failed to invite members")}}),y=d=>{if(v.length===0){G.error("Please enter at least one valid email address");return}if(!d.role){G.error("Please select a role");return}N.mutate({emails:v,role:d.role})},D=v.length>0&&!!I;return s.jsxs(Kt,{open:e,onOpenChange:n,children:[s.jsx(Vt,{asChild:!0,children:t}),s.jsxs(Qt,{className:"sm:max-w-lg",children:[s.jsx(Ut,{children:s.jsx(Gt,{children:"Invite members"})}),s.jsx(Ht,{...p,children:s.jsxs("form",{onSubmit:p.handleSubmit(y),className:"space-y-4",children:[s.jsx(rt,{control:p.control,name:"emailsText",render:({field:d})=>s.jsxs(ct,{children:[s.jsx(Wt,{children:"Email addresses"}),s.jsx(mt,{children:s.jsx(Yt,{...d,disabled:N.isPending,placeholder:`Enter email addresses separated by commas or new lines
1
+ import{J as Dt,r as ce,s as fe,o as De,b as $t,z as kt,a as pe,t as ue,x as G,K as ie,j as s,B as Pe,e as Y,w as Ft,n as Tt,c as ze,l as Xe,E as Lt}from"./index-DGBhnElr.js";import{C as Ot}from"./collection-display-button-DeSxG6UB.js";import{S as qt}from"./search-input-B6qLYIdC.js";import{P as Ee}from"./index-eAGChOCR.js";import{C as Bt}from"./collection-table-wrapper-xdclfmzd.js";import{E as We}from"./empty-state-CEv_S9NU.js";import{b as Kt,h as Vt,a as Qt,c as Ut,d as Gt,D as Jt}from"./dialog-DWzrMeko.js";import{a as Ht,F as rt,b as ct,c as Wt,d as mt,f as dt}from"./form-x_GA0lGZ.js";import{S as et,a as tt,b as st,c as nt,d as it}from"./select-C4bCQJgN.js";import{T as Yt}from"./textarea-DTBlkTwn.js";import{u as at}from"./use-org-auth-client-CC9Iglye.js";import{u as It}from"./use-organization-roles-BAYYxXBp.js";import{u as Zt}from"./use-members-B9Eyug-z.js";import{S as $e,u as ke}from"./constants-ChKBx8P9.js";import{a as Xt,b as es,c as ts,T as ss}from"./tooltip-CkuZjpG2.js";import{a as ut,e as ft,g as gt,b as ht,c as pt,d as xt,f as bt,A as jt}from"./alert-dialog-ffhzv4m-.js";import{A as Ve}from"./avatar-CMxH2q_w.js";import{B as Ue}from"./badge-CgoHsUkF.js";import{C as vt}from"./card-BiS_R1xQ.js";import{D as At,a as Mt,b as Et,e as ns,d as is,f as ls,c as lt,i as as}from"./dropdown-menu-D9UMjJNs.js";import{i as Pt}from"./DotsVertical-D5hdBGsZ.js";import{a as os}from"./SearchMd-MizqCBM1.js";import{i as rs}from"./Shield01-oTE-LfH6.js";import{s as _t,a as cs}from"./XClose-DfIvwfxS.js";import{s as ms}from"./Trash01-Cn1Fmdwd.js";import{C as Ct}from"./checkbox-yg1I1N9G.js";import{a as Ye,b as Ze,c as yt,C as ds,e as us,f as fs,d as gs}from"./command-BdLpLF4Y.js";import{a as hs,b as ps,P as xs}from"./popover-Le9pRw8B.js";import{t as bs}from"./ChevronDown-vyFW7nWm.js";import{s as js}from"./Plus-DAOphtXP.js";import"./Check-CrFTsmMd.js";import"./view-mode-toggle-yG7ozqz2.js";import"./X-DcV2kx7g.js";import"./table-DUHnOueh.js";import"./label-DuKyp2cN.js";import"./ChevronUp-B_8XT1h5.js";import"./User01-D9nCHLW_.js";import"./ChevronRight-B1QR9mxi.js";import"./index-CopHENRs.js";const vs=Dt().email("Invalid email address");function Cs(t){if(!t.trim())return[];const e=t.split(/[,;\n]/).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(e))}function ys({trigger:t}){const[e,n]=ce.useState(!1),{locator:o}=fe(),r=at(),l=De(),{data:i}=$t.useSession(),a=i?.user?.email,{roles:m,isLoading:g}=It(),h=m.filter(d=>d.role!=="owner"),p=kt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),j=p.watch("emailsText"),I=p.watch("role"),v=Cs(j).filter(d=>{const c=vs.safeParse(d).success,x=!a||d!==a.toLowerCase();return c&&x}),N=pe({mutationFn:async({emails:d,role:c})=>{if(!c)throw new Error("Please select a role");const x=await Promise.allSettled(d.map(async w=>{const M=await r.organization.inviteMember({email:w,role:c});if(M.error)throw new Error(M.error.message);return M.data})),A=x.filter(w=>w.status==="rejected");if(A.length>0)throw new Error(`Failed to invite ${A.length} member${A.length>1?"s":""}`);return x},onSuccess:(d,{emails:c,role:x})=>{ue("member_invited",{count:c.length,role:x}),l.invalidateQueries({queryKey:ie.members(o)}),l.invalidateQueries({queryKey:ie.invitations(o)}),G.success(c.length===1?"Member invited successfully!":`${c.length} members invited successfully!`),p.reset({emailsText:"",role:"user"}),n(!1)},onError:(d,{emails:c,role:x})=>{ue("member_invite_failed",{count:c.length,role:x,error:d instanceof Error?d.message:String(d)}),G.error(d instanceof Error?d.message:"Failed to invite members")}}),y=d=>{if(v.length===0){G.error("Please enter at least one valid email address");return}if(!d.role){G.error("Please select a role");return}N.mutate({emails:v,role:d.role})},D=v.length>0&&!!I;return s.jsxs(Kt,{open:e,onOpenChange:n,children:[s.jsx(Vt,{asChild:!0,children:t}),s.jsxs(Qt,{className:"sm:max-w-lg",children:[s.jsx(Ut,{children:s.jsx(Gt,{children:"Invite members"})}),s.jsx(Ht,{...p,children:s.jsxs("form",{onSubmit:p.handleSubmit(y),className:"space-y-4",children:[s.jsx(rt,{control:p.control,name:"emailsText",render:({field:d})=>s.jsxs(ct,{children:[s.jsx(Wt,{children:"Email addresses"}),s.jsx(mt,{children:s.jsx(Yt,{...d,disabled:N.isPending,placeholder:`Enter email addresses separated by commas or new lines
2
2
  e.g. user1@example.com, user2@example.com
3
3
  or one per line`,className:"min-h-[120px] resize-none"})}),s.jsx(dt,{})]})}),s.jsx(rt,{control:p.control,name:"role",render:({field:d})=>s.jsxs(ct,{children:[s.jsx(mt,{children:s.jsxs(et,{value:d.value,onValueChange:d.onChange,disabled:N.isPending||g,children:[s.jsx(tt,{className:"w-full",children:s.jsx(st,{placeholder:"Select a role"})}),s.jsx(nt,{children:h.map(c=>{const x=[];return c.isBuiltin||(c.allowsAllStaticPermissions?x.push("Full org access"):c.staticPermissionCount&&c.staticPermissionCount>0&&x.push(`${c.staticPermissionCount} org perm${c.staticPermissionCount!==1?"s":""}`),c.allowsAllConnections?x.push("All connections"):c.connectionCount&&c.connectionCount>0&&x.push(`${c.connectionCount} connection${c.connectionCount!==1?"s":""}`),(c.connectionCount!==0||c.allowsAllConnections)&&(c.allowsAllTools?x.push("all tools"):c.toolCount&&c.toolCount>0&&x.push(`${c.toolCount} tool${c.toolCount!==1?"s":""}`))),s.jsx(it,{value:c.role,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:c.label}),!c.isBuiltin&&x.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:x.join(", ")})]})},c.role)})})]})}),s.jsx(dt,{})]})}),s.jsxs(Jt,{children:[s.jsx(Pe,{variant:"outline",onClick:()=>{p.reset({emailsText:"",role:"user"}),n(!1)},type:"button",disabled:N.isPending,children:"Cancel"}),s.jsx(Pe,{type:"submit",disabled:N.isPending||!D,children:N.isPending?"Inviting...":`Invite ${v.length||0} Member${v.length!==1?"s":""}`})]})]})})]})]})}function Ss(){const t=Y.c(10),{org:e,locator:n}=fe();let o;t[0]!==e.id||t[1]!==e.slug?(o={connectionId:$e,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=o):o=t[2];const r=ke(o);let l;t[3]!==n?(l=ie.invitations(n),t[3]=n,t[4]=l):l=t[4];let i;t[5]!==r?(i=async()=>{const m=await r.callTool({name:"ORGANIZATION_GET",arguments:{}});return(m.structuredContent??m)?.invitations??[]},t[5]=r,t[6]=i):i=t[6];let a;return t[7]!==l||t[8]!==i?(a={queryKey:l,queryFn:i},t[7]=l,t[8]=i,t[9]=a):a=t[9],Ft(a)}function ws(){const t=Y.c(10),{locator:e}=fe(),n=at(),o=De();let r;t[0]!==n?(r=async g=>{const h=await n.organization.cancelInvitation({invitationId:g});if(h?.error)throw new Error(h.error.message);return h.data},t[0]=n,t[1]=r):r=t[1];let l;t[2]!==e||t[3]!==o?(l=()=>{o.invalidateQueries({queryKey:ie.invitations(e)}),G.success("Invitation cancelled")},t[2]=e,t[3]=o,t[4]=l):l=t[4];let i;t[5]!==r||t[6]!==l?(i={mutationFn:r,onSuccess:l,onError:Ns},t[5]=r,t[6]=l,t[7]=i):i=t[7];const a=pe(i);let m;return t[8]!==a?(m={cancel:a},t[8]=a,t[9]=m):m=t[9],m}function Ns(t){G.error(t instanceof Error?t.message:"Failed to cancel invitation")}function Ts(){const t=Y.c(10),{org:e,locator:n}=fe();let o;t[0]!==e.id||t[1]!==e.slug?(o={connectionId:$e,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=o):o=t[2];const r=ke(o);let l;t[3]!==n?(l=ie.tags(n),t[3]=n,t[4]=l):l=t[4];let i;t[5]!==r?(i=async()=>{const m=await r.callTool({name:"TAGS_LIST",arguments:{}});return(m.structuredContent??m).tags},t[5]=r,t[6]=i):i=t[6];let a;return t[7]!==l||t[8]!==i?(a={queryKey:l,queryFn:i,staleTime:3e4},t[7]=l,t[8]=i,t[9]=a):a=t[9],Tt(a)}function Is(){const t=Y.c(11),e=De(),{org:n,locator:o}=fe();let r;t[0]!==n.id||t[1]!==n.slug?(r={connectionId:$e,orgId:n.id,orgSlug:n.slug},t[0]=n.id,t[1]=n.slug,t[2]=r):r=t[2];const l=ke(r);let i;t[3]!==l?(i=async g=>{const h=await l.callTool({name:"TAGS_CREATE",arguments:{name:g}});return(h.structuredContent??h).tag},t[3]=l,t[4]=i):i=t[4];let a;t[5]!==o||t[6]!==e?(a=()=>{e.invalidateQueries({queryKey:ie.tags(o)})},t[5]=o,t[6]=e,t[7]=a):a=t[7];let m;return t[8]!==i||t[9]!==a?(m={mutationFn:i,onSuccess:a,onError:As},t[8]=i,t[9]=a,t[10]=m):m=t[10],pe(m)}function As(t){G.error(t instanceof Error?t.message:"Failed to create tag")}function Ms(t){const e=Y.c(13),{org:n,locator:o}=fe();let r;e[0]!==n.id||e[1]!==n.slug?(r={connectionId:$e,orgId:n.id,orgSlug:n.slug},e[0]=n.id,e[1]=n.slug,e[2]=r):r=e[2];const l=ke(r);let i;e[3]!==o||e[4]!==t?(i=ie.memberTags(o,t),e[3]=o,e[4]=t,e[5]=i):i=e[5];let a;e[6]!==l||e[7]!==t?(a=async()=>{const h=await l.callTool({name:"MEMBER_TAGS_GET",arguments:{memberId:t}});return(h.structuredContent??h).tags},e[6]=l,e[7]=t,e[8]=a):a=e[8];const m=!!t;let g;return e[9]!==i||e[10]!==a||e[11]!==m?(g={queryKey:i,queryFn:a,staleTime:3e4,enabled:m},e[9]=i,e[10]=a,e[11]=m,e[12]=g):g=e[12],Tt(g)}function Es(){const t=Y.c(11),e=De(),{org:n,locator:o}=fe();let r;t[0]!==n.id||t[1]!==n.slug?(r={connectionId:$e,orgId:n.id,orgSlug:n.slug},t[0]=n.id,t[1]=n.slug,t[2]=r):r=t[2];const l=ke(r);let i;t[3]!==l?(i=async g=>{const{memberId:h,tagIds:p}=g,j=await l.callTool({name:"MEMBER_TAGS_SET",arguments:{memberId:h,tagIds:p}});return j.structuredContent??j},t[3]=l,t[4]=i):i=t[4];let a;t[5]!==o||t[6]!==e?(a=(g,h)=>{e.invalidateQueries({queryKey:ie.memberTags(o,h.memberId)})},t[5]=o,t[6]=e,t[7]=a):a=t[7];let m;return t[8]!==i||t[9]!==a?(m={mutationFn:i,onSuccess:a,onError:Ps},t[8]=i,t[9]=a,t[10]=m):m=t[10],pe(m)}function Ps(t){G.error(t instanceof Error?t.message:"Failed to update member tags")}function Rt(t){const e=Y.c(44),{memberId:n,className:o,disabled:r,placeholder:l,maxDisplay:i}=t,a=r===void 0?!1:r,m=l===void 0?"Add tags...":l,g=i===void 0?2:i,[h,p]=ce.useState(!1),[j,I]=ce.useState(""),{data:R,isLoading:v}=Ts(),N=R===void 0?[]:R,{data:y,isLoading:D}=Ms(n),d=y===void 0?[]:y,c=Is(),x=Es(),A=v||D,w=d.map(Rs);let M;e[0]!==j?(M=S=>S.name.toLowerCase().includes(j.toLowerCase()),e[0]=j,e[1]=M):M=e[1];const z=N.filter(M);let T;e[2]!==j?(T=S=>S.name.toLowerCase()===j.toLowerCase(),e[2]=j,e[3]=T):T=e[3];const K=N.find(T),E=j.trim()&&!K,k=async S=>{const he=w.includes(S.id)?w.filter(je=>je!==S.id):[...w,S.id];await x.mutateAsync({memberId:n,tagIds:he})},P=async()=>{if(!j.trim())return;const S=await c.mutateAsync(j.trim());await x.mutateAsync({memberId:n,tagIds:[...w,S.id]}),I("")},u=async S=>{const ne=w.filter(he=>he!==S);await x.mutateAsync({memberId:n,tagIds:ne})},C=c.isPending||x.isPending,O=ps;let $;e[4]!==h?($=()=>p(!h),e[4]=h,e[5]=$):$=e[5];let F;e[6]!==o?(F=ze("h-auto min-h-8 px-2 py-1 justify-start font-normal","hover:bg-accent/50",o),e[6]=o,e[7]=F):F=e[7];const V=a||A,L=A?s.jsx(Xe,{size:14,className:"animate-spin text-muted-foreground"}):d.length>0?s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[d.slice(0,g).map(_s),d.length>g&&s.jsxs(Ue,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:["+",d.length-g]})]}):s.jsx("span",{className:"text-muted-foreground text-xs",children:m});let Q;e[8]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(bs,{size:14,className:"ml-1 shrink-0 opacity-50"}),e[8]=Q):Q=e[8];let q;e[9]!==V||e[10]!==L||e[11]!==$||e[12]!==F?(q=s.jsx(xs,{asChild:!0,children:s.jsxs(Pe,{variant:"ghost",size:"sm",onClick:$,className:F,disabled:V,children:[L,Q]})}),e[9]=V,e[10]=L,e[11]=$,e[12]=F,e[13]=q):q=e[13];const U=hs,J="w-56 p-0",H="start";let W;e[14]===Symbol.for("react.memo_cache_sentinel")?(W=()=>p(!1),e[14]=W):W=e[14];const le=fs,xe=!1;let Z;e[15]!==j?(Z=s.jsx(gs,{placeholder:"Search or create...",value:j,onValueChange:I,className:"h-9"}),e[15]=j,e[16]=Z):Z=e[16];const ae=us,me=d.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Ye,{heading:"Selected",children:d.map(S=>s.jsx(Ze,{onSelect:()=>k(S),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ct,{checked:!0,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:S.name})]}),s.jsx("button",{onClick:ne=>{ne.stopPropagation(),u(S.id)},className:"opacity-50 hover:opacity-100",disabled:C,children:s.jsx(_t,{size:14})})]})},S.id))}),s.jsx(yt,{})]}),_e=Ye,be="Available",Re=z.length===0&&!E&&s.jsx(ds,{children:"No tags found."}),ge=z.filter(S=>!w.includes(S.id)).map(S=>s.jsx(Ze,{onSelect:()=>k(S),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ct,{checked:!1,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:S.name})]})},S.id));let oe;e[17]!==_e||e[18]!==Re||e[19]!==ge?(oe=s.jsxs(_e,{heading:be,children:[Re,ge]}),e[17]=_e,e[18]=Re,e[19]=ge,e[20]=oe):oe=e[20];let re;e[21]!==P||e[22]!==C||e[23]!==j||e[24]!==E?(re=E&&s.jsxs(s.Fragment,{children:[s.jsx(yt,{}),s.jsx(Ye,{children:s.jsx(Ze,{onSelect:P,className:"cursor-pointer",disabled:C,children:s.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[C?s.jsx(Xe,{size:14,className:"animate-spin"}):s.jsx(js,{size:14}),s.jsxs("span",{children:['Create "',j.trim(),'"']})]})})})]}),e[21]=P,e[22]=C,e[23]=j,e[24]=E,e[25]=re):re=e[25];let X;e[26]!==ae||e[27]!==me||e[28]!==oe||e[29]!==re?(X=s.jsxs(ae,{children:[me,oe,re]}),e[26]=ae,e[27]=me,e[28]=oe,e[29]=re,e[30]=X):X=e[30];let ee;e[31]!==le||e[32]!==Z||e[33]!==X?(ee=s.jsxs(le,{shouldFilter:xe,children:[Z,X]}),e[31]=le,e[32]=Z,e[33]=X,e[34]=ee):ee=e[34];let te;e[35]!==U||e[36]!==W||e[37]!==ee?(te=s.jsx(U,{className:J,align:H,onEscapeKeyDown:W,children:ee}),e[35]=U,e[36]=W,e[37]=ee,e[38]=te):te=e[38];let se;return e[39]!==O||e[40]!==h||e[41]!==q||e[42]!==te?(se=s.jsxs(O,{open:h,onOpenChange:p,children:[q,te]}),e[39]=O,e[40]=h,e[41]=q,e[42]=te,e[43]=se):se=e[43],se}function _s(t){return s.jsx(Ue,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:t.name},t.id)}function Rs(t){return t.id}const St=["bg-neutral-400","bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500","bg-slate-500"],zs={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function Qe(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function Ds(t){const e=new Map;for(const[n,o]of Object.entries(zs))e.set(n,o);for(let n=0;n<t.length;n++){const o=t[n];o&&!e.has(o.role)&&e.set(o.role,St[n%St.length]??"bg-neutral-400")}return e}function $s(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function Ke(t){const e=Y.c(79),{role:n,memberId:o,isOwner:r,roleColorMap:l,selectableRoles:i,onRoleChange:a,size:m,className:g}=t,h=m===void 0?"xs":m;let p,j,I,R,v,N,y,D,d,c,x;if(e[0]!==g||e[1]!==r||e[2]!==o||e[3]!==a||e[4]!==n||e[5]!==l||e[6]!==i||e[7]!==h){x=Symbol.for("react.early_return_sentinel");e:{const P=l.get(n)??"bg-neutral-400";if(r){let u;e[19]!==o||e[20]!==a?(u=J=>a(o,J),e[19]=o,e[20]=a,e[21]=u):u=e[21];let C;e[22]!==n?(C=s.jsx("span",{className:"capitalize truncate",children:n}),e[22]=n,e[23]=C):C=e[23];const O=s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:ze("size-2 rounded-full shrink-0",P)}),C]});let $;e[24]!==O?($=s.jsx(st,{children:O}),e[24]=O,e[25]=$):$=e[25];let F;e[26]!==g||e[27]!==h||e[28]!==$?(F=s.jsx(tt,{size:h,className:g,children:$}),e[26]=g,e[27]=h,e[28]=$,e[29]=F):F=e[29];let V;if(e[30]!==l||e[31]!==i){let J;e[33]!==l?(J=H=>{const W=l.get(H.role)??"bg-neutral-400";return s.jsx(it,{value:H.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:ze("size-3 rounded-full",W)}),s.jsx("span",{className:"capitalize",children:H.label})]})},H.role)},e[33]=l,e[34]=J):J=e[34],V=i.map(J),e[30]=l,e[31]=i,e[32]=V}else V=e[32];let L;e[35]!==V?(L=s.jsx(nt,{children:V}),e[35]=V,e[36]=L):L=e[36];let Q;e[37]!==r||e[38]!==n||e[39]!==u||e[40]!==F||e[41]!==L?(Q=s.jsx(Xt,{asChild:!0,children:s.jsx("div",{className:"w-fit",children:s.jsxs(et,{value:n,onValueChange:u,disabled:r,children:[F,L]})})}),e[37]=r,e[38]=n,e[39]=u,e[40]=F,e[41]=L,e[42]=Q):Q=e[42];let q;e[43]===Symbol.for("react.memo_cache_sentinel")?(q=s.jsx(es,{children:s.jsx("p",{children:"The owner role cannot be changed"})}),e[43]=q):q=e[43];let U;e[44]!==Q?(U=s.jsx(ts,{children:s.jsxs(ss,{children:[Q,q]})}),e[44]=Q,e[45]=U):U=e[45],x=U;break e}I=et,D=n,e[46]!==o||e[47]!==a?(d=u=>a(o,u),e[46]=o,e[47]=a,e[48]=d):d=e[48],c=r,j=tt,N=h,y=g,p=st,v="flex items-center gap-2 min-w-0",R=ze("size-2 rounded-full shrink-0",P)}e[0]=g,e[1]=r,e[2]=o,e[3]=a,e[4]=n,e[5]=l,e[6]=i,e[7]=h,e[8]=p,e[9]=j,e[10]=I,e[11]=R,e[12]=v,e[13]=N,e[14]=y,e[15]=D,e[16]=d,e[17]=c,e[18]=x}else p=e[8],j=e[9],I=e[10],R=e[11],v=e[12],N=e[13],y=e[14],D=e[15],d=e[16],c=e[17],x=e[18];if(x!==Symbol.for("react.early_return_sentinel"))return x;let A;e[49]!==R?(A=s.jsx("div",{className:R}),e[49]=R,e[50]=A):A=e[50];let w;e[51]!==n?(w=s.jsx("span",{className:"capitalize truncate",children:n}),e[51]=n,e[52]=w):w=e[52];let M;e[53]!==A||e[54]!==w||e[55]!==v?(M=s.jsxs("div",{className:v,children:[A,w]}),e[53]=A,e[54]=w,e[55]=v,e[56]=M):M=e[56];let z;e[57]!==p||e[58]!==M?(z=s.jsx(p,{children:M}),e[57]=p,e[58]=M,e[59]=z):z=e[59];let T;e[60]!==j||e[61]!==z||e[62]!==N||e[63]!==y?(T=s.jsx(j,{size:N,className:y,children:z}),e[60]=j,e[61]=z,e[62]=N,e[63]=y,e[64]=T):T=e[64];let K;if(e[65]!==l||e[66]!==i){let P;e[68]!==l?(P=u=>{const C=l.get(u.role)??"bg-neutral-400";return s.jsx(it,{value:u.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:ze("size-3 rounded-full",C)}),s.jsx("span",{className:"capitalize",children:u.label})]})},u.role)},e[68]=l,e[69]=P):P=e[69],K=i.map(P),e[65]=l,e[66]=i,e[67]=K}else K=e[67];let E;e[70]!==K?(E=s.jsx(nt,{children:K}),e[70]=K,e[71]=E):E=e[71];let k;return e[72]!==I||e[73]!==T||e[74]!==E||e[75]!==D||e[76]!==d||e[77]!==c?(k=s.jsxs(I,{value:D,onValueChange:d,disabled:c,children:[T,E]}),e[72]=I,e[73]=T,e[74]=E,e[75]=D,e[76]=d,e[77]=c,e[78]=k):k=e[78],k}function wt(t){const e=Y.c(51),{member:n,roles:o,onChangeRole:r,onRemove:l,isUpdating:i}=t,a=i===void 0?!1:i,m=n.role==="owner";let g,h,p,j,I,R,v,N,y;if(e[0]!==m||e[1]!==a||e[2]!==n.id||e[3]!==n.role||e[4]!==r||e[5]!==o){let T;e[15]!==n.role?(T=u=>u.role!==n.role&&u.role!=="owner",e[15]=n.role,e[16]=T):T=e[16];const K=o.filter(T);j=At;let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(Pt,{size:20}),e[17]=E):E=e[17],e[18]!==m?(y=s.jsx(Mt,{asChild:!0,children:s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:m,onClick:Fs,children:E})}),e[18]=m,e[19]=y):y=e[19],p=Et,v="end",N=ks,h=ns;let k;e[20]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(cs,{size:16}),e[20]=k):k=e[20],e[21]!==a?(R=s.jsxs(is,{disabled:a,children:[k,"Change Role"]}),e[21]=a,e[22]=R):R=e[22],g=ls;let P;e[23]!==a||e[24]!==n.id||e[25]!==r?(P=u=>{const C=[];return u.isBuiltin||(u.allowsAllStaticPermissions?C.push("Full org access"):u.staticPermissionCount&&u.staticPermissionCount>0&&C.push(`${u.staticPermissionCount} org perm${u.staticPermissionCount!==1?"s":""}`),u.allowsAllConnections?C.push("All connections"):u.connectionCount&&u.connectionCount>0&&C.push(`${u.connectionCount} connection${u.connectionCount!==1?"s":""}`),(u.connectionCount!==0||u.allowsAllConnections)&&(u.allowsAllTools?C.push("all tools"):u.toolCount&&u.toolCount>0&&C.push(`${u.toolCount} tool${u.toolCount!==1?"s":""}`))),s.jsxs(lt,{onClick:O=>{O.stopPropagation(),r(n.id,u.role)},disabled:a,children:[u.isBuiltin?s.jsx(rs,{size:16}):s.jsx(os,{size:16}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:u.label}),!u.isBuiltin&&C.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:C.join(", ")})]})]},u.role)},e[23]=a,e[24]=n.id,e[25]=r,e[26]=P):P=e[26],I=K.map(P),e[0]=m,e[1]=a,e[2]=n.id,e[3]=n.role,e[4]=r,e[5]=o,e[6]=g,e[7]=h,e[8]=p,e[9]=j,e[10]=I,e[11]=R,e[12]=v,e[13]=N,e[14]=y}else g=e[6],h=e[7],p=e[8],j=e[9],I=e[10],R=e[11],v=e[12],N=e[13],y=e[14];let D;e[27]!==g||e[28]!==I?(D=s.jsx(g,{children:I}),e[27]=g,e[28]=I,e[29]=D):D=e[29];let d;e[30]!==h||e[31]!==R||e[32]!==D?(d=s.jsxs(h,{children:[R,D]}),e[30]=h,e[31]=R,e[32]=D,e[33]=d):d=e[33];let c;e[34]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(as,{}),e[34]=c):c=e[34];let x;e[35]!==n.id||e[36]!==l?(x=T=>{T.stopPropagation(),l(n.id)},e[35]=n.id,e[36]=l,e[37]=x):x=e[37];let A;e[38]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(ms,{size:16}),e[38]=A):A=e[38];let w;e[39]!==x?(w=s.jsxs(lt,{variant:"destructive",onClick:x,children:[A,"Remove Member"]}),e[39]=x,e[40]=w):w=e[40];let M;e[41]!==p||e[42]!==w||e[43]!==v||e[44]!==N||e[45]!==d?(M=s.jsxs(p,{align:v,onClick:N,children:[d,c,w]}),e[41]=p,e[42]=w,e[43]=v,e[44]=N,e[45]=d,e[46]=M):M=e[46];let z;return e[47]!==j||e[48]!==M||e[49]!==y?(z=s.jsxs(j,{children:[y,M]}),e[47]=j,e[48]=M,e[49]=y,e[50]=z):z=e[50],z}function ks(t){return t.stopPropagation()}function Fs(t){return t.stopPropagation()}function Nt(t){const e=Y.c(8),{invitationId:n,onCancel:o,isCancelling:r}=t,l=r===void 0?!1:r;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(Mt,{asChild:!0,children:s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Os,children:s.jsx(Pt,{size:20})})}),e[0]=i):i=e[0];let a;e[1]!==n||e[2]!==o?(a=h=>{h.stopPropagation(),o(n)},e[1]=n,e[2]=o,e[3]=a):a=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(_t,{size:16}),e[4]=m):m=e[4];let g;return e[5]!==l||e[6]!==a?(g=s.jsxs(At,{children:[i,s.jsx(Et,{align:"end",onClick:Ls,children:s.jsxs(lt,{variant:"destructive",onClick:a,disabled:l,children:[m,"Cancel Invitation"]})})]}),e[5]=l,e[6]=a,e[7]=g):g=e[7],g}function Ls(t){return t.stopPropagation()}function Os(t){return t.stopPropagation()}function qs(){const t=Y.c(101),{data:e}=Zt(),{data:n}=Ss(),o=ws(),r=De(),{locator:l}=fe(),i=at(),[a,m]=ce.useState(null),[g,h]=ce.useState(null),[p,j]=ce.useState(""),[I,R]=ce.useState("table"),[v,N]=ce.useState("member"),[y,D]=ce.useState("asc"),d=e?.data?.members;let c;t[0]!==v?(c=f=>{v===f?D(Zs):(N(f),D("asc"))},t[0]=v,t[1]=c):c=t[1];const x=c;let A=d??[],w=n??[];if(p){const f=p.toLowerCase();A=A.filter(b=>b.user?.name?.toLowerCase().includes(f)||b.user?.email?.toLowerCase().includes(f)||b.role?.toLowerCase().includes(f)),w=w.filter(b=>b.email?.toLowerCase().includes(f)||b.role?.toLowerCase().includes(f))}if(v&&y){let f;t[2]!==y||t[3]!==v?(f=(b,_)=>{let B,de;e:switch(v){case"member":{B=b.user?.name||"",de=_.user?.name||"";break e}case"role":{B=b.role||"",de=_.role||"";break e}case"joined":{B=b.createdAt?typeof b.createdAt=="string"?b.createdAt:b.createdAt.toISOString():"",de=_.createdAt?typeof _.createdAt=="string"?_.createdAt:_.createdAt.toISOString():"";break e}default:return 0}return y==="asc"?B.localeCompare(de):de.localeCompare(B)},t[2]=y,t[3]=v,t[4]=f):f=t[4],A=[...A].sort(f)}const M=A;let z;t[5]!==i?(z=async f=>{const b=await i.organization.removeMember({memberIdOrEmail:f});if(b?.error)throw new Error(b.error.message)},t[5]=i,t[6]=z):z=t[6];let T;t[7]!==l||t[8]!==r?(T=()=>{ue("member_removed"),r.invalidateQueries({queryKey:ie.members(l)}),G.success("Member has been removed from the organization"),m(null)},t[7]=l,t[8]=r,t[9]=T):T=t[9];let K;t[10]!==z||t[11]!==T?(K={mutationFn:z,onSuccess:T,onError:Ys},t[10]=z,t[11]=T,t[12]=K):K=t[12];const E=pe(K);let k;t[13]!==i?(k=async f=>{const{memberId:b,role:_}=f,B=await i.organization.updateMemberRole({memberId:b,role:[_]});if(B?.error)throw new Error(B.error.message)},t[13]=i,t[14]=k):k=t[14];let P;t[15]!==l||t[16]!==r?(P=(f,b)=>{ue("member_role_updated",{new_role:b.role}),r.invalidateQueries({queryKey:ie.members(l)}),G.success("Member's role has been updated")},t[15]=l,t[16]=r,t[17]=P):P=t[17];let u;t[18]!==k||t[19]!==P?(u={mutationFn:k,onSuccess:P,onError:Ws},t[18]=k,t[19]=P,t[20]=u):u=t[20];const C=pe(u);let O;t[21]!==i?(O=async f=>{const{invitationId:b,role:_,email:B}=f,de=await i.organization.cancelInvitation({invitationId:b});if(de?.error)throw new Error(de.error.message);const ot=await i.organization.inviteMember({email:B,role:_});if(ot?.error)throw new Error(ot.error.message)},t[21]=i,t[22]=O):O=t[22];let $;t[23]!==l||t[24]!==r?($=(f,b)=>{ue("invitation_role_updated",{new_role:b.role}),r.invalidateQueries({queryKey:ie.invitations(l)}),G.success("Invitation role has been updated")},t[23]=l,t[24]=r,t[25]=$):$=t[25];let F;t[26]!==O||t[27]!==$?(F={mutationFn:O,onSuccess:$,onError:Hs},t[26]=O,t[27]=$,t[28]=F):F=t[28];const V=pe(F),{roles:L,customRoles:Q}=It();let q;t[29]!==Q?(q=Ds(Q),t[29]=Q,t[30]=q):q=t[30];const U=q;let J;t[31]!==L?(J=L.filter(Js),t[31]=L,t[32]=J):J=t[32];const H=J;let W;t[33]===Symbol.for("react.memo_cache_sentinel")?(W={id:"member",header:"Member",render:Gs,cellClassName:"flex-1 min-w-0",sortable:!0},t[33]=W):W=t[33];let le;t[34]!==U||t[35]!==H||t[36]!==V||t[37]!==C?(le={id:"role",header:"Role",render:f=>f.type==="member"?s.jsx(Ke,{role:f.data.role,memberId:f.data.id,isOwner:f.data.role==="owner",roleColorMap:U,selectableRoles:H,onRoleChange:(b,_)=>C.mutate({memberId:b,role:_}),className:"w-36"}):s.jsx(Ke,{role:f.data.role,memberId:f.data.id,isOwner:!1,roleColorMap:U,selectableRoles:H,onRoleChange:(b,_)=>V.mutate({invitationId:b,role:_,email:f.data.email}),className:"w-36"}),cellClassName:"w-36 shrink-0",sortable:!0},t[34]=U,t[35]=H,t[36]=V,t[37]=C,t[38]=le):le=t[38];let xe,Z;t[39]===Symbol.for("react.memo_cache_sentinel")?(xe={id:"tags",header:"Tags",render:Us,cellClassName:"w-40 shrink-0"},Z={id:"joined",header:"Joined",render:Qs,cellClassName:"w-48 shrink-0",sortable:!0},t[39]=xe,t[40]=Z):(xe=t[39],Z=t[40]);let ae;t[41]!==o.cancel.isPending||t[42]!==L||t[43]!==C?(ae={id:"actions",header:"",render:f=>f.type==="member"?s.jsx(wt,{member:f.data,roles:L,onChangeRole:(b,_)=>C.mutate({memberId:b,role:_}),onRemove:m,isUpdating:C.isPending}):s.jsx(Nt,{invitationId:f.data.id,onCancel:h,isCancelling:o.cancel.isPending}),cellClassName:"w-12 shrink-0"},t[41]=o.cancel.isPending,t[42]=L,t[43]=C,t[44]=ae):ae=t[44];let me;t[45]!==le||t[46]!==ae?(me=[W,le,xe,Z,ae],t[45]=le,t[46]=ae,t[47]=me):me=t[47];const _e=me;let be;t[48]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(ys,{trigger:s.jsx(Pe,{children:"Invite Member"})})}),t[48]=be):be=t[48];const Re=be,ge=[...M.map(Vs),...w.filter(Ks).map(Bs)],oe=Ee,re=!!g;let X;t[49]===Symbol.for("react.memo_cache_sentinel")?(X=()=>h(null),t[49]=X):X=t[49];let ee;t[50]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsxs(ht,{children:[s.jsx(pt,{children:"Cancel Invitation"}),s.jsx(xt,{children:"Are you sure you want to cancel this invitation? The invitee will no longer be able to join the organization with this invitation."})]}),t[50]=ee):ee=t[50];let te;t[51]===Symbol.for("react.memo_cache_sentinel")?(te=s.jsx(bt,{children:"Keep Invitation"}),t[51]=te):te=t[51];let se;t[52]!==o.cancel||t[53]!==g?(se=()=>{g&&(o.cancel.mutate(g),h(null))},t[52]=o.cancel,t[53]=g,t[54]=se):se=t[54];let S;t[55]!==o.cancel.isPending||t[56]!==se?(S=s.jsxs(ut,{children:[ee,s.jsxs(ft,{children:[te,s.jsx(gt,{onClick:se,disabled:o.cancel.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Invitation"})]})]}),t[55]=o.cancel.isPending,t[56]=se,t[57]=S):S=t[57];let ne;t[58]!==re||t[59]!==S?(ne=s.jsx(jt,{open:re,onOpenChange:X,children:S}),t[58]=re,t[59]=S,t[60]=ne):ne=t[60];const he=!!a;let je;t[61]===Symbol.for("react.memo_cache_sentinel")?(je=()=>m(null),t[61]=je):je=t[61];let Fe;t[62]===Symbol.for("react.memo_cache_sentinel")?(Fe=s.jsxs(ht,{children:[s.jsx(pt,{children:"Remove Member"}),s.jsx(xt,{children:"Are you sure you want to remove this member from the organization? This action cannot be undone."})]}),t[62]=Fe):Fe=t[62];let Le;t[63]===Symbol.for("react.memo_cache_sentinel")?(Le=s.jsx(bt,{children:"Cancel"}),t[63]=Le):Le=t[63];let ve;t[64]!==a||t[65]!==E?(ve=()=>a&&E.mutate(a),t[64]=a,t[65]=E,t[66]=ve):ve=t[66];let Ce;t[67]!==E.isPending||t[68]!==ve?(Ce=s.jsxs(ut,{children:[Fe,s.jsxs(ft,{children:[Le,s.jsx(gt,{onClick:ve,disabled:E.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),t[67]=E.isPending,t[68]=ve,t[69]=Ce):Ce=t[69];let ye;t[70]!==he||t[71]!==Ce?(ye=s.jsx(jt,{open:he,onOpenChange:je,children:Ce}),t[70]=he,t[71]=Ce,t[72]=ye):ye=t[72];const Ge=Ee,Je=Ee,zt="flex flex-col gap-6";let Se;t[73]===Symbol.for("react.memo_cache_sentinel")?(Se=s.jsx(Ee.Title,{children:"Members"}),t[73]=Se):Se=t[73];let Oe;t[74]===Symbol.for("react.memo_cache_sentinel")?(Oe=f=>{f.key==="Escape"&&(j(""),f.target.blur())},t[74]=Oe):Oe=t[74];let we;t[75]!==p?(we=s.jsx(qt,{value:p,onChange:j,placeholder:"Search members...",className:"w-full md:w-[375px]",onKeyDown:Oe}),t[75]=p,t[76]=we):we=t[76];let qe;t[77]===Symbol.for("react.memo_cache_sentinel")?(qe=[{id:"member",label:"Name"},{id:"role",label:"Role"},{id:"joined",label:"Joined"}],t[77]=qe):qe=t[77];let Ne;t[78]!==x||t[79]!==y||t[80]!==v||t[81]!==I?(Ne=s.jsx(Ot,{viewMode:I,onViewModeChange:R,sortKey:v,sortDirection:y,onSort:x,sortOptions:qe}),t[78]=x,t[79]=y,t[80]=v,t[81]=I,t[82]=Ne):Ne=t[82];let Te;t[83]!==we||t[84]!==Ne?(Te=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[we,Ne]}),Re]}),t[83]=we,t[84]=Ne,t[85]=Te):Te=t[85];const He=I==="cards"?s.jsx("div",{children:ge.length===0?s.jsx(We,{title:"No members found",description:p?`No members match "${p}"`:"Invite members to get started."}):s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4",children:ge.map(f=>{if(f.type==="invitation")return s.jsxs(vt,{className:"transition-colors relative opacity-75",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Nt,{invitationId:f.data.id,onCancel:h,isCancelling:o.cancel.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Ve,{fallback:Qe(f.data.email),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:f.data.email}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(Ue,{variant:"outline",className:"w-fit text-amber-600 border-amber-400",children:"Pending"})}),s.jsx(Ke,{role:f.data.role,memberId:f.data.id,isOwner:!1,roleColorMap:U,selectableRoles:H,onRoleChange:(_,B)=>V.mutate({invitationId:_,role:B,email:f.data.email}),className:"w-fit"})]})]})]},`inv-${f.data.id}`);const b=f.data;return s.jsxs(vt,{className:"transition-colors relative",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(wt,{member:b,roles:L,onChangeRole:(_,B)=>C.mutate({memberId:_,role:B}),onRemove:m,isUpdating:C.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Ve,{url:b.user?.image??void 0,fallback:Qe(b.user?.name),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:b.user?.name||"Unknown"}),s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:b.user?.email}),s.jsx(Ke,{role:b.role,memberId:b.id,isOwner:b.role==="owner",roleColorMap:U,selectableRoles:H,onRoleChange:(_,B)=>C.mutate({memberId:_,role:B}),className:"w-fit"}),s.jsx(Rt,{memberId:b.id,maxDisplay:3})]})]})]},b.id)})})}):s.jsx(Bt,{columns:_e,data:ge,isLoading:!1,sortKey:v,sortDirection:y,onSort:x,emptyState:p?s.jsx(We,{title:"No members found",description:`No members match "${p}"`}):s.jsx(We,{title:"No members found",description:"Invite members to get started."})});let Ie;t[86]!==Se||t[87]!==Te||t[88]!==He?(Ie=s.jsxs("div",{className:zt,children:[Se,Te,He]}),t[86]=Se,t[87]=Te,t[88]=He,t[89]=Ie):Ie=t[89];let Ae;t[90]!==Je.Body||t[91]!==Ie?(Ae=s.jsx(Je.Body,{children:Ie}),t[90]=Je.Body,t[91]=Ie,t[92]=Ae):Ae=t[92];let Me;t[93]!==Ge.Content||t[94]!==Ae?(Me=s.jsx(Ge.Content,{children:Ae}),t[93]=Ge.Content,t[94]=Ae,t[95]=Me):Me=t[95];let Be;return t[96]!==oe||t[97]!==ne||t[98]!==ye||t[99]!==Me?(Be=s.jsxs(oe,{children:[ne,ye,Me]}),t[96]=oe,t[97]=ne,t[98]=ye,t[99]=Me,t[100]=Be):Be=t[100],Be}function Bs(t){return{type:"invitation",data:t}}function Ks(t){return t.status==="pending"}function Vs(t){return{type:"member",data:t}}function Qs(t){return t.type==="member"?s.jsx("span",{className:"text-sm text-foreground",children:t.data.createdAt?$s(t.data.createdAt):"N/A"}):s.jsx(Ue,{variant:"outline",children:"Pending"})}function Us(t){return t.type==="member"?s.jsx(Rt,{memberId:t.data.id,maxDisplay:2}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}function Gs(t){return t.type==="member"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ve,{url:t.data.user?.image??void 0,fallback:Qe(t.data.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.user?.name||"Unknown"}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.data.user?.email})]})]}):s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ve,{fallback:Qe(t.data.email),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.email}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:"Invitation sent"})]})]})}function Js(t){return t.role!=="owner"}function Hs(t,e){ue("invitation_role_update_failed",{new_role:e.role,error:t instanceof Error?t.message:String(t)}),G.error(t instanceof Error?t.message:"Failed to update invitation role")}function Ws(t,e){ue("member_role_update_failed",{new_role:e.role,error:t instanceof Error?t.message:String(t)}),G.error(t instanceof Error?t.message:"Failed to update role")}function Ys(t){ue("member_remove_failed",{error:t instanceof Error?t.message:String(t)}),G.error(t instanceof Error?t.message:"Failed to remove member")}function Zs(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Ln(){const t=Y.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Ee,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:"Failed to load members"})})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Lt,{fallback:e,children:s.jsx(ce.Suspense,{fallback:s.jsx(Ee,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(Xe,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(qs,{})})}),t[1]=n):n=t[1],n}export{Ln as default};
@@ -1,4 +1,4 @@
1
- import{r as a,bc as D,e as Me,j as _,_ as te}from"./index-Dcg8Qevd.js";import{S as me}from"./index-CZLTTN-z.js";function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Pe(e){if(Array.isArray(e))return e}function Re(e,t,r){return(t=Le(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Se(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,u,l=[],c=!0,g=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(O){g=!0,o=O}finally{try{if(!c&&r.return!=null&&(u=r.return(),Object(u)!==u))return}finally{if(g)throw o}}return l}}function xe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as a,bc as D,e as Me,j as _,_ as te}from"./index-DGBhnElr.js";import{S as me}from"./index-bLj_vX-5.js";function ue(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Pe(e){if(Array.isArray(e))return e}function Re(e,t,r){return(t=Le(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Se(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,i,u,l=[],c=!0,g=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);c=!0);}catch(O){g=!0,o=O}finally{try{if(!c&&r.return!=null&&(u=r.return(),Object(u)!==u))return}finally{if(g)throw o}}return l}}function xe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ce(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function se(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ce(Object(r),!0).forEach(function(n){Re(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ce(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Te(e,t){if(e==null)return{};var r,n,o=_e(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _e(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Ce(e,t){return Pe(e)||Se(e,t)||Ve(e,t)||xe()}function Ie(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Le(e){var t=Ie(e,"string");return typeof t=="symbol"?t:t+""}function Ve(e,t){if(e){if(typeof e=="string")return ue(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ue(e,t):void 0}}function Ae(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function le(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function fe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?le(Object(r),!0).forEach(function(n){Ae(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function $e(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,i){return i(o)},n)}}function K(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,l=new Array(u),c=0;c<u;c++)l[c]=arguments[c];return t.apply(r,[].concat(o,l))}}}function Q(e){return{}.toString.call(e).includes("Object")}function De(e){return!Object.keys(e).length}function q(e){return typeof e=="function"}function Ne(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ze(e,t){return Q(t)||T("changeType"),Object.keys(t).some(function(r){return!Ne(e,r)})&&T("changeField"),t}function Ke(e){q(e)||T("selectorType")}function ke(e){q(e)||Q(e)||T("handlerType"),Q(e)&&Object.values(e).some(function(t){return!q(t)})&&T("handlersType")}function qe(e){e||T("initialIsRequired"),Q(e)||T("initialType"),De(e)&&T("initialContent")}function We(e,t){throw new Error(e[t]||e.default)}var Fe={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},T=K(We)(Fe),J={changes:ze,selector:Ke,handler:ke,initial:qe};function Ue(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};J.initial(e),J.handler(t);var r={current:e},n=K(He)(r,t),o=K(Be)(r),i=K(J.changes)(e),u=K(Je)(r);function l(){var g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(O){return O};return J.selector(g),g(r.current)}function c(g){$e(n,o,i,u)(g)}return[l,c]}function Je(e,t){return q(t)?t(e.current):t}function Be(e,t){return e.current=fe(fe({},e.current),t),t}function He(e,t,r){return q(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var Qe={create:Ue},Ge={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Ye(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,l=new Array(u),c=0;c<u;c++)l[c]=arguments[c];return t.apply(r,[].concat(o,l))}}}function Xe(e){return{}.toString.call(e).includes("Object")}function Ze(e){return e||de("configIsRequired"),Xe(e)||de("configType"),e.urls?(et(),{paths:{vs:e.urls.monacoBase}}):e}function et(){console.warn(he.deprecation)}function tt(e,t){throw new Error(e[t]||e.default)}var he={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
3
3
  You are using deprecated way of configuration.
4
4