decocms 2.293.7 → 2.293.8

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 (219) hide show
  1. package/dist/client/assets/{AlertCircle-DXfdk9MK.js → AlertCircle-DveGq_Ka.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-m25Ex3xE.js → ArrowNarrowLeft-DHWYg1cd.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-DOO4R0VI.js → ArrowUpRight-CCBySLzZ.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-BC9E8CH0.js → CheckCircle-6bGazfo7.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-0xFW1Tjk.js → ChevronDown-Bg0fGsAy.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-Da2pMeyD.js → ChevronRight-DMa-ECep.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-C8WLqMFJ.js → ChevronUp-hL_C00tb.js} +1 -1
  8. package/dist/client/assets/{Container-BuB3esl0.js → Container-L4zxxTEg.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-C2eXnxdz.js → DotsVertical-DCxBI0BW.js} +1 -1
  10. package/dist/client/assets/{LinkExternal01-BoMA8nX9.js → LinkExternal01-BQ6T0Nws.js} +1 -1
  11. package/dist/client/assets/{Lock01-D-9xfOJy.js → Lock01-0zry6wgC.js} +1 -1
  12. package/dist/client/assets/{Palette-B95ZD3_M.js → Palette-Cd-fSUE0.js} +1 -1
  13. package/dist/client/assets/{Play-DINvkeGT.js → Play-PF2rNc4W.js} +1 -1
  14. package/dist/client/assets/{Plus-Cz_QF-nO.js → Plus-DYo953wk.js} +1 -1
  15. package/dist/client/assets/{RefreshCcw01-C9pW6sTt.js → RefreshCcw01-D1Vi0tae.js} +1 -1
  16. package/dist/client/assets/{SearchMd-BRBTca_N.js → SearchMd-BxcVY0hk.js} +1 -1
  17. package/dist/client/assets/{Settings02-rRANi0Px.js → Settings02-DfEUH8Vu.js} +1 -1
  18. package/dist/client/assets/{Shield01-Ca51KHJr.js → Shield01-DkQy31Nt.js} +1 -1
  19. package/dist/client/assets/{Star01-DeIf7B7B.js → Star01-B6ksoZr0.js} +1 -1
  20. package/dist/client/assets/{Sun-DhTV9qec.js → Sun-vFyK4_Ll.js} +1 -1
  21. package/dist/client/assets/{Tool01-Ba9DB62y.js → Tool01-Cb8li5k6.js} +1 -1
  22. package/dist/client/assets/{Trash01--9QdImzp.js → Trash01-CqSlmOZQ.js} +1 -1
  23. package/dist/client/assets/{User01-Blfyt5S4.js → User01-BHjwWDd7.js} +1 -1
  24. package/dist/client/assets/{Users03-BFWP6Eo7.js → Users03-CsGzKQhD.js} +1 -1
  25. package/dist/client/assets/{X-Bq9xP96R.js → X-BSw526sh.js} +1 -1
  26. package/dist/client/assets/{XCircle-Cc09MSdO.js → XCircle-DGL-4U6P.js} +1 -1
  27. package/dist/client/assets/{XClose-CVgNkrOC.js → XClose-DfM5GjZF.js} +1 -1
  28. package/dist/client/assets/{Zap-jDm5-swv.js → Zap-D55ucbXC.js} +1 -1
  29. package/dist/client/assets/{ZapSquare-CLMBz7MJ.js → ZapSquare-T3gHYvlz.js} +1 -1
  30. package/dist/client/assets/{accordion-DAgtJ1RN.js → accordion-BEf7bBJ7.js} +1 -1
  31. package/dist/client/assets/{agent-icon-Bei3Y6Nv.js → agent-icon-ChIrIWeW.js} +1 -1
  32. package/dist/client/assets/{agents-list-BEcGQnnc.js → agents-list-DdL2YfiV.js} +1 -1
  33. package/dist/client/assets/ai-providers-ObNEA0nx.js +1 -0
  34. package/dist/client/assets/{alert-dialog-BVSxM9YJ.js → alert-dialog-D6jDWQW-.js} +1 -1
  35. package/dist/client/assets/{auth-catchall-DsAh3g7W.js → auth-catchall-M0Jr5kFb.js} +1 -1
  36. package/dist/client/assets/{automation-list-row-OM3ZLG5b.js → automation-list-row-Csh5lumM.js} +1 -1
  37. package/dist/client/assets/{automations-Bfdp-lBm.js → automations-obZ5ZVAW.js} +1 -1
  38. package/dist/client/assets/{avatar-LDMZpKRg.js → avatar-CKkXwPlY.js} +1 -1
  39. package/dist/client/assets/{badge-D4FFGy4o.js → badge-yfBx4pKw.js} +1 -1
  40. package/dist/client/assets/{brand-context-DoIQ0i3H.js → brand-context-DVAt0TKP.js} +1 -1
  41. package/dist/client/assets/{card-Du9Iuv0G.js → card-e-NpS5kl.js} +1 -1
  42. package/dist/client/assets/{chat-context-Cu3HdQoP.js → chat-context-GRw0JUF-.js} +1 -1
  43. package/dist/client/assets/{checkbox-D3HYUnZN.js → checkbox-BWpfDwfi.js} +1 -1
  44. package/dist/client/assets/{collection-detail-C_Qc4MbL.js → collection-detail-DOCM2IPO.js} +1 -1
  45. package/dist/client/assets/{collection-display-button-SRtbYzi1.js → collection-display-button-BANI3stw.js} +1 -1
  46. package/dist/client/assets/{collection-search-BvT81eua.js → collection-search-DyFOds5R.js} +1 -1
  47. package/dist/client/assets/{collection-search-jeIjsobA.js → collection-search-w3FCfjcj.js} +1 -1
  48. package/dist/client/assets/{collection-table-wrapper-D1vIquPS.js → collection-table-wrapper-Ro_jHI87.js} +1 -1
  49. package/dist/client/assets/{collection-tabs-DPgWxe2m.js → collection-tabs-BI0p7qpI.js} +1 -1
  50. package/dist/client/assets/{collections-Di3Xclr5.js → collections-FijcH0pF.js} +1 -1
  51. package/dist/client/assets/{command-CqgC97xW.js → command-nLSAlSuK.js} +1 -1
  52. package/dist/client/assets/{connection-card-DqAomVSf.js → connection-card-wj_vHsSr.js} +1 -1
  53. package/dist/client/assets/{connection-detail-CGFhkom4.js → connection-detail-BvUUuCYo.js} +1 -1
  54. package/dist/client/assets/{connection-form-helpers-Bf4nHE9_.js → connection-form-helpers-WMrQb6eb.js} +1 -1
  55. package/dist/client/assets/{connections-nP3l3Xn5.js → connections-D0bzAtOI.js} +1 -1
  56. package/dist/client/assets/{constants-Bymra3Z3.js → constants-ChdU9xvz.js} +1 -1
  57. package/dist/client/assets/{constants-CRmflr8M.js → constants-D7vrREO4.js} +1 -1
  58. package/dist/client/assets/{dialog-Bnn50qLi.js → dialog-B0QYUD88.js} +1 -1
  59. package/dist/client/assets/{domain-settings-DyvTdw8S.js → domain-settings-9Q2boaGd.js} +1 -1
  60. package/dist/client/assets/{drawer-t00j5Ew9.js → drawer-B9QExE6j.js} +1 -1
  61. package/dist/client/assets/{dropdown-menu-CqTx-nNo.js → dropdown-menu-Dqqv-DxC.js} +1 -1
  62. package/dist/client/assets/{dynamic-plugin-layout-aon9v2dL.js → dynamic-plugin-layout-BVAHZf_l.js} +1 -1
  63. package/dist/client/assets/{empty-state-DQOABzrz.js → empty-state-Brbj3WdC.js} +1 -1
  64. package/dist/client/assets/{empty-state-BCisGTAH.js → empty-state-CtpU7jLB.js} +1 -1
  65. package/dist/client/assets/{extract-connection-data-Db8ZLaq1.js → extract-connection-data-BdGRQa2R.js} +1 -1
  66. package/dist/client/assets/{features-B0-ag3C3.js → features-CW2iqt4o.js} +1 -1
  67. package/dist/client/assets/{form-B5N66yji.js → form-CEqJ4N_7.js} +1 -1
  68. package/dist/client/assets/{general-C2wzdkNU.js → general-DfPdaroT.js} +1 -1
  69. package/dist/client/assets/{index-CDTT3e7s.js → index-B6VjlsLE.js} +1 -1
  70. package/dist/client/assets/index-B6jYwthz.js +1 -0
  71. package/dist/client/assets/{index-BOmVBt-L.js → index-B9-yB4gn.js} +1 -1
  72. package/dist/client/assets/{index-C31S4jpX.js → index-Bf3SCl0m.js} +3 -3
  73. package/dist/client/assets/{index-CzZ-Z-oS.js → index-BsAZNtTY.js} +1 -1
  74. package/dist/client/assets/{index-skEMlwzP.js → index-C-hC1pHz.js} +1 -1
  75. package/dist/client/assets/{index-YLWObp9P.js → index-C2C_Qiwh.js} +1 -1
  76. package/dist/client/assets/{index-SH970SJ0.js → index-CZs7_uJZ.js} +1 -1
  77. package/dist/client/assets/{index-D_S2FIdU.js → index-CwWV7ZbX.js} +1 -1
  78. package/dist/client/assets/{index-_ffZL8NJ.js → index-DCHF8zOG.js} +1 -1
  79. package/dist/client/assets/{index-DzRCCgl0.js → index-DRficqI-.js} +1 -1
  80. package/dist/client/assets/{index-CRBLJNJY.js → index-DcVnAzZR.js} +1 -1
  81. package/dist/client/assets/{index-CCSxUcSR.js → index-O-xThSQt.js} +2 -2
  82. package/dist/client/assets/{index-D0dh_hfJ.js → index-VDFVZp7i.js} +1 -1
  83. package/dist/client/assets/{index-DZ4C7ecc.js → index-dnp-3LXJ.js} +1 -1
  84. package/dist/client/assets/{index-BwHYJNqQ.js → index-wTKQdlAH.js} +1 -1
  85. package/dist/client/assets/{infiniteQueryObserver-COI6ybpz.js → infiniteQueryObserver-BVq9Pm2a.js} +1 -1
  86. package/dist/client/assets/{input-CGOXGU1T.js → input-oRQz03qA.js} +1 -1
  87. package/dist/client/assets/{integration-icon-CsIISZIk.js → integration-icon-Dl850mlU.js} +1 -1
  88. package/dist/client/assets/{label-D4SEK3ff.js → label-C1-enMbO.js} +1 -1
  89. package/dist/client/assets/{layout-4V4C6eb5.js → layout-DNdIWyZp.js} +1 -1
  90. package/dist/client/assets/{lean-canvas-recruit-modal-Bh9iIV1t.js → lean-canvas-recruit-modal-CRZY0Eb-.js} +1 -1
  91. package/dist/client/assets/{login-DzbRx3GK.js → login-BfUv2H8w.js} +1 -1
  92. package/dist/client/assets/{members-S87fVUKE.js → members-CCgRCx0J.js} +1 -1
  93. package/dist/client/assets/{monaco-editor-lCTWnCWQ.js → monaco-editor-u9gnS6t8.js} +1 -1
  94. package/dist/client/assets/{monitoring-stats-row-Bdkg2lXe.js → monitoring-stats-row--8mo81f4.js} +1 -1
  95. package/dist/client/assets/{oauth-callback-gRWCWpy9.js → oauth-callback-CXfLfK0p.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-ai-provider-pudhCVgi.js → oauth-callback-ai-provider-CBc0oyoe.js} +1 -1
  97. package/dist/client/assets/{onboarding-D_RZPnOJ.js → onboarding-CvXVvrci.js} +1 -1
  98. package/dist/client/assets/{org-layout-CyPgK3Oz.js → org-layout-uft5TcR0.js} +1 -1
  99. package/dist/client/assets/{org-plugin-layout-CuqX6Tv7.js → org-plugin-layout-BCAbckW3.js} +1 -1
  100. package/dist/client/assets/{pair-B_xTWu6o.js → pair-D89tt-Oa.js} +1 -1
  101. package/dist/client/assets/{plugin-empty-state-31-4FfVV.js → plugin-empty-state-CdC4a2f5.js} +1 -1
  102. package/dist/client/assets/{plugin-header-SM3MfaW8.js → plugin-header-C436xgxX.js} +1 -1
  103. package/dist/client/assets/{plugin-layout-oCouCQJ1.js → plugin-layout-Ck_aFT7l.js} +1 -1
  104. package/dist/client/assets/{popover-CA7wjTzr.js → popover-Co2M62hE.js} +1 -1
  105. package/dist/client/assets/{profile-D1kET1t3.js → profile-D8aA_SfN.js} +1 -1
  106. package/dist/client/assets/{project-app-view-BnnlNd0S.js → project-app-view-BQN6gYM4.js} +1 -1
  107. package/dist/client/assets/registry-F9ZprpXD.js +2 -0
  108. package/dist/client/assets/{registry-layout-C7uUKQwM.js → registry-layout-CDOchZNA.js} +1 -1
  109. package/dist/client/assets/{required-auth-layout-BARTxmgG.js → required-auth-layout-WPul4l6C.js} +1 -1
  110. package/dist/client/assets/{reset-password-DldtE7pq.js → reset-password-CCvsOolV.js} +1 -1
  111. package/dist/client/assets/{roles-jDo56Odb.js → roles-CfoKq5oL.js} +1 -1
  112. package/dist/client/assets/{scroll-area-CO1r6tWJ.js → scroll-area-ePY6ucBL.js} +1 -1
  113. package/dist/client/assets/{search-input-ChGtPve4.js → search-input-BA02UXZa.js} +1 -1
  114. package/dist/client/assets/{select-CuiyoiL_.js → select-Cq_PvnKV.js} +1 -1
  115. package/dist/client/assets/{select-model-DnX3-EsU.js → select-model-BpJHvnyq.js} +1 -1
  116. package/dist/client/assets/{settings-layout-CTMYFxx3.js → settings-layout-Dl8RrXAU.js} +1 -1
  117. package/dist/client/assets/{settings-section-BmjPsExf.js → settings-section-BzS4xloW.js} +1 -1
  118. package/dist/client/assets/{shell-layout-CWH_Y15a.js → shell-layout-DOMzE0SQ.js} +1 -1
  119. package/dist/client/assets/{skeleton-BodtHV9I.js → skeleton-YcXGprZE.js} +1 -1
  120. package/dist/client/assets/{sso-C2OaFdPj.js → sso-pG-n5D-C.js} +1 -1
  121. package/dist/client/assets/{store-DQliQdSk.js → store-DsWe3E_F.js} +1 -1
  122. package/dist/client/assets/store-registry-C1Sfy2sE.js +2 -0
  123. package/dist/client/assets/{switch-CdHRMTW9.js → switch-BjSXi4cA.js} +1 -1
  124. package/dist/client/assets/{table-DVtFTUHZ.js → table-q-k_hgAt.js} +1 -1
  125. package/dist/client/assets/{tabs-BgJeSqk4.js → tabs-C3iMtl0f.js} +1 -1
  126. package/dist/client/assets/{task-status-CfDV-ew7.js → task-status-jHWa41cV.js} +1 -1
  127. package/dist/client/assets/{textarea-DzkVG7JD.js → textarea-BSpBSpMd.js} +1 -1
  128. package/dist/client/assets/{toggle-group-qQMNUT-A.js → toggle-group-Z4_K_UMR.js} +1 -1
  129. package/dist/client/assets/{tools-list-m5KatPL5.js → tools-list-DVlfSdCs.js} +1 -1
  130. package/dist/client/assets/{tooltip-BqNUzMrI.js → tooltip-CZKTj_88.js} +1 -1
  131. package/dist/client/assets/{types-AfFc_tMd.js → types-CTCqQWQm.js} +1 -1
  132. package/dist/client/assets/{use-ai-providers-BK_veNO4.js → use-ai-providers-Bi5zwgNs.js} +1 -1
  133. package/dist/client/assets/{use-collections-DwZut8wL.js → use-collections-DpHr_hEj.js} +1 -1
  134. package/dist/client/assets/{use-connection-BJpbsOIS.js → use-connection-Dkzl6ATr.js} +1 -1
  135. package/dist/client/assets/{use-copy-Bo8GL7eE.js → use-copy-CpuPfSHn.js} +1 -1
  136. package/dist/client/assets/{use-create-virtual-mcp-D6JQCBq2.js → use-create-virtual-mcp-BDDTbSDu.js} +1 -1
  137. package/dist/client/assets/{use-decopilot-events-C5NKtuSG.js → use-decopilot-events-DfNhZiit.js} +1 -1
  138. package/dist/client/assets/{use-delete-connection-DxaPbg-L.js → use-delete-connection-DzmSSfSC.js} +1 -1
  139. package/dist/client/assets/{use-infinite-scroll-x7s39dsa.js → use-infinite-scroll-ZB6EnEL9.js} +1 -1
  140. package/dist/client/assets/{use-list-state-BnhDBtx8.js → use-list-state-BxmWtMlf.js} +1 -1
  141. package/dist/client/assets/{use-mcp-tools-CpGxrE2n.js → use-mcp-tools-dN493Per.js} +1 -1
  142. package/dist/client/assets/{use-members-CguSIAh8.js → use-members-BLQ9W5Dc.js} +1 -1
  143. package/dist/client/assets/{use-navigate-to-agent-DL1SSMeI.js → use-navigate-to-agent-CBd-r96N.js} +1 -1
  144. package/dist/client/assets/{use-org-sso-BRsOtHzg.js → use-org-sso-Fy8p-ia7.js} +1 -1
  145. package/dist/client/assets/{use-organization-roles-CIvbWsgj.js → use-organization-roles-BY5zQhyp.js} +1 -1
  146. package/dist/client/assets/{use-organization-settings-DXVGYoSK.js → use-organization-settings-BiTIuKde.js} +1 -1
  147. package/dist/client/assets/{use-registry-connections-BKsU7-eH.js → use-registry-connections-B1h0NOZd.js} +1 -1
  148. package/dist/client/assets/{use-status-sounds-BCtmxJQJ.js → use-status-sounds-ChN-g_Kb.js} +1 -1
  149. package/dist/client/assets/{use-tasks-BImSKPbl.js → use-tasks-CMJbyrNa.js} +1 -1
  150. package/dist/client/assets/{use-view-mode-R5lOl_7l.js → use-view-mode-BglVjHEt.js} +1 -1
  151. package/dist/client/assets/{use-virtual-mcp-mfRFtB08.js → use-virtual-mcp-Cn-xT_JW.js} +1 -1
  152. package/dist/client/assets/useInfiniteQuery-BTmoYoSz.js +1 -0
  153. package/dist/client/assets/useSuspenseInfiniteQuery-D3qWdmTu.js +1 -0
  154. package/dist/client/assets/{user-DdWZGaQJ.js → user-BnKZSLel.js} +1 -1
  155. package/dist/client/assets/{view-mode-toggle-DhxRxMVU.js → view-mode-toggle-BueYVsWt.js} +1 -1
  156. package/dist/client/assets/{workflow-BIU8orVo.js → workflow-DbzdHDRp.js} +1 -1
  157. package/dist/client/assets/workflow-detail-D1gDF37Z.js +1 -0
  158. package/dist/client/index.html +1 -1
  159. package/dist/server/cli.js +3 -3
  160. package/dist/server/migrate.js +88 -88
  161. package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
  162. package/dist/server/node_modules/ansi-styles/index.js +223 -0
  163. package/dist/server/node_modules/ansi-styles/package.json +54 -0
  164. package/dist/server/node_modules/ansi-styles/readme.md +173 -0
  165. package/dist/server/node_modules/environment/index.d.ts +74 -0
  166. package/dist/server/node_modules/environment/index.js +47 -0
  167. package/dist/server/node_modules/{slice-ansi → environment}/license +0 -1
  168. package/dist/server/node_modules/environment/package.json +74 -0
  169. package/dist/server/node_modules/environment/readme.md +94 -0
  170. package/dist/server/node_modules/escape-string-regexp/index.d.ts +18 -0
  171. package/dist/server/node_modules/escape-string-regexp/index.js +11 -0
  172. package/dist/server/node_modules/escape-string-regexp/license +9 -0
  173. package/dist/server/node_modules/escape-string-regexp/package.json +43 -0
  174. package/dist/server/node_modules/escape-string-regexp/readme.md +29 -0
  175. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  176. package/dist/server/node_modules/is-fullwidth-code-point/index.js +12 -0
  177. package/dist/server/node_modules/is-fullwidth-code-point/license +9 -0
  178. package/dist/server/node_modules/is-fullwidth-code-point/package.json +53 -0
  179. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +31 -0
  180. package/dist/server/node_modules/is-unicode-supported/index.d.ts +12 -0
  181. package/dist/server/node_modules/is-unicode-supported/index.js +21 -0
  182. package/dist/server/node_modules/is-unicode-supported/license +9 -0
  183. package/dist/server/node_modules/is-unicode-supported/package.json +47 -0
  184. package/dist/server/node_modules/is-unicode-supported/readme.md +35 -0
  185. package/dist/server/node_modules/mimic-fn/index.d.ts +54 -0
  186. package/dist/server/node_modules/mimic-fn/index.js +13 -0
  187. package/dist/server/node_modules/mimic-fn/license +9 -0
  188. package/dist/server/node_modules/{onetime → mimic-fn}/package.json +15 -16
  189. package/dist/server/node_modules/mimic-fn/readme.md +69 -0
  190. package/dist/server/node_modules/pg-int8/LICENSE +13 -0
  191. package/dist/server/node_modules/pg-int8/README.md +16 -0
  192. package/dist/server/node_modules/pg-int8/index.js +100 -0
  193. package/dist/server/node_modules/pg-int8/package.json +24 -0
  194. package/dist/server/node_modules/postgres-date/index.js +116 -0
  195. package/dist/server/node_modules/postgres-date/license +21 -0
  196. package/dist/server/node_modules/postgres-date/package.json +33 -0
  197. package/dist/server/node_modules/postgres-date/readme.md +49 -0
  198. package/dist/server/node_modules/postgres-interval/index.d.ts +20 -0
  199. package/dist/server/node_modules/postgres-interval/index.js +125 -0
  200. package/dist/server/node_modules/postgres-interval/license +21 -0
  201. package/dist/server/node_modules/postgres-interval/package.json +36 -0
  202. package/dist/server/node_modules/postgres-interval/readme.md +48 -0
  203. package/package.json +1 -1
  204. package/dist/client/assets/ai-providers-Dp405boW.js +0 -1
  205. package/dist/client/assets/index-ShFS2Xm9.js +0 -1
  206. package/dist/client/assets/registry-D3F48l8n.js +0 -2
  207. package/dist/client/assets/store-registry-BFBR78Ii.js +0 -2
  208. package/dist/client/assets/useInfiniteQuery-W0R8FLKd.js +0 -1
  209. package/dist/client/assets/useSuspenseInfiniteQuery-Vv5DMGlP.js +0 -1
  210. package/dist/client/assets/workflow-detail-cJknrHKx.js +0 -1
  211. package/dist/server/node_modules/onetime/index.d.ts +0 -64
  212. package/dist/server/node_modules/onetime/index.js +0 -44
  213. package/dist/server/node_modules/onetime/readme.md +0 -94
  214. package/dist/server/node_modules/slice-ansi/index.d.ts +0 -19
  215. package/dist/server/node_modules/slice-ansi/index.js +0 -260
  216. package/dist/server/node_modules/slice-ansi/package.json +0 -59
  217. package/dist/server/node_modules/slice-ansi/readme.md +0 -54
  218. package/dist/server/node_modules/slice-ansi/tokenize-ansi.js +0 -752
  219. /package/dist/server/node_modules/{onetime → ansi-styles}/license +0 -0
@@ -1,4 +1,4 @@
1
- import{e as M,j as t,s as z,o as je,b as ze,r as O,K as ne,n as Fe,a as He,c as he,B as oe,t as V,x as ie,G as We,F as Je,v as ve,P as Xe,l as xe,w as Ze,f as et}from"./index-CCSxUcSR.js";import{S as re,u as $,d as we,W as Be,j as ye}from"./constants-Bymra3Z3.js";import{a as Ne}from"./use-navigate-to-agent-DL1SSMeI.js";import{a as ce,b as le,c as de,d as ue,D as tt}from"./dialog-Bnn50qLi.js";import{i as Ae}from"./RefreshCcw01-C9pW6sTt.js";import{C as qe}from"./collection-search-BvT81eua.js";import{C as nt}from"./checkbox-D3HYUnZN.js";import{b as Ee,u as st}from"./use-connection-BJpbsOIS.js";import{i as it}from"./Lock01-D-9xfOJy.js";import{n as ot}from"./agent-icon-Bei3Y6Nv.js";import{e as at}from"./extract-connection-data-Db8ZLaq1.js";import{b as Se,a as Oe,c as Le,D as Re}from"./drawer-t00j5Ew9.js";import{u as Me}from"./tooltip-BqNUzMrI.js";import{I as ke}from"./integration-icon-CsIISZIk.js";import{u as rt,d as Qe}from"./use-mcp-tools-CpGxrE2n.js";import{a as Ue,b as ct}from"./use-virtual-mcp-mfRFtB08.js";function ae(i){const e=M.c(4),{size:n,className:a}=i;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=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]=c):c=e[0];let s;return e[1]!==a||e[2]!==n?(s=t.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:a,children:c}),e[1]=a,e[2]=n,e[3]=s):s=e[3],s}function lt(i){return i.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function dt(){const i=await fetch("/api/deco-sites");if(!i.ok){const e=await i.json().catch(()=>({}));throw new Error(e.error??`Failed to load sites (${i.status})`)}return i.json()}function Kt(i){const e=M.c(65),{open:n,onOpenChange:a,onBack:c}=i,{org:s}=z(),l=Ne(),m=je(),{data:f}=ze.useSession(),[x,h]=O.useState(null),[T,d]=O.useState("");let u;e[0]!==s.id?(u={connectionId:re,orgId:s.id},e[0]=s.id,e[1]=u):u=e[1];const p=$(u);let r;e[2]!==f?.user?.email?(r=ne.decoSites(f?.user?.email),e[2]=f?.user?.email,e[3]=r):r=e[3];const g=n&&!!f?.user?.email;let C;e[4]!==r||e[5]!==g?(C={queryKey:r,queryFn:dt,enabled:g,staleTime:6e4,retry:!1},e[4]=r,e[5]=g,e[6]=C):C=e[6];const{data:_,isLoading:N,error:b}=Fe(C),I=_?.sites??[];let o;e[7]!==a?(o=w=>{w||(h(null),d("")),a(w)},e[7]=a,e[8]=o):o=e[8];const y=o;let A;e[9]!==T?(A=w=>w.name.toLowerCase().includes(T.toLowerCase())||w.domains?.[0]?.domain.toLowerCase().includes(T.toLowerCase()),e[9]=T,e[10]=A):A=e[10];const j=I.filter(A),E=!x||j.some(w=>w.name===x);let v;e[11]!==p||e[12]!==s.id?(v=async w=>{V("deco_site_import_started",{site_name:w});const G=await fetch("/api/deco-sites/connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:w,orgId:s.id})}),D=await G.json().catch(ft);if(!G.ok)throw new Error(D.error??`Failed to create connection (${G.status})`);const L=D.connId;if(!L)throw new Error("Server did not return a connection ID");const ge=D.icon??null,te=lt(w),Pe=await p.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:w,description:"Imported from deco.cx",pinned:!0,icon:ge??null,subtype:"project",metadata:{instructions:null,enabled_plugins:[],ui:{banner:null,bannerColor:"#22C55E",icon:ge,themeColor:"#22C55E",slug:te,pinnedViews:[{connectionId:L,toolName:"file_explorer",label:"Preview",icon:null},{connectionId:L,toolName:"fetch_assets",label:"Assets",icon:null},{connectionId:L,toolName:"get_monitor_data",label:"Monitor",icon:null},{connectionId:L,toolName:"list_pull_requests",label:"Pull Requests",icon:null},{connectionId:L,toolName:"list_releases",label:"Releases",icon:null}],layout:{defaultMainView:{type:"ext-apps",id:L,toolName:"file_explorer"}}}},connections:[{connection_id:L}]}}}),Ge=Pe.structuredContent??Pe;return{slug:te,virtualMcpId:Ge.item.id,connId:L,item:Ge.item}},e[11]=p,e[12]=s.id,e[13]=v):v=e[13];let S;e[14]!==p||e[15]!==y||e[16]!==l||e[17]!==s.id||e[18]!==m?(S=w=>{const{slug:G,virtualMcpId:D,item:L}=w;V("deco_site_import_succeeded",{site_name:L.title,virtual_mcp_id:D,slug:G}),m.setQueryData(ne.collectionItem(p,s.id,"","VIRTUAL_MCP",D),{item:L}),m.invalidateQueries({predicate:ge=>{const te=ge.queryKey;return te[1]===s.id&&te[3]==="collection"&&te[4]==="VIRTUAL_MCP"}}),m.invalidateQueries({queryKey:ne.projects(s.id)}),ie.success(`Imported ${G} from deco.cx`),y(!1),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),l(D)},e[14]=p,e[15]=y,e[16]=l,e[17]=s.id,e[18]=m,e[19]=S):S=e[19];let k;e[20]!==v||e[21]!==S?(k={mutationFn:v,onSuccess:S,onError:mt},e[20]=v,e[21]=S,e[22]=k):k=e[22];const U=He(k),F=le,se=ce,R="sm:max-w-[900px] p-0 gap-0 overflow-hidden";let P;e[23]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(de,{className:"sr-only",children:t.jsx(ue,{children:"Import from deco.cx"})}),e[23]=P):P=e[23];let H;e[24]!==c?(H=c&&t.jsx("button",{type:"button",onClick:c,className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors","aria-label":"Go back",children:t.jsx(Ae,{size:18})}),e[24]=c,e[25]=H):H=e[25];let me;e[26]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Import from deco.cx"}),e[26]=me):me=e[26];let B;e[27]!==H?(B=t.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3",children:[H,me]}),e[27]=H,e[28]=B):B=e[28];let fe;e[29]===Symbol.for("react.memo_cache_sentinel")?(fe=w=>{w.key==="Escape"&&d("")},e[29]=fe):fe=e[29];let q;e[30]!==T?(q=t.jsx("div",{children:t.jsx(qe,{value:T,onChange:d,placeholder:"Search sites...",onKeyDown:fe})}),e[30]=T,e[31]=q):q=e[31];const Ke="pb-0 min-h-[300px]";let Q;e[32]!==N?(Q=N&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"Loading sites..."}),e[32]=N,e[33]=Q):Q=e[33];const _e=!N&&!b&&I.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."}),Ce=!N&&I.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:[j.length===0&&t.jsxs("p",{className:"col-span-3 text-sm text-muted-foreground text-center py-8",children:["No sites match “",T,"”"]}),j.map(w=>{const G=w.domains?.find(ut)?.domain??w.domains?.[0]?.domain,D=x===w.name;return t.jsxs("button",{type:"button",onClick:()=>h(w.name),className:he("flex flex-col rounded-xl border overflow-hidden text-left transition-all cursor-pointer",D?"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:w.thumb_url?t.jsx("img",{src:w.thumb_url,alt:w.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:w.name}),G&&t.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:G})]})]},w.name)})]});let Y;e[34]!==Q||e[35]!==_e||e[36]!==Ce?(Y=t.jsxs("div",{className:Ke,children:[Q,_e,Ce]}),e[34]=Q,e[35]=_e,e[36]=Ce,e[37]=Y):Y=e[37];let K;e[38]!==y?(K=()=>y(!1),e[38]=y,e[39]=K):K=e[39];let W;e[40]!==U.isPending||e[41]!==K?(W=t.jsx(oe,{variant:"outline",onClick:K,disabled:U.isPending,children:"Cancel"}),e[40]=U.isPending,e[41]=K,e[42]=W):W=e[42];const Ie=!x||!E||U.isPending||N;let J;e[43]!==U||e[44]!==x?(J=()=>x&&U.mutate(x),e[43]=U,e[44]=x,e[45]=J):J=e[45];const Te=U.isPending?"Importing...":"Import";let X;e[46]!==Ie||e[47]!==J||e[48]!==Te?(X=t.jsx(oe,{disabled:Ie,onClick:J,children:Te}),e[46]=Ie,e[47]=J,e[48]=Te,e[49]=X):X=e[49];let Z;e[50]!==W||e[51]!==X?(Z=t.jsxs(tt,{className:"px-8 py-5 border-t border-border",children:[W,X]}),e[50]=W,e[51]=X,e[52]=Z):Z=e[52];let ee;e[53]!==se||e[54]!==P||e[55]!==B||e[56]!==q||e[57]!==Y||e[58]!==Z?(ee=t.jsxs(se,{className:R,children:[P,B,q,Y,Z]}),e[53]=se,e[54]=P,e[55]=B,e[56]=q,e[57]=Y,e[58]=Z,e[59]=ee):ee=e[59];let pe;return e[60]!==F||e[61]!==y||e[62]!==n||e[63]!==ee?(pe=t.jsx(F,{open:n,onOpenChange:y,children:ee}),e[60]=F,e[61]=y,e[62]=n,e[63]=ee,e[64]=pe):pe=e[64],pe}function ut(i){return i.production}function mt(i){V("deco_site_import_failed",{error:i instanceof Error?i.message:"Unknown error"}),ie.error("Import failed: "+(i instanceof Error?i.message:"Unknown error"))}function ft(){return{}}function Ye(i,e){const n=M.c(11),{org:a}=z();let c;n[0]!==a.id?(c=we.REGISTRY(a.id),n[0]=a.id,n[1]=c):c=n[1];const s=c;let l;n[2]!==a.id||n[3]!==s?(l={connectionId:s,orgId:a.id},n[2]=a.id,n[3]=s,n[4]=l):l=n[4];const m=$(l);let f;n[5]!==i?(f={name:i},n[5]=i,n[6]=f):f=n[6];const x=e?.enabled??!0;let h;return n[7]!==m||n[8]!==f||n[9]!==x?(h={client:m,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:f,enabled:x,staleTime:3e5,select:pt},n[7]=m,n[8]=f,n[9]=x,n[10]=h):h=n[10],rt(h)}function pt(i){return i.structuredContent?.item??null}const gt="deco/mcp-github";function ht(i){const{org:e}=z(),{data:n}=ze.useSession(),a=Ee(),c=je(),[s,l]=O.useState("idle"),[m,f]=O.useState(null),[x,h]=O.useState(null),{data:T,isLoading:d}=Ye(gt,{enabled:i.enabled}),u=O.useRef(!1);i.enabled&&T&&!d&&!u.current&&n?.user?.id&&s==="idle"&&(u.current=!0,p());async function p(){if(!(!T||!n?.user?.id||!e))try{l("installing"),f(null);const g=at(T,e.id,n.user.id,{remoteIndex:0});if(!g.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:_}=await a.create.mutateAsync(g);l("authenticating");const N=new URL(`/mcp/${_}`,window.location.origin),b=await We({url:N.href,token:null});if(b.supportsOAuth&&!b.isAuthenticated){const{token:I,tokenInfo:o,error:y}=await Je({connectionId:_,scope:"offline_access"});if(y||!I){try{await a.delete.mutateAsync(_)}catch{}throw new Error(y??"No token received from GitHub")}if(o)try{(await fetch(`/api/connections/${_}/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:_,data:{connection_token:I}})}catch{await a.update.mutateAsync({id:_,data:{connection_token:I}})}}ve(c,e.id),h(g),l("ready")}catch(g){f(g instanceof Error?g.message:String(g)),l("error")}}function r(){l("idle"),f(null),h(null),u.current=!1}return i.enabled&&d&&s==="idle"?{status:"installing",error:null,connection:null,retry:r}:{status:s,error:m,connection:x,retry:r}}function Wt(i){const e=M.c(21),{open:n,onOpenChange:a,title:c,hideAutoRespondCheckbox:s,onImportComplete:l}=i,m=c===void 0?"Import from GitHub":c,f=s===void 0?!1:s,[x]=Xe(),[h,T]=O.useState(null);if(!x.experimental_vibecode)return null;let d;e[0]!==m?(d=t.jsx(de,{className:"sr-only",children:t.jsx(ue,{children:m})}),e[0]=m,e[1]=d):d=e[1];let u;e[2]!==h||e[3]!==m?(u=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:h?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>T(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(Ae,{size:16})}),t.jsx("img",{src:h.avatarUrl,alt:h.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:h.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(ae,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:m})]})}),e[2]=h,e[3]=m,e[4]=u):u=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(xe,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=p):p=e[5];let r;e[6]!==a?(r=()=>a(!1),e[6]=a,e[7]=r):r=e[7];let g;e[8]!==f||e[9]!==l||e[10]!==h||e[11]!==r?(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(xt,{onComplete:r,selectedInstallation:h,onSelectInstallation:T,hideAutoRespondCheckbox:f,onImportComplete:l})})}),e[8]=f,e[9]=l,e[10]=h,e[11]=r,e[12]=g):g=e[12];let C;e[13]!==d||e[14]!==u||e[15]!==g?(C=t.jsxs(ce,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[d,u,g]}),e[13]=d,e[14]=u,e[15]=g,e[16]=C):C=e[16];let _;return e[17]!==a||e[18]!==n||e[19]!==C?(_=t.jsx(le,{open:n,onOpenChange:a,children:C}),e[17]=a,e[18]=n,e[19]=C,e[20]=_):_=e[20],_}function xt({onComplete:i,selectedInstallation:e,onSelectInstallation:n,hideAutoRespondCheckbox:a,onImportComplete:c}){const{org:s}=z(),l=je(),m=Ne(),[f,x]=O.useState(null),[h,T]=O.useState(!0),d=a?!0:h,u=st({slug:"mcp-github"}),p=ht({enabled:u.length===0}),r=u.length===1?u[0]??null:f,g=$({connectionId:r?.id??"",orgId:s.id}),C=$({connectionId:re,orgId:s.id}),_=async(o,y)=>{try{const j=await g.callTool({name:"get_file_contents",arguments:{owner:o.owner,repo:o.name,path:y}});if(j.isError)return null;const v=j.content?.find(S=>S.type==="resource")?.resource?.text;if(!v)return null;try{const S=JSON.parse(v);return typeof S=="string"?S:JSON.stringify(S)}catch{return v}}catch{return null}},N=(o,y)=>{Promise.all([_(y,"AGENTS.md"),_(y,"CLAUDE.md")]).then(async([A,j])=>{const E=A??j??null;E&&(await C.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:o,data:{metadata:{instructions:E}}}}),ve(l,s.id))}).catch(A=>{console.error("GitHub instructions fetch failed:",A)})},b=async({virtualMcpId:o,repo:y,connectionId:A})=>{const j=await g.callTool({name:"TRIGGER_LIST",arguments:{}}),E=j.structuredContent??j,v=E.triggers?.find(R=>R.type==="github.issues.opened")??E.triggers?.find(R=>{const P=R.type.toLowerCase();return/\bissues?\./.test(P)&&(P.endsWith(".opened")||P.endsWith(".created"))});if(!v)throw new Error("No issue-created trigger exposed by GitHub connection");const S=new Set;if(Array.isArray(v.params))for(const R of v.params)S.add(R.name);else if(v.params&&typeof v.params=="object")for(const R of Object.keys(v.params))S.add(R);if(v.paramsSchema)for(const R of Object.keys(v.paramsSchema))S.add(R);const k={};S.has("repo")?k.repo=`${y.owner}/${y.name}`:(S.has("owner")&&(k.owner=y.owner),S.has("name")&&(k.name=y.name),S.has("repository")&&(k.repository=`${y.owner}/${y.name}`));const U=`A new GitHub issue has been opened in ${y.owner}/${y.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.`,F=await C.callTool({name:"AUTOMATION_CREATE",arguments:{name:`${y.name}: auto-respond to issues`,virtual_mcp_id:o,agent:{id:o},messages:U,active:!0}}),se=F.structuredContent??F;await C.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:se.id,type:"event",connection_id:A,event_type:v.type,params:k}})},I=He({mutationFn:async o=>{if(!r||!e)throw new Error("No GitHub connection or installation");const y=r.id,A=await C.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:y},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"}}}},connections:[{connection_id:y}]}}}),j=A.structuredContent??A,E=j.item.id;return d&&await b({virtualMcpId:E,repo:o,connectionId:y}).catch(v=>{console.error("Failed to set up issue automation:",v),ie.warning("Imported repo, but failed to set up issue auto-response. You can add the trigger manually from the automations view.")}),{virtualMcpId:E,repo:o,connectionId:y,item:j.item}},onSuccess:({virtualMcpId:o,repo:y,connectionId:A,item:j})=>{if(l.setQueryData(ne.collectionItem(C,s.id,"","VIRTUAL_MCP",o),{item:j}),ve(l,s.id),N(o,y),c){c({virtualMcpId:o,repo:y,connectionId:A});return}ie.success(`Imported ${y.name} from GitHub`),i(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),m(o)},onError:o=>{ie.error("Failed to import repo: "+(o instanceof Error?o.message:"Unknown error"))}});return p.status==="installing"||p.status==="authenticating"?t.jsx(be,{status:p.status,error:null,retry:p.retry}):p.status==="error"?t.jsx(be,{status:"error",error:p.error,retry:p.retry}):u.length===0&&p.status==="idle"?t.jsx(be,{status:"installing",error:null,retry:p.retry}):u.length>1&&!r?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"})}),u.map(o=>t.jsxs("button",{type:"button",onClick:()=>x(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(ae,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:o.title})]},o.id))]}):r?e?t.jsx(_t,{connectionId:r.id,orgId:s.id,installation:e,onSelectRepo:o=>I.mutate(o),isSaving:I.isPending,autoRespondToIssues:h,onAutoRespondChange:T,hideAutoRespondCheckbox:a}):t.jsx(Nt,{connectionId:r.id,orgId:s.id,onSelect:n,showBackButton:u.length>1,onBack:()=>x(null)}):null}function Nt(i){const e=M.c(30),{connectionId:n,orgId:a,onSelect:c,showBackButton:s,onBack:l}=i;let m;e[0]!==a?(m={connectionId:re,orgId:a},e[0]=a,e[1]=m):m=e[1];const f=$(m);let x;e[2]!==n||e[3]!==a?(x=ne.githubUserOrgs(a,n),e[2]=n,e[3]=a,e[4]=x):x=e[4];let h;e[5]!==n||e[6]!==f?(h=async()=>{const o=(await f.callTool({name:"GITHUB_LIST_USER_ORGS",arguments:{connectionId:n}})).content?.[0]?.text;if(!o)throw new Error("No response from GITHUB_LIST_USER_ORGS");return JSON.parse(o)},e[5]=n,e[6]=f,e[7]=h):h=e[7];let T;e[8]!==x||e[9]!==h?(T={queryKey:x,queryFn:h},e[8]=x,e[9]=h,e[10]=T):T=e[10];const d=Fe(T);if(d.isLoading){let I;return e[11]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(xe,{size:18,className:"animate-spin text-muted-foreground"})}),e[11]=I):I=e[11],I}if(d.isError){let I;return e[12]===Symbol.for("react.memo_cache_sentinel")?(I=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[12]=I):I=e[12],I}const u=d.data;if(!u)return null;let p;e[13]!==l||e[14]!==s?(p=s&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(Ae,{size:12}),"Change connection"]})}),e[13]=l,e[14]=s,e[15]=p):p=e[15];let r;if(e[16]!==u.installations||e[17]!==c){let I;e[19]!==c?(I=o=>t.jsxs("button",{type:"button",onClick:()=>c(o),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:o.avatarUrl,alt:o.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:o.login}),o.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 →"})]},o.installationId),e[19]=c,e[20]=I):I=e[20],r=u.installations.map(I),e[16]=u.installations,e[17]=c,e[18]=r}else r=e[18];let g;e[21]!==r?(g=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:r}),e[21]=r,e[22]=g):g=e[22];const C=u.appSlug?`https://github.com/apps/${u.appSlug}/installations/new`:"https://github.com/settings/installations";let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("span",{className:"underline underline-offset-2",children:"Install the GitHub App"}),e[23]=_):_=e[23];let N;e[24]!==C?(N=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:["Account not listed?"," ",_]})}),e[24]=C,e[25]=N):N=e[25];let b;return e[26]!==N||e[27]!==p||e[28]!==g?(b=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[p,g,N]}),e[26]=N,e[27]=p,e[28]=g,e[29]=b):b=e[29],b}function _t(i){const e=M.c(24),{connectionId:n,orgId:a,installation:c,onSelectRepo:s,isSaving:l,autoRespondToIssues:m,onAutoRespondChange:f,hideAutoRespondCheckbox:x}=i,[h,T]=O.useState(""),d=O.useDeferredValue(h),u=h!==d;let p;e[0]!==u||e[1]!==h?(p=t.jsx(qe,{placeholder:"Search repositories...",value:h,onChange:T,isSearching:u}),e[0]=u,e[1]=h,e[2]=p):p=e[2];const r=u?"opacity-40":"opacity-100";let g;e[3]!==r?(g=he("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",r),e[3]=r,e[4]=g):g=e[4];let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(xe,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=C):C=e[5];let _;e[6]!==n||e[7]!==d||e[8]!==c||e[9]!==l||e[10]!==s||e[11]!==a?(_=t.jsx(O.Suspense,{fallback:C,children:t.jsx(Ct,{connectionId:n,orgId:a,installation:c,query:d,onSelectRepo:s,isSaving:l})}),e[6]=n,e[7]=d,e[8]=c,e[9]=l,e[10]=s,e[11]=a,e[12]=_):_=e[12];let N;e[13]!==g||e[14]!==_?(N=t.jsx("div",{className:g,children:_}),e[13]=g,e[14]=_,e[15]=N):N=e[15];let b;e[16]!==m||e[17]!==x||e[18]!==f?(b=!x&&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(nt,{checked:m,onCheckedChange:o=>f(o===!0)}),t.jsx("span",{className:"text-xs text-foreground",children:"Auto-respond to new issues with a PR"})]}),e[16]=m,e[17]=x,e[18]=f,e[19]=b):b=e[19];let I;return e[20]!==p||e[21]!==N||e[22]!==b?(I=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[p,N,b]}),e[20]=p,e[21]=N,e[22]=b,e[23]=I):I=e[23],I}function Ct(i){const e=M.c(28),{connectionId:n,orgId:a,installation:c,query:s,onSelectRepo:l,isSaving:m}=i;let f;e[0]!==n||e[1]!==a?(f={connectionId:n,orgId:a},e[0]=n,e[1]=a,e[2]=f):f=e[2];const x=$(f),h=c.type==="User"?"user":"org",T=s?`${h}:${c.login} ${s} in:name`:`${h}:${c.login}`;let d;e[3]!==n||e[4]!==c.login||e[5]!==a||e[6]!==s?(d=ne.githubOrgRepos(a,n,c.login,s),e[3]=n,e[4]=c.login,e[5]=a,e[6]=s,e[7]=d):d=e[7];let u;e[8]!==x||e[9]!==T?(u=async()=>{const N=(await x.callTool({name:"search_repositories",arguments:{query:T,page:1,perPage:30}})).content?.[0]?.text;if(!N)throw new Error("No response from search_repositories");return(JSON.parse(N).items??[]).map(It)},e[8]=x,e[9]=T,e[10]=u):u=e[10];let p;e[11]!==d||e[12]!==u?(p={queryKey:d,queryFn:u},e[11]=d,e[12]=u,e[13]=p):p=e[13];const{data:r}=Ze(p);if(r.length===0){let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("p",{className:"text-sm text-muted-foreground",children:"No repositories found"}),e[14]=_):_=e[14];let N;e[15]!==s?(N=s&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Try a different search term"}),e[15]=s,e[16]=N):N=e[16];let b;return e[17]!==N?(b=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[_,N]}),e[17]=N,e[18]=b):b=e[18],b}let g;if(e[19]!==m||e[20]!==l||e[21]!==r){let _;e[23]!==m||e[24]!==l?(_=N=>t.jsxs("button",{type:"button",onClick:()=>l(N),disabled:m,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(ae,{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(it,{size:10}):t.jsx(ot,{size:10}),N.private?"Private":"Public"]})]},N.fullName),e[23]=m,e[24]=l,e[25]=_):_=e[25],g=r.map(_),e[19]=m,e[20]=l,e[21]=r,e[22]=g}else g=e[22];let C;return e[26]!==g?(C=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:g}),e[26]=g,e[27]=C):C=e[27],C}function It(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 be(i){const e=M.c(33),{status:n,error:a,retry:c}=i;if(n==="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(ae,{className:"size-5 text-destructive"})}),e[0]=o):o=e[0];let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("p",{className:"text-sm font-medium",children:"Connection failed"}),e[1]=y):y=e[1];const A=a??"Something went wrong while connecting to GitHub.";let j;e[2]!==A?(j=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[y,t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:A})]}),e[2]=A,e[3]=j):j=e[3];let E;e[4]!==c?(E=t.jsx("button",{type:"button",onClick:c,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]=c,e[5]=E):E=e[5];let v;return e[6]!==j||e[7]!==E?(v=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[o,j,E]}),e[6]=j,e[7]=E,e[8]=v):v=e[8],v}const s=n==="authenticating";let l;e[9]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(ae,{className:"size-5 text-foreground"})}),e[9]=l):l=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"relative size-10",children:[l,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(xe,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[10]=m):m=e[10];const f=s?"Authenticating with GitHub":"Setting up GitHub";let x;e[11]!==f?(x=t.jsx("p",{className:"text-sm font-medium",children:f}),e[11]=f,e[12]=x):x=e[12];const h=s?"Complete the OAuth flow in your browser":"Installing the GitHub connection...";let T;e[13]!==h?(T=t.jsx("p",{className:"text-xs text-muted-foreground",children:h}),e[13]=h,e[14]=T):T=e[14];let d;e[15]!==x||e[16]!==T?(d=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[x,T]}),e[15]=x,e[16]=T,e[17]=d):d=e[17];const u=s?"bg-muted-foreground/30":"bg-foreground animate-pulse";let p;e[18]!==u?(p=he("size-1.5 rounded-full",u),e[18]=u,e[19]=p):p=e[19];let r;e[20]!==p?(r=t.jsx("span",{className:p}),e[20]=p,e[21]=r):r=e[21];const g=s?"bg-foreground animate-pulse":"bg-muted-foreground/30";let C;e[22]!==g?(C=he("size-1.5 rounded-full",g),e[22]=g,e[23]=C):C=e[23];let _;e[24]!==C?(_=t.jsx("span",{className:C}),e[24]=C,e[25]=_):_=e[25];let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[26]=N):N=e[26];let b;e[27]!==r||e[28]!==_?(b=t.jsxs("div",{className:"flex items-center gap-1.5",children:[r,_,N]}),e[27]=r,e[28]=_,e[29]=b):b=e[29];let I;return e[30]!==b||e[31]!==d?(I=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[m,d,b]}),e[30]=b,e[31]=d,e[32]=I):I=e[32],I}const Tt=["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 De(i){const e=M.c(7),{onRecruit:n,isRecruiting:a,isLoading:c}=i;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=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]=s):s=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=l):l=e[1];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"space-y-2",children:[l,t.jsx("ul",{className:"space-y-1.5",children:Tt.map(yt)})]}),e[2]=m):m=e[2];const f=a||c,x=a?"Setting up...":"Add Site Diagnostics";let h;return e[3]!==n||e[4]!==f||e[5]!==x?(h=t.jsxs("div",{className:"flex flex-col gap-6",children:[s,m,t.jsx(oe,{onClick:n,disabled:f,className:"w-full cursor-pointer",children:x})]}),e[3]=n,e[4]=f,e[5]=x,e[6]=h):h=e[6],h}function yt(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 Jt({open:i,onOpenChange:e,existingAgent:n}){const a=Me(),{org:c}=z(),s=Ne(),l=Ee(),m=Ue(),f=$({connectionId:re,orgId:c.id}),x=Qe({client:f}),[h,T]=O.useState(!1),d=Be.find(I=>I.id==="site-diagnostics"),{data:u,isLoading:p}=Ye(d.appId,{enabled:i}),r=u?.title||u?.server?.title||u?.server?.name||d.title,g=u?.server?.icons?.[0]?.src??d.icon,C=u?.server?.description??null,_=t.jsx(ke,{icon:g,name:r,size:"sm"}),N=async()=>{if(u){if(n){e(!1),s(n.id);return}T(!0);try{const I=await x.mutateAsync({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:d.appId},limit:1,offset:0}});let o;const A=I?.structuredContent?.items?.find(E=>E.app_id===d.appId);if(A)o=A.id;else{const E=u.server?.remotes?.[0]?.url;if(!E)throw new Error("Registry item is missing a remote URL for site-diagnostics");o=(await l.create.mutateAsync({title:r,description:C,icon:u.server?.icons?.[0]?.src??d.icon,connection_type:"HTTP",connection_url:E,app_name:u.server?.name??"site-diagnostics",app_id:d.appId,metadata:{type:"site-diagnostics",source:"store",registry_item_id:d.appId,verified:!0}})).id}const j=await m.create.mutateAsync({title:r,description:C,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"}}}}});V("agent_recruit_confirmed",{template_id:"site-diagnostics",agent_id:j.id}),e(!1),s(j.id)}catch(I){V("agent_recruit_failed",{template_id:"site-diagnostics",error:I instanceof Error?I.message:String(I)}),console.error("Failed to create Site Diagnostics agent:",I)}finally{T(!1)}}},b=`Add ${r}`;return a?t.jsx(Se,{open:i,onOpenChange:e,children:t.jsxs(Oe,{className:"h-[70dvh]",children:[t.jsx(Le,{className:"px-4 pt-4 pb-4 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-3",children:[_,t.jsx(Re,{className:"text-xl font-semibold",children:b})]})}),t.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:t.jsx(De,{onRecruit:N,isRecruiting:h,isLoading:p})})]})}):t.jsx(le,{open:i,onOpenChange:e,children:t.jsxs(ce,{className:"sm:max-w-[500px] p-8",children:[t.jsx(de,{className:"mb-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[_,t.jsx(ue,{className:"text-xl font-semibold",children:b})]})}),t.jsx(De,{onRecruit:N,isRecruiting:h,isLoading:p})]})})}const bt=`<role>
1
+ import{e as M,j as t,s as z,o as je,b as ze,r as O,K as ne,n as Fe,a as He,c as he,B as oe,t as V,x as ie,G as We,F as Je,v as ve,P as Xe,l as xe,w as Ze,f as et}from"./index-O-xThSQt.js";import{S as re,u as $,d as we,W as Be,j as ye}from"./constants-ChdU9xvz.js";import{a as Ne}from"./use-navigate-to-agent-CBd-r96N.js";import{a as ce,b as le,c as de,d as ue,D as tt}from"./dialog-B0QYUD88.js";import{i as Ae}from"./RefreshCcw01-D1Vi0tae.js";import{C as qe}from"./collection-search-DyFOds5R.js";import{C as nt}from"./checkbox-BWpfDwfi.js";import{b as Ee,u as st}from"./use-connection-Dkzl6ATr.js";import{i as it}from"./Lock01-0zry6wgC.js";import{n as ot}from"./agent-icon-ChIrIWeW.js";import{e as at}from"./extract-connection-data-BdGRQa2R.js";import{b as Se,a as Oe,c as Le,D as Re}from"./drawer-B9QExE6j.js";import{u as Me}from"./tooltip-CZKTj_88.js";import{I as ke}from"./integration-icon-Dl850mlU.js";import{u as rt,d as Qe}from"./use-mcp-tools-dN493Per.js";import{a as Ue,b as ct}from"./use-virtual-mcp-Cn-xT_JW.js";function ae(i){const e=M.c(4),{size:n,className:a}=i;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=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]=c):c=e[0];let s;return e[1]!==a||e[2]!==n?(s=t.jsx("svg",{width:n,height:n,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",className:a,children:c}),e[1]=a,e[2]=n,e[3]=s):s=e[3],s}function lt(i){return i.toLowerCase().trim().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function dt(){const i=await fetch("/api/deco-sites");if(!i.ok){const e=await i.json().catch(()=>({}));throw new Error(e.error??`Failed to load sites (${i.status})`)}return i.json()}function Kt(i){const e=M.c(65),{open:n,onOpenChange:a,onBack:c}=i,{org:s}=z(),l=Ne(),m=je(),{data:f}=ze.useSession(),[x,h]=O.useState(null),[T,d]=O.useState("");let u;e[0]!==s.id?(u={connectionId:re,orgId:s.id},e[0]=s.id,e[1]=u):u=e[1];const p=$(u);let r;e[2]!==f?.user?.email?(r=ne.decoSites(f?.user?.email),e[2]=f?.user?.email,e[3]=r):r=e[3];const g=n&&!!f?.user?.email;let C;e[4]!==r||e[5]!==g?(C={queryKey:r,queryFn:dt,enabled:g,staleTime:6e4,retry:!1},e[4]=r,e[5]=g,e[6]=C):C=e[6];const{data:_,isLoading:N,error:b}=Fe(C),I=_?.sites??[];let o;e[7]!==a?(o=w=>{w||(h(null),d("")),a(w)},e[7]=a,e[8]=o):o=e[8];const y=o;let A;e[9]!==T?(A=w=>w.name.toLowerCase().includes(T.toLowerCase())||w.domains?.[0]?.domain.toLowerCase().includes(T.toLowerCase()),e[9]=T,e[10]=A):A=e[10];const j=I.filter(A),E=!x||j.some(w=>w.name===x);let v;e[11]!==p||e[12]!==s.id?(v=async w=>{V("deco_site_import_started",{site_name:w});const G=await fetch("/api/deco-sites/connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:w,orgId:s.id})}),D=await G.json().catch(ft);if(!G.ok)throw new Error(D.error??`Failed to create connection (${G.status})`);const L=D.connId;if(!L)throw new Error("Server did not return a connection ID");const ge=D.icon??null,te=lt(w),Pe=await p.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:w,description:"Imported from deco.cx",pinned:!0,icon:ge??null,subtype:"project",metadata:{instructions:null,enabled_plugins:[],ui:{banner:null,bannerColor:"#22C55E",icon:ge,themeColor:"#22C55E",slug:te,pinnedViews:[{connectionId:L,toolName:"file_explorer",label:"Preview",icon:null},{connectionId:L,toolName:"fetch_assets",label:"Assets",icon:null},{connectionId:L,toolName:"get_monitor_data",label:"Monitor",icon:null},{connectionId:L,toolName:"list_pull_requests",label:"Pull Requests",icon:null},{connectionId:L,toolName:"list_releases",label:"Releases",icon:null}],layout:{defaultMainView:{type:"ext-apps",id:L,toolName:"file_explorer"}}}},connections:[{connection_id:L}]}}}),Ge=Pe.structuredContent??Pe;return{slug:te,virtualMcpId:Ge.item.id,connId:L,item:Ge.item}},e[11]=p,e[12]=s.id,e[13]=v):v=e[13];let S;e[14]!==p||e[15]!==y||e[16]!==l||e[17]!==s.id||e[18]!==m?(S=w=>{const{slug:G,virtualMcpId:D,item:L}=w;V("deco_site_import_succeeded",{site_name:L.title,virtual_mcp_id:D,slug:G}),m.setQueryData(ne.collectionItem(p,s.id,"","VIRTUAL_MCP",D),{item:L}),m.invalidateQueries({predicate:ge=>{const te=ge.queryKey;return te[1]===s.id&&te[3]==="collection"&&te[4]==="VIRTUAL_MCP"}}),m.invalidateQueries({queryKey:ne.projects(s.id)}),ie.success(`Imported ${G} from deco.cx`),y(!1),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),l(D)},e[14]=p,e[15]=y,e[16]=l,e[17]=s.id,e[18]=m,e[19]=S):S=e[19];let k;e[20]!==v||e[21]!==S?(k={mutationFn:v,onSuccess:S,onError:mt},e[20]=v,e[21]=S,e[22]=k):k=e[22];const U=He(k),F=le,se=ce,R="sm:max-w-[900px] p-0 gap-0 overflow-hidden";let P;e[23]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(de,{className:"sr-only",children:t.jsx(ue,{children:"Import from deco.cx"})}),e[23]=P):P=e[23];let H;e[24]!==c?(H=c&&t.jsx("button",{type:"button",onClick:c,className:"flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors","aria-label":"Go back",children:t.jsx(Ae,{size:18})}),e[24]=c,e[25]=H):H=e[25];let me;e[26]===Symbol.for("react.memo_cache_sentinel")?(me=t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Import from deco.cx"}),e[26]=me):me=e[26];let B;e[27]!==H?(B=t.jsxs("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3",children:[H,me]}),e[27]=H,e[28]=B):B=e[28];let fe;e[29]===Symbol.for("react.memo_cache_sentinel")?(fe=w=>{w.key==="Escape"&&d("")},e[29]=fe):fe=e[29];let q;e[30]!==T?(q=t.jsx("div",{children:t.jsx(qe,{value:T,onChange:d,placeholder:"Search sites...",onKeyDown:fe})}),e[30]=T,e[31]=q):q=e[31];const Ke="pb-0 min-h-[300px]";let Q;e[32]!==N?(Q=N&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:"Loading sites..."}),e[32]=N,e[33]=Q):Q=e[33];const _e=!N&&!b&&I.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."}),Ce=!N&&I.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:[j.length===0&&t.jsxs("p",{className:"col-span-3 text-sm text-muted-foreground text-center py-8",children:["No sites match “",T,"”"]}),j.map(w=>{const G=w.domains?.find(ut)?.domain??w.domains?.[0]?.domain,D=x===w.name;return t.jsxs("button",{type:"button",onClick:()=>h(w.name),className:he("flex flex-col rounded-xl border overflow-hidden text-left transition-all cursor-pointer",D?"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:w.thumb_url?t.jsx("img",{src:w.thumb_url,alt:w.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:w.name}),G&&t.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:G})]})]},w.name)})]});let Y;e[34]!==Q||e[35]!==_e||e[36]!==Ce?(Y=t.jsxs("div",{className:Ke,children:[Q,_e,Ce]}),e[34]=Q,e[35]=_e,e[36]=Ce,e[37]=Y):Y=e[37];let K;e[38]!==y?(K=()=>y(!1),e[38]=y,e[39]=K):K=e[39];let W;e[40]!==U.isPending||e[41]!==K?(W=t.jsx(oe,{variant:"outline",onClick:K,disabled:U.isPending,children:"Cancel"}),e[40]=U.isPending,e[41]=K,e[42]=W):W=e[42];const Ie=!x||!E||U.isPending||N;let J;e[43]!==U||e[44]!==x?(J=()=>x&&U.mutate(x),e[43]=U,e[44]=x,e[45]=J):J=e[45];const Te=U.isPending?"Importing...":"Import";let X;e[46]!==Ie||e[47]!==J||e[48]!==Te?(X=t.jsx(oe,{disabled:Ie,onClick:J,children:Te}),e[46]=Ie,e[47]=J,e[48]=Te,e[49]=X):X=e[49];let Z;e[50]!==W||e[51]!==X?(Z=t.jsxs(tt,{className:"px-8 py-5 border-t border-border",children:[W,X]}),e[50]=W,e[51]=X,e[52]=Z):Z=e[52];let ee;e[53]!==se||e[54]!==P||e[55]!==B||e[56]!==q||e[57]!==Y||e[58]!==Z?(ee=t.jsxs(se,{className:R,children:[P,B,q,Y,Z]}),e[53]=se,e[54]=P,e[55]=B,e[56]=q,e[57]=Y,e[58]=Z,e[59]=ee):ee=e[59];let pe;return e[60]!==F||e[61]!==y||e[62]!==n||e[63]!==ee?(pe=t.jsx(F,{open:n,onOpenChange:y,children:ee}),e[60]=F,e[61]=y,e[62]=n,e[63]=ee,e[64]=pe):pe=e[64],pe}function ut(i){return i.production}function mt(i){V("deco_site_import_failed",{error:i instanceof Error?i.message:"Unknown error"}),ie.error("Import failed: "+(i instanceof Error?i.message:"Unknown error"))}function ft(){return{}}function Ye(i,e){const n=M.c(11),{org:a}=z();let c;n[0]!==a.id?(c=we.REGISTRY(a.id),n[0]=a.id,n[1]=c):c=n[1];const s=c;let l;n[2]!==a.id||n[3]!==s?(l={connectionId:s,orgId:a.id},n[2]=a.id,n[3]=s,n[4]=l):l=n[4];const m=$(l);let f;n[5]!==i?(f={name:i},n[5]=i,n[6]=f):f=n[6];const x=e?.enabled??!0;let h;return n[7]!==m||n[8]!==f||n[9]!==x?(h={client:m,toolName:"COLLECTION_REGISTRY_APP_GET",toolArguments:f,enabled:x,staleTime:3e5,select:pt},n[7]=m,n[8]=f,n[9]=x,n[10]=h):h=n[10],rt(h)}function pt(i){return i.structuredContent?.item??null}const gt="deco/mcp-github";function ht(i){const{org:e}=z(),{data:n}=ze.useSession(),a=Ee(),c=je(),[s,l]=O.useState("idle"),[m,f]=O.useState(null),[x,h]=O.useState(null),{data:T,isLoading:d}=Ye(gt,{enabled:i.enabled}),u=O.useRef(!1);i.enabled&&T&&!d&&!u.current&&n?.user?.id&&s==="idle"&&(u.current=!0,p());async function p(){if(!(!T||!n?.user?.id||!e))try{l("installing"),f(null);const g=at(T,e.id,n.user.id,{remoteIndex:0});if(!g.connection_url)throw new Error("Registry item is missing a remote URL for mcp-github");const{id:_}=await a.create.mutateAsync(g);l("authenticating");const N=new URL(`/mcp/${_}`,window.location.origin),b=await We({url:N.href,token:null});if(b.supportsOAuth&&!b.isAuthenticated){const{token:I,tokenInfo:o,error:y}=await Je({connectionId:_,scope:"offline_access"});if(y||!I){try{await a.delete.mutateAsync(_)}catch{}throw new Error(y??"No token received from GitHub")}if(o)try{(await fetch(`/api/connections/${_}/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:_,data:{connection_token:I}})}catch{await a.update.mutateAsync({id:_,data:{connection_token:I}})}}ve(c,e.id),h(g),l("ready")}catch(g){f(g instanceof Error?g.message:String(g)),l("error")}}function r(){l("idle"),f(null),h(null),u.current=!1}return i.enabled&&d&&s==="idle"?{status:"installing",error:null,connection:null,retry:r}:{status:s,error:m,connection:x,retry:r}}function Wt(i){const e=M.c(21),{open:n,onOpenChange:a,title:c,hideAutoRespondCheckbox:s,onImportComplete:l}=i,m=c===void 0?"Import from GitHub":c,f=s===void 0?!1:s,[x]=Xe(),[h,T]=O.useState(null);if(!x.experimental_vibecode)return null;let d;e[0]!==m?(d=t.jsx(de,{className:"sr-only",children:t.jsx(ue,{children:m})}),e[0]=m,e[1]=d):d=e[1];let u;e[2]!==h||e[3]!==m?(u=t.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 gap-3 shrink-0",children:h?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>T(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(Ae,{size:16})}),t.jsx("img",{src:h.avatarUrl,alt:h.login,className:"size-5 rounded-full ring-1 ring-border shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:h.login})]}):t.jsxs(t.Fragment,{children:[t.jsx(ae,{className:"size-4 text-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:m})]})}),e[2]=h,e[3]=m,e[4]=u):u=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(xe,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=p):p=e[5];let r;e[6]!==a?(r=()=>a(!1),e[6]=a,e[7]=r):r=e[7];let g;e[8]!==f||e[9]!==l||e[10]!==h||e[11]!==r?(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(xt,{onComplete:r,selectedInstallation:h,onSelectInstallation:T,hideAutoRespondCheckbox:f,onImportComplete:l})})}),e[8]=f,e[9]=l,e[10]=h,e[11]=r,e[12]=g):g=e[12];let C;e[13]!==d||e[14]!==u||e[15]!==g?(C=t.jsxs(ce,{className:"sm:max-w-[560px] h-[85svh] sm:h-[520px] p-0 gap-0 overflow-hidden flex flex-col",children:[d,u,g]}),e[13]=d,e[14]=u,e[15]=g,e[16]=C):C=e[16];let _;return e[17]!==a||e[18]!==n||e[19]!==C?(_=t.jsx(le,{open:n,onOpenChange:a,children:C}),e[17]=a,e[18]=n,e[19]=C,e[20]=_):_=e[20],_}function xt({onComplete:i,selectedInstallation:e,onSelectInstallation:n,hideAutoRespondCheckbox:a,onImportComplete:c}){const{org:s}=z(),l=je(),m=Ne(),[f,x]=O.useState(null),[h,T]=O.useState(!0),d=a?!0:h,u=st({slug:"mcp-github"}),p=ht({enabled:u.length===0}),r=u.length===1?u[0]??null:f,g=$({connectionId:r?.id??"",orgId:s.id}),C=$({connectionId:re,orgId:s.id}),_=async(o,y)=>{try{const j=await g.callTool({name:"get_file_contents",arguments:{owner:o.owner,repo:o.name,path:y}});if(j.isError)return null;const v=j.content?.find(S=>S.type==="resource")?.resource?.text;if(!v)return null;try{const S=JSON.parse(v);return typeof S=="string"?S:JSON.stringify(S)}catch{return v}}catch{return null}},N=(o,y)=>{Promise.all([_(y,"AGENTS.md"),_(y,"CLAUDE.md")]).then(async([A,j])=>{const E=A??j??null;E&&(await C.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:o,data:{metadata:{instructions:E}}}}),ve(l,s.id))}).catch(A=>{console.error("GitHub instructions fetch failed:",A)})},b=async({virtualMcpId:o,repo:y,connectionId:A})=>{const j=await g.callTool({name:"TRIGGER_LIST",arguments:{}}),E=j.structuredContent??j,v=E.triggers?.find(R=>R.type==="github.issues.opened")??E.triggers?.find(R=>{const P=R.type.toLowerCase();return/\bissues?\./.test(P)&&(P.endsWith(".opened")||P.endsWith(".created"))});if(!v)throw new Error("No issue-created trigger exposed by GitHub connection");const S=new Set;if(Array.isArray(v.params))for(const R of v.params)S.add(R.name);else if(v.params&&typeof v.params=="object")for(const R of Object.keys(v.params))S.add(R);if(v.paramsSchema)for(const R of Object.keys(v.paramsSchema))S.add(R);const k={};S.has("repo")?k.repo=`${y.owner}/${y.name}`:(S.has("owner")&&(k.owner=y.owner),S.has("name")&&(k.name=y.name),S.has("repository")&&(k.repository=`${y.owner}/${y.name}`));const U=`A new GitHub issue has been opened in ${y.owner}/${y.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.`,F=await C.callTool({name:"AUTOMATION_CREATE",arguments:{name:`${y.name}: auto-respond to issues`,virtual_mcp_id:o,agent:{id:o},messages:U,active:!0}}),se=F.structuredContent??F;await C.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:se.id,type:"event",connection_id:A,event_type:v.type,params:k}})},I=He({mutationFn:async o=>{if(!r||!e)throw new Error("No GitHub connection or installation");const y=r.id,A=await C.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:y},instructions:null,ui:{pinnedViews:null,layout:{defaultMainView:{type:"preview"}}}},connections:[{connection_id:y}]}}}),j=A.structuredContent??A,E=j.item.id;return d&&await b({virtualMcpId:E,repo:o,connectionId:y}).catch(v=>{console.error("Failed to set up issue automation:",v),ie.warning("Imported repo, but failed to set up issue auto-response. You can add the trigger manually from the automations view.")}),{virtualMcpId:E,repo:o,connectionId:y,item:j.item}},onSuccess:({virtualMcpId:o,repo:y,connectionId:A,item:j})=>{if(l.setQueryData(ne.collectionItem(C,s.id,"","VIRTUAL_MCP",o),{item:j}),ve(l,s.id),N(o,y),c){c({virtualMcpId:o,repo:y,connectionId:A});return}ie.success(`Imported ${y.name} from GitHub`),i(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),m(o)},onError:o=>{ie.error("Failed to import repo: "+(o instanceof Error?o.message:"Unknown error"))}});return p.status==="installing"||p.status==="authenticating"?t.jsx(be,{status:p.status,error:null,retry:p.retry}):p.status==="error"?t.jsx(be,{status:"error",error:p.error,retry:p.retry}):u.length===0&&p.status==="idle"?t.jsx(be,{status:"installing",error:null,retry:p.retry}):u.length>1&&!r?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"})}),u.map(o=>t.jsxs("button",{type:"button",onClick:()=>x(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(ae,{className:"size-3.5 text-muted-foreground"})}),t.jsx("span",{className:"text-sm font-medium",children:o.title})]},o.id))]}):r?e?t.jsx(_t,{connectionId:r.id,orgId:s.id,installation:e,onSelectRepo:o=>I.mutate(o),isSaving:I.isPending,autoRespondToIssues:h,onAutoRespondChange:T,hideAutoRespondCheckbox:a}):t.jsx(Nt,{connectionId:r.id,orgId:s.id,onSelect:n,showBackButton:u.length>1,onBack:()=>x(null)}):null}function Nt(i){const e=M.c(30),{connectionId:n,orgId:a,onSelect:c,showBackButton:s,onBack:l}=i;let m;e[0]!==a?(m={connectionId:re,orgId:a},e[0]=a,e[1]=m):m=e[1];const f=$(m);let x;e[2]!==n||e[3]!==a?(x=ne.githubUserOrgs(a,n),e[2]=n,e[3]=a,e[4]=x):x=e[4];let h;e[5]!==n||e[6]!==f?(h=async()=>{const o=(await f.callTool({name:"GITHUB_LIST_USER_ORGS",arguments:{connectionId:n}})).content?.[0]?.text;if(!o)throw new Error("No response from GITHUB_LIST_USER_ORGS");return JSON.parse(o)},e[5]=n,e[6]=f,e[7]=h):h=e[7];let T;e[8]!==x||e[9]!==h?(T={queryKey:x,queryFn:h},e[8]=x,e[9]=h,e[10]=T):T=e[10];const d=Fe(T);if(d.isLoading){let I;return e[11]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(xe,{size:18,className:"animate-spin text-muted-foreground"})}),e[11]=I):I=e[11],I}if(d.isError){let I;return e[12]===Symbol.for("react.memo_cache_sentinel")?(I=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[12]=I):I=e[12],I}const u=d.data;if(!u)return null;let p;e[13]!==l||e[14]!==s?(p=s&&t.jsx("div",{className:"flex items-center gap-1 px-4 pt-3 pb-1 shrink-0",children:t.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[t.jsx(Ae,{size:12}),"Change connection"]})}),e[13]=l,e[14]=s,e[15]=p):p=e[15];let r;if(e[16]!==u.installations||e[17]!==c){let I;e[19]!==c?(I=o=>t.jsxs("button",{type:"button",onClick:()=>c(o),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:o.avatarUrl,alt:o.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:o.login}),o.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 →"})]},o.installationId),e[19]=c,e[20]=I):I=e[20],r=u.installations.map(I),e[16]=u.installations,e[17]=c,e[18]=r}else r=e[18];let g;e[21]!==r?(g=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden [scrollbar-gutter:stable]",children:r}),e[21]=r,e[22]=g):g=e[22];const C=u.appSlug?`https://github.com/apps/${u.appSlug}/installations/new`:"https://github.com/settings/installations";let _;e[23]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("span",{className:"underline underline-offset-2",children:"Install the GitHub App"}),e[23]=_):_=e[23];let N;e[24]!==C?(N=t.jsx("div",{className:"px-4 py-3 border-t border-border shrink-0",children:t.jsxs("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:["Account not listed?"," ",_]})}),e[24]=C,e[25]=N):N=e[25];let b;return e[26]!==N||e[27]!==p||e[28]!==g?(b=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[p,g,N]}),e[26]=N,e[27]=p,e[28]=g,e[29]=b):b=e[29],b}function _t(i){const e=M.c(24),{connectionId:n,orgId:a,installation:c,onSelectRepo:s,isSaving:l,autoRespondToIssues:m,onAutoRespondChange:f,hideAutoRespondCheckbox:x}=i,[h,T]=O.useState(""),d=O.useDeferredValue(h),u=h!==d;let p;e[0]!==u||e[1]!==h?(p=t.jsx(qe,{placeholder:"Search repositories...",value:h,onChange:T,isSearching:u}),e[0]=u,e[1]=h,e[2]=p):p=e[2];const r=u?"opacity-40":"opacity-100";let g;e[3]!==r?(g=he("flex-1 overflow-hidden flex flex-col transition-opacity duration-150",r),e[3]=r,e[4]=g):g=e[4];let C;e[5]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(xe,{size:18,className:"animate-spin text-muted-foreground"})}),e[5]=C):C=e[5];let _;e[6]!==n||e[7]!==d||e[8]!==c||e[9]!==l||e[10]!==s||e[11]!==a?(_=t.jsx(O.Suspense,{fallback:C,children:t.jsx(Ct,{connectionId:n,orgId:a,installation:c,query:d,onSelectRepo:s,isSaving:l})}),e[6]=n,e[7]=d,e[8]=c,e[9]=l,e[10]=s,e[11]=a,e[12]=_):_=e[12];let N;e[13]!==g||e[14]!==_?(N=t.jsx("div",{className:g,children:_}),e[13]=g,e[14]=_,e[15]=N):N=e[15];let b;e[16]!==m||e[17]!==x||e[18]!==f?(b=!x&&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(nt,{checked:m,onCheckedChange:o=>f(o===!0)}),t.jsx("span",{className:"text-xs text-foreground",children:"Auto-respond to new issues with a PR"})]}),e[16]=m,e[17]=x,e[18]=f,e[19]=b):b=e[19];let I;return e[20]!==p||e[21]!==N||e[22]!==b?(I=t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[p,N,b]}),e[20]=p,e[21]=N,e[22]=b,e[23]=I):I=e[23],I}function Ct(i){const e=M.c(28),{connectionId:n,orgId:a,installation:c,query:s,onSelectRepo:l,isSaving:m}=i;let f;e[0]!==n||e[1]!==a?(f={connectionId:n,orgId:a},e[0]=n,e[1]=a,e[2]=f):f=e[2];const x=$(f),h=c.type==="User"?"user":"org",T=s?`${h}:${c.login} ${s} in:name`:`${h}:${c.login}`;let d;e[3]!==n||e[4]!==c.login||e[5]!==a||e[6]!==s?(d=ne.githubOrgRepos(a,n,c.login,s),e[3]=n,e[4]=c.login,e[5]=a,e[6]=s,e[7]=d):d=e[7];let u;e[8]!==x||e[9]!==T?(u=async()=>{const N=(await x.callTool({name:"search_repositories",arguments:{query:T,page:1,perPage:30}})).content?.[0]?.text;if(!N)throw new Error("No response from search_repositories");return(JSON.parse(N).items??[]).map(It)},e[8]=x,e[9]=T,e[10]=u):u=e[10];let p;e[11]!==d||e[12]!==u?(p={queryKey:d,queryFn:u},e[11]=d,e[12]=u,e[13]=p):p=e[13];const{data:r}=Ze(p);if(r.length===0){let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("p",{className:"text-sm text-muted-foreground",children:"No repositories found"}),e[14]=_):_=e[14];let N;e[15]!==s?(N=s&&t.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Try a different search term"}),e[15]=s,e[16]=N):N=e[16];let b;return e[17]!==N?(b=t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-1",children:[_,N]}),e[17]=N,e[18]=b):b=e[18],b}let g;if(e[19]!==m||e[20]!==l||e[21]!==r){let _;e[23]!==m||e[24]!==l?(_=N=>t.jsxs("button",{type:"button",onClick:()=>l(N),disabled:m,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(ae,{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(it,{size:10}):t.jsx(ot,{size:10}),N.private?"Private":"Public"]})]},N.fullName),e[23]=m,e[24]=l,e[25]=_):_=e[25],g=r.map(_),e[19]=m,e[20]=l,e[21]=r,e[22]=g}else g=e[22];let C;return e[26]!==g?(C=t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col [scrollbar-gutter:stable]",children:g}),e[26]=g,e[27]=C):C=e[27],C}function It(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 be(i){const e=M.c(33),{status:n,error:a,retry:c}=i;if(n==="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(ae,{className:"size-5 text-destructive"})}),e[0]=o):o=e[0];let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx("p",{className:"text-sm font-medium",children:"Connection failed"}),e[1]=y):y=e[1];const A=a??"Something went wrong while connecting to GitHub.";let j;e[2]!==A?(j=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[y,t.jsx("p",{className:"text-xs text-muted-foreground max-w-[260px] leading-relaxed",children:A})]}),e[2]=A,e[3]=j):j=e[3];let E;e[4]!==c?(E=t.jsx("button",{type:"button",onClick:c,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]=c,e[5]=E):E=e[5];let v;return e[6]!==j||e[7]!==E?(v=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[o,j,E]}),e[6]=j,e[7]=E,e[8]=v):v=e[8],v}const s=n==="authenticating";let l;e[9]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("div",{className:"size-10 rounded-full bg-muted flex items-center justify-center",children:t.jsx(ae,{className:"size-5 text-foreground"})}),e[9]=l):l=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"relative size-10",children:[l,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(xe,{size:12,className:"animate-spin text-muted-foreground"})})]}),e[10]=m):m=e[10];const f=s?"Authenticating with GitHub":"Setting up GitHub";let x;e[11]!==f?(x=t.jsx("p",{className:"text-sm font-medium",children:f}),e[11]=f,e[12]=x):x=e[12];const h=s?"Complete the OAuth flow in your browser":"Installing the GitHub connection...";let T;e[13]!==h?(T=t.jsx("p",{className:"text-xs text-muted-foreground",children:h}),e[13]=h,e[14]=T):T=e[14];let d;e[15]!==x||e[16]!==T?(d=t.jsxs("div",{className:"flex flex-col items-center gap-1 text-center",children:[x,T]}),e[15]=x,e[16]=T,e[17]=d):d=e[17];const u=s?"bg-muted-foreground/30":"bg-foreground animate-pulse";let p;e[18]!==u?(p=he("size-1.5 rounded-full",u),e[18]=u,e[19]=p):p=e[19];let r;e[20]!==p?(r=t.jsx("span",{className:p}),e[20]=p,e[21]=r):r=e[21];const g=s?"bg-foreground animate-pulse":"bg-muted-foreground/30";let C;e[22]!==g?(C=he("size-1.5 rounded-full",g),e[22]=g,e[23]=C):C=e[23];let _;e[24]!==C?(_=t.jsx("span",{className:C}),e[24]=C,e[25]=_):_=e[25];let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx("span",{className:"size-1.5 rounded-full bg-muted-foreground/30"}),e[26]=N):N=e[26];let b;e[27]!==r||e[28]!==_?(b=t.jsxs("div",{className:"flex items-center gap-1.5",children:[r,_,N]}),e[27]=r,e[28]=_,e[29]=b):b=e[29];let I;return e[30]!==b||e[31]!==d?(I=t.jsxs("div",{className:"flex flex-col items-center gap-4 px-6 py-10",children:[m,d,b]}),e[30]=b,e[31]=d,e[32]=I):I=e[32],I}const Tt=["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 De(i){const e=M.c(7),{onRecruit:n,isRecruiting:a,isLoading:c}=i;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=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]=s):s=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=l):l=e[1];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"space-y-2",children:[l,t.jsx("ul",{className:"space-y-1.5",children:Tt.map(yt)})]}),e[2]=m):m=e[2];const f=a||c,x=a?"Setting up...":"Add Site Diagnostics";let h;return e[3]!==n||e[4]!==f||e[5]!==x?(h=t.jsxs("div",{className:"flex flex-col gap-6",children:[s,m,t.jsx(oe,{onClick:n,disabled:f,className:"w-full cursor-pointer",children:x})]}),e[3]=n,e[4]=f,e[5]=x,e[6]=h):h=e[6],h}function yt(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 Jt({open:i,onOpenChange:e,existingAgent:n}){const a=Me(),{org:c}=z(),s=Ne(),l=Ee(),m=Ue(),f=$({connectionId:re,orgId:c.id}),x=Qe({client:f}),[h,T]=O.useState(!1),d=Be.find(I=>I.id==="site-diagnostics"),{data:u,isLoading:p}=Ye(d.appId,{enabled:i}),r=u?.title||u?.server?.title||u?.server?.name||d.title,g=u?.server?.icons?.[0]?.src??d.icon,C=u?.server?.description??null,_=t.jsx(ke,{icon:g,name:r,size:"sm"}),N=async()=>{if(u){if(n){e(!1),s(n.id);return}T(!0);try{const I=await x.mutateAsync({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:d.appId},limit:1,offset:0}});let o;const A=I?.structuredContent?.items?.find(E=>E.app_id===d.appId);if(A)o=A.id;else{const E=u.server?.remotes?.[0]?.url;if(!E)throw new Error("Registry item is missing a remote URL for site-diagnostics");o=(await l.create.mutateAsync({title:r,description:C,icon:u.server?.icons?.[0]?.src??d.icon,connection_type:"HTTP",connection_url:E,app_name:u.server?.name??"site-diagnostics",app_id:d.appId,metadata:{type:"site-diagnostics",source:"store",registry_item_id:d.appId,verified:!0}})).id}const j=await m.create.mutateAsync({title:r,description:C,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"}}}}});V("agent_recruit_confirmed",{template_id:"site-diagnostics",agent_id:j.id}),e(!1),s(j.id)}catch(I){V("agent_recruit_failed",{template_id:"site-diagnostics",error:I instanceof Error?I.message:String(I)}),console.error("Failed to create Site Diagnostics agent:",I)}finally{T(!1)}}},b=`Add ${r}`;return a?t.jsx(Se,{open:i,onOpenChange:e,children:t.jsxs(Oe,{className:"h-[70dvh]",children:[t.jsx(Le,{className:"px-4 pt-4 pb-4 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-3",children:[_,t.jsx(Re,{className:"text-xl font-semibold",children:b})]})}),t.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:t.jsx(De,{onRecruit:N,isRecruiting:h,isLoading:p})})]})}):t.jsx(le,{open:i,onOpenChange:e,children:t.jsxs(ce,{className:"sm:max-w-[500px] p-8",children:[t.jsx(de,{className:"mb-4",children:t.jsxs("div",{className:"flex items-center gap-3",children:[_,t.jsx(ue,{className:"text-xl font-semibold",children:b})]})}),t.jsx(De,{onRecruit:N,isRecruiting:h,isLoading:p})]})})}const bt=`<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-CCSxUcSR.js";import{I}from"./input-CGOXGU1T.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-O-xThSQt.js";import{I}from"./input-oRQz03qA.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 It,r as re,s as fe,o as Re,b as xe,z as Mt,a as pe,t as ue,x as U,K as ne,j as s,B as Ie,e as W,w as At,n as bt,c as Pe,l as Ge,E as _t}from"./index-CCSxUcSR.js";import{C as Et}from"./collection-display-button-SRtbYzi1.js";import{S as Pt}from"./search-input-ChGtPve4.js";import{P as Te}from"./index-_ffZL8NJ.js";import{C as Rt}from"./collection-table-wrapper-D1vIquPS.js";import{E as Ve}from"./empty-state-BCisGTAH.js";import{b as zt,h as $t,a as Dt,c as kt,d as Ft,D as Lt}from"./dialog-Bnn50qLi.js";import{a as Ot,F as et,b as tt,c as qt,d as st,f as nt}from"./form-B5N66yji.js";import{S as Je,a as He,b as We,c as Ye,d as Ze}from"./select-CuiyoiL_.js";import{T as Bt}from"./textarea-DzkVG7JD.js";import{u as jt}from"./use-organization-roles-CIvbWsgj.js";import{u as Kt}from"./use-members-CguSIAh8.js";import{S as ze,u as $e}from"./constants-Bymra3Z3.js";import{a as Vt,b as Qt,c as Ut,T as Gt}from"./tooltip-BqNUzMrI.js";import{a as it,e as at,g as lt,b as ot,c as rt,d as ct,f as mt,A as dt}from"./alert-dialog-BVSxM9YJ.js";import{A as Oe}from"./avatar-LDMZpKRg.js";import{B as Be}from"./badge-D4FFGy4o.js";import{C as ut}from"./card-Du9Iuv0G.js";import{D as vt,a as Ct,b as yt,e as Jt,d as Ht,f as Wt,c as Xe,i as Yt}from"./dropdown-menu-CqTx-nNo.js";import{i as St}from"./DotsVertical-C2eXnxdz.js";import{a as Zt}from"./SearchMd-BRBTca_N.js";import{i as Xt}from"./Shield01-Ca51KHJr.js";import{s as wt,a as es}from"./XClose-CVgNkrOC.js";import{s as ts}from"./Trash01--9QdImzp.js";import{C as ft}from"./checkbox-D3HYUnZN.js";import{a as Qe,b as Ue,c as ht,C as ss,e as ns,f as is,d as as}from"./command-CqgC97xW.js";import{a as ls,b as os,P as rs}from"./popover-CA7wjTzr.js";import{t as cs}from"./ChevronDown-0xFW1Tjk.js";import{s as ms}from"./Plus-Cz_QF-nO.js";import"./view-mode-toggle-DhxRxMVU.js";import"./X-Bq9xP96R.js";import"./table-DVtFTUHZ.js";import"./label-D4SEK3ff.js";import"./ChevronUp-C8WLqMFJ.js";import"./User01-Blfyt5S4.js";import"./ChevronRight-Da2pMeyD.js";import"./index-SH970SJ0.js";const ds=It().email("Invalid email address");function us(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 fs({trigger:t}){const[e,n]=re.useState(!1),{locator:i}=fe(),r=Re(),{data:a}=xe.useSession(),o=a?.user?.email,{roles:l,isLoading:u}=jt(),f=l.filter(p=>p.role!=="owner"),m=Mt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),S=m.watch("emailsText"),g=m.watch("role"),b=us(S).filter(p=>{const c=ds.safeParse(p).success,x=!o||p!==o.toLowerCase();return c&&x}),T=pe({mutationFn:async({emails:p,role:c})=>{if(!c)throw new Error("Please select a role");const x=await Promise.allSettled(p.map(async E=>{const w=await xe.organization.inviteMember({email:E,role:c});if(w.error)throw new Error(w.error.message);return w.data})),C=x.filter(E=>E.status==="rejected");if(C.length>0)throw new Error(`Failed to invite ${C.length} member${C.length>1?"s":""}`);return x},onSuccess:(p,{emails:c,role:x})=>{ue("member_invited",{count:c.length,role:x}),r.invalidateQueries({queryKey:ne.members(i)}),r.invalidateQueries({queryKey:ne.invitations(i)}),U.success(c.length===1?"Member invited successfully!":`${c.length} members invited successfully!`),m.reset({emailsText:"",role:"user"}),n(!1)},onError:(p,{emails:c,role:x})=>{ue("member_invite_failed",{count:c.length,role:x,error:p instanceof Error?p.message:String(p)}),U.error(p instanceof Error?p.message:"Failed to invite members")}}),y=p=>{if(b.length===0){U.error("Please enter at least one valid email address");return}if(!p.role){U.error("Please select a role");return}T.mutate({emails:b,role:p.role})},M=b.length>0&&!!g;return s.jsxs(zt,{open:e,onOpenChange:n,children:[s.jsx($t,{asChild:!0,children:t}),s.jsxs(Dt,{className:"sm:max-w-lg",children:[s.jsx(kt,{children:s.jsx(Ft,{children:"Invite members"})}),s.jsx(Ot,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(y),className:"space-y-4",children:[s.jsx(et,{control:m.control,name:"emailsText",render:({field:p})=>s.jsxs(tt,{children:[s.jsx(qt,{children:"Email addresses"}),s.jsx(st,{children:s.jsx(Bt,{...p,disabled:T.isPending,placeholder:`Enter email addresses separated by commas or new lines
1
+ import{J as It,r as re,s as fe,o as Re,b as xe,z as Mt,a as pe,t as ue,x as U,K as ne,j as s,B as Ie,e as W,w as At,n as bt,c as Pe,l as Ge,E as _t}from"./index-O-xThSQt.js";import{C as Et}from"./collection-display-button-BANI3stw.js";import{S as Pt}from"./search-input-BA02UXZa.js";import{P as Te}from"./index-DCHF8zOG.js";import{C as Rt}from"./collection-table-wrapper-Ro_jHI87.js";import{E as Ve}from"./empty-state-CtpU7jLB.js";import{b as zt,h as $t,a as Dt,c as kt,d as Ft,D as Lt}from"./dialog-B0QYUD88.js";import{a as Ot,F as et,b as tt,c as qt,d as st,f as nt}from"./form-CEqJ4N_7.js";import{S as Je,a as He,b as We,c as Ye,d as Ze}from"./select-Cq_PvnKV.js";import{T as Bt}from"./textarea-BSpBSpMd.js";import{u as jt}from"./use-organization-roles-BY5zQhyp.js";import{u as Kt}from"./use-members-BLQ9W5Dc.js";import{S as ze,u as $e}from"./constants-ChdU9xvz.js";import{a as Vt,b as Qt,c as Ut,T as Gt}from"./tooltip-CZKTj_88.js";import{a as it,e as at,g as lt,b as ot,c as rt,d as ct,f as mt,A as dt}from"./alert-dialog-D6jDWQW-.js";import{A as Oe}from"./avatar-CKkXwPlY.js";import{B as Be}from"./badge-yfBx4pKw.js";import{C as ut}from"./card-e-NpS5kl.js";import{D as vt,a as Ct,b as yt,e as Jt,d as Ht,f as Wt,c as Xe,i as Yt}from"./dropdown-menu-Dqqv-DxC.js";import{i as St}from"./DotsVertical-DCxBI0BW.js";import{a as Zt}from"./SearchMd-BxcVY0hk.js";import{i as Xt}from"./Shield01-DkQy31Nt.js";import{s as wt,a as es}from"./XClose-DfM5GjZF.js";import{s as ts}from"./Trash01-CqSlmOZQ.js";import{C as ft}from"./checkbox-BWpfDwfi.js";import{a as Qe,b as Ue,c as ht,C as ss,e as ns,f as is,d as as}from"./command-nLSAlSuK.js";import{a as ls,b as os,P as rs}from"./popover-Co2M62hE.js";import{t as cs}from"./ChevronDown-Bg0fGsAy.js";import{s as ms}from"./Plus-DYo953wk.js";import"./view-mode-toggle-BueYVsWt.js";import"./X-BSw526sh.js";import"./table-q-k_hgAt.js";import"./label-C1-enMbO.js";import"./ChevronUp-hL_C00tb.js";import"./User01-BHjwWDd7.js";import"./ChevronRight-DMa-ECep.js";import"./index-CZs7_uJZ.js";const ds=It().email("Invalid email address");function us(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 fs({trigger:t}){const[e,n]=re.useState(!1),{locator:i}=fe(),r=Re(),{data:a}=xe.useSession(),o=a?.user?.email,{roles:l,isLoading:u}=jt(),f=l.filter(p=>p.role!=="owner"),m=Mt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),S=m.watch("emailsText"),g=m.watch("role"),b=us(S).filter(p=>{const c=ds.safeParse(p).success,x=!o||p!==o.toLowerCase();return c&&x}),T=pe({mutationFn:async({emails:p,role:c})=>{if(!c)throw new Error("Please select a role");const x=await Promise.allSettled(p.map(async E=>{const w=await xe.organization.inviteMember({email:E,role:c});if(w.error)throw new Error(w.error.message);return w.data})),C=x.filter(E=>E.status==="rejected");if(C.length>0)throw new Error(`Failed to invite ${C.length} member${C.length>1?"s":""}`);return x},onSuccess:(p,{emails:c,role:x})=>{ue("member_invited",{count:c.length,role:x}),r.invalidateQueries({queryKey:ne.members(i)}),r.invalidateQueries({queryKey:ne.invitations(i)}),U.success(c.length===1?"Member invited successfully!":`${c.length} members invited successfully!`),m.reset({emailsText:"",role:"user"}),n(!1)},onError:(p,{emails:c,role:x})=>{ue("member_invite_failed",{count:c.length,role:x,error:p instanceof Error?p.message:String(p)}),U.error(p instanceof Error?p.message:"Failed to invite members")}}),y=p=>{if(b.length===0){U.error("Please enter at least one valid email address");return}if(!p.role){U.error("Please select a role");return}T.mutate({emails:b,role:p.role})},M=b.length>0&&!!g;return s.jsxs(zt,{open:e,onOpenChange:n,children:[s.jsx($t,{asChild:!0,children:t}),s.jsxs(Dt,{className:"sm:max-w-lg",children:[s.jsx(kt,{children:s.jsx(Ft,{children:"Invite members"})}),s.jsx(Ot,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(y),className:"space-y-4",children:[s.jsx(et,{control:m.control,name:"emailsText",render:({field:p})=>s.jsxs(tt,{children:[s.jsx(qt,{children:"Email addresses"}),s.jsx(st,{children:s.jsx(Bt,{...p,disabled:T.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(nt,{})]})}),s.jsx(et,{control:m.control,name:"role",render:({field:p})=>s.jsxs(tt,{children:[s.jsx(st,{children:s.jsxs(Je,{value:p.value,onValueChange:p.onChange,disabled:T.isPending||u,children:[s.jsx(He,{className:"w-full",children:s.jsx(We,{placeholder:"Select a role"})}),s.jsx(Ye,{children:f.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(Ze,{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(nt,{})]})}),s.jsxs(Lt,{children:[s.jsx(Ie,{variant:"outline",onClick:()=>{m.reset({emailsText:"",role:"user"}),n(!1)},type:"button",disabled:T.isPending,children:"Cancel"}),s.jsx(Ie,{type:"submit",disabled:T.isPending||!M,children:T.isPending?"Inviting...":`Invite ${b.length||0} Member${b.length!==1?"s":""}`})]})]})})]})]})}function hs(){const t=W.c(9),{org:e,locator:n}=fe();let i;t[0]!==e.id?(i={connectionId:ze,orgId:e.id},t[0]=e.id,t[1]=i):i=t[1];const r=$e(i);let a;t[2]!==n?(a=ne.invitations(n),t[2]=n,t[3]=a):a=t[3];let o;t[4]!==r?(o=async()=>{const u=await r.callTool({name:"ORGANIZATION_GET",arguments:{}});return(u.structuredContent??u)?.invitations??[]},t[4]=r,t[5]=o):o=t[5];let l;return t[6]!==a||t[7]!==o?(l={queryKey:a,queryFn:o},t[6]=a,t[7]=o,t[8]=l):l=t[8],At(l)}function gs(){const t=W.c(5),{locator:e}=fe(),n=Re();let i;t[0]!==e||t[1]!==n?(i={mutationFn:xs,onSuccess:()=>{n.invalidateQueries({queryKey:ne.invitations(e)}),U.success("Invitation cancelled")},onError:ps},t[0]=e,t[1]=n,t[2]=i):i=t[2];const r=pe(i);let a;return t[3]!==r?(a={cancel:r},t[3]=r,t[4]=a):a=t[4],a}function ps(t){U.error(t instanceof Error?t.message:"Failed to cancel invitation")}async function xs(t){const e=await xe.organization.cancelInvitation({invitationId:t});if(e?.error)throw new Error(e.error.message);return e.data}function bs(){const t=W.c(9),{org:e,locator:n}=fe();let i;t[0]!==e.id?(i={connectionId:ze,orgId:e.id},t[0]=e.id,t[1]=i):i=t[1];const r=$e(i);let a;t[2]!==n?(a=ne.tags(n),t[2]=n,t[3]=a):a=t[3];let o;t[4]!==r?(o=async()=>{const u=await r.callTool({name:"TAGS_LIST",arguments:{}});return(u.structuredContent??u).tags},t[4]=r,t[5]=o):o=t[5];let l;return t[6]!==a||t[7]!==o?(l={queryKey:a,queryFn:o,staleTime:3e4},t[6]=a,t[7]=o,t[8]=l):l=t[8],bt(l)}function js(){const t=W.c(10),e=Re(),{org:n,locator:i}=fe();let r;t[0]!==n.id?(r={connectionId:ze,orgId:n.id},t[0]=n.id,t[1]=r):r=t[1];const a=$e(r);let o;t[2]!==a?(o=async f=>{const m=await a.callTool({name:"TAGS_CREATE",arguments:{name:f}});return(m.structuredContent??m).tag},t[2]=a,t[3]=o):o=t[3];let l;t[4]!==i||t[5]!==e?(l=()=>{e.invalidateQueries({queryKey:ne.tags(i)})},t[4]=i,t[5]=e,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u={mutationFn:o,onSuccess:l,onError:vs},t[7]=o,t[8]=l,t[9]=u):u=t[9],pe(u)}function vs(t){U.error(t instanceof Error?t.message:"Failed to create tag")}function Cs(t){const e=W.c(12),{org:n,locator:i}=fe();let r;e[0]!==n.id?(r={connectionId:ze,orgId:n.id},e[0]=n.id,e[1]=r):r=e[1];const a=$e(r);let o;e[2]!==i||e[3]!==t?(o=ne.memberTags(i,t),e[2]=i,e[3]=t,e[4]=o):o=e[4];let l;e[5]!==a||e[6]!==t?(l=async()=>{const m=await a.callTool({name:"MEMBER_TAGS_GET",arguments:{memberId:t}});return(m.structuredContent??m).tags},e[5]=a,e[6]=t,e[7]=l):l=e[7];const u=!!t;let f;return e[8]!==o||e[9]!==l||e[10]!==u?(f={queryKey:o,queryFn:l,staleTime:3e4,enabled:u},e[8]=o,e[9]=l,e[10]=u,e[11]=f):f=e[11],bt(f)}function ys(){const t=W.c(10),e=Re(),{org:n,locator:i}=fe();let r;t[0]!==n.id?(r={connectionId:ze,orgId:n.id},t[0]=n.id,t[1]=r):r=t[1];const a=$e(r);let o;t[2]!==a?(o=async f=>{const{memberId:m,tagIds:S}=f,g=await a.callTool({name:"MEMBER_TAGS_SET",arguments:{memberId:m,tagIds:S}});return g.structuredContent??g},t[2]=a,t[3]=o):o=t[3];let l;t[4]!==i||t[5]!==e?(l=(f,m)=>{e.invalidateQueries({queryKey:ne.memberTags(i,m.memberId)})},t[4]=i,t[5]=e,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u={mutationFn:o,onSuccess:l,onError:Ss},t[7]=o,t[8]=l,t[9]=u):u=t[9],pe(u)}function Ss(t){U.error(t instanceof Error?t.message:"Failed to update member tags")}function Nt(t){const e=W.c(44),{memberId:n,className:i,disabled:r,placeholder:a,maxDisplay:o}=t,l=r===void 0?!1:r,u=a===void 0?"Add tags...":a,f=o===void 0?2:o,[m,S]=re.useState(!1),[g,$]=re.useState(""),{data:b,isLoading:T}=bs(),y=b===void 0?[]:b,{data:M,isLoading:p}=Cs(n),c=M===void 0?[]:M,x=js(),C=ys(),E=T||p,w=c.map(Ns);let A;e[0]!==g?(A=v=>v.name.toLowerCase().includes(g.toLowerCase()),e[0]=g,e[1]=A):A=e[1];const P=y.filter(A);let _;e[2]!==g?(_=v=>v.name.toLowerCase()===g.toLowerCase(),e[2]=g,e[3]=_):_=e[3];const R=y.find(_),z=g.trim()&&!R,L=async v=>{const ge=w.includes(v.id)?w.filter(_e=>_e!==v.id):[...w,v.id];await C.mutateAsync({memberId:n,tagIds:ge})},I=async()=>{if(!g.trim())return;const v=await x.mutateAsync(g.trim());await C.mutateAsync({memberId:n,tagIds:[...w,v.id]}),$("")},d=async v=>{const te=w.filter(ge=>ge!==v);await C.mutateAsync({memberId:n,tagIds:te})},N=x.isPending||C.isPending,q=os;let k;e[4]!==m?(k=()=>S(!m),e[4]=m,e[5]=k):k=e[5];let D;e[6]!==i?(D=Pe("h-auto min-h-8 px-2 py-1 justify-start font-normal","hover:bg-accent/50",i),e[6]=i,e[7]=D):D=e[7];const V=l||E,O=E?s.jsx(Ge,{size:14,className:"animate-spin text-muted-foreground"}):c.length>0?s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[c.slice(0,f).map(ws),c.length>f&&s.jsxs(Be,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:["+",c.length-f]})]}):s.jsx("span",{className:"text-muted-foreground text-xs",children:u});let B;e[8]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(cs,{size:14,className:"ml-1 shrink-0 opacity-50"}),e[8]=B):B=e[8];let K;e[9]!==V||e[10]!==O||e[11]!==k||e[12]!==D?(K=s.jsx(rs,{asChild:!0,children:s.jsxs(Ie,{variant:"ghost",size:"sm",onClick:k,className:D,disabled:V,children:[O,B]})}),e[9]=V,e[10]=O,e[11]=k,e[12]=D,e[13]=K):K=e[13];const Q=ls,G="w-56 p-0",ce="start";let J;e[14]===Symbol.for("react.memo_cache_sentinel")?(J=()=>S(!1),e[14]=J):J=e[14];const Me=is,Ae=!1;let ie;e[15]!==g?(ie=s.jsx(as,{placeholder:"Search or create...",value:g,onValueChange:$,className:"h-9"}),e[15]=g,e[16]=ie):ie=e[16];const he=ns,me=c.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Qe,{heading:"Selected",children:c.map(v=>s.jsx(Ue,{onSelect:()=>L(v),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(ft,{checked:!0,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:v.name})]}),s.jsx("button",{onClick:te=>{te.stopPropagation(),d(v.id)},className:"opacity-50 hover:opacity-100",disabled:N,children:s.jsx(wt,{size:14})})]})},v.id))}),s.jsx(ht,{})]}),de=Qe,be="Available",ae=P.length===0&&!z&&s.jsx(ss,{children:"No tags found."}),le=P.filter(v=>!w.includes(v.id)).map(v=>s.jsx(Ue,{onSelect:()=>L(v),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ft,{checked:!1,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:v.name})]})},v.id));let H;e[17]!==de||e[18]!==ae||e[19]!==le?(H=s.jsxs(de,{heading:be,children:[ae,le]}),e[17]=de,e[18]=ae,e[19]=le,e[20]=H):H=e[20];let oe;e[21]!==I||e[22]!==N||e[23]!==g||e[24]!==z?(oe=z&&s.jsxs(s.Fragment,{children:[s.jsx(ht,{}),s.jsx(Qe,{children:s.jsx(Ue,{onSelect:I,className:"cursor-pointer",disabled:N,children:s.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[N?s.jsx(Ge,{size:14,className:"animate-spin"}):s.jsx(ms,{size:14}),s.jsxs("span",{children:['Create "',g.trim(),'"']})]})})})]}),e[21]=I,e[22]=N,e[23]=g,e[24]=z,e[25]=oe):oe=e[25];let Y;e[26]!==he||e[27]!==me||e[28]!==H||e[29]!==oe?(Y=s.jsxs(he,{children:[me,H,oe]}),e[26]=he,e[27]=me,e[28]=H,e[29]=oe,e[30]=Y):Y=e[30];let Z;e[31]!==Me||e[32]!==ie||e[33]!==Y?(Z=s.jsxs(Me,{shouldFilter:Ae,children:[ie,Y]}),e[31]=Me,e[32]=ie,e[33]=Y,e[34]=Z):Z=e[34];let X;e[35]!==Q||e[36]!==J||e[37]!==Z?(X=s.jsx(Q,{className:G,align:ce,onEscapeKeyDown:J,children:Z}),e[35]=Q,e[36]=J,e[37]=Z,e[38]=X):X=e[38];let ee;return e[39]!==q||e[40]!==m||e[41]!==K||e[42]!==X?(ee=s.jsxs(q,{open:m,onOpenChange:S,children:[K,X]}),e[39]=q,e[40]=m,e[41]=K,e[42]=X,e[43]=ee):ee=e[43],ee}function ws(t){return s.jsx(Be,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:t.name},t.id)}function Ns(t){return t.id}const gt=["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"],Ts={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 Is(t){const e=new Map;for(const[n,i]of Object.entries(Ts))e.set(n,i);for(let n=0;n<t.length;n++){const i=t[n];i&&!e.has(i.role)&&e.set(i.role,gt[n%gt.length]??"bg-neutral-400")}return e}function Ms(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function Le(t){const e=W.c(79),{role:n,memberId:i,isOwner:r,roleColorMap:a,selectableRoles:o,onRoleChange:l,size:u,className:f}=t,m=u===void 0?"xs":u;let S,g,$,b,T,y,M,p,c,x,C;if(e[0]!==f||e[1]!==r||e[2]!==i||e[3]!==l||e[4]!==n||e[5]!==a||e[6]!==o||e[7]!==m){C=Symbol.for("react.early_return_sentinel");e:{const I=a.get(n)??"bg-neutral-400";if(r){let d;e[19]!==i||e[20]!==l?(d=G=>l(i,G),e[19]=i,e[20]=l,e[21]=d):d=e[21];let N;e[22]!==n?(N=s.jsx("span",{className:"capitalize truncate",children:n}),e[22]=n,e[23]=N):N=e[23];const q=s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:Pe("size-2 rounded-full shrink-0",I)}),N]});let k;e[24]!==q?(k=s.jsx(We,{children:q}),e[24]=q,e[25]=k):k=e[25];let D;e[26]!==f||e[27]!==m||e[28]!==k?(D=s.jsx(He,{size:m,className:f,children:k}),e[26]=f,e[27]=m,e[28]=k,e[29]=D):D=e[29];let V;if(e[30]!==a||e[31]!==o){let G;e[33]!==a?(G=ce=>{const J=a.get(ce.role)??"bg-neutral-400";return s.jsx(Ze,{value:ce.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:Pe("size-3 rounded-full",J)}),s.jsx("span",{className:"capitalize",children:ce.label})]})},ce.role)},e[33]=a,e[34]=G):G=e[34],V=o.map(G),e[30]=a,e[31]=o,e[32]=V}else V=e[32];let O;e[35]!==V?(O=s.jsx(Ye,{children:V}),e[35]=V,e[36]=O):O=e[36];let B;e[37]!==r||e[38]!==n||e[39]!==d||e[40]!==D||e[41]!==O?(B=s.jsx(Vt,{asChild:!0,children:s.jsx("div",{className:"w-fit",children:s.jsxs(Je,{value:n,onValueChange:d,disabled:r,children:[D,O]})})}),e[37]=r,e[38]=n,e[39]=d,e[40]=D,e[41]=O,e[42]=B):B=e[42];let K;e[43]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Qt,{children:s.jsx("p",{children:"The owner role cannot be changed"})}),e[43]=K):K=e[43];let Q;e[44]!==B?(Q=s.jsx(Ut,{children:s.jsxs(Gt,{children:[B,K]})}),e[44]=B,e[45]=Q):Q=e[45],C=Q;break e}$=Je,p=n,e[46]!==i||e[47]!==l?(c=d=>l(i,d),e[46]=i,e[47]=l,e[48]=c):c=e[48],x=r,g=He,y=m,M=f,S=We,T="flex items-center gap-2 min-w-0",b=Pe("size-2 rounded-full shrink-0",I)}e[0]=f,e[1]=r,e[2]=i,e[3]=l,e[4]=n,e[5]=a,e[6]=o,e[7]=m,e[8]=S,e[9]=g,e[10]=$,e[11]=b,e[12]=T,e[13]=y,e[14]=M,e[15]=p,e[16]=c,e[17]=x,e[18]=C}else S=e[8],g=e[9],$=e[10],b=e[11],T=e[12],y=e[13],M=e[14],p=e[15],c=e[16],x=e[17],C=e[18];if(C!==Symbol.for("react.early_return_sentinel"))return C;let E;e[49]!==b?(E=s.jsx("div",{className:b}),e[49]=b,e[50]=E):E=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 A;e[53]!==E||e[54]!==w||e[55]!==T?(A=s.jsxs("div",{className:T,children:[E,w]}),e[53]=E,e[54]=w,e[55]=T,e[56]=A):A=e[56];let P;e[57]!==S||e[58]!==A?(P=s.jsx(S,{children:A}),e[57]=S,e[58]=A,e[59]=P):P=e[59];let _;e[60]!==g||e[61]!==P||e[62]!==y||e[63]!==M?(_=s.jsx(g,{size:y,className:M,children:P}),e[60]=g,e[61]=P,e[62]=y,e[63]=M,e[64]=_):_=e[64];let R;if(e[65]!==a||e[66]!==o){let I;e[68]!==a?(I=d=>{const N=a.get(d.role)??"bg-neutral-400";return s.jsx(Ze,{value:d.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:Pe("size-3 rounded-full",N)}),s.jsx("span",{className:"capitalize",children:d.label})]})},d.role)},e[68]=a,e[69]=I):I=e[69],R=o.map(I),e[65]=a,e[66]=o,e[67]=R}else R=e[67];let z;e[70]!==R?(z=s.jsx(Ye,{children:R}),e[70]=R,e[71]=z):z=e[71];let L;return e[72]!==$||e[73]!==_||e[74]!==z||e[75]!==p||e[76]!==c||e[77]!==x?(L=s.jsxs($,{value:p,onValueChange:c,disabled:x,children:[_,z]}),e[72]=$,e[73]=_,e[74]=z,e[75]=p,e[76]=c,e[77]=x,e[78]=L):L=e[78],L}function pt(t){const e=W.c(51),{member:n,roles:i,onChangeRole:r,onRemove:a,isUpdating:o}=t,l=o===void 0?!1:o,u=n.role==="owner";let f,m,S,g,$,b,T,y,M;if(e[0]!==u||e[1]!==l||e[2]!==n.id||e[3]!==n.role||e[4]!==r||e[5]!==i){let _;e[15]!==n.role?(_=d=>d.role!==n.role&&d.role!=="owner",e[15]=n.role,e[16]=_):_=e[16];const R=i.filter(_);g=vt;let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(St,{size:20}),e[17]=z):z=e[17],e[18]!==u?(M=s.jsx(Ct,{asChild:!0,children:s.jsx(Ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:u,onClick:_s,children:z})}),e[18]=u,e[19]=M):M=e[19],S=yt,T="end",y=As,m=Jt;let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx(es,{size:16}),e[20]=L):L=e[20],e[21]!==l?(b=s.jsxs(Ht,{disabled:l,children:[L,"Change Role"]}),e[21]=l,e[22]=b):b=e[22],f=Wt;let I;e[23]!==l||e[24]!==n.id||e[25]!==r?(I=d=>{const N=[];return d.isBuiltin||(d.allowsAllStaticPermissions?N.push("Full org access"):d.staticPermissionCount&&d.staticPermissionCount>0&&N.push(`${d.staticPermissionCount} org perm${d.staticPermissionCount!==1?"s":""}`),d.allowsAllConnections?N.push("All connections"):d.connectionCount&&d.connectionCount>0&&N.push(`${d.connectionCount} connection${d.connectionCount!==1?"s":""}`),(d.connectionCount!==0||d.allowsAllConnections)&&(d.allowsAllTools?N.push("all tools"):d.toolCount&&d.toolCount>0&&N.push(`${d.toolCount} tool${d.toolCount!==1?"s":""}`))),s.jsxs(Xe,{onClick:q=>{q.stopPropagation(),r(n.id,d.role)},disabled:l,children:[d.isBuiltin?s.jsx(Xt,{size:16}):s.jsx(Zt,{size:16}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:d.label}),!d.isBuiltin&&N.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:N.join(", ")})]})]},d.role)},e[23]=l,e[24]=n.id,e[25]=r,e[26]=I):I=e[26],$=R.map(I),e[0]=u,e[1]=l,e[2]=n.id,e[3]=n.role,e[4]=r,e[5]=i,e[6]=f,e[7]=m,e[8]=S,e[9]=g,e[10]=$,e[11]=b,e[12]=T,e[13]=y,e[14]=M}else f=e[6],m=e[7],S=e[8],g=e[9],$=e[10],b=e[11],T=e[12],y=e[13],M=e[14];let p;e[27]!==f||e[28]!==$?(p=s.jsx(f,{children:$}),e[27]=f,e[28]=$,e[29]=p):p=e[29];let c;e[30]!==m||e[31]!==b||e[32]!==p?(c=s.jsxs(m,{children:[b,p]}),e[30]=m,e[31]=b,e[32]=p,e[33]=c):c=e[33];let x;e[34]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx(Yt,{}),e[34]=x):x=e[34];let C;e[35]!==n.id||e[36]!==a?(C=_=>{_.stopPropagation(),a(n.id)},e[35]=n.id,e[36]=a,e[37]=C):C=e[37];let E;e[38]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(ts,{size:16}),e[38]=E):E=e[38];let w;e[39]!==C?(w=s.jsxs(Xe,{variant:"destructive",onClick:C,children:[E,"Remove Member"]}),e[39]=C,e[40]=w):w=e[40];let A;e[41]!==S||e[42]!==w||e[43]!==T||e[44]!==y||e[45]!==c?(A=s.jsxs(S,{align:T,onClick:y,children:[c,x,w]}),e[41]=S,e[42]=w,e[43]=T,e[44]=y,e[45]=c,e[46]=A):A=e[46];let P;return e[47]!==g||e[48]!==A||e[49]!==M?(P=s.jsxs(g,{children:[M,A]}),e[47]=g,e[48]=A,e[49]=M,e[50]=P):P=e[50],P}function As(t){return t.stopPropagation()}function _s(t){return t.stopPropagation()}function xt(t){const e=W.c(8),{invitationId:n,onCancel:i,isCancelling:r}=t,a=r===void 0?!1:r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ct,{asChild:!0,children:s.jsx(Ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Ps,children:s.jsx(St,{size:20})})}),e[0]=o):o=e[0];let l;e[1]!==n||e[2]!==i?(l=m=>{m.stopPropagation(),i(n)},e[1]=n,e[2]=i,e[3]=l):l=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(wt,{size:16}),e[4]=u):u=e[4];let f;return e[5]!==a||e[6]!==l?(f=s.jsxs(vt,{children:[o,s.jsx(yt,{align:"end",onClick:Es,children:s.jsxs(Xe,{variant:"destructive",onClick:l,disabled:a,children:[u,"Cancel Invitation"]})})]}),e[5]=a,e[6]=l,e[7]=f):f=e[7],f}function Es(t){return t.stopPropagation()}function Ps(t){return t.stopPropagation()}function Rs(){const t=W.c(86),{data:e}=Kt(),{data:n}=hs(),i=gs(),r=Re(),{locator:a}=fe(),[o,l]=re.useState(null),[u,f]=re.useState(null),[m,S]=re.useState(""),[g,$]=re.useState("table"),[b,T]=re.useState("member"),[y,M]=re.useState("asc"),p=e?.data?.members;let c;t[0]!==b?(c=h=>{b===h?M(Gs):(T(h),M("asc"))},t[0]=b,t[1]=c):c=t[1];const x=c;let C=p??[],E=n??[];if(m){const h=m.toLowerCase();C=C.filter(j=>j.user?.name?.toLowerCase().includes(h)||j.user?.email?.toLowerCase().includes(h)||j.role?.toLowerCase().includes(h)),E=E.filter(j=>j.email?.toLowerCase().includes(h)||j.role?.toLowerCase().includes(h))}if(b&&y){let h;t[2]!==y||t[3]!==b?(h=(j,F)=>{let se,Ee;e:switch(b){case"member":{se=j.user?.name||"",Ee=F.user?.name||"";break e}case"role":{se=j.role||"",Ee=F.role||"";break e}case"joined":{se=j.createdAt?typeof j.createdAt=="string"?j.createdAt:j.createdAt.toISOString():"",Ee=F.createdAt?typeof F.createdAt=="string"?F.createdAt:F.createdAt.toISOString():"";break e}default:return 0}return y==="asc"?se.localeCompare(Ee):Ee.localeCompare(se)},t[2]=y,t[3]=b,t[4]=h):h=t[4],C=[...C].sort(h)}const w=C;let A;t[5]!==a||t[6]!==r?(A={mutationFn:Us,onSuccess:()=>{ue("member_removed"),r.invalidateQueries({queryKey:ne.members(a)}),U.success("Member has been removed from the organization"),l(null)},onError:Qs},t[5]=a,t[6]=r,t[7]=A):A=t[7];const P=pe(A);let _;t[8]!==a||t[9]!==r?(_={mutationFn:Vs,onSuccess:(h,j)=>{ue("member_role_updated",{new_role:j.role}),r.invalidateQueries({queryKey:ne.members(a)}),U.success("Member's role has been updated")},onError:Ks},t[8]=a,t[9]=r,t[10]=_):_=t[10];const R=pe(_);let z;t[11]!==a||t[12]!==r?(z={mutationFn:Bs,onSuccess:(h,j)=>{ue("invitation_role_updated",{new_role:j.role}),r.invalidateQueries({queryKey:ne.invitations(a)}),U.success("Invitation role has been updated")},onError:qs},t[11]=a,t[12]=r,t[13]=z):z=t[13];const L=pe(z),{roles:I,customRoles:d}=jt();let N;t[14]!==d?(N=Is(d),t[14]=d,t[15]=N):N=t[15];const q=N;let k;t[16]!==I?(k=I.filter(Os),t[16]=I,t[17]=k):k=t[17];const D=k;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V={id:"member",header:"Member",render:Ls,cellClassName:"flex-1 min-w-0",sortable:!0},t[18]=V):V=t[18];let O;t[19]!==q||t[20]!==D||t[21]!==L||t[22]!==R?(O={id:"role",header:"Role",render:h=>h.type==="member"?s.jsx(Le,{role:h.data.role,memberId:h.data.id,isOwner:h.data.role==="owner",roleColorMap:q,selectableRoles:D,onRoleChange:(j,F)=>R.mutate({memberId:j,role:F}),className:"w-36"}):s.jsx(Le,{role:h.data.role,memberId:h.data.id,isOwner:!1,roleColorMap:q,selectableRoles:D,onRoleChange:(j,F)=>L.mutate({invitationId:j,role:F,email:h.data.email}),className:"w-36"}),cellClassName:"w-36 shrink-0",sortable:!0},t[19]=q,t[20]=D,t[21]=L,t[22]=R,t[23]=O):O=t[23];let B,K;t[24]===Symbol.for("react.memo_cache_sentinel")?(B={id:"tags",header:"Tags",render:Fs,cellClassName:"w-40 shrink-0"},K={id:"joined",header:"Joined",render:ks,cellClassName:"w-48 shrink-0",sortable:!0},t[24]=B,t[25]=K):(B=t[24],K=t[25]);let Q;t[26]!==i.cancel.isPending||t[27]!==I||t[28]!==R?(Q={id:"actions",header:"",render:h=>h.type==="member"?s.jsx(pt,{member:h.data,roles:I,onChangeRole:(j,F)=>R.mutate({memberId:j,role:F}),onRemove:l,isUpdating:R.isPending}):s.jsx(xt,{invitationId:h.data.id,onCancel:f,isCancelling:i.cancel.isPending}),cellClassName:"w-12 shrink-0"},t[26]=i.cancel.isPending,t[27]=I,t[28]=R,t[29]=Q):Q=t[29];let G;t[30]!==Q||t[31]!==O?(G=[V,O,B,K,Q],t[30]=Q,t[31]=O,t[32]=G):G=t[32];const ce=G;let J;t[33]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(fs,{trigger:s.jsx(Ie,{children:"Invite Member"})})}),t[33]=J):J=t[33];const Me=J,Ae=[...w.map(Ds),...E.filter($s).map(zs)],ie=Te,he=!!u;let me;t[34]===Symbol.for("react.memo_cache_sentinel")?(me=()=>f(null),t[34]=me):me=t[34];let de;t[35]===Symbol.for("react.memo_cache_sentinel")?(de=s.jsxs(ot,{children:[s.jsx(rt,{children:"Cancel Invitation"}),s.jsx(ct,{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[35]=de):de=t[35];let be;t[36]===Symbol.for("react.memo_cache_sentinel")?(be=s.jsx(mt,{children:"Keep Invitation"}),t[36]=be):be=t[36];let ae;t[37]!==i.cancel||t[38]!==u?(ae=()=>{u&&(i.cancel.mutate(u),f(null))},t[37]=i.cancel,t[38]=u,t[39]=ae):ae=t[39];let le;t[40]!==i.cancel.isPending||t[41]!==ae?(le=s.jsxs(it,{children:[de,s.jsxs(at,{children:[be,s.jsx(lt,{onClick:ae,disabled:i.cancel.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Invitation"})]})]}),t[40]=i.cancel.isPending,t[41]=ae,t[42]=le):le=t[42];let H;t[43]!==he||t[44]!==le?(H=s.jsx(dt,{open:he,onOpenChange:me,children:le}),t[43]=he,t[44]=le,t[45]=H):H=t[45];const oe=!!o;let Y;t[46]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>l(null),t[46]=Y):Y=t[46];let Z;t[47]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsxs(ot,{children:[s.jsx(rt,{children:"Remove Member"}),s.jsx(ct,{children:"Are you sure you want to remove this member from the organization? This action cannot be undone."})]}),t[47]=Z):Z=t[47];let X;t[48]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(mt,{children:"Cancel"}),t[48]=X):X=t[48];let ee;t[49]!==o||t[50]!==P?(ee=()=>o&&P.mutate(o),t[49]=o,t[50]=P,t[51]=ee):ee=t[51];let v;t[52]!==P.isPending||t[53]!==ee?(v=s.jsxs(it,{children:[Z,s.jsxs(at,{children:[X,s.jsx(lt,{onClick:ee,disabled:P.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),t[52]=P.isPending,t[53]=ee,t[54]=v):v=t[54];let te;t[55]!==oe||t[56]!==v?(te=s.jsx(dt,{open:oe,onOpenChange:Y,children:v}),t[55]=oe,t[56]=v,t[57]=te):te=t[57];const ge=Te,_e=Te,Tt="flex flex-col gap-6";let je;t[58]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(Te.Title,{children:"Members"}),t[58]=je):je=t[58];let De;t[59]===Symbol.for("react.memo_cache_sentinel")?(De=h=>{h.key==="Escape"&&(S(""),h.target.blur())},t[59]=De):De=t[59];let ve;t[60]!==m?(ve=s.jsx(Pt,{value:m,onChange:S,placeholder:"Search members...",className:"w-full md:w-[375px]",onKeyDown:De}),t[60]=m,t[61]=ve):ve=t[61];let ke;t[62]===Symbol.for("react.memo_cache_sentinel")?(ke=[{id:"member",label:"Name"},{id:"role",label:"Role"},{id:"joined",label:"Joined"}],t[62]=ke):ke=t[62];let Ce;t[63]!==x||t[64]!==y||t[65]!==b||t[66]!==g?(Ce=s.jsx(Et,{viewMode:g,onViewModeChange:$,sortKey:b,sortDirection:y,onSort:x,sortOptions:ke}),t[63]=x,t[64]=y,t[65]=b,t[66]=g,t[67]=Ce):Ce=t[67];let ye;t[68]!==ve||t[69]!==Ce?(ye=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[ve,Ce]}),Me]}),t[68]=ve,t[69]=Ce,t[70]=ye):ye=t[70];const Ke=g==="cards"?s.jsx("div",{children:Ae.length===0?s.jsx(Ve,{title:"No members found",description:m?`No members match "${m}"`:"Invite members to get started."}):s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4",children:Ae.map(h=>{if(h.type==="invitation")return s.jsxs(ut,{className:"transition-colors relative opacity-75",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(xt,{invitationId:h.data.id,onCancel:f,isCancelling:i.cancel.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Oe,{fallback:qe(h.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:h.data.email}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(Be,{variant:"outline",className:"w-fit text-amber-600 border-amber-400",children:"Pending"})}),s.jsx(Le,{role:h.data.role,memberId:h.data.id,isOwner:!1,roleColorMap:q,selectableRoles:D,onRoleChange:(F,se)=>L.mutate({invitationId:F,role:se,email:h.data.email}),className:"w-fit"})]})]})]},`inv-${h.data.id}`);const j=h.data;return s.jsxs(ut,{className:"transition-colors relative",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(pt,{member:j,roles:I,onChangeRole:(F,se)=>R.mutate({memberId:F,role:se}),onRemove:l,isUpdating:R.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Oe,{url:j.user?.image??void 0,fallback:qe(j.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:j.user?.name||"Unknown"}),s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:j.user?.email}),s.jsx(Le,{role:j.role,memberId:j.id,isOwner:j.role==="owner",roleColorMap:q,selectableRoles:D,onRoleChange:(F,se)=>R.mutate({memberId:F,role:se}),className:"w-fit"}),s.jsx(Nt,{memberId:j.id,maxDisplay:3})]})]})]},j.id)})})}):s.jsx(Rt,{columns:ce,data:Ae,isLoading:!1,sortKey:b,sortDirection:y,onSort:x,emptyState:m?s.jsx(Ve,{title:"No members found",description:`No members match "${m}"`}):s.jsx(Ve,{title:"No members found",description:"Invite members to get started."})});let Se;t[71]!==je||t[72]!==ye||t[73]!==Ke?(Se=s.jsxs("div",{className:Tt,children:[je,ye,Ke]}),t[71]=je,t[72]=ye,t[73]=Ke,t[74]=Se):Se=t[74];let we;t[75]!==_e.Body||t[76]!==Se?(we=s.jsx(_e.Body,{children:Se}),t[75]=_e.Body,t[76]=Se,t[77]=we):we=t[77];let Ne;t[78]!==ge.Content||t[79]!==we?(Ne=s.jsx(ge.Content,{children:we}),t[78]=ge.Content,t[79]=we,t[80]=Ne):Ne=t[80];let Fe;return t[81]!==ie||t[82]!==H||t[83]!==te||t[84]!==Ne?(Fe=s.jsxs(ie,{children:[H,te,Ne]}),t[81]=ie,t[82]=H,t[83]=te,t[84]=Ne,t[85]=Fe):Fe=t[85],Fe}function zs(t){return{type:"invitation",data:t}}function $s(t){return t.status==="pending"}function Ds(t){return{type:"member",data:t}}function ks(t){return t.type==="member"?s.jsx("span",{className:"text-sm text-foreground",children:t.data.createdAt?Ms(t.data.createdAt):"N/A"}):s.jsx(Be,{variant:"outline",children:"Pending"})}function Fs(t){return t.type==="member"?s.jsx(Nt,{memberId:t.data.id,maxDisplay:2}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}function Ls(t){return t.type==="member"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Oe,{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(Oe,{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 Os(t){return t.role!=="owner"}function qs(t,e){ue("invitation_role_update_failed",{new_role:e.role,error:t instanceof Error?t.message:String(t)}),U.error(t instanceof Error?t.message:"Failed to update invitation role")}async function Bs(t){const{invitationId:e,role:n,email:i}=t,r=await xe.organization.cancelInvitation({invitationId:e});if(r?.error)throw new Error(r.error.message);const a=await xe.organization.inviteMember({email:i,role:n});if(a?.error)throw new Error(a.error.message)}function Ks(t,e){ue("member_role_update_failed",{new_role:e.role,error:t instanceof Error?t.message:String(t)}),U.error(t instanceof Error?t.message:"Failed to update role")}async function Vs(t){const{memberId:e,role:n}=t,i=await xe.organization.updateMemberRole({memberId:e,role:[n]});if(i?.error)throw new Error(i.error.message)}function Qs(t){ue("member_remove_failed",{error:t instanceof Error?t.message:String(t)}),U.error(t instanceof Error?t.message:"Failed to remove member")}async function Us(t){const e=await xe.organization.removeMember({memberIdOrEmail:t});if(e?.error)throw new Error(e.error.message)}function Gs(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Pn(){const t=W.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Te,{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(_t,{fallback:e,children:s.jsx(re.Suspense,{fallback:s.jsx(Te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(Ge,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(Rs,{})})}),t[1]=n):n=t[1],n}export{Pn as default};
@@ -1,4 +1,4 @@
1
- import{r as a,bc as D,e as Me,j as _,_ as te}from"./index-CCSxUcSR.js";import{S as me}from"./index-CDTT3e7s.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-O-xThSQt.js";import{S as me}from"./index-B6VjlsLE.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