decocms 2.310.1 → 2.310.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/client/assets/{AlertCircle-BUuG9jUS.js → AlertCircle-B72APkrz.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-B2WgGuUG.js → ArrowNarrowLeft-Dz0P9WNF.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-BRxJDyw2.js → ArrowUpRight-CCQZEQ7k.js} +1 -1
  4. package/dist/client/assets/{Check-DNFNSXQB.js → Check-CUpq9BBu.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-fDjMIV_J.js → CheckCircle-DTCxFilU.js} +1 -1
  6. package/dist/client/assets/{ChevronDown-plDbvt9_.js → ChevronDown-D5WF5tyi.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-C6IGuK_L.js → ChevronRight-DwbV0YDZ.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-BQpSShtW.js → ChevronUp-CDMPc0ql.js} +1 -1
  9. package/dist/client/assets/{Container-cby1lpQK.js → Container-BioZd28q.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CrL41KCh.js → DotsVertical-D8wcDPCU.js} +1 -1
  11. package/dist/client/assets/{LinkExternal01-DDjHJHtD.js → LinkExternal01-CKpEz_fF.js} +1 -1
  12. package/dist/client/assets/{Lock01-CMc8wMJA.js → Lock01-CHfwR6Qi.js} +1 -1
  13. package/dist/client/assets/{Palette-BsSq52os.js → Palette-brLBiHpP.js} +1 -1
  14. package/dist/client/assets/{Play-B93BJPTD.js → Play-DRCdZRLW.js} +1 -1
  15. package/dist/client/assets/{Plus-CsU0klMp.js → Plus-DNkjVBwq.js} +1 -1
  16. package/dist/client/assets/{RefreshCcw01-GcJ7_jjW.js → RefreshCcw01-CdP9yH0w.js} +1 -1
  17. package/dist/client/assets/{SearchMd-CLV2ZHE1.js → SearchMd-JqX1mLMq.js} +1 -1
  18. package/dist/client/assets/{Settings02-CMQBJ6AU.js → Settings02-D1Jfvo1d.js} +1 -1
  19. package/dist/client/assets/{Shield01-Bb8uicnU.js → Shield01-D5fQpAyA.js} +1 -1
  20. package/dist/client/assets/{Star01-DOzaFb6_.js → Star01-Y834gtsL.js} +1 -1
  21. package/dist/client/assets/{Sun-Bp560G7u.js → Sun-BgOSswUu.js} +1 -1
  22. package/dist/client/assets/{Tool01-B1WXLPyp.js → Tool01-CXQZ3p7Z.js} +1 -1
  23. package/dist/client/assets/{Trash01-WbvRG8Rr.js → Trash01-B8-uqWxa.js} +1 -1
  24. package/dist/client/assets/{User01-Dqi_S_yw.js → User01-Cxb6YtJq.js} +1 -1
  25. package/dist/client/assets/{Users03-CmMFskSR.js → Users03-CXkopkPu.js} +1 -1
  26. package/dist/client/assets/{X-26aOhFK-.js → X-CdXDgTcN.js} +1 -1
  27. package/dist/client/assets/{XCircle-DuIm7Kpp.js → XCircle-CjR4LC4r.js} +1 -1
  28. package/dist/client/assets/{XClose-Bet7IpXN.js → XClose-zqTFiPq2.js} +1 -1
  29. package/dist/client/assets/{Zap-DHkXBm_R.js → Zap--FKeiDFf.js} +1 -1
  30. package/dist/client/assets/{ZapSquare-B0Ev1OMS.js → ZapSquare-CliIuzcs.js} +1 -1
  31. package/dist/client/assets/{accordion-D1MMgTV5.js → accordion-BBKL1fM-.js} +1 -1
  32. package/dist/client/assets/{agent-icon-BhSIvnHs.js → agent-icon-CaG-DX2m.js} +1 -1
  33. package/dist/client/assets/{agents-list-DfRZsmWN.js → agents-list-BUqQO9y3.js} +1 -1
  34. package/dist/client/assets/ai-providers-BvV5AI1b.js +1 -0
  35. package/dist/client/assets/{alert-dialog-Booud0bQ.js → alert-dialog-B-P8jHly.js} +1 -1
  36. package/dist/client/assets/{auth-catchall-CfLpBYfo.js → auth-catchall-CyIMPFaS.js} +1 -1
  37. package/dist/client/assets/{automation-list-row-3UbFqf20.js → automation-list-row-Qk3UXtKg.js} +1 -1
  38. package/dist/client/assets/{automations-Bpw-Bphr.js → automations-CkkIdwK3.js} +1 -1
  39. package/dist/client/assets/{avatar-Dr_hgnh5.js → avatar-CYyuZ3vB.js} +1 -1
  40. package/dist/client/assets/{badge-Dc_jqHv8.js → badge-C-R5WeFR.js} +1 -1
  41. package/dist/client/assets/{brand-context-DDkAkGby.js → brand-context-BqPn2XVA.js} +1 -1
  42. package/dist/client/assets/{card-I8QwhHay.js → card-BWjsP1pO.js} +1 -1
  43. package/dist/client/assets/{chat-context-DANvJNxJ.js → chat-context-D7DJNKEQ.js} +1 -1
  44. package/dist/client/assets/{checkbox-YDqzyyON.js → checkbox-DRyB8BVf.js} +1 -1
  45. package/dist/client/assets/{collection-detail-CEcX9P1L.js → collection-detail-BiG3-7wS.js} +1 -1
  46. package/dist/client/assets/{collection-display-button-CEbXTT1D.js → collection-display-button-D0yyhe94.js} +1 -1
  47. package/dist/client/assets/{collection-search-ZtrOS_FO.js → collection-search-BtC9EgTH.js} +1 -1
  48. package/dist/client/assets/{collection-search-54YVIzGK.js → collection-search-CVa4reVh.js} +1 -1
  49. package/dist/client/assets/{collection-table-wrapper-CykRk2i4.js → collection-table-wrapper-C2Zi2ikn.js} +1 -1
  50. package/dist/client/assets/{collection-tabs-BJYdyh2U.js → collection-tabs-8bicuWoG.js} +1 -1
  51. package/dist/client/assets/{collections-B4Ew0_5W.js → collections-ZqRHYd6U.js} +1 -1
  52. package/dist/client/assets/{command-BUdSnxPX.js → command-BUJHwA-d.js} +1 -1
  53. package/dist/client/assets/{connection-card-CPkO4XVy.js → connection-card-CiNzXirJ.js} +1 -1
  54. package/dist/client/assets/{connection-detail-7MO-vamz.js → connection-detail-DQFCqOq5.js} +1 -1
  55. package/dist/client/assets/{connection-form-helpers-DTw0Qq7p.js → connection-form-helpers-BFnOvbFy.js} +1 -1
  56. package/dist/client/assets/{connections-Cae6WzSq.js → connections-BzqA2cUL.js} +1 -1
  57. package/dist/client/assets/{constants-8vN_wpoM.js → constants-BmLTAQzq.js} +1 -1
  58. package/dist/client/assets/{constants-C0Z_UV1B.js → constants-Df56C9B1.js} +1 -1
  59. package/dist/client/assets/{dialog-ChC8b-fd.js → dialog-HqMwvS0c.js} +1 -1
  60. package/dist/client/assets/{domain-settings-wSm6QNFe.js → domain-settings-8zUtZk7o.js} +1 -1
  61. package/dist/client/assets/{drawer-C1rmyAh5.js → drawer-hkToOxOG.js} +1 -1
  62. package/dist/client/assets/{dropdown-menu-BYnm4L0S.js → dropdown-menu-CD1YJIi0.js} +1 -1
  63. package/dist/client/assets/{dynamic-plugin-layout-C8rDQhFA.js → dynamic-plugin-layout--sGvQXk2.js} +1 -1
  64. package/dist/client/assets/{empty-state-B5SEGNSf.js → empty-state-B29HN9Vl.js} +1 -1
  65. package/dist/client/assets/{empty-state-CS1xioMM.js → empty-state-CElAqeAn.js} +1 -1
  66. package/dist/client/assets/{extract-connection-data-CnZlsGuF.js → extract-connection-data-DYXiFLZH.js} +1 -1
  67. package/dist/client/assets/{features-B16s5Y96.js → features-Dvru3uGD.js} +1 -1
  68. package/dist/client/assets/{form-DgLK3RL7.js → form-CKajJk24.js} +1 -1
  69. package/dist/client/assets/{general-f6TAIn-G.js → general-D8u2dVV2.js} +1 -1
  70. package/dist/client/assets/{index-fsAFWsFR.js → index--52kuhAD.js} +1 -1
  71. package/dist/client/assets/{index-DsyVbeAM.js → index-BPbckF-i.js} +3 -3
  72. package/dist/client/assets/{index-CbahmBQ1.js → index-BPgW_PVH.js} +1 -1
  73. package/dist/client/assets/index-BTded5vd.js +1 -0
  74. package/dist/client/assets/{index-CgQIf70g.js → index-Boo37gVZ.js} +1 -1
  75. package/dist/client/assets/{index-CGzddOPN.js → index-CHpjwsZ-.js} +1 -1
  76. package/dist/client/assets/{index-TdWHe30j.js → index-CMbhqARA.js} +1 -1
  77. package/dist/client/assets/{index-BtR3GFsv.js → index-CO402MfB.js} +1 -1
  78. package/dist/client/assets/{index-C5EaiV0u.js → index-CgQG3OxM.js} +1 -1
  79. package/dist/client/assets/{index-DlX-BDoo.js → index-ClxNnAsp.js} +1 -1
  80. package/dist/client/assets/{index-CVMf-cdp.js → index-CnR4TnGO.js} +1 -1
  81. package/dist/client/assets/{index-D3id_i25.js → index-D7rGFiVq.js} +1 -1
  82. package/dist/client/assets/{index-BrFuw-qb.js → index-D9-ppQFz.js} +1 -1
  83. package/dist/client/assets/{index-ofAY-Kzj.js → index-DVk4aJ0j.js} +1 -1
  84. package/dist/client/assets/{index-DCa8vMMj.js → index-Y4klGMPr.js} +1 -1
  85. package/dist/client/assets/{index--hcGoWBP.js → index-k8njt3_A.js} +2 -2
  86. package/dist/client/assets/{infiniteQueryObserver-Bw_LLK9Y.js → infiniteQueryObserver-IG8f9wWg.js} +1 -1
  87. package/dist/client/assets/{input-Di5VhXrx.js → input-DrFzs1Yw.js} +1 -1
  88. package/dist/client/assets/{integration-icon-BFclX5Vo.js → integration-icon-DUMCOZJc.js} +1 -1
  89. package/dist/client/assets/{label--CSWWgsb.js → label-0J4Z8Ji8.js} +1 -1
  90. package/dist/client/assets/{layout-DGzZ7eIZ.js → layout-zbF9c9kI.js} +1 -1
  91. package/dist/client/assets/{lean-canvas-recruit-modal-BRNt7FNZ.js → lean-canvas-recruit-modal-D2QgFiqW.js} +1 -1
  92. package/dist/client/assets/{login-CWxs7FH8.js → login-m1plet6k.js} +1 -1
  93. package/dist/client/assets/{members-D-RcZScv.js → members-DsVQeYYP.js} +1 -1
  94. package/dist/client/assets/{monaco-editor-BRZw2Ss_.js → monaco-editor-Br1M5lwR.js} +1 -1
  95. package/dist/client/assets/{monitoring-stats-row-BELQHcMp.js → monitoring-stats-row-BtBHpMXc.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-D1mU79r6.js → oauth-callback-D6DOFeyW.js} +1 -1
  97. package/dist/client/assets/{oauth-callback-ai-provider-BI3N0zYC.js → oauth-callback-ai-provider-wUhwntlH.js} +1 -1
  98. package/dist/client/assets/{onboarding-Corplh-J.js → onboarding-dml5YruP.js} +1 -1
  99. package/dist/client/assets/{org-layout-Dw015CRn.js → org-layout-QSP-N9k0.js} +1 -1
  100. package/dist/client/assets/{org-plugin-layout-BhY_p3Sb.js → org-plugin-layout-ZONr0rlX.js} +1 -1
  101. package/dist/client/assets/{pair-BkQ-4R0Y.js → pair-mf97TAS_.js} +2 -2
  102. package/dist/client/assets/{plugin-empty-state-Daxzikof.js → plugin-empty-state-CFxEUNdF.js} +1 -1
  103. package/dist/client/assets/{plugin-header-DxSn3bJb.js → plugin-header-HXnwUdYS.js} +1 -1
  104. package/dist/client/assets/{plugin-layout-CLDR8aeJ.js → plugin-layout-ZwMLw5wK.js} +1 -1
  105. package/dist/client/assets/{popover-BxTvqO7l.js → popover-DUMNq33j.js} +1 -1
  106. package/dist/client/assets/{profile-CiaA4yp_.js → profile-CyqjRQfg.js} +1 -1
  107. package/dist/client/assets/{project-app-view-C9qLbJFL.js → project-app-view-Di4yF5Oz.js} +1 -1
  108. package/dist/client/assets/registry-DgOCTdY8.js +2 -0
  109. package/dist/client/assets/{registry-layout-DUo-P35f.js → registry-layout-B2U_9fgO.js} +1 -1
  110. package/dist/client/assets/{required-auth-layout-BnqlPeG9.js → required-auth-layout-PH0-_blQ.js} +1 -1
  111. package/dist/client/assets/{reset-password-DHzLCFSu.js → reset-password-5ioWEbN5.js} +1 -1
  112. package/dist/client/assets/{roles-qTMcTl_m.js → roles-4ojRgHgc.js} +1 -1
  113. package/dist/client/assets/{scroll-area-VgUNFi6v.js → scroll-area-D_tsHfC-.js} +1 -1
  114. package/dist/client/assets/{search-input-Fm6Uugnb.js → search-input-Boj5tfQn.js} +1 -1
  115. package/dist/client/assets/{select-4BiO-1He.js → select-B3lWwv9y.js} +1 -1
  116. package/dist/client/assets/{select-model-DbFtB1R4.js → select-model-C-fLwr4k.js} +1 -1
  117. package/dist/client/assets/{settings-layout-B4AxAY74.js → settings-layout-U-ZhWkRq.js} +1 -1
  118. package/dist/client/assets/{settings-section-BqQHUry6.js → settings-section-qufbNRCL.js} +1 -1
  119. package/dist/client/assets/{shell-layout-CcLP72E6.js → shell-layout-G8D-0WXl.js} +1 -1
  120. package/dist/client/assets/{skeleton-D_v3jh_x.js → skeleton-BfKJMKYc.js} +1 -1
  121. package/dist/client/assets/{sso-BgjWtdcn.js → sso-BdojNoX2.js} +1 -1
  122. package/dist/client/assets/{store-IULAwEa2.js → store-DGVb_5C1.js} +1 -1
  123. package/dist/client/assets/store-registry-KlW3QwUJ.js +2 -0
  124. package/dist/client/assets/{switch-Uh77-H9s.js → switch-YLfAn92x.js} +1 -1
  125. package/dist/client/assets/{table-BCa0VyBS.js → table-wHPRdxYv.js} +1 -1
  126. package/dist/client/assets/{tabs-CJMCPubd.js → tabs-8aX3BTo-.js} +1 -1
  127. package/dist/client/assets/{task-status-QVkFLAWD.js → task-status-CY3ltf_M.js} +1 -1
  128. package/dist/client/assets/{textarea-IkB1PXd2.js → textarea-BJZt5-vN.js} +1 -1
  129. package/dist/client/assets/{toggle-group-CxTeQVbK.js → toggle-group-C_B32Tm8.js} +1 -1
  130. package/dist/client/assets/{tools-list-PZv7L79s.js → tools-list-bxPeEc0p.js} +1 -1
  131. package/dist/client/assets/{tooltip-DwEKoS3m.js → tooltip-B26xbtws.js} +1 -1
  132. package/dist/client/assets/{types-DBa5NWuL.js → types-DfgXo_cD.js} +1 -1
  133. package/dist/client/assets/{use-ai-providers-hUoQ1QKn.js → use-ai-providers-CnyJW7s-.js} +1 -1
  134. package/dist/client/assets/{use-collections-CbyJ6t6i.js → use-collections-D66SnH5Q.js} +1 -1
  135. package/dist/client/assets/{use-connection-BZIS5d-M.js → use-connection-9VrA1Bg7.js} +1 -1
  136. package/dist/client/assets/{use-copy-BhwMe7lW.js → use-copy-DpxSUjqd.js} +1 -1
  137. package/dist/client/assets/{use-create-virtual-mcp-Qup6KxHA.js → use-create-virtual-mcp-DBfs4FWm.js} +1 -1
  138. package/dist/client/assets/{use-debounced-autosave-De7heoii.js → use-debounced-autosave-Ja8PcJv_.js} +1 -1
  139. package/dist/client/assets/{use-decopilot-events-BSFPv0OJ.js → use-decopilot-events-DjAxcjIH.js} +1 -1
  140. package/dist/client/assets/{use-delete-connection-CVL2tyXf.js → use-delete-connection-7Blp6D0s.js} +1 -1
  141. package/dist/client/assets/{use-infinite-scroll-B1XpJhs7.js → use-infinite-scroll-IwyU_OvC.js} +1 -1
  142. package/dist/client/assets/{use-list-state-NYzHNEE3.js → use-list-state-Dk2QFrYd.js} +1 -1
  143. package/dist/client/assets/{use-mcp-tools-DEJYwjVI.js → use-mcp-tools-C7yIpDHe.js} +1 -1
  144. package/dist/client/assets/{use-members-CE8F-6Pl.js → use-members-Bg4ZFsu9.js} +1 -1
  145. package/dist/client/assets/{use-navigate-to-agent-BQCBqC6w.js → use-navigate-to-agent-BehsrrsA.js} +1 -1
  146. package/dist/client/assets/{use-org-auth-client-DWMaaDOW.js → use-org-auth-client-mkgKwCAh.js} +1 -1
  147. package/dist/client/assets/{use-org-sso-DG73ueOt.js → use-org-sso-Xv4QV2bL.js} +1 -1
  148. package/dist/client/assets/{use-organization-roles-C_InafKr.js → use-organization-roles-BmH8DM7C.js} +1 -1
  149. package/dist/client/assets/{use-organization-settings-DU3tZPVG.js → use-organization-settings-Coi7Ggqq.js} +1 -1
  150. package/dist/client/assets/{use-registry-connections-BB_6SUlA.js → use-registry-connections-_83vUYHS.js} +1 -1
  151. package/dist/client/assets/{use-status-sounds--S4wlp-c.js → use-status-sounds-DLYnzZvv.js} +1 -1
  152. package/dist/client/assets/{use-tasks-BXrbnymy.js → use-tasks-CUt44N_R.js} +1 -1
  153. package/dist/client/assets/{use-view-mode-30iczyXm.js → use-view-mode-CZXZPLm6.js} +1 -1
  154. package/dist/client/assets/{use-virtual-mcp-DqC7TCRl.js → use-virtual-mcp-BlYQqAfZ.js} +1 -1
  155. package/dist/client/assets/useInfiniteQuery-BJ1I2JSf.js +1 -0
  156. package/dist/client/assets/useSuspenseInfiniteQuery-BpfkmtaB.js +1 -0
  157. package/dist/client/assets/{user-CU2SK3qY.js → user-BFqIXUgg.js} +1 -1
  158. package/dist/client/assets/{view-mode-toggle-ChONnJPm.js → view-mode-toggle-BC7A6oBR.js} +1 -1
  159. package/dist/client/assets/{workflow-C2A8waKp.js → workflow-B3ajRQIi.js} +1 -1
  160. package/dist/client/assets/workflow-detail-l83JU-Mp.js +1 -0
  161. package/dist/client/index.html +1 -1
  162. package/dist/server/cli.js +4 -4
  163. package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
  164. package/dist/server/node_modules/ansi-styles/index.js +223 -0
  165. package/dist/server/node_modules/ansi-styles/package.json +54 -0
  166. package/dist/server/node_modules/ansi-styles/readme.md +173 -0
  167. package/dist/server/node_modules/escape-string-regexp/index.d.ts +18 -0
  168. package/dist/server/node_modules/escape-string-regexp/index.js +11 -0
  169. package/dist/server/node_modules/escape-string-regexp/package.json +43 -0
  170. package/dist/server/node_modules/escape-string-regexp/readme.md +29 -0
  171. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  172. package/dist/server/node_modules/is-fullwidth-code-point/index.js +12 -0
  173. package/dist/server/node_modules/{slice-ansi → is-fullwidth-code-point}/license +0 -1
  174. package/dist/server/node_modules/is-fullwidth-code-point/package.json +53 -0
  175. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +31 -0
  176. package/dist/server/server.js +3 -3
  177. package/package.json +1 -1
  178. package/dist/client/assets/ai-providers-C2Z8tM8W.js +0 -1
  179. package/dist/client/assets/index-Cf1ZbDa8.js +0 -1
  180. package/dist/client/assets/registry-Ijr9ccjx.js +0 -2
  181. package/dist/client/assets/store-registry-BRPkAkWY.js +0 -2
  182. package/dist/client/assets/useInfiniteQuery-Cy6k7dIo.js +0 -1
  183. package/dist/client/assets/useSuspenseInfiniteQuery-DvQj0VfO.js +0 -1
  184. package/dist/client/assets/workflow-detail-DtfIhsSe.js +0 -1
  185. package/dist/server/node_modules/get-east-asian-width/index.d.ts +0 -60
  186. package/dist/server/node_modules/get-east-asian-width/index.js +0 -30
  187. package/dist/server/node_modules/get-east-asian-width/lookup-data.js +0 -18
  188. package/dist/server/node_modules/get-east-asian-width/lookup.js +0 -135
  189. package/dist/server/node_modules/get-east-asian-width/package.json +0 -71
  190. package/dist/server/node_modules/get-east-asian-width/readme.md +0 -65
  191. package/dist/server/node_modules/get-east-asian-width/utilities.js +0 -24
  192. package/dist/server/node_modules/mimic-fn/index.d.ts +0 -54
  193. package/dist/server/node_modules/mimic-fn/index.js +0 -13
  194. package/dist/server/node_modules/mimic-fn/package.json +0 -42
  195. package/dist/server/node_modules/mimic-fn/readme.md +0 -69
  196. package/dist/server/node_modules/slice-ansi/index.d.ts +0 -19
  197. package/dist/server/node_modules/slice-ansi/index.js +0 -260
  198. package/dist/server/node_modules/slice-ansi/package.json +0 -59
  199. package/dist/server/node_modules/slice-ansi/readme.md +0 -54
  200. package/dist/server/node_modules/slice-ansi/tokenize-ansi.js +0 -752
  201. /package/dist/server/node_modules/{get-east-asian-width → ansi-styles}/license +0 -0
  202. /package/dist/server/node_modules/{mimic-fn → escape-string-regexp}/license +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-C9qLbJFL.js","assets/index--hcGoWBP.js","assets/index-CpHJcJk3.css","assets/pair-BkQ-4R0Y.js","assets/agent-icon-BhSIvnHs.js","assets/AlertCircle-BUuG9jUS.js","assets/Tool01-B1WXLPyp.js","assets/XClose-Bet7IpXN.js","assets/RefreshCcw01-GcJ7_jjW.js","assets/ArrowNarrowLeft-B2WgGuUG.js","assets/XCircle-DuIm7Kpp.js","assets/ArrowUpRight-BRxJDyw2.js","assets/ZapSquare-B0Ev1OMS.js","assets/Users03-CmMFskSR.js","assets/CheckCircle-fDjMIV_J.js","assets/Check-DNFNSXQB.js","assets/ChevronDown-plDbvt9_.js","assets/ChevronRight-C6IGuK_L.js","assets/ChevronUp-BQpSShtW.js","assets/DotsVertical-CrL41KCh.js","assets/Container-cby1lpQK.js","assets/Star01-DOzaFb6_.js","assets/Palette-BsSq52os.js","assets/SearchMd-CLV2ZHE1.js","assets/index-DlX-BDoo.js","assets/tooltip-DwEKoS3m.js","assets/X-26aOhFK-.js","assets/LinkExternal01-DDjHJHtD.js","assets/Lock01-CMc8wMJA.js","assets/Sun-Bp560G7u.js","assets/Play-B93BJPTD.js","assets/Plus-CsU0klMp.js","assets/Settings02-CMQBJ6AU.js","assets/Shield01-Bb8uicnU.js","assets/Trash01-WbvRG8Rr.js","assets/User01-Dqi_S_yw.js","assets/Zap-DHkXBm_R.js","assets/index-CbahmBQ1.js","assets/use-copy-BhwMe7lW.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-ChC8b-fd.js","assets/content-blocks-o63cs2vh.js","assets/types-DBa5NWuL.js","assets/constants-C0Z_UV1B.js","assets/chat-context-DANvJNxJ.js","assets/use-virtual-mcp-DqC7TCRl.js","assets/use-collections-CbyJ6t6i.js","assets/use-ai-providers-hUoQ1QKn.js","assets/use-decopilot-events-BSFPv0OJ.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-BXrbnymy.js","assets/use-organization-settings-DU3tZPVG.js","assets/shell-layout-CcLP72E6.js","assets/required-auth-layout-BnqlPeG9.js","assets/use-org-sso-DG73ueOt.js","assets/integration-icon-BFclX5Vo.js","assets/use-mcp-tools-DEJYwjVI.js"])))=>i.map(i=>d[i]);
2
- import{o as fs,r as P,p as zl,q as $l,e as F,s as be,K as zs,n as Xo,a as Jo,c as ie,j as o,l as Be,B as oe,E as Ut,b as Ei,v as hi,f as Lt,d as nn,w as Fl,x as ge,y as Hl,V as Wl,t as Ce,z as Zo,C as Ul,D as Ht,F as Vl,G as Nn,L as Kl,H as Ui,I as si,J as dt,M as Qo,P as ql,_ as Gl,Q as ea,R as ta,T as Yl,g as Xl}from"./index--hcGoWBP.js";import{C as Ee,u as Jl,w as Zl,A as Ql,T as ec,a as tc,S as sc}from"./index-CGzddOPN.js";import{I as ms}from"./integration-icon-BFclX5Vo.js";import{S as Ot,u as We,g as sa,a as ia}from"./constants-C0Z_UV1B.js";import{u as Nt,a as ic}from"./use-virtual-mcp-DqC7TCRl.js";import{a as rc}from"./Users03-CmMFskSR.js";import{u as ra,a as xt,b as Ti,c as _s,t as nc,d as jn}from"./chat-context-DANvJNxJ.js";import{i as $s}from"./AlertCircle-BUuG9jUS.js";import{i as oc}from"./CheckCircle-fDjMIV_J.js";import{n as En,a as ac}from"./ZapSquare-B0Ev1OMS.js";import{i as lc,a as cc,b as hc,c as Ri,d as dc}from"./XCircle-DuIm7Kpp.js";import{s as hs,i as uc}from"./XClose-Bet7IpXN.js";import{c as fc,r as mc,p as na,f as Tn,a as _c,F as pc,t as Rn,M as on,G as oa,L as gc,i as vc,b as xc,d as bc,e as Sc}from"./pair-BkQ-4R0Y.js";import{C as yc,a as Dn,b as Mn,c as wc,d as Cc,e as kc,f as Nc}from"./command-BUdSnxPX.js";import{P as qs,a as Gs,b as Ys}from"./popover-BxTvqO7l.js";import{i as As,a as bi,b as jc,c as Ec,p as Di,g as Mi,d as an,e as aa,h as pr,f as Vi,j as In,A as An,k as la,l as Tc,m as Rc,n as Dc,t as Mc,o as Ic,q as di,r as ca,s as ha,u as da,v as Bn,w as Ac,x as Bs,y as Bc,z as Pc,B as ua}from"./agent-icon-BhSIvnHs.js";import{u as ps,a as Lc}from"./use-mcp-tools-DEJYwjVI.js";import{u as Oc,a as zc}from"./use-ai-providers-hUoQ1QKn.js";import{g as Gt,c as Pn,u as $c,b as gr,d as Fc,e as Hc,f as Wc,T as Uc}from"./index-ofAY-Kzj.js";import{u as Ii,i as Vc}from"./shell-layout-CcLP72E6.js";import{i as Kc,P as ht,u as qc,c as Gc,d as Yc,e as Xc}from"./index-DlX-BDoo.js";import{u as fa,T as Ge,a as Ye,b as Xe,c as Jc}from"./tooltip-DwEKoS3m.js";import{u as Zc}from"./use-status-sounds--S4wlp-c.js";import{E as Fs}from"./empty-state-CS1xioMM.js";import{A as Qc,a as eh,b as th,c as sh,R as ma,d as ih,e as rh}from"./accordion-D1MMgTV5.js";import{u as Ai,a as ln,b as nh}from"./use-connection-BZIS5d-M.js";import{g as oh}from"./constants-8vN_wpoM.js";import{u as ah,g as lh}from"./types-DBa5NWuL.js";import{u as _a,G as ch}from"./lean-canvas-recruit-modal-BRNt7FNZ.js";import{U as pa}from"./user-CU2SK3qY.js";import{T as hh,u as ga}from"./tools-list-PZv7L79s.js";import{u as dh}from"./unwrap-tool-result-BYXdCQMg.js";import{s as va,g as uh}from"./connection-slug-eyAPH6o3.js";import{A as xa,a as ba,b as Sa,c as ya,d as wa,e as Ca,f as ka,g as Na}from"./alert-dialog-Booud0bQ.js";import{D as fh,a as cn,b as hn,c as ja,d as Ea}from"./dialog-ChC8b-fd.js";import{C as mh,a as Ln}from"./card-I8QwhHay.js";import{I as gs}from"./input-Di5VhXrx.js";import{L as Ps}from"./label--CSWWgsb.js";import{S as is,a as rs,b as ns,c as os,d as Pt}from"./select-4BiO-1He.js";import{S as vr}from"./switch-Uh77-H9s.js";import{T as On}from"./textarea-IkB1PXd2.js";import{i as ui}from"./Play-B93BJPTD.js";import{s as ds}from"./Plus-CsU0klMp.js";import{a as _h}from"./Settings02-CMQBJ6AU.js";import{t as Ta,i as ph}from"./Tool01-B1WXLPyp.js";import{s as xr}from"./Trash01-WbvRG8Rr.js";import{u as Ra}from"./use-debounced-autosave-De7heoii.js";import{S as Da}from"./scroll-area-VgUNFi6v.js";import{i as Ma,a as gh}from"./SearchMd-CLV2ZHE1.js";import{C as vh}from"./collection-tabs-BJYdyh2U.js";import{C as xh}from"./checkbox-YDqzyyON.js";import{u as bh,T as Ki,a as Sh,b as yh,c as qi}from"./tabs-CJMCPubd.js";import{D as wh,a as Ch,b as kh}from"./drawer-C1rmyAh5.js";import{i as Bi}from"./Check-DNFNSXQB.js";import{n as Yt}from"./LinkExternal01-DDjHJHtD.js";import{S as Nh}from"./index-CbahmBQ1.js";import{D as as,a as ls,b as cs,c as kt,d as jh,e as Eh,f as Th}from"./dropdown-menu-BYnm4L0S.js";import{t as br}from"./ChevronDown-plDbvt9_.js";import{i as Ia}from"./RefreshCcw01-GcJ7_jjW.js";import{V as Rh}from"./view-mode-toggle-ChONnJPm.js";import{M as Dh}from"./select-model-DbFtB1R4.js";import{u as Mh}from"./use-organization-settings-DU3tZPVG.js";import{u as Xs,a as Ih,b as Ah,c as Bh,A as Ph,d as Lh}from"./automation-list-row-3UbFqf20.js";import{i as Hs}from"./Zap-DHkXBm_R.js";import{S as Oh}from"./search-input-Fm6Uugnb.js";import"./use-navigate-to-agent-BQCBqC6w.js";import"./use-tasks-BXrbnymy.js";import"./use-collections-CbyJ6t6i.js";import"./collection-search-54YVIzGK.js";import"./form-DgLK3RL7.js";import"./Star01-DOzaFb6_.js";import"./Lock01-CMc8wMJA.js";import"./X-26aOhFK-.js";import"./toggle-group-CxTeQVbK.js";import"./index-D3id_i25.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-CPkO4XVy.js";import"./use-registry-connections-BB_6SUlA.js";import"./useInfiniteQuery-Cy6k7dIo.js";import"./infiniteQueryObserver-Bw_LLK9Y.js";import"./extract-connection-data-CnZlsGuF.js";import"./Container-cby1lpQK.js";import"./connection-form-helpers-DTw0Qq7p.js";import"./use-infinite-scroll-B1XpJhs7.js";import"./useSuspenseInfiniteQuery-DvQj0VfO.js";import"./badge-Dc_jqHv8.js";import"./ChevronRight-C6IGuK_L.js";import"./use-decopilot-events-BSFPv0OJ.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-BhwMe7lW.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-Bp560G7u.js";import"./index-C5EaiV0u.js";import"./ArrowNarrowLeft-B2WgGuUG.js";import"./ArrowUpRight-BRxJDyw2.js";import"./ChevronUp-BQpSShtW.js";import"./DotsVertical-CrL41KCh.js";import"./Palette-BsSq52os.js";import"./Shield01-Bb8uicnU.js";import"./User01-Dqi_S_yw.js";import"./skeleton-D_v3jh_x.js";import"./avatar-Dr_hgnh5.js";import"./index-DCa8vMMj.js";import"./collection-search-ZtrOS_FO.js";import"./use-create-virtual-mcp-Qup6KxHA.js";import"./task-status-QVkFLAWD.js";import"./required-auth-layout-BnqlPeG9.js";import"./use-org-sso-DG73ueOt.js";import"./collections-B4Ew0_5W.js";import"./settings-section-BqQHUry6.js";import"./formatDistanceToNow-Cb2QZZJn.js";function zh(t,e){const s=fs(e);return $h({filters:{...t,status:"pending"}},s).length}function zn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function $h(t={},e){const s=fs(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=zn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=zl(r.current,zn(s,i.current));r.current!==a&&(r.current=a,$l.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Fh(t,e){const s=F.c(40),{org:i,locator:r}=be();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Ot,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=We(n),l=fs();let h;s[3]!==t||s[4]!==i.id?(h=zs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Xo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const k=w.content,R=Array.isArray(k)&&k[0]&&typeof k[0]=="object"?k[0].text??"Create failed":"Create failed";throw new Error(R)}return w.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:zs.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Jo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),P.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let w;return s[32]!==x?(w={status:"error",error:x},s[32]=x,s[33]=w):w=s[33],w}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function ys(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $n(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Hh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Wh(t){const e=F.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Uh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Uh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Vh(t){const e=F.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==f?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=w):w=e[29],w}function Kh(t){const e=F.c(19),{part:s}=t,i=s.input?.agent_id,r=Nt(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(ms,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=ie("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Be,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(lc,{size:12,className:"text-destructive"}):c?o.jsx($s,{size:12,className:"text-warning"}):o.jsx(oc,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function qh(t){const e=F.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=ra(),{tasks:h,taskId:c}=xt(),{selectedModel:u,selectedVirtualMcp:d}=Ti();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=X=>X.id===c,e[17]=c,e[18]=N):N=e[18];const k=h.find(N),R=fc(l),E=[...l].reverse().find(rd),B=E?.metadata?.usage,A=E?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,T=B?.contextTokens??B?.totalTokens??0,y=A&&A>0?(T/A*100).toFixed(1):null,C=l;let j;e[19]!==C?(j=C.filter(id).reduce(sd,0),e[19]=C,e[20]=j):j=e[20];const D=j,M=l;let I;e[21]!==M?(I=M.filter(td).reduce(ed,0),e[21]=M,e[22]=I):I=e[22];const O=I,q=Math.max(0,R.totalTokens-D-O),H=l[0],U=l.at(-1),Q=H?.metadata?.created_at??k?.created_at,ee=U?.metadata?.created_at??k?.updated_at,W=l.filter(Qh),Y=l.flatMap(Jh),$=u?.modelId?Hh(u.modelId):"—",K=d?.title??"Decopilot",L=[{label:"Session",value:k?.title??"New chat"},{label:"Messages",value:W.length},{label:"Agent",value:K},{label:"Model",value:$},{label:"Context Limit",value:A?ys(A):"—"},{label:"Session Tokens (billed)",value:R.totalTokens>0?ys(R.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:R.inputTokens>0?ys(R.inputTokens):"0"},{label:"Output Tokens",value:R.outputTokens>0?ys(R.outputTokens):"0"},{label:"Reasoning Tokens",value:R.reasoningTokens>0?ys(R.reasoningTokens):"0"},{label:"Cost",value:R.cost>0?`$${R.cost<.001?R.cost.toFixed(6):R.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:$n(Q)},{label:"Last Activity",value:$n(ee)}];if(!k&&W.length===0){let X;e[23]!==r?(X=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=X):X=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let fe;e[26]!==i?(fe=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(hs,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=fe):fe=e[27];let de;e[28]!==s||e[29]!==fe?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:fe})]}),e[28]=s,e[29]=fe,e[30]=de):de=e[30];let ue;e[31]===Symbol.for("react.memo_cache_sentinel")?(ue=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=ue):ue=e[31];let ve;e[32]!==X||e[33]!==de?(ve=o.jsxs("div",{className:X,children:[de,ue]}),e[32]=X,e[33]=de,e[34]=ve):ve=e[34],S=ve;break e}e[35]!==r?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let Z;e[37]===Symbol.for("react.memo_cache_sentinel")?(Z=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=Z):Z=e[37];let te;e[38]!==i?(te=i?o.jsx(En,{size:14}):o.jsx(hs,{size:14}),e[38]=i,e[39]=te):te=e[39],e[40]!==s||e[41]!==te?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Z,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:te})]}),e[40]=s,e[41]=te,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=Y.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:Y.map(Xh)})]}),m=o.jsx(Wh,{items:L});let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=se):se=e[43],e[44]!==O||e[45]!==q||e[46]!==D?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[se,o.jsx(Vh,{userTokens:D,assistantTokens:O,otherTokens:q})]}),e[44]=O,e[45]=q,e[46]=D,e[47]=p):p=e[47],g=W.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:W.map(X=>{const he=X.metadata?.created_at,fe=n?.id===X.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(fe?null:X),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:ie("shrink-0 font-medium",X.role==="user"?"text-chart-1":"text-chart-2"),children:X.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:X.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),fe&&o.jsxs(o.Fragment,{children:[X.role==="assistant"&&(()=>{const de=X.metadata?._request;if(!de)return null;const ue=de.systemSections??[],ve=Math.max(1,...ue.map(Yh)),De=ue.reduce(Gh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),ue.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(De/4).toLocaleString()," ","tok"]})]}),ue.map((Ue,Ke)=>{const Qe=Ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Ke}`,me=Ue.chars/ve*100,Tt=Math.round(Ue.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:Qe}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Tt.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${me}%`}})})]},Ke)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(X,null,2)})]})]},X.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Gh(t,e){return t+e.chars}function Yh(t){return t.chars}function Xh(t,e){return o.jsx(Kh,{part:t},e)}function Jh(t){return(t.parts??[]).filter(Zh)}function Zh(t){return t.type==="tool-subtask"}function Qh(t){return t.role!=="system"}function ed(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function td(t){return t.role==="assistant"}function sd(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function id(t){return t.role==="user"}function rd(t){return t.role==="assistant"&&t.metadata?.usage}const Fn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Hn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function nd(){const t=Fn[Math.floor(Math.random()*Fn.length)],e=Hn[Math.floor(Math.random()*Hn.length)];return`deco/${t}-${e}`}function od(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function ad(t){const e=F.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=We(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:dd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ps(g);let x,w;e[11]!==r||e[12]!==a?(w=new Set(Object.keys(a?.[r]??{})),x=[...w].sort().map(hd),e[11]=r,e[12]=a,e[13]=x,e[14]=w):(x=e[13],w=e[14]);const N=x;let k;if(e[15]!==v||e[16]!==w){const A=Array.isArray(v)?v:v?.branches??[];let T;e[18]!==w?(T=y=>!w.has(y.name),e[18]=w,e[19]=T):T=e[19],k=A.filter(cd).filter(T).map(ld),e[15]=v,e[16]=w,e[17]=k}else k=e[17];const R=k,E=Array.isArray(v)?null:v?.default_branch??null;let B;return e[20]!==E||e[21]!==S||e[22]!==b||e[23]!==R||e[24]!==N?(B={yours:N,others:R,defaultBase:E,isLoading:b,isError:S},e[20]=E,e[21]=S,e[22]=b,e[23]=R,e[24]=N,e[25]=B):B=e[25],B}function ld(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function cd(t){return typeof t.name=="string"}function hd(t){return{name:t,source:"yours"}}function dd(t){return od(t)}function ud(t){const e=F.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=ad(_);let b;e[9]!==u?(b=D=>{u(D),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(As,{className:"h-3.5 w-3.5"}),e[11]=w):w=e[11];let N;e[12]!==x?(N=o.jsx(qs,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[w,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=N):N=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(Cc,{placeholder:"Search branches…"}),e[14]=k):k=e[14];let R;e[15]!==S?(R=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[k,o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(nd()),children:"New"})]}),e[15]=S,e[16]=R):R=e[16];let E;e[17]!==v?(E=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=E):E=e[18];let B;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(B=!v&&!g&&m.length===0&&p.length===0&&o.jsx(yc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=B):B=e[23];let A;e[24]!==S||e[25]!==m?(A=m.length>0&&o.jsx(Dn,{heading:"Your branches",children:m.map(D=>o.jsxs(Mn,{value:D.name,onSelect:()=>S(D.name),children:[o.jsx(As,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:D.name})]},D.name))}),e[24]=S,e[25]=m,e[26]=A):A=e[26];let T;e[27]!==p||e[28]!==S?(T=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(wc,{}),o.jsx(Dn,{heading:"Other branches in repo",children:p.map(D=>o.jsxs(Mn,{value:D.name,onSelect:()=>S(D.name),children:[o.jsx(As,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:D.name}),D.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",D.author]})]},D.name))})]}),e[27]=p,e[28]=S,e[29]=T):T=e[29];let y;e[30]!==T||e[31]!==E||e[32]!==B||e[33]!==A?(y=o.jsxs(kc,{children:[E,B,A,T]}),e[30]=T,e[31]=E,e[32]=B,e[33]=A,e[34]=y):y=e[34];let C;e[35]!==y||e[36]!==R?(C=o.jsx(Gs,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Nc,{children:[R,y]})}),e[35]=y,e[36]=R,e[37]=C):C=e[37];let j;return e[38]!==d||e[39]!==C||e[40]!==N?(j=o.jsxs(Ys,{open:d,onOpenChange:f,children:[N,C]}),e[38]=d,e[39]=C,e[40]=N,e[41]=j):j=e[41],j}function fd(){const t=F.c(27),{org:e}=be(),{selectedVirtualMcp:s}=Ti(),{data:i}=Ei.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=xt();let a;t[0]!==e.id?(a=sa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Nt(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(rc,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(ms,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(ud,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(Ee.IceBreakers,{})}),t[24]=x):x=t[24];let w;return t[25]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=w):w=t[26],w}function md(){const t=F.c(26),{org:e}=be(),s=Oc(),{isChatEmpty:i}=ra(),[r,n]=P.useState("chat"),a=Jl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Ee,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Ee.Main,{className:"flex flex-col items-center",children:o.jsx(Ee.EmptyState,{children:o.jsx(Ee.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Zl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(Ee.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(fd,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(Ee.Messages,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(qh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(Ee,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Aa(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Ee.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ut,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(Ee.Skeleton,{}),children:o.jsx(md,{})})}),t[1]=s):s=t[1],s}async function _d(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ba=["VM_START"],ii=new Map,pd=t=>`${t.virtualMcpId}::${t.branch??""}`,Gi=new Set,Si={mark:(t,e)=>Gi.add(`${t}::${e}`),clear:(t,e)=>Gi.delete(`${t}::${e}`),isStopped:(t,e)=>Gi.has(`${t}::${e}`)};function dn(t){const e=fs();return Jo({mutationKey:Ba,mutationFn:async s=>{s.branch&&Si.clear(s.virtualMcpId,s.branch);const i=pd(s),r=ii.get(i);if(r)return r;const n=(async()=>(await _d(t,"VM_START",s)).structuredContent)();ii.set(i,n);try{return await n}finally{ii.get(i)===n&&ii.delete(i)}},onSuccess:()=>{hi(e)}})}function Pa(t,e){const s=F.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ba,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],zh(i)>0}const gd={settings:Ec,automations:jc,env:bi,preview:cc,git:As};function Wn(t){const e=Di(t);if(e.type==="icon"){const s=Mi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Yi(t){if(t.kind==="system")return{kind:"component",Component:gd[t.tabId]};const e=Wn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Wn(s.icon);return i||{kind:"fallback"}}function vd(t){const{org:e}=be(),s=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),{data:i}=Fl({queryKey:zs.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function La(t){const e=F.c(8),s=Lt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=nn(i),n=Nt(t.virtualMcpId),a=vd(t.taskId),{currentBranch:l}=xt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Gt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ai(m),{activeTab:g,mainOpen:v}=mc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(xd)}:null}),b=na(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const E of f){const B=Tn(E.appId,E.toolName);x.set(B,{id:B,title:E.toolName,appId:E.appId,iconKey:E.toolName})}for(const E of d){const B=Tn(E.connectionId,E.toolName);x.set(B,{id:B,title:E.label||E.toolName,appId:E.connectionId,iconKey:E.toolName,iconUrl:E.icon??null})}let w;e[2]!==p?(w=E=>({id:E.id,title:E.title,kind:"agent",icon:Yi({tabId:E.id,kind:"agent",appId:E.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const N=[...u.map(w),...Array.from(x.values()).map(E=>({id:E.id,title:E.title,kind:"expanded",icon:Yi({tabId:E.iconKey,kind:"expanded",appId:E.appId,iconUrl:E.iconUrl,connections:p})})),...S.map(E=>({id:E.id,title:E.title,kind:"system",icon:Yi({tabId:E.id,kind:"system",connections:p})}))];let k;return e[4]!==g||e[5]!==v||e[6]!==s?(k=E=>{const B=_c({clickedId:E,activeTab:g,mainOpen:v});s({to:".",search:A=>({...A,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=k):k=e[7],{activeTab:g,mainOpen:v,setActiveTab:k,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:N}}function xd(t){return{id:t.id}}function Oa(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-Di4yF5Oz.js","assets/index-k8njt3_A.js","assets/index-CpHJcJk3.css","assets/pair-mf97TAS_.js","assets/agent-icon-CaG-DX2m.js","assets/AlertCircle-B72APkrz.js","assets/Tool01-CXQZ3p7Z.js","assets/XClose-zqTFiPq2.js","assets/RefreshCcw01-CdP9yH0w.js","assets/ArrowNarrowLeft-Dz0P9WNF.js","assets/XCircle-CjR4LC4r.js","assets/ArrowUpRight-CCQZEQ7k.js","assets/ZapSquare-CliIuzcs.js","assets/Users03-CXkopkPu.js","assets/CheckCircle-DTCxFilU.js","assets/Check-CUpq9BBu.js","assets/ChevronDown-D5WF5tyi.js","assets/ChevronRight-DwbV0YDZ.js","assets/ChevronUp-CDMPc0ql.js","assets/DotsVertical-D8wcDPCU.js","assets/Container-BioZd28q.js","assets/Star01-Y834gtsL.js","assets/Palette-brLBiHpP.js","assets/SearchMd-JqX1mLMq.js","assets/index-ClxNnAsp.js","assets/tooltip-B26xbtws.js","assets/X-CdXDgTcN.js","assets/LinkExternal01-CKpEz_fF.js","assets/Lock01-CHfwR6Qi.js","assets/Sun-BgOSswUu.js","assets/Play-DRCdZRLW.js","assets/Plus-DNkjVBwq.js","assets/Settings02-D1Jfvo1d.js","assets/Shield01-D5fQpAyA.js","assets/Trash01-B8-uqWxa.js","assets/User01-Cxb6YtJq.js","assets/Zap--FKeiDFf.js","assets/index-BPgW_PVH.js","assets/use-copy-DpxSUjqd.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-HqMwvS0c.js","assets/content-blocks-o63cs2vh.js","assets/types-DfgXo_cD.js","assets/constants-Df56C9B1.js","assets/chat-context-D7DJNKEQ.js","assets/use-virtual-mcp-BlYQqAfZ.js","assets/use-collections-D66SnH5Q.js","assets/use-ai-providers-CnyJW7s-.js","assets/use-decopilot-events-DjAxcjIH.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-CUt44N_R.js","assets/use-organization-settings-Coi7Ggqq.js","assets/shell-layout-G8D-0WXl.js","assets/required-auth-layout-PH0-_blQ.js","assets/use-org-sso-Xv4QV2bL.js","assets/integration-icon-DUMCOZJc.js","assets/use-mcp-tools-C7yIpDHe.js"])))=>i.map(i=>d[i]);
2
+ import{o as fs,r as P,p as zl,q as $l,e as F,s as be,K as zs,n as Xo,a as Jo,c as ie,j as o,l as Be,B as oe,E as Ut,b as Ei,v as hi,f as Lt,d as nn,w as Fl,x as ge,y as Hl,V as Wl,t as Ce,z as Zo,C as Ul,D as Ht,F as Vl,G as Nn,L as Kl,H as Ui,I as si,J as dt,M as Qo,P as ql,_ as Gl,Q as ea,R as ta,T as Yl,g as Xl}from"./index-k8njt3_A.js";import{C as Ee,u as Jl,w as Zl,A as Ql,T as ec,a as tc,S as sc}from"./index-CHpjwsZ-.js";import{I as ms}from"./integration-icon-DUMCOZJc.js";import{S as Ot,u as We,g as sa,a as ia}from"./constants-Df56C9B1.js";import{u as Nt,a as ic}from"./use-virtual-mcp-BlYQqAfZ.js";import{a as rc}from"./Users03-CXkopkPu.js";import{u as ra,a as xt,b as Ti,c as _s,t as nc,d as jn}from"./chat-context-D7DJNKEQ.js";import{i as $s}from"./AlertCircle-B72APkrz.js";import{i as oc}from"./CheckCircle-DTCxFilU.js";import{n as En,a as ac}from"./ZapSquare-CliIuzcs.js";import{i as lc,a as cc,b as hc,c as Ri,d as dc}from"./XCircle-CjR4LC4r.js";import{s as hs,i as uc}from"./XClose-zqTFiPq2.js";import{c as fc,r as mc,p as na,f as Tn,a as _c,F as pc,t as Rn,M as on,G as oa,L as gc,i as vc,b as xc,d as bc,e as Sc}from"./pair-mf97TAS_.js";import{C as yc,a as Dn,b as Mn,c as wc,d as Cc,e as kc,f as Nc}from"./command-BUJHwA-d.js";import{P as qs,a as Gs,b as Ys}from"./popover-DUMNq33j.js";import{i as As,a as bi,b as jc,c as Ec,p as Di,g as Mi,d as an,e as aa,h as pr,f as Vi,j as In,A as An,k as la,l as Tc,m as Rc,n as Dc,t as Mc,o as Ic,q as di,r as ca,s as ha,u as da,v as Bn,w as Ac,x as Bs,y as Bc,z as Pc,B as ua}from"./agent-icon-CaG-DX2m.js";import{u as ps,a as Lc}from"./use-mcp-tools-C7yIpDHe.js";import{u as Oc,a as zc}from"./use-ai-providers-CnyJW7s-.js";import{g as Gt,c as Pn,u as $c,b as gr,d as Fc,e as Hc,f as Wc,T as Uc}from"./index-DVk4aJ0j.js";import{u as Ii,i as Vc}from"./shell-layout-G8D-0WXl.js";import{i as Kc,P as ht,u as qc,c as Gc,d as Yc,e as Xc}from"./index-ClxNnAsp.js";import{u as fa,T as Ge,a as Ye,b as Xe,c as Jc}from"./tooltip-B26xbtws.js";import{u as Zc}from"./use-status-sounds-DLYnzZvv.js";import{E as Fs}from"./empty-state-CElAqeAn.js";import{A as Qc,a as eh,b as th,c as sh,R as ma,d as ih,e as rh}from"./accordion-BBKL1fM-.js";import{u as Ai,a as ln,b as nh}from"./use-connection-9VrA1Bg7.js";import{g as oh}from"./constants-BmLTAQzq.js";import{u as ah,g as lh}from"./types-DfgXo_cD.js";import{u as _a,G as ch}from"./lean-canvas-recruit-modal-D2QgFiqW.js";import{U as pa}from"./user-BFqIXUgg.js";import{T as hh,u as ga}from"./tools-list-bxPeEc0p.js";import{u as dh}from"./unwrap-tool-result-BYXdCQMg.js";import{s as va,g as uh}from"./connection-slug-eyAPH6o3.js";import{A as xa,a as ba,b as Sa,c as ya,d as wa,e as Ca,f as ka,g as Na}from"./alert-dialog-B-P8jHly.js";import{D as fh,a as cn,b as hn,c as ja,d as Ea}from"./dialog-HqMwvS0c.js";import{C as mh,a as Ln}from"./card-BWjsP1pO.js";import{I as gs}from"./input-DrFzs1Yw.js";import{L as Ps}from"./label-0J4Z8Ji8.js";import{S as is,a as rs,b as ns,c as os,d as Pt}from"./select-B3lWwv9y.js";import{S as vr}from"./switch-YLfAn92x.js";import{T as On}from"./textarea-BJZt5-vN.js";import{i as ui}from"./Play-DRCdZRLW.js";import{s as ds}from"./Plus-DNkjVBwq.js";import{a as _h}from"./Settings02-D1Jfvo1d.js";import{t as Ta,i as ph}from"./Tool01-CXQZ3p7Z.js";import{s as xr}from"./Trash01-B8-uqWxa.js";import{u as Ra}from"./use-debounced-autosave-Ja8PcJv_.js";import{S as Da}from"./scroll-area-D_tsHfC-.js";import{i as Ma,a as gh}from"./SearchMd-JqX1mLMq.js";import{C as vh}from"./collection-tabs-8bicuWoG.js";import{C as xh}from"./checkbox-DRyB8BVf.js";import{u as bh,T as Ki,a as Sh,b as yh,c as qi}from"./tabs-8aX3BTo-.js";import{D as wh,a as Ch,b as kh}from"./drawer-hkToOxOG.js";import{i as Bi}from"./Check-CUpq9BBu.js";import{n as Yt}from"./LinkExternal01-CKpEz_fF.js";import{S as Nh}from"./index-BPgW_PVH.js";import{D as as,a as ls,b as cs,c as kt,d as jh,e as Eh,f as Th}from"./dropdown-menu-CD1YJIi0.js";import{t as br}from"./ChevronDown-D5WF5tyi.js";import{i as Ia}from"./RefreshCcw01-CdP9yH0w.js";import{V as Rh}from"./view-mode-toggle-BC7A6oBR.js";import{M as Dh}from"./select-model-C-fLwr4k.js";import{u as Mh}from"./use-organization-settings-Coi7Ggqq.js";import{u as Xs,a as Ih,b as Ah,c as Bh,A as Ph,d as Lh}from"./automation-list-row-Qk3UXtKg.js";import{i as Hs}from"./Zap--FKeiDFf.js";import{S as Oh}from"./search-input-Boj5tfQn.js";import"./use-navigate-to-agent-BehsrrsA.js";import"./use-tasks-CUt44N_R.js";import"./use-collections-D66SnH5Q.js";import"./collection-search-CVa4reVh.js";import"./form-CKajJk24.js";import"./Star01-Y834gtsL.js";import"./Lock01-CHfwR6Qi.js";import"./X-CdXDgTcN.js";import"./toggle-group-C_B32Tm8.js";import"./index-D7rGFiVq.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-CiNzXirJ.js";import"./use-registry-connections-_83vUYHS.js";import"./useInfiniteQuery-BJ1I2JSf.js";import"./infiniteQueryObserver-IG8f9wWg.js";import"./extract-connection-data-DYXiFLZH.js";import"./Container-BioZd28q.js";import"./connection-form-helpers-BFnOvbFy.js";import"./use-infinite-scroll-IwyU_OvC.js";import"./useSuspenseInfiniteQuery-BpfkmtaB.js";import"./badge-C-R5WeFR.js";import"./ChevronRight-DwbV0YDZ.js";import"./use-decopilot-events-DjAxcjIH.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-DpxSUjqd.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-BgOSswUu.js";import"./index-CgQG3OxM.js";import"./ArrowNarrowLeft-Dz0P9WNF.js";import"./ArrowUpRight-CCQZEQ7k.js";import"./ChevronUp-CDMPc0ql.js";import"./DotsVertical-D8wcDPCU.js";import"./Palette-brLBiHpP.js";import"./Shield01-D5fQpAyA.js";import"./User01-Cxb6YtJq.js";import"./skeleton-BfKJMKYc.js";import"./avatar-CYyuZ3vB.js";import"./index-Y4klGMPr.js";import"./collection-search-BtC9EgTH.js";import"./use-create-virtual-mcp-DBfs4FWm.js";import"./task-status-CY3ltf_M.js";import"./required-auth-layout-PH0-_blQ.js";import"./use-org-sso-Xv4QV2bL.js";import"./collections-ZqRHYd6U.js";import"./settings-section-qufbNRCL.js";import"./formatDistanceToNow-Cb2QZZJn.js";function zh(t,e){const s=fs(e);return $h({filters:{...t,status:"pending"}},s).length}function zn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function $h(t={},e){const s=fs(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=zn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=zl(r.current,zn(s,i.current));r.current!==a&&(r.current=a,$l.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Fh(t,e){const s=F.c(40),{org:i,locator:r}=be();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Ot,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=We(n),l=fs();let h;s[3]!==t||s[4]!==i.id?(h=zs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Xo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const k=w.content,R=Array.isArray(k)&&k[0]&&typeof k[0]=="object"?k[0].text??"Create failed":"Create failed";throw new Error(R)}return w.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:zs.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Jo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),P.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let w;return s[32]!==x?(w={status:"error",error:x},s[32]=x,s[33]=w):w=s[33],w}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function ys(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function $n(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Hh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Wh(t){const e=F.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Uh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Uh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Vh(t){const e=F.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==f?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=w):w=e[29],w}function Kh(t){const e=F.c(19),{part:s}=t,i=s.input?.agent_id,r=Nt(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(ms,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=ie("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Be,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(lc,{size:12,className:"text-destructive"}):c?o.jsx($s,{size:12,className:"text-warning"}):o.jsx(oc,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function qh(t){const e=F.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=ra(),{tasks:h,taskId:c}=xt(),{selectedModel:u,selectedVirtualMcp:d}=Ti();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=X=>X.id===c,e[17]=c,e[18]=N):N=e[18];const k=h.find(N),R=fc(l),E=[...l].reverse().find(rd),B=E?.metadata?.usage,A=E?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,T=B?.contextTokens??B?.totalTokens??0,y=A&&A>0?(T/A*100).toFixed(1):null,C=l;let j;e[19]!==C?(j=C.filter(id).reduce(sd,0),e[19]=C,e[20]=j):j=e[20];const D=j,M=l;let I;e[21]!==M?(I=M.filter(td).reduce(ed,0),e[21]=M,e[22]=I):I=e[22];const O=I,q=Math.max(0,R.totalTokens-D-O),H=l[0],U=l.at(-1),Q=H?.metadata?.created_at??k?.created_at,ee=U?.metadata?.created_at??k?.updated_at,W=l.filter(Qh),Y=l.flatMap(Jh),$=u?.modelId?Hh(u.modelId):"—",K=d?.title??"Decopilot",L=[{label:"Session",value:k?.title??"New chat"},{label:"Messages",value:W.length},{label:"Agent",value:K},{label:"Model",value:$},{label:"Context Limit",value:A?ys(A):"—"},{label:"Session Tokens (billed)",value:R.totalTokens>0?ys(R.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:R.inputTokens>0?ys(R.inputTokens):"0"},{label:"Output Tokens",value:R.outputTokens>0?ys(R.outputTokens):"0"},{label:"Reasoning Tokens",value:R.reasoningTokens>0?ys(R.reasoningTokens):"0"},{label:"Cost",value:R.cost>0?`$${R.cost<.001?R.cost.toFixed(6):R.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:$n(Q)},{label:"Last Activity",value:$n(ee)}];if(!k&&W.length===0){let X;e[23]!==r?(X=ie("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=X):X=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let fe;e[26]!==i?(fe=i?o.jsx(En,{size:14,className:"text-muted-foreground"}):o.jsx(hs,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=fe):fe=e[27];let de;e[28]!==s||e[29]!==fe?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:fe})]}),e[28]=s,e[29]=fe,e[30]=de):de=e[30];let ue;e[31]===Symbol.for("react.memo_cache_sentinel")?(ue=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=ue):ue=e[31];let ve;e[32]!==X||e[33]!==de?(ve=o.jsxs("div",{className:X,children:[de,ue]}),e[32]=X,e[33]=de,e[34]=ve):ve=e[34],S=ve;break e}e[35]!==r?(v=ie("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let Z;e[37]===Symbol.for("react.memo_cache_sentinel")?(Z=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=Z):Z=e[37];let te;e[38]!==i?(te=i?o.jsx(En,{size:14}):o.jsx(hs,{size:14}),e[38]=i,e[39]=te):te=e[39],e[40]!==s||e[41]!==te?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Z,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:te})]}),e[40]=s,e[41]=te,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=Y.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:Y.map(Xh)})]}),m=o.jsx(Wh,{items:L});let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=se):se=e[43],e[44]!==O||e[45]!==q||e[46]!==D?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[se,o.jsx(Vh,{userTokens:D,assistantTokens:O,otherTokens:q})]}),e[44]=O,e[45]=q,e[46]=D,e[47]=p):p=e[47],g=W.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:W.map(X=>{const he=X.metadata?.created_at,fe=n?.id===X.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(fe?null:X),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:ie("shrink-0 font-medium",X.role==="user"?"text-chart-1":"text-chart-2"),children:X.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:X.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),fe&&o.jsxs(o.Fragment,{children:[X.role==="assistant"&&(()=>{const de=X.metadata?._request;if(!de)return null;const ue=de.systemSections??[],ve=Math.max(1,...ue.map(Yh)),De=ue.reduce(Gh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),ue.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(De/4).toLocaleString()," ","tok"]})]}),ue.map((Ue,Ke)=>{const Qe=Ue.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Ke}`,me=Ue.chars/ve*100,Tt=Math.round(Ue.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:Qe}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Tt.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${me}%`}})})]},Ke)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(X,null,2)})]})]},X.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Gh(t,e){return t+e.chars}function Yh(t){return t.chars}function Xh(t,e){return o.jsx(Kh,{part:t},e)}function Jh(t){return(t.parts??[]).filter(Zh)}function Zh(t){return t.type==="tool-subtask"}function Qh(t){return t.role!=="system"}function ed(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function td(t){return t.role==="assistant"}function sd(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function id(t){return t.role==="user"}function rd(t){return t.role==="assistant"&&t.metadata?.usage}const Fn=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Hn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function nd(){const t=Fn[Math.floor(Math.random()*Fn.length)],e=Hn[Math.floor(Math.random()*Hn.length)];return`deco/${t}-${e}`}function od(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function ad(t){const e=F.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=We(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:dd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ps(g);let x,w;e[11]!==r||e[12]!==a?(w=new Set(Object.keys(a?.[r]??{})),x=[...w].sort().map(hd),e[11]=r,e[12]=a,e[13]=x,e[14]=w):(x=e[13],w=e[14]);const N=x;let k;if(e[15]!==v||e[16]!==w){const A=Array.isArray(v)?v:v?.branches??[];let T;e[18]!==w?(T=y=>!w.has(y.name),e[18]=w,e[19]=T):T=e[19],k=A.filter(cd).filter(T).map(ld),e[15]=v,e[16]=w,e[17]=k}else k=e[17];const R=k,E=Array.isArray(v)?null:v?.default_branch??null;let B;return e[20]!==E||e[21]!==S||e[22]!==b||e[23]!==R||e[24]!==N?(B={yours:N,others:R,defaultBase:E,isLoading:b,isError:S},e[20]=E,e[21]=S,e[22]=b,e[23]=R,e[24]=N,e[25]=B):B=e[25],B}function ld(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function cd(t){return typeof t.name=="string"}function hd(t){return{name:t,source:"yours"}}function dd(t){return od(t)}function ud(t){const e=F.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=ad(_);let b;e[9]!==u?(b=D=>{u(D),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let w;e[11]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(As,{className:"h-3.5 w-3.5"}),e[11]=w):w=e[11];let N;e[12]!==x?(N=o.jsx(qs,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[w,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=N):N=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(Cc,{placeholder:"Search branches…"}),e[14]=k):k=e[14];let R;e[15]!==S?(R=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[k,o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(nd()),children:"New"})]}),e[15]=S,e[16]=R):R=e[16];let E;e[17]!==v?(E=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=E):E=e[18];let B;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(B=!v&&!g&&m.length===0&&p.length===0&&o.jsx(yc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=B):B=e[23];let A;e[24]!==S||e[25]!==m?(A=m.length>0&&o.jsx(Dn,{heading:"Your branches",children:m.map(D=>o.jsxs(Mn,{value:D.name,onSelect:()=>S(D.name),children:[o.jsx(As,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:D.name})]},D.name))}),e[24]=S,e[25]=m,e[26]=A):A=e[26];let T;e[27]!==p||e[28]!==S?(T=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(wc,{}),o.jsx(Dn,{heading:"Other branches in repo",children:p.map(D=>o.jsxs(Mn,{value:D.name,onSelect:()=>S(D.name),children:[o.jsx(As,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:D.name}),D.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",D.author]})]},D.name))})]}),e[27]=p,e[28]=S,e[29]=T):T=e[29];let y;e[30]!==T||e[31]!==E||e[32]!==B||e[33]!==A?(y=o.jsxs(kc,{children:[E,B,A,T]}),e[30]=T,e[31]=E,e[32]=B,e[33]=A,e[34]=y):y=e[34];let C;e[35]!==y||e[36]!==R?(C=o.jsx(Gs,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Nc,{children:[R,y]})}),e[35]=y,e[36]=R,e[37]=C):C=e[37];let j;return e[38]!==d||e[39]!==C||e[40]!==N?(j=o.jsxs(Ys,{open:d,onOpenChange:f,children:[N,C]}),e[38]=d,e[39]=C,e[40]=N,e[41]=j):j=e[41],j}function fd(){const t=F.c(27),{org:e}=be(),{selectedVirtualMcp:s}=Ti(),{data:i}=Ei.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=xt();let a;t[0]!==e.id?(a=sa(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Nt(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(rc,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(ms,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(ud,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(Ee.IceBreakers,{})}),t[24]=x):x=t[24];let w;return t[25]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=w):w=t[26],w}function md(){const t=F.c(26),{org:e}=be(),s=Oc(),{isChatEmpty:i}=ra(),[r,n]=P.useState("chat"),a=Jl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Ee,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Ee.Main,{className:"flex flex-col items-center",children:o.jsx(Ee.EmptyState,{children:o.jsx(Ee.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Zl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(Ee.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(fd,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee.Main,{children:o.jsx(Ee.Messages,{})}),o.jsx(Ee.Footer,{children:o.jsx(Ee.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=ie("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(qh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(Ee,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Aa(){const t=F.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Ee.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ut,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(Ee.Skeleton,{}),children:o.jsx(md,{})})}),t[1]=s):s=t[1],s}async function _d(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ba=["VM_START"],ii=new Map,pd=t=>`${t.virtualMcpId}::${t.branch??""}`,Gi=new Set,Si={mark:(t,e)=>Gi.add(`${t}::${e}`),clear:(t,e)=>Gi.delete(`${t}::${e}`),isStopped:(t,e)=>Gi.has(`${t}::${e}`)};function dn(t){const e=fs();return Jo({mutationKey:Ba,mutationFn:async s=>{s.branch&&Si.clear(s.virtualMcpId,s.branch);const i=pd(s),r=ii.get(i);if(r)return r;const n=(async()=>(await _d(t,"VM_START",s)).structuredContent)();ii.set(i,n);try{return await n}finally{ii.get(i)===n&&ii.delete(i)}},onSuccess:()=>{hi(e)}})}function Pa(t,e){const s=F.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ba,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],zh(i)>0}const gd={settings:Ec,automations:jc,env:bi,preview:cc,git:As};function Wn(t){const e=Di(t);if(e.type==="icon"){const s=Mi(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Yi(t){if(t.kind==="system")return{kind:"component",Component:gd[t.tabId]};const e=Wn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Wn(s.icon);return i||{kind:"fallback"}}function vd(t){const{org:e}=be(),s=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),{data:i}=Fl({queryKey:zs.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function La(t){const e=F.c(8),s=Lt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=nn(i),n=Nt(t.virtualMcpId),a=vd(t.taskId),{currentBranch:l}=xt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Gt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ai(m),{activeTab:g,mainOpen:v}=mc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(xd)}:null}),b=na(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const E of f){const B=Tn(E.appId,E.toolName);x.set(B,{id:B,title:E.toolName,appId:E.appId,iconKey:E.toolName})}for(const E of d){const B=Tn(E.connectionId,E.toolName);x.set(B,{id:B,title:E.label||E.toolName,appId:E.connectionId,iconKey:E.toolName,iconUrl:E.icon??null})}let w;e[2]!==p?(w=E=>({id:E.id,title:E.title,kind:"agent",icon:Yi({tabId:E.id,kind:"agent",appId:E.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const N=[...u.map(w),...Array.from(x.values()).map(E=>({id:E.id,title:E.title,kind:"expanded",icon:Yi({tabId:E.iconKey,kind:"expanded",appId:E.appId,iconUrl:E.iconUrl,connections:p})})),...S.map(E=>({id:E.id,title:E.title,kind:"system",icon:Yi({tabId:E.id,kind:"system",connections:p})}))];let k;return e[4]!==g||e[5]!==v||e[6]!==s?(k=E=>{const B=_c({clickedId:E,activeTab:g,mainOpen:v});s({to:".",search:A=>({...A,main:B}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=k):k=e[7],{activeTab:g,mainOpen:v,setActiveTab:k,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:N}}function xd(t){return{id:t.id}}function Oa(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
3
3
  <current_instructions>${n}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function bd(t){const e=F.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:u}=t,d=a===void 0?"lg":a,f=c===void 0?!0:c,_=u===void 0?!1:u,[m,p]=P.useState(!1),[g,v]=P.useState("icons"),[b,S]=P.useState(""),[x,w]=P.useState("blue");let N;e[0]!==s?(N=Di(s),e[0]=s,e[1]=N):N=e[1];const k=N,R=k.type==="icon"||k.type==="url"&&k.color?k.color:x;let E;e[2]!==i||e[3]!==R?(E=me=>{i(Vi(me,R))},e[2]=i,e[3]=R,e[4]=E):E=e[4];const B=E;let A;e[5]!==i||e[6]!==r||e[7]!==k.name||e[8]!==k.type||e[9]!==k.url?(A=me=>{w(me),r?.(me),k.type==="icon"?i(Vi(k.name,me)):k.type==="url"&&i(In(k.url,me))},e[5]=i,e[6]=r,e[7]=k.name,e[8]=k.type,e[9]=k.url,e[10]=A):A=e[10];const T=A;let y;e[11]!==i||e[12]!==R?(y=me=>{i(In(me,R)),p(!1)},e[11]=i,e[12]=R,e[13]=y):y=e[13];const C=y;let j;e[14]!==i||e[15]!==R?(j=()=>{const me=an(),Tt=me[Math.floor(Math.random()*me.length)];i(Vi(Tt,R))},e[14]=i,e[15]=R,e[16]=j):j=e[16];const D=j;let M,I,O,q,H,U,Q,ee;if(e[17]!==l||e[18]!==_||e[19]!==m||e[20]!==d){const me={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};I=Ys,U=_?!1:m,Q=p,M=qs,H=!0,ee="button",O=_,q=ie("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",me[d],l),e[17]=l,e[18]=_,e[19]=m,e[20]=d,e[21]=M,e[22]=I,e[23]=O,e[24]=q,e[25]=H,e[26]=U,e[27]=Q,e[28]=ee}else M=e[21],I=e[22],O=e[23],q=e[24],H=e[25],U=e[26],Q=e[27],ee=e[28];let W;e[29]!==h||e[30]!==n||e[31]!==d||e[32]!==s?(W=o.jsx(An,{icon:s,name:n,size:d,className:h}),e[29]=h,e[30]=n,e[31]=d,e[32]=s,e[33]=W):W=e[33];let Y;e[34]!==_||e[35]!==f?(Y=f&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(la,{size:16,className:"text-white"})}),e[34]=_,e[35]=f,e[36]=Y):Y=e[36];let $;e[37]!==O||e[38]!==q||e[39]!==W||e[40]!==Y||e[41]!==ee?($=o.jsxs("button",{type:ee,disabled:O,className:q,children:[W,Y]}),e[37]=O,e[38]=q,e[39]=W,e[40]=Y,e[41]=ee,e[42]=$):$=e[42];let K;e[43]!==M||e[44]!==H||e[45]!==$?(K=o.jsx(M,{asChild:H,children:$}),e[43]=M,e[44]=H,e[45]=$,e[46]=K):K=e[46];let L;e[47]!==n||e[48]!==s?(L=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(An,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=L):L=e[49];let Z;e[50]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>v("icons"),e[50]=Z):Z=e[50];const te=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let se;e[51]!==te?(se=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",te),e[51]=te,e[52]=se):se=e[52];let X;e[53]!==se?(X=o.jsx("button",{type:"button",onClick:Z,className:se,children:"Icons"}),e[53]=se,e[54]=X):X=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const fe=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==fe?(de=ie("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",fe),e[56]=fe,e[57]=de):de=e[57];let ue;e[58]!==de?(ue=o.jsx("button",{type:"button",onClick:he,className:de,children:"Upload"}),e[58]=de,e[59]=ue):ue=e[59];let ve;e[60]===Symbol.for("react.memo_cache_sentinel")?(ve=o.jsx("div",{className:"flex-1"}),e[60]=ve):ve=e[60];let De;e[61]!==X||e[62]!==ue?(De=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[X,ue,ve]}),e[61]=X,e[62]=ue,e[63]=De):De=e[63];let Ue;e[64]!==T||e[65]!==D||e[66]!==B||e[67]!==C||e[68]!==k.name||e[69]!==k.type||e[70]!==b||e[71]!==R||e[72]!==g?(Ue=g==="icons"?o.jsx(Cd,{search:b,onSearchChange:S,selectedColor:R,onColorChange:T,onSelectIcon:B,onRandom:D,currentIconName:k.type==="icon"?k.name:null}):o.jsx(kd,{onUpload:C}),e[64]=T,e[65]=D,e[66]=B,e[67]=C,e[68]=k.name,e[69]=k.type,e[70]=b,e[71]=R,e[72]=g,e[73]=Ue):Ue=e[73];let Ke;e[74]!==L||e[75]!==De||e[76]!==Ue?(Ke=o.jsx(Gs,{align:"start",className:"w-80 p-0",onOpenAutoFocus:Sd,children:o.jsxs("div",{className:"flex flex-col",children:[L,De,Ue]})}),e[74]=L,e[75]=De,e[76]=Ue,e[77]=Ke):Ke=e[77];let Qe;return e[78]!==I||e[79]!==U||e[80]!==Q||e[81]!==K||e[82]!==Ke?(Qe=o.jsxs(I,{open:U,onOpenChange:Q,children:[K,Ke]}),e[78]=I,e[79]=U,e[80]=Q,e[81]=K,e[82]=Ke,e[83]=Qe):Qe=e[83],Qe}function Sd(t){return t.preventDefault()}function yd(t){const e=F.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=P.useState(!1);let a,l,h,c,u,d,f;if(e[0]!==r||e[1]!==s){const b=aa(s);l=Ys,d=r,f=n,a=qs,u=!0,h="button",c=ie("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=u,e[7]=d,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],u=e[6],d=e[7],f=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let m;e[12]!==a||e[13]!==u||e[14]!==_?(m=o.jsx(a,{asChild:u,children:_}),e[12]=a,e[13]=u,e[14]=_,e[15]=m):m=e[15];let p;e[16]!==i||e[17]!==s?(p=Rc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:ie("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Gs,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:wd,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==d||e[23]!==f||e[24]!==m||e[25]!==g?(v=o.jsxs(l,{open:d,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=d,e[23]=f,e[24]=m,e[25]=g,e[26]=v):v=e[26],v}function wd(t){return t.preventDefault()}function Cd(t){const e=F.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,u,d,f,_,m,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=an(),w=aa(r);u=s.trim()?x.filter(T=>{const y=pr(T),C=s.toLowerCase();return y.includes(C)||T.toLowerCase().includes(C)}):x,m="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ma,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=N):N=e[14];let k;e[15]!==i?(k=T=>i(T.target.value),e[15]=i,e[16]=k):k=e[16];let R;e[17]!==s||e[18]!==k?(R=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(gs,{value:s,onChange:k,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=k,e[19]=R):R=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Tc,{size:14,className:"text-muted-foreground"}),e[20]=E):E=e[20];let B;e[21]!==l?(B=o.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:E}),e[21]=l,e[22]=B):B=e[22];let A;e[23]!==n||e[24]!==r?(A=o.jsx(yd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=A):A=e[25],e[26]!==B||e[27]!==A||e[28]!==R?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[R,B,A]}),e[26]=B,e[27]=A,e[28]=R,e[29]=p):p=e[29],c=Da,_="h-56",d="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(T=>{const y=Mi(T);return y?o.jsx("button",{type:"button",onClick:()=>a(T),className:ie("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===T?ie(w.bg,w.text):ie(w.text,"hover:bg-accent")),title:T,children:o.jsx(y,{size:18})},T):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=_,e[12]=m,e[13]=p}else c=e[7],u=e[8],d=e[9],f=e[10],_=e[11],m=e[12],p=e[13];let g;e[30]!==d||e[31]!==f?(g=o.jsx("div",{className:d,children:f}),e[30]=d,e[31]=f,e[32]=g):g=e[32];let v;e[33]!==u.length?(v=u.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=v):v=e[34];let b;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(b=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=b):b=e[39];let S;return e[40]!==m||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:m,children:[p,b]}),e[40]=m,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function kd(t){const e=F.c(27),{onUpload:s}=t,i=P.useRef(null);let r;e[0]!==s?(r=N=>{const k=N.target.files?.[0];if(!k)return;if(k.size>2097152){ge.error("Image must be smaller than 2MB"),N.target.value="";return}const R=new FileReader;R.onerror=()=>{ge.error("Failed to read image file"),i.current&&(i.current.value="")},R.onloadend=()=>{R.readyState===FileReader.DONE&&R.result&&s(R.result),i.current&&(i.current.value="")},R.readAsDataURL(k)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=P.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const N=a.trim();N&&(s(N),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let u;e[5]!==n?(u=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i.current?.click(),e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsxs("button",{type:"button",onClick:d,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[o.jsx(hc,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=N=>l(N.target.value),e[10]=m):m=e[10];let p;e[11]!==c?(p=N=>{N.key==="Enter"&&(N.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(gs,{value:a,onChange:m,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const b=!v;let S;e[18]!==c||e[19]!==b?(S=o.jsx(oe,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let w;return e[24]!==x||e[25]!==u?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,_,x]}),e[24]=x,e[25]=u,e[26]=w):w=e[26],w}function Nd(t){const e=F.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Di(s);if(n.type==="icon"){const a=Mi(n.name);if(a){let l;e[2]!==a?(l=o.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Kc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function jd(t){const e=F.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=P.useState(!1),[h,c]=P.useState("");let u;e[0]!==s?(u=Di(s),e[0]=s,e[1]=u):u=e[1];const d=u,f=d.type==="icon"?d.name:null;let _,m,p,g,v,b,S,x,w,N,k,R,E,B,A;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const I=an();g=h.trim()?I.filter(W=>{const Y=h.toLowerCase();return pr(W).includes(Y)||W.toLowerCase().includes(Y)}):I,p=Ys,v=n?!1:a,b=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let q;e[24]!==r||e[25]!==O?(q=ie("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=q):q=e[26];let H;e[27]!==s?(H=o.jsx(Nd,{value:s}),e[27]=s,e[28]=H):H=e[28],e[29]!==n||e[30]!==q||e[31]!==H?(S=o.jsx(qs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:q,children:H})}),e[29]=n,e[30]=q,e[31]=H,e[32]=S):S=e[32],m=Gs,E="start",B="w-64 p-0",A=Ed,k="flex flex-col";let U;e[33]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(Ma,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=U):U=e[33];let Q;e[34]===Symbol.for("react.memo_cache_sentinel")?(Q=W=>c(W.target.value),e[34]=Q):Q=e[34],e[35]!==h?(R=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[U,o.jsx(gs,{value:h,onChange:Q,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=R):R=e[36],_=Da,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let ee;e[37]!==f||e[38]!==i?(ee=W=>{const Y=Mi(W);return Y?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${W}`),l(!1)},className:ie("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===W?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:pr(W),children:o.jsx(Y,{size:16})},W):null},e[37]=f,e[38]=i,e[39]=ee):ee=e[39],w=g.map(ee),e[2]=r,e[3]=f,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=m,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=w,e[18]=N,e[19]=k,e[20]=R,e[21]=E,e[22]=B,e[23]=A}else _=e[9],m=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],w=e[17],N=e[18],k=e[19],R=e[20],E=e[21],B=e[22],A=e[23];let T;e[40]!==x||e[41]!==w?(T=o.jsx("div",{className:x,children:w}),e[40]=x,e[41]=w,e[42]=T):T=e[42];let y;e[43]!==g.length?(y=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=y):y=e[44];let C;e[45]!==_||e[46]!==T||e[47]!==y||e[48]!==N?(C=o.jsxs(_,{className:N,children:[T,y]}),e[45]=_,e[46]=T,e[47]=y,e[48]=N,e[49]=C):C=e[49];let j;e[50]!==C||e[51]!==k||e[52]!==R?(j=o.jsxs("div",{className:k,children:[R,C]}),e[50]=C,e[51]=k,e[52]=R,e[53]=j):j=e[53];let D;e[54]!==m||e[55]!==j||e[56]!==E||e[57]!==B||e[58]!==A?(D=o.jsx(m,{align:E,className:B,onOpenAutoFocus:A,children:j}),e[54]=m,e[55]=j,e[56]=E,e[57]=B,e[58]=A,e[59]=D):D=e[59];let M;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==D?(M=o.jsxs(p,{open:v,onOpenChange:b,children:[S,D]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=D,e[65]=M):M=e[65],M}function Ed(t){return t.preventDefault()}function fi(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Be,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Xi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(Hl,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function Td(t){const e=F.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=ie("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let u;e[5]!==s.tags?(u=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let d;e[7]!==c||e[8]!==u?(d=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,u]}),e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]!==s.description?(f=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[d,f]}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let m;e[15]!==n||e[16]!==i||e[17]!==r?(m=o.jsx(xh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=m):m=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==m?(p=o.jsxs("label",{className:h,children:[_,m]}),e[19]=h,e[20]=_,e[21]=m,e[22]=p):p=e[22],p}function un(t){const e=F.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const d=s.map(Rd);if(s.length===0){let f;e[8]!==n?(f=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>o.jsx(Td,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,d),disabled:a},f.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;return e[10]!==l||e[11]!==h?(u=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Rd(t){return t.id}function Dd(t){const e=F.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=be();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=We(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Lc(c);let d;e[6]!==u.tools?(d=u.tools.map(Md),e[6]=u.tools,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(un,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Md(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(hh,{annotations:t.annotations,_meta:t._meta})}}function Id(t){const e=F.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=be();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=We(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=ah(c);let d;e[6]!==u.resources?(d=u.resources.map(Ad),e[6]=u.resources,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(un,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Ad(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Bd(t){const e=F.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=be();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=We(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=bh(c);let d;e[6]!==u.prompts?(d=u.prompts.map(Pd),e[6]=u.prompts,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(un,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function Pd(t){return{id:t.name,name:t.name,description:t.description}}function Ld(t){const e=F.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:u,toggleAllPrompts:d,onTabChange:f}=t,_=n[r],m=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?u(r):d(r)},e[0]=i,e[1]=r,e[2]=d,e[3]=u,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(ms,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let x;e[13]!==b||e[14]!==S?(x=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=x):x=e[15];let w;e[16]!==v||e[17]!==x?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let k;e[20]!==f?(k=M=>f(M),e[20]=f,e[21]=k):k=e[21];let R;e[22]!==i||e[23]!==k?(R=o.jsx(vh,{tabs:N,activeTab:i,onTabChange:k}),e[22]=i,e[23]=k,e[24]=R):R=e[24];const E=m?"Deselect all":"Select all";let B;e[25]!==g||e[26]!==E?(B=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:E}),e[25]=g,e[26]=E,e[27]=B):B=e[27];let A;e[28]!==B||e[29]!==R?(A=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[R,B]}),e[28]=B,e[29]=R,e[30]=A):A=e[30];let T;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(T=i==="tools"&&o.jsx(Ut,{fallback:Xi("Tools not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(fi,{}),children:o.jsx(Dd,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(M,I)=>a(r,M,I)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=T):T=e[35];let y;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(y=i==="resources"&&o.jsx(Ut,{fallback:Xi("Resources not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(fi,{}),children:o.jsx(Id,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(M,I)=>l(r,M,I)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=y):y=e[40];let C;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(C=i==="prompts"&&o.jsx(Ut,{fallback:Xi("Prompts not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(fi,{}),children:o.jsx(Bd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(M,I)=>h(r,M,I)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=C):C=e[45];let j;e[46]!==T||e[47]!==y||e[48]!==C?(j=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,y,C]}),e[46]=T,e[47]=y,e[48]=C,e[49]=j):j=e[49];let D;return e[50]!==A||e[51]!==j||e[52]!==w?(D=o.jsxs(o.Fragment,{children:[w,A,j]}),e[50]=A,e[51]=j,e[52]=w,e[53]=D):D=e[53],D}function Od(t){const e=F.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=ga(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(Dc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let d;e[4]!==s||e[5]!==i?(d=i&&o.jsx(oe,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=d):d=e[6];let f;return e[7]!==d?(f=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,u,d]}),e[7]=d,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function zd(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Un(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function $d(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Fd(t){const e=F.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,u]=P.useReducer($d,h),d=ln(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let _;e[3]!==f?(_=zd(f),e[3]=f,e[4]=_):_=e[4];const m=_;let p;e[5]!==n||e[6]!==m?(p=(U,Q,ee,W)=>{const Y=m[U]?.[Q];let $;Y===null?$=W.filter(L=>L!==ee):Y?.includes(ee)?$=Y.filter(L=>L!==ee):($=[...Y??[],ee],$.length===W.length&&($=null));const K={...m};K[U]?K[U]={...K[U]}:K[U]={tools:null,resources:null,prompts:null},K[U][Q]=$,n.setValue("connections",Un(K),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=m,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==m?(v=(U,Q)=>{const W=m[U]?.[Q]===null?[]:null,Y={...m};Y[U]?Y[U]={...Y[U]}:Y[U]={tools:null,resources:null,prompts:null},Y[U][Q]=W,n.setValue("connections",Un(Y),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=m,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(U,Q,ee)=>g(U,"tools",Q,ee),e[11]=g,e[12]=S):S=e[12];const x=S;let w;e[13]!==g?(w=(U,Q,ee)=>g(U,"resources",Q,ee),e[13]=g,e[14]=w):w=e[14];const N=w;let k;e[15]!==g?(k=(U,Q,ee)=>g(U,"prompts",Q,ee),e[15]=g,e[16]=k):k=e[16];const R=k;let E;e[17]!==b?(E=U=>b(U,"tools"),e[17]=b,e[18]=E):E=e[18];const B=E;let A;e[19]!==b?(A=U=>b(U,"resources"),e[19]=b,e[20]=A):A=e[20];const T=A;let y;e[21]!==b?(y=U=>b(U,"prompts"),e[21]=b,e[22]=y):y=e[22];const C=y;if(!r||!d)return null;let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(fi,{}),e[23]=j):j=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=U=>u({type:"SET_ACTIVE_TAB",payload:U}),e[24]=D):D=e[24];let M;e[25]!==d||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==C||e[30]!==T||e[31]!==B||e[32]!==R||e[33]!==N||e[34]!==x?(M=o.jsx(Ld,{currentConnection:d,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:x,toggleResource:N,togglePrompt:R,toggleAllTools:B,toggleAllResources:T,toggleAllPrompts:C,onTabChange:D},r),e[25]=d,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=C,e[30]=T,e[31]=B,e[32]=R,e[33]=N,e[34]=x,e[35]=M):M=e[35];let I;e[36]!==l||e[37]!==r||e[38]!==M?(I=o.jsx(P.Suspense,{fallback:j,children:o.jsx(Od,{connectionId:r,onAuthenticate:l,children:M})}),e[36]=l,e[37]=r,e[38]=M,e[39]=I):I=e[39];let O;e[40]!==i?(O=o.jsx(fh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(oe,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let q;e[42]!==I||e[43]!==O?(q=o.jsxs(cn,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[I,O]}),e[42]=I,e[43]=O,e[44]=q):q=e[44];let H;return e[45]!==i||e[46]!==s||e[47]!==q?(H=o.jsx(hn,{open:s,onOpenChange:i,children:q}),e[45]=i,e[46]=s,e[47]=q,e[48]=H):H=e[48],H}const Ji={tools:null,resources:null,prompts:null},Hd=Wl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Wd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Ud(t){const e=F.c(11),{url:s,agentId:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Ce("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),ge.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Bi,{size:20,className:"text-green-600"}):o.jsx(Ri,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let u;e[5]!==c?(u=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==h||e[9]!==u?(d=o.jsxs(oe,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,u]}),e[7]=l,e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Vd(t){const e=F.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{Ce("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=va(i),f=Wd(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),_=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(_,"_blank"),ge.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=n):n=e[3];const a=n;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),h=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=o.jsxs(oe,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function Kd(t){const e=F.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=P.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{Ce("agent_connect_action",{agent_id:r,action:"install_claude_code"});const _=va(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${_}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),ge.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const h=l;let c;e[4]!==n?(c=n?o.jsx(Bi,{size:20,className:"text-green-600"}):o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=n,e[5]=c):c=e[5];const u=n?"Copied!":"Install on Claude Code";let d;e[6]!==u?(d=o.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=d):d=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==d?(f=o.jsxs(oe,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,d]}),e[8]=h,e[9]=c,e[10]=d,e[11]=f):f=e[11],f}function qd({virtualMcp:t}){const{org:e}=be(),s=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),[i,r]=P.useState(null),[n,a]=P.useState(!1),[l,h]=P.useState(!1),c=t.id,u=t.title||`agent-${c.slice(0,8)}`,d=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),Ce("agent_typegen_key_generated",{agent_id:c})}catch{Ce("agent_typegen_key_failed",{agent_id:c}),ge.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{Ce("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(d),h(!0),ge.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(oe,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(Be,{size:14,className:"animate-spin"}):o.jsx(gh,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:d}),o.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Bi,{size:12,className:"text-green-600"}):o.jsx(Ri,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Gd,{apiKey:i,agentId:c})]})}function Gd(t){const e=F.c(21),{apiKey:s,agentId:i}=t,[r,n]=P.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
4
4
  ${h}`;let u;e[0]!==i||e[1]!==s||e[2]!==c?(u=async()=>{Ce("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=u):u=e[3];const d=u,f=!s;let _;e[4]!==f?(_=ie({"opacity-50":f}),e[4]=f,e[5]=_):_=e[5];let m;e[6]!==l||e[7]!==_?(m=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=m):m=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==m?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[m,p,g]}),e[11]=m,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Bi,{size:12,className:"text-green-600"}):o.jsx(Ri,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==b?(S=o.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:d,children:b}),e[15]=d,e[16]=b,e[17]=S):S=e[17];let x;return e[18]!==v||e[19]!==S?(x=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=x):x=e[20],x}function Yd(t){const e=F.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(qd,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Xd(t){const e=F.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=be(),a=`/api/${n.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const u=c,d=fa();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(Ud,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let _,m;e[8]!==u||e[9]!==r.id||e[10]!==h.href?(_=o.jsx(Vd,{url:h.href,serverName:u,agentId:r.id}),m=o.jsx(Kd,{url:h.href,serverName:u,agentId:r.id}),e[8]=u,e[9]=r.id,e[10]=h.href,e[11]=_,e[12]=m):(_=e[11],m=e[12]);let p;e[13]!==f||e[14]!==_||e[15]!==m?(p=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,_,m]})}),e[13]=f,e[14]=_,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=o.jsx(Yd,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let b;e[20]!==p||e[21]!==v?(b=o.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=b):b=e[22];const S=b;if(d){let k;e[23]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(wh,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=k):k=e[23];let R;e[24]!==S?(R=o.jsx(Ch,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[k,S]})}),e[24]=S,e[25]=R):R=e[25];let E;return e[26]!==i||e[27]!==s||e[28]!==R?(E=o.jsx(kh,{open:s,onOpenChange:i,children:R}),e[26]=i,e[27]=s,e[28]=R,e[29]=E):E=e[29],E}let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(ja,{children:o.jsx(Ea,{children:"Connect"})}),e[30]=x):x=e[30];let w;e[31]!==S?(w=o.jsxs(cn,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[x,S]}),e[31]=S,e[32]=w):w=e[32];let N;return e[33]!==i||e[34]!==s||e[35]!==w?(N=o.jsx(hn,{open:s,onOpenChange:i,children:w}),e[33]=i,e[34]=s,e[35]=w,e[36]=N):N=e[36],N}function Jd(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Zd(t){const e=F.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=ln(s),{org:u}=be();if(!c)return null;let d;e[0]!==c?(d=uh(c),e[0]=c,e[1]=d):d=e[1];const f=d;let _;e[2]!==s?(_=o.jsx(su,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let m;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(m=o.jsx(tu,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:u.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=m):m=e[18];let p;return e[19]!==_||e[20]!==m?(p=o.jsx(P.Suspense,{fallback:_,children:m}),e[19]=_,e[20]=m,e[21]=p):p=e[21],p}const Vn="__new_instance__";async function Qd(t,e){const s=t?.idToken??null;if(s){const r=Kn(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return Kn(e)}function Kn(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function eu(t){const e=F.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=Ai(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Vn?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(rs,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(ns,{})}),e[6]=u):u=e[6];let d;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(Pt,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],d=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=d}else d=e[10];let f;e[14]!==a?(f=a&&o.jsx(Pt,{value:Vn,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let _;e[16]!==d||e[17]!==f?(_=o.jsxs(os,{children:[d,f]}),e[16]=d,e[17]=f,e[18]=_):_=e[18];let m;return e[19]!==i||e[20]!==c||e[21]!==_?(m=o.jsxs(is,{value:i,onValueChange:c,children:[u,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=m):m=e[22],m}function tu(t){const e=F.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:u,onOpenSettings:d,onRemove:f,onAuthenticate:_,onSwitchInstance:m,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=ga(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==x?(w=ie("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=w):w=e[3];let N;e[4]!==h||e[5]!==l?(N={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=N):N=e[6];let k;e[7]!==n||e[8]!==i?(k=o.jsx(ms,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=k):k=e[9];let R;e[10]!==i?(R=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=R):R=e[11];let E;e[12]!==r||e[13]!==S?(E=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=E):E=e[14];let B;e[15]!==R||e[16]!==E?(B=o.jsxs("div",{className:"flex-1 min-w-0",children:[R,E]}),e[15]=R,e[16]=E,e[17]=B):B=e[17];let A;e[18]!==s||e[19]!==S||e[20]!==_?(A=S?o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:W=>{W.preventDefault(),W.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ge,{delayDuration:0,children:[o.jsx(Ye,{asChild:!0,children:o.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:o.jsx(_h,{size:16})})}),o.jsx(Xe,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=A):A=e[21];let T;e[22]!==N||e[23]!==k||e[24]!==B||e[25]!==A?(T=o.jsxs(Kl,{to:"/$org/settings/connections/$appSlug",params:N,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[k,B,A]}),e[22]=N,e[23]=k,e[24]=B,e[25]=A,e[26]=T):T=e[26];let y;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==m||e[31]!==u?(y=c&&o.jsx(eu,{appName:c,connectionId:s,usedConnectionIds:u,onSwitchInstance:m,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=m,e[31]=u,e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Ic,{size:13}),e[33]=C):C=e[33];let j;e[34]!==d?(j=o.jsx(Ye,{asChild:!0,children:o.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,"aria-label":"Configure resources",children:C})}),e[34]=d,e[35]=j):j=e[35];let D;e[36]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(Xe,{side:"bottom",children:"Configure resources"}),e[36]=D):D=e[36];let M;e[37]!==j?(M=o.jsxs(Ge,{delayDuration:0,children:[j,D]}),e[37]=j,e[38]=M):M=e[38];let I;e[39]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(hs,{size:13}),e[39]=I):I=e[39];let O;e[40]!==f?(O=o.jsx(Ye,{asChild:!0,children:o.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:I})}),e[40]=f,e[41]=O):O=e[41];let q;e[42]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Xe,{side:"bottom",children:"Remove"}),e[42]=q):q=e[42];let H;e[43]!==O?(H=o.jsxs(Ge,{delayDuration:0,children:[O,q]}),e[43]=O,e[44]=H):H=e[44];let U;e[45]!==M||e[46]!==H?(U=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[M,H]}),e[45]=M,e[46]=H,e[47]=U):U=e[47];let Q;e[48]!==y||e[49]!==U?(Q=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[y,U]}),e[48]=y,e[49]=U,e[50]=Q):Q=e[50];let ee;return e[51]!==T||e[52]!==Q||e[53]!==w?(ee=o.jsxs("div",{className:w,children:[T,Q]}),e[51]=T,e[52]=Q,e[53]=w,e[54]=ee):ee=e[54],ee}function su(t){const e=F.c(17),{connection_id:s}=t,i=ln(s);if(!i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(za,{}),e[0]=d):d=e[0],d}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(ms,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let u;return e[15]!==h?(u=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=u):u=e[16],u}function za(){const t=F.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function iu({virtualMcpId:t,form:e,debouncedSave:s,flushAndSave:i}){const{org:r}=be(),n=We({connectionId:Ot,orgId:r.id,orgSlug:r.slug}),a=Nt(t),l=(a?.connections??[]).map(C=>C.connection_id).sort(),{data:h}=Xo({queryKey:zs.projectConnectionDetails(t,l),enabled:l.length>0,queryFn:async()=>await Promise.all(l.map(async j=>{try{const D=await n.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:j}}),{item:M}=dh(D),I=(M?.tools??[]).filter(O=>!!lh(O._meta)).map(O=>({name:O.name,description:O.description}));return{fetchOk:!0,id:j,title:M?.title??j,icon:M?.icon??null,uiTools:I}}catch{return{fetchOk:!1,id:j,title:j,icon:null,uiTools:[]}}}))}),c=(h??[]).filter(C=>C.uiTools.length>0),u=new Set(pc),d=e.watch("metadata.ui.pinnedViews")??[],f=e.watch("metadata.ui.layout")??null,_=f?.defaultMainView??null,m=f?.chatDefaultOpen??!1,p=!_||_.type==="chat"?"chat":_.type==="instructions"||_.type==="connections"||_.type==="layout"?"settings":u.has(_.type)?_.type:`${_.type}:${_.id??""}:${_.toolName??""}`,g=C=>{const[j,D,M]=C.split(":");return j?j==="chat"?{type:j}:u.has(j)?{type:j}:j==="ext-apps"&&D?{type:"ext-apps",id:D,toolName:M||void 0}:null:null},v=C=>{e.setValue("metadata.ui.pinnedViews",C,{shouldDirty:!0})},b=C=>{e.setValue("metadata.ui.layout",{...f,...C},{shouldDirty:!0})},S=P.useRef(!1);if(h&&h.length>0&&!S.current){S.current=!0;const C=new Set((h??[]).filter(M=>M.fetchOk).map(M=>M.id)),j=new Set(c.flatMap(M=>M.uiTools.map(I=>`${M.id}:${I.name}`))),D=d.filter(M=>!C.has(M.connectionId)||j.has(`${M.connectionId}:${M.toolName}`));D.length!==d.length&&(v(D),_?.type==="ext-apps"&&!D.some(M=>M.connectionId===_.id&&M.toolName===_.toolName)&&b({defaultMainView:{type:"chat"}}),s())}const x=(C,j)=>{if(d.some(M=>M.connectionId===C&&M.toolName===j)){const M=d.filter(O=>!(O.connectionId===C&&O.toolName===j));v(M);const I=`ext-apps:${C}:${j}`;p===I&&b({defaultMainView:{type:"chat"}})}else v([...d,{connectionId:C,toolName:j,label:Rn(j),icon:null}]);i()},w=(C,j,D)=>{v(d.map(M=>M.connectionId===C&&M.toolName===j?{...M,label:D}:M)),s()},N=()=>{i()},k=(C,j,D)=>{v(d.map(M=>M.connectionId===C&&M.toolName===j?{...M,icon:D}:M)),i()},R=C=>{b({defaultMainView:g(C)}),i()},E=l.length===0,B=h&&c.length===0,A=!!Gt(a),T=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];A&&(T.push({value:"env",label:"Terminal"}),T.push({value:"preview",label:"Preview"}));for(const C of d)T.push({value:`ext-apps:${C.connectionId}:${C.toolName}`,label:C.label||C.toolName});const y=c.length>0||E||B;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(mh,{className:"p-6 gap-5",children:[o.jsxs(Ln,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ps,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(is,{value:p,onValueChange:R,children:[o.jsx(rs,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(ns,{})}),o.jsx(os,{children:T.map(C=>o.jsx(Pt,{value:C.value,className:"capitalize",children:C.label},C.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ps,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Ge,{delayDuration:0,children:[o.jsx(Ye,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(vr,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:C=>{b({chatDefaultOpen:C}),i()}})})}),p==="chat"&&o.jsx(Xe,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),y&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Ln,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ps,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),E&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),B&&!E&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),c.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:c.map((C,j)=>o.jsxs("div",{children:[j>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(ms,{icon:C.icon,name:C.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:C.title})]}),o.jsx("div",{className:"space-y-1.5",children:C.uiTools.map(D=>{const M=d.some(O=>O.connectionId===C.id&&O.toolName===D.name),I=d.find(O=>O.connectionId===C.id&&O.toolName===D.name);return o.jsxs("div",{className:ie("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",M?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(jd,{value:I?.icon??null,onChange:O=>k(C.id,D.name,O),disabled:!M}),o.jsx(gs,{value:M&&I?I.label:Rn(D.name),onChange:O=>w(C.id,D.name,O.target.value),onBlur:N,className:"h-7 text-sm w-40",disabled:!M,readOnly:!M})]}),o.jsx(vr,{checked:M,onCheckedChange:()=>x(C.id,D.name)})]},D.name)})})]},C.id))})]})]})]})]})}function ru({virtualMcp:t,hideOwnTitle:e}){const{org:s}=be(),i=ic(),r=nh(),n=fs(),a=We({connectionId:Ot,orgId:s.id,orgSlug:s.slug}),l=Zo({resolver:Ul(Hd),defaultValues:t}),h=l.watch("connections"),c=!!Gt(t),[u,d]=P.useReducer(Jd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,_]=P.useState(!1),[m,p]=P.useState(!1),{createNewTask:g,setChatOpen:v}=Ii(),{sendMessage:b}=_s(),S=_a(),x=async()=>{if(m)return;const L=l.getValues("metadata.instructions");if(L?.trim()){p(!0);try{T(),Ce("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await S(["studio-agent-manager"]),v(!0),await b({tiptapDoc:Oa({managerAgentId:ia.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{p(!1)}}},w=()=>{T(),Ce("agent_test_clicked",{agent_id:t.id}),g()},N=P.useRef(null),k=P.useRef(new Set),R=P.useRef(0),E=P.useRef(null),B=P.useRef(null),A=3e4,T=()=>{B.current&&(clearTimeout(B.current),B.current=null),N.current!==null&&(Ce("agent_updated",{agent_id:t.id,fields:Array.from(k.current),instructions_length:E.current,save_count:R.current,edit_duration_ms:Date.now()-N.current}),N.current=null,k.current=new Set,R.current=0,E.current=null)},y=async()=>{const L=Object.keys(l.formState.dirtyFields);if(L.length===0)return;const Z=L.includes("metadata"),te=l.getValues(),se=await i.update.mutateAsync({id:t.id,data:te});N.current===null&&(N.current=Date.now());for(const X of L)k.current.add(X);R.current+=1,Z&&(E.current=te.metadata?.instructions?.length??0),B.current&&clearTimeout(B.current),B.current=setTimeout(T,A),l.reset(se)},{schedule:C,flush:j}=Ra({save:y}),D=()=>{Ce("connections_dialog_opened",{source:"agent_settings",mode:"add"}),d({type:"SET_ADD_DIALOG_OPEN",payload:!0})},M=async L=>{const Z=l.getValues("connections");if(Z.some(X=>X.connection_id===L))return;l.setValue("connections",[...Z,{connection_id:L,selected_tools:Ji.tools,selected_resources:Ji.resources,selected_prompts:Ji.prompts}],{shouldDirty:!0}),C(),d({type:"SET_ADD_DIALOG_OPEN",payload:!1});const te=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),se=await Nn({url:te.href,token:null,orgId:s.id});se.supportsOAuth&&!se.isAuthenticated&&await U(L)},I=L=>{const te=l.getValues("connections").filter(se=>se.connection_id!==L);l.setValue("connections",te,{shouldDirty:!0}),C()},O=(L,Z)=>{const te=l.getValues("connections");if(te.some(se=>se.connection_id===Z)){ge.error("This instance is already added to the agent");return}l.setValue("connections",te.map(se=>se.connection_id===L?{...se,connection_id:Z}:se),{shouldDirty:!0}),C()},q=async L=>{if(l.getValues("connections").find(te=>te.connection_id===L))try{const te=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:se}=te.structuredContent??{};if(!se)return;const X=se.title.replace(/\s*\(.*?\)\s*$/,""),he=oh("conn"),fe=`${X} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:he,title:fe,description:se.description??null,connection_type:se.connection_type,connection_url:se.connection_url??null,connection_token:null,icon:se.icon??null,app_name:se.app_name??null,app_id:se.app_id??null,connection_headers:se.connection_headers??null});const de=new URL(`/api/${s.slug}/mcp/${he}`,window.location.origin),ue=await Nn({url:de.href,token:null,orgId:s.id});if(ue.supportsOAuth&&!ue.isAuthenticated){const ve=await U(he);if(!ve){await r.delete.mutateAsync(he);return}await r.update.mutateAsync({id:he,data:{title:`${X} (${ve})`}})}O(L,he),ge.success("New instance created")}catch(te){console.error("Failed to create instance:",te),ge.error("Failed to create instance")}},H=L=>{d({type:"OPEN_SETTINGS",payload:L})},U=async L=>{const{token:Z,tokenInfo:te,error:se}=await Vl({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(se||!Z)return ge.error(`Authentication failed: ${se}`),null;if(te)try{const he=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:te.accessToken,refreshToken:te.refreshToken,expiresIn:te.expiresIn,scope:te.scope,clientId:te.clientId,clientSecret:te.clientSecret,tokenEndpoint:te.tokenEndpoint})});if(!he.ok)console.error("Failed to save OAuth token:",await he.text()),await r.update.mutateAsync({id:L,data:{connection_token:Z}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(fe){console.warn("Failed to refresh connection tools after OAuth:",fe)}}catch(he){console.error("Error saving OAuth token:",he),await r.update.mutateAsync({id:L,data:{connection_token:Z}})}else await r.update.mutateAsync({id:L,data:{connection_token:Z}});const X=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await n.invalidateQueries({queryKey:zs.isMCPAuthenticated(X.href,null)}),ge.success("Authentication successful"),Qd(te,Z)},Q=()=>{const L=l.getValues("metadata.instructions")??"",Z=`<role>
5
5
  Define who this agent is and what it specializes in.
@@ -179,4 +179,4 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
179
179
  `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Sr.get()},set promptLabel(t){Sr.set(t)},get tooMuchOutput(){return yr.get()},set tooMuchOutput(t){yr.set(t)}}}_verifyIntegers(...t){for(ft of t)if(ft===1/0||isNaN(ft)||ft%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(ft of t)if(ft&&(ft===1/0||isNaN(ft)||ft%1!==0||ft<0))throw new Error("This API only accepts positive integers")}};var Rp=2,Dp=1,Mp=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=r-h-e;return{cols:Math.max(Rp,Math.floor(u/t.css.cell.width)),rows:Math.max(Dp,Math.floor(c/t.css.cell.height))}}};function Ip({source:t,onReady:e,onSelectionChange:s,className:i}){const r=P.useRef(null),n=P.useRef(null),a=P.useRef(s);a.current=s;const l=Xt(),h=P.useRef(t);return h.current=t,Qu((c,u)=>{c===h.current&&n.current?.write(u)}),P.useEffect(()=>{const c=r.current;if(!c)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new Tp({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),_=new Mp;f.loadAddon(_),f.open(c),_.fit();const m=l.getBuffer(t);m&&f.write(m),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{ref:r,className:ie("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function Ap(){const t=F.c(2),s=Cn()?.entity;let i;return t[0]!==s?(i=Gt(s),t[0]=s,t[1]=i):i=t[1],i}const Bp={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}},Pp=["dev","start"];function Lp({daemonOpen:t=!1}){const{org:e}=be(),s=Cn(),i=fs(),{data:r}=Ei.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=xt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,u=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[d,f]=P.useState(null),[_,m]=P.useState(""),[p,g]=P.useState(""),[v,b]=P.useState(!1),[S,x]=P.useState(new Set),w=P.useRef(!1),N=P.useRef(Date.now()),[k,R]=P.useState("setup"),[E,B]=P.useState([]),A=P.useRef(new Map),{sendMessage:T}=_s(),{setChatOpen:y}=Ii(),[C,j]=P.useState(!1),D=P.useRef(null),M=G=>{R(G),j(!1),D.current=null},I=(G,ne,_e)=>{G===k&&(j(ne),D.current=ne?_e:null)},O=()=>{const G=D.current?.();if(!G)return;y(!0),T({parts:[{type:"text",text:`<server-logs>
180
180
  ${G}
181
181
  </server-logs>`}]}),A.current.get(k)?.clearSelection()},q=We({connectionId:Ot,orgId:e.id,orgSlug:e.slug}),H=Xt(),U=Pa(s?.entity?.id,n??void 0),Q=H.suspended?"suspended":H.notFound?"creating":u?"running":U?"creating":"idle",ee=d??Q;if(P.useEffect(()=>{d==="creating"&&Q==="running"&&f(null),d==="stopping"&&Q==="idle"&&f(null)},[Q,d]),S.size>0){let G=!1;const ne=new Set(S);for(const _e of S)H.activeProcesses.includes(_e)||(ne.delete(_e),G=!0);G&&x(ne)}const W=dn(q),{mutate:Y,isPending:$}=W,K=s?.entity?.id,L=H.notFound?c?.vmId??null:null,Z=P.useRef(null);P.useEffect(()=>{if(!L||!K||$||Z.current===L)return;Z.current=L;const G={virtualMcpId:K};n&&(G.branch=n),Y(G,{onError:ne=>{console.error("[env] reprovision VM_START failed",ne)}})},[L,K,n,$,Y]);const te=P.useRef(!1);P.useEffect(()=>{if(H.scripts.length>0&&!te.current){te.current=!0;for(const G of Pp)if(H.scripts.includes(G)){B([G]),M(G);break}}},[H.scripts]);const se=async(G,ne)=>{const _e=await q.callTool({name:G,arguments:ne}),St=_e.content;if(St?.[0]?.text?.startsWith("Error:"))throw new Error(St[0].text);return _e.structuredContent??_e},X=async G=>{if(!(v||!u||!K||!n)){b(!0);try{const ne=new URLSearchParams({virtualMcpId:K,branch:n}).toString(),_e=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/exec/${encodeURIComponent(G)}?${ne}`,{method:"POST"});if(!_e.ok)throw new Error(`Exec failed: ${_e.statusText}`)}finally{b(!1)}}},he=async G=>{if(!(!u||!K||!n)&&!S.has(G)){x(ne=>{const _e=new Set(ne);return _e.add(G),_e});try{const ne=new URLSearchParams({virtualMcpId:K,branch:n}).toString(),_e=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/kill/${encodeURIComponent(G)}?${ne}`,{method:"POST"});if(!_e.ok)throw new Error(`Kill failed: ${_e.statusText}`)}catch{x(ne=>{const _e=new Set(ne);return _e.delete(G),_e}),ge.error(`Failed to stop ${G}`)}}},fe=G=>{E.includes(G)||B(ne=>[...ne,G]),M(G),X(G)},de=async()=>{if(!w.current){w.current=!0,s?.entity?.id&&n&&Si.clear(s.entity.id,n),N.current=Date.now(),f("creating"),m("Connecting..."),g(""),te.current=!1,B([]),M("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const G={virtualMcpId:s.entity.id};n&&(G.branch=n);const ne=await se("VM_START",G);if(!ne.vmId||!ne.branch)throw new Error("Invalid VM response — missing fields");n||a(ne.branch),m(""),hi(i)}catch(G){f("error"),g(G instanceof Error?G.message:"Failed to start VM")}finally{w.current=!1}}},ue=async()=>{const G=u?.branch??n;f("stopping");const ne=s?.entity?.id;if(ne&&G&&Si.mark(ne,G),ne&&G)try{await q.callTool({name:"VM_DELETE",arguments:{virtualMcpId:ne,branch:G}})}catch{}hi(i)},ve=Ap(),De=s?.entity?.metadata?.runtime,Ue="__none__",Ke=Object.keys(Bp),Qe=async(G,ne)=>{if(s?.entity)try{await q.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...De,[G]:ne}}}}}),hi(i)}catch{ge.error("Failed to update setting")}};if(ee==="idle"||ee==="stopping"){const G=ee==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[ve&&o.jsxs("a",{href:`https://github.com/${ve.owner}/${ve.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(ch,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[ve.owner,"/",ve.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",ve.owner,"/",ve.name]})]}),o.jsx(Yt,{size:14,className:"text-muted-foreground shrink-0"})]}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ps,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(is,{value:De?.selected??Ue,onValueChange:ne=>Qe("selected",ne===Ue?null:ne),children:[o.jsx(rs,{id:"env-runtime",className:"w-28",children:o.jsx(ns,{placeholder:"None"})}),o.jsxs(os,{children:[o.jsx(Pt,{value:Ue,children:"None"}),Ke.map(ne=>o.jsx(Pt,{value:ne,children:ne},ne))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ps,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(gs,{id:"env-port",placeholder:"3001",className:"w-20 h-8",defaultValue:De?.port??"",onBlur:ne=>Qe("port",ne.target.value||null)})]}),o.jsxs(oe,{onClick:de,disabled:G,children:[G?o.jsx(Be,{size:14,className:"animate-spin"}):o.jsx(ui,{size:14}),G?"Stopping...":"Run"]})]})]})})}if(ee==="creating"){const G=H.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Be,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:G}),o.jsx(gc,{since:N.current})]})}if(ee==="error")return o.jsx(Va,{errorMsg:p,onRetry:de});if(ee==="suspended")return o.jsx(Ua,{onResume:de});const me=["setup",...E,...t?["daemon"]:[]],Tt=H.scripts.filter(G=>!E.includes(G));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[me.map(G=>o.jsx("button",{type:"button",onClick:()=>M(G),className:ie("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",k===G?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:G},G)),Tt.length>0&&o.jsxs(as,{children:[o.jsx(ls,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(ds,{size:14})})}),o.jsx(cs,{align:"start",children:Tt.map(G=>o.jsx(kt,{onClick:()=>fe(G),children:G},G))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:u?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(Ge,{children:[o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(u?.vmId??""),children:u.vmId})}),o.jsx(Xe,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(as,{children:[o.jsx(ls,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(br,{size:10})})}),o.jsx(cs,{align:"center",children:o.jsxs(kt,{onClick:ue,children:[o.jsx(Bn,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[C&&o.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Ac,{size:12}),"Add to chat"]}),k!=="setup"&&k!=="daemon"&&E.includes(k)&&(()=>{const G=H.activeProcesses.includes(k),ne=S.has(k),_e=G&&!ne,St=v||ne,Hi=()=>X(k),re=()=>he(k),Me=v?"Running...":ne?"Stopping...":G?"Restart":"Run";return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:St,onClick:Hi,className:ie("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",_e?"rounded-l-md border-r-0":"rounded-md"),children:[St?o.jsx(Be,{size:12,className:"animate-spin"}):o.jsx(ui,{size:12}),Me]}),_e&&o.jsxs(as,{children:[o.jsx(ls,{asChild:!0,children:o.jsx("button",{type:"button",disabled:St,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(br,{size:12})})}),o.jsx(cs,{align:"end",children:o.jsxs(kt,{onClick:re,children:[o.jsx(Bn,{size:12}),"Stop"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:me.map(G=>o.jsx("div",{className:ie("h-full",k===G?"block":"hidden"),children:H.hasData(G)||G==="setup"||G==="daemon"?o.jsx(Ip,{source:G,onReady:ne=>{A.current.set(G,ne)},onSelectionChange:(ne,_e)=>I(G,ne,_e),className:"h-full"}):o.jsx(Fs,{className:"h-full",image:null,title:`Script "${G}" not running`,description:`Click Run to start "${G}".`,actions:o.jsxs(oe,{variant:"outline",size:"sm",disabled:v,onClick:()=>X(G),children:[v?o.jsx(Be,{size:14,className:"animate-spin"}):o.jsx(ui,{size:14}),"Run"]})})},G))})]})})}function Op(t){const e=F.c(1);let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Lp,{}),e[0]=s):s=e[0],s}function Os(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function zp(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),u=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${u} UTC`}return t}function $p(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function Fp(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Hp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Wp=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Up(t){const e=F.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Xs(),[h,c]=P.useState(!1),u=i??h;let d;e[0]!==r?(d=A=>{r?r(A):c(A)},e[0]=r,e[1]=d):d=e[1];const f=d;let _;e[2]!==l||e[3]!==s||e[4]!==f?(_=async A=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:A}),ge.success("Starter added"),f(!1)}catch(T){const y=T,C=y instanceof Error?y.message:"Failed to add starter";ge.error(C)}},e[2]=l,e[3]=s,e[4]=f,e[5]=_):_=e[5];const m=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(ls,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",children:[o.jsx(ds,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(jh,{className:"gap-2.5",children:[o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==m?(v=Wp.map(A=>o.jsxs(kt,{className:"gap-2.5",onSelect:()=>m(A.cron),disabled:l.isPending,children:[o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",A.label]},A.cron)),e[8]=l,e[9]=m,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(Eh,{children:[g,o.jsx(Th,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=b):b=e[12];let S;e[13]!==f||e[14]!==n?(S=()=>{f(!1),n?.()},e[13]=f,e[14]=n,e[15]=S):S=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let w;e[17]!==S?(w=o.jsxs(kt,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=w):w=e[18];let N;e[19]!==f||e[20]!==a?(N=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=N):N=e[21];let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=k):k=e[22];let R;e[23]!==N?(R=o.jsxs(kt,{className:"gap-2.5",onSelect:N,children:[k,"Event"]}),e[23]=N,e[24]=R):R=e[24];let E;e[25]!==R||e[26]!==b||e[27]!==w?(E=o.jsxs(cs,{align:"end",className:"w-[200px]",children:[b,w,R]}),e[25]=R,e[26]=b,e[27]=w,e[28]=E):E=e[28];let B;return e[29]!==f||e[30]!==u||e[31]!==E?(B=o.jsxs(as,{open:u,onOpenChange:f,children:[p,E]}),e[29]=f,e[30]=u,e[31]=E,e[32]=B):B=e[32],B}function Vp(t){const e=F.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Xs(),[l,h]=P.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?Fp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const u=c,[d,f]=P.useState(u?.count??1),[_,m]=P.useState(!1),[p,g]=P.useState(s.cron_expression??""),v=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),ge.success("Starter removed")}catch{ge.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const x=S;let w;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(w=async()=>{const H=p.trim();if(!H||!Os(H)||H===s.cron_expression){m(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:H}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),m(!1)}catch{ge.error("Failed to update starter"),g(s.cron_expression??""),m(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=w):w=e[12];const N=w;let k;e[13]!==n||e[14]!==i||e[15]!==u||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(k=async H=>{if(!u)return;const U=Math.max(1,H),Q=$p(U,u.unit);if(Q!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:Q}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{ge.error("Failed to update starter"),f(u.count)}},e[13]=n,e[14]=i,e[15]=u,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=k):k=e[19];const R=k;let E;e[20]!==b?(E=b?o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=E):E=e[21];let B;e[22]!==r||e[23]!==d||e[24]!==p||e[25]!==R||e[26]!==N||e[27]!==u||e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(B=u&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:d,onChange:H=>f(parseInt(H.target.value)||1),onBlur:()=>R(d),onKeyDown:H=>{H.key==="Enter"&&H.target.blur(),H.key==="Escape"&&f(u.count)},disabled:v,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),o.jsx("span",{className:"text-sm",children:Hp(u.unit,d)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:H=>g(H.target.value),onBlur:N,onKeyDown:H=>{H.key==="Enter"&&H.target.blur(),H.key==="Escape"&&(m(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!Os(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?zp(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Kp).join(", ")})]}),e[22]=r,e[23]=d,e[24]=p,e[25]=R,e[26]=N,e[27]=u,e[28]=b,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=B):B=e[34];let A;e[35]!==v?(A=v&&o.jsx(Be,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=A):A=e[36];let T;e[37]!==u||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(T=b&&!u&&!_&&o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),m(!0)},children:o.jsx(ph,{size:13,className:"text-muted-foreground"})}),e[37]=u,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=T):T=e[41];let y;e[42]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(hs,{size:13,className:"text-muted-foreground"})}),e[42]=y):y=e[42];let C;e[43]!==A||e[44]!==T?(C=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[A,T,y]}),e[43]=A,e[44]=T,e[45]=C):C=e[45];let j;e[46]!==C||e[47]!==E||e[48]!==B?(j=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[E,B,C]}),e[46]=C,e[47]=E,e[48]=B,e[49]=j):j=e[49];let D;e[50]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsxs(Sa,{children:[o.jsx(ya,{children:"Remove Starter"}),o.jsx(wa,{children:"Are you sure you want to remove this starter?"})]}),e[50]=D):D=e[50];let M;e[51]===Symbol.for("react.memo_cache_sentinel")?(M=o.jsx(ka,{children:"Cancel"}),e[51]=M):M=e[51];let I;e[52]!==x?(I=o.jsxs(ba,{children:[D,o.jsxs(Ca,{children:[M,o.jsx(Na,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=I):I=e[53];let O;e[54]!==l||e[55]!==I?(O=o.jsx(xa,{open:l,onOpenChange:h,children:I}),e[54]=l,e[55]=I,e[56]=O):O=e[56];let q;return e[57]!==j||e[58]!==O?(q=o.jsxs(o.Fragment,{children:[j,O]}),e[57]=j,e[58]=O,e[59]=q):q=e[59],q}function Kp(t){const[e,s]=t;return`${e}: ${s}`}function qp(t){const e=F.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const n=Ai(r),[a,l]=P.useState(),[h,c]=P.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[d,f]=P.useState(u),{triggerAdd:_}=Xs(),{data:m,isLoading:p}=Ih(a);let g,v,b,S,x,w;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==d||e[9]!==n||e[10]!==m){const R=m?.find(I=>I.type===h);let E;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==d?(E=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:d}),Ce("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),ge.success("Event trigger added"),i()}catch{ge.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=d,e[23]=E):E=e[23],g=E,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let B,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=o.jsx(Hs,{size:14,className:"text-muted-foreground shrink-0"}),B=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=B,e[25]=A):(B=e[24],A=e[25]);let T;e[26]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(hs,{size:13}),e[26]=T):T=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[A,B,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:T})]}),e[27]=i,e[28]=b):b=e[28];const y=a??"";let C;e[29]===Symbol.for("react.memo_cache_sentinel")?(C=I=>{l(I),c(void 0),f({})},e[29]=C):C=e[29];let j;e[30]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(rs,{className:"w-full",children:o.jsx(ns,{placeholder:"Select connection..."})}),e[30]=j):j=e[30];let D;e[31]!==n?(D=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map(Xp),e[31]=n,e[32]=D):D=e[32];let M;e[33]!==D?(M=o.jsx(os,{children:D}),e[33]=D,e[34]=M):M=e[34],e[35]!==y||e[36]!==M?(S=o.jsxs(is,{value:y,onValueChange:C,children:[j,M]}),e[35]=y,e[36]=M,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==m?(x=a&&o.jsxs(is,{value:h??"",onValueChange:I=>{c(I),f({})},children:[o.jsx(rs,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Be,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(ns,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(os,{children:m?.map(Yp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=m,e[42]=x):x=e[42],w=R?.paramsSchema&&Object.keys(R.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(R.paramsSchema).map(I=>{const[O,q]=I;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,q.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",q.description]})]}),q.enum?o.jsxs(is,{value:d[O]??"",onValueChange:H=>f(U=>({...U,[O]:H})),children:[o.jsx(rs,{className:"w-full",children:o.jsx(ns,{placeholder:`Select ${O}...`})}),o.jsx(os,{children:q.enum.map(Gp)})]}):o.jsx("input",{type:"text",value:d[O]??"",onChange:H=>f(U=>({...U,[O]:H.target.value})),placeholder:q.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=d,e[9]=n,e[10]=m,e[11]=g,e[12]=v,e[13]=b,e[14]=S,e[15]=x,e[16]=w}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],w=e[16];let N;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(N=a&&h&&o.jsx(oe,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Be,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=N):N=e[47];let k;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==w||e[53]!==N?(k=o.jsxs("div",{className:v,children:[b,S,x,w,N]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=w,e[53]=N,e[54]=k):k=e[54],k}function Gp(t){return o.jsx(Pt,{value:t,children:t},t)}function Yp(t){return o.jsx(Pt,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function Xp(t){return o.jsx(Pt,{value:t.id,children:t.title},t.id)}function Jp({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=be(),{update:a,triggerAdd:l}=Xs(),h=Ai(),c=new Map(h.map(re=>[re.id,re.title])),{createTaskWithMessage:u}=xt(),{setModel:d,setSimpleModeTier:f,credentialId:_,selectedModel:m}=Ti(),p=Mh(),{setChatOpen:g}=Ii(),{sendMessage:v}=_s(),b=_a(),[S,x]=ql(),w=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[N,k]=P.useState(w),[R,E]=P.useState(!1),[B,A]=P.useState(!1),[T,y]=P.useState(""),[C,j]=P.useState(!1),[D,M]=P.useState(!1),I=P.useRef(!1),O=P.useRef(!1),q=P.useRef(w),H=async()=>{if(D)return;const Me=jn(N).filter(bs=>bs.type==="text").map(bs=>bs.text).join(`
182
- `);if(Me.trim()){M(!0);try{Ke(),Ce("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Me.length}),await b(["studio-automation-manager"]),g(!0),await v({tiptapDoc:Oa({managerAgentId:ia.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Me})})}finally{M(!1)}}},U=e.models?.credentialId||_||"",Q=e.models?.thinking?.id||m?.modelId||"",ee=e.models?.tier??"",W=Zo({defaultValues:{name:e.name,active:e.active,credential_id:U,model_id:Q,tier:ee}}),Y=W.watch("active"),$=W.watch("credential_id"),K=W.watch("model_id"),{models:L,isLoading:Z}=zc($||void 0),te=L.find(re=>re.modelId===K)??null,se=W.watch("tier"),X=["fast","smart","thinking"].find(re=>p.chat[re]?.modelId===K&&p.chat[re]?.keyId===$),he=se||X||"smart",fe=re=>{const Me=p.chat[re];Me&&(W.setValue("credential_id",Me.keyId),W.setValue("model_id",Me.modelId),W.setValue("tier",re),me("credential_id"),me("model_id"),me("tier"),G())},de=P.useRef(null),ue=P.useRef(new Set),ve=P.useRef(0),De=P.useRef(null),Ue=3e4,Ke=()=>{De.current&&(clearTimeout(De.current),De.current=null),de.current!==null&&(Ce("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(ue.current),save_count:ve.current,edit_duration_ms:Date.now()-de.current}),de.current=null,ue.current=new Set,ve.current=0)},Qe=P.useRef(new Set),me=re=>{Qe.current.add(re)},Tt=async()=>{const re=Array.from(Qe.current);if(!(re.length>0)&&!O.current)return!0;const bs=O.current;O.current=!1,Qe.current=new Set;const rt=W.getValues(),Pl=q.current;try{const Ss=rt.credential_id&&rt.model_id?rt.credential_id:"",Wi=rt.credential_id&&rt.model_id?rt.model_id:"",kn=p.enabled?rt.tier||X:rt.tier||void 0,Ll={id:t,name:rt.name,active:rt.active,models:{credentialId:Ss,thinking:{id:Wi},...kn?{tier:kn}:{}},messages:nc(Pl),temperature:0};await a.mutateAsync(Ll),de.current===null&&(de.current=Date.now());for(const Ol of re)ue.current.add(Ol);return bs&&ue.current.add("messages"),ve.current+=1,De.current&&clearTimeout(De.current),De.current=setTimeout(Ke,Ue),Ss!==rt.credential_id&&W.setValue("credential_id",Ss),Wi!==rt.model_id&&W.setValue("model_id",Wi),!0}catch{O.current=!0;for(const Ss of re)Qe.current.add(Ss);return!1}},{schedule:G,flush:ne}=Ra({save:Tt}),_e=re=>{re&&me(re),G()},St=re=>{if(q.current=re,k(re),!I.current){I.current=!0;return}O.current=!0,G()},Hi=async()=>{Ce("automation_test_clicked",{automation_id:t,agent_id:r});const re=await ne();if(Ke(),!re)return;if(!N){ge.error("No instructions configured for this automation");return}p.enabled?f(he):te&&$&&d({...te,keyId:$}),g(!0),x({...S,toolApprovalLevel:"auto"});const Me=jn(N);u({message:{tiptapDoc:N,parts:Me},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(oe,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Ia,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(Ht,{control:W.control,name:"name",render:({field:re})=>o.jsx(gs,{...re,onChange:Me=>{re.onChange(Me),_e("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(xr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ht,{control:W.control,name:"active",render:({field:re})=>o.jsx(vr,{checked:re.value,onCheckedChange:Me=>{re.onChange(Me),me("active"),setTimeout(()=>ne(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Y?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(pa,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Up,{automationId:t,open:R,onOpenChange:E,onCustomSelect:()=>{A(!0),j(!1),y("")},onEventSelect:()=>{j(!0),A(!1)}})]}),e.triggers.length===0&&!B?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>E(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(re=>o.jsx(Vp,{trigger:re,automationId:t,connectionName:re.connection_id?c.get(re.connection_id):void 0},re.id))}),B&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:T,onChange:re=>y(re.target.value),onBlur:async()=>{const re=T.trim();if(!(!re||!Os(re)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:re}),Ce("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ge.success("Starter added"),A(!1),y("")}catch{ge.error("Failed to add starter")}},onKeyDown:async re=>{const Me=T.trim();re.key==="Enter"&&Me&&Os(Me)&&re.target.blur(),re.key==="Escape"&&(A(!1),y(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),T&&!Os(T)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Be,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{A(!1),y("")},children:o.jsx(hs,{size:13})})]}),C&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Be,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(qp,{automationId:t,onDone:()=>j(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:D||!N,onClick:H,children:[o.jsx(Ta,{size:13}),"Improve"]})]}),o.jsx(ec,{tiptapDoc:N,setTiptapDoc:St,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(tc,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[p.enabled?o.jsx(sc,{tier:he,onSelect:fe}):o.jsx(Dh,{model:te,isLoading:Z,credentialId:$||null,onCredentialChange:re=>{W.setValue("credential_id",re??""),W.setValue("model_id",""),W.setValue("tier",""),me("credential_id"),me("model_id"),me("tier"),G()},onModelChange:re=>{W.setValue("model_id",re.modelId),W.setValue("tier",""),me("tier"),_e("model_id")},placeholder:"Model"}),o.jsxs(Ge,{children:[o.jsx(Ye,{asChild:!0,children:o.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Hi,disabled:!r,children:[o.jsx(uc,{size:16}),"Test"]})}),o.jsx(Xe,{children:"Test Automation"})]})]})]})})]})]})]})}function Zp(t){const e=F.c(5),{tabId:s}=t;let i;e[0]!==s?(i=na(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ht,{children:o.jsx(ht.Content,{children:o.jsx(ht.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Qp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Qp(t){const e=F.c(8),{id:s}=t,i=Lt(),{data:r,isLoading:n}=Ah(s);let a;e[0]!==i?(a=()=>i({to:".",search:eg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Jp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function eg(t){return{...t,main:"automations"}}function tg(t){const e=F.c(20),{virtualMcpId:s}=t,i=Lt(),{data:r}=Bh(s),n=r===void 0?[]:r,{create:a}=Xs(),{selectedModel:l,credentialId:h}=Ti(),[c,u]=P.useState(""),d=c.toLowerCase(),f=n.filter(T=>T.name.toLowerCase().includes(d));let _;e[0]!==i?(_=T=>i({to:".",search:y=>({...y,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=_):_=e[1];const m=_,p=async()=>{if(a.isPending)return;Ce("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const T=l?.modelId&&h?{credentialId:h,modelId:l.modelId}:null,y=await a.mutateAsync(Lh(s,T));m(y.id)},g=ht,v=ht,b=ht;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ht.Title,{children:"Automations"}),e[2]=S):S=e[2];const x=n.length>0&&o.jsx(Oh,{value:c,onChange:u,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(ds,{size:14}),e[3]=w):w=e[3];let N;e[4]!==a.isPending||e[5]!==p?(N=o.jsxs(oe,{size:"sm",onClick:p,disabled:a.isPending,children:[w,"New automation"]}),e[4]=a.isPending,e[5]=p,e[6]=N):N=e[6];let k;e[7]!==x||e[8]!==N?(k=o.jsxs("div",{className:"flex flex-col gap-6",children:[S,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[x,N]})]}),e[7]=x,e[8]=N,e[9]=k):k=e[9];const R=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Fs,{image:o.jsx(Hs,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(oe,{size:"sm",onClick:p,disabled:a.isPending,children:[o.jsx(ds,{size:14}),"New automation"]})})}):f.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Fs,{image:o.jsx(Hs,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${c}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:f.map(T=>o.jsx(Ph,{automation:T,onClick:()=>m(T.id)},T.id))});let E;e[10]!==R||e[11]!==b.Body||e[12]!==k?(E=o.jsxs(b.Body,{children:[k,R]}),e[10]=R,e[11]=b.Body,e[12]=k,e[13]=E):E=e[13];let B;e[14]!==E||e[15]!==v.Content?(B=o.jsx(v.Content,{children:E}),e[14]=E,e[15]=v.Content,e[16]=B):B=e[16];let A;return e[17]!==g||e[18]!==B?(A=o.jsx(g,{children:B}),e[17]=g,e[18]=B,e[19]=A):A=e[19],A}function sg(t){const e=F.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(tg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Uo=P.lazy(()=>Gl(()=>import("./project-app-view-C9qLbJFL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function ig(t){const e=F.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=La(r);if(vc(n)){let m;return e[3]!==i?(m=o.jsx(qn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Lu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(sg,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Op,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(bf,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Zp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=xc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Uo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Uo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx(qn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function rg(t){const e=F.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ta.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=ea(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(ma,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function ng(t){const e=F.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Pn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ta.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=ea(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const B=d.current;if(!B)return;const A=Pn(r,n),T=A.chat>0&&A.chat<100?u:A.chat,y=A.chat>0&&A.chat<100?100-u:A.main;B.setLayout([T,y])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Aa,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(rg,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ih,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=ie("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=N):N=e[19];let k;e[20]!==i||e[21]!==s?(k=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ut,{children:o.jsx(ig,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=k):k=e[22];let R;e[23]!==h.main||e[24]!==k?(R=o.jsx(ma,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:k}),e[23]=h.main,e[24]=k,e[25]=R):R=e[25];let E;return e[26]!==R||e[27]!==m||e[28]!==b?(E=o.jsxs(rh,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,R]},m),e[26]=R,e[27]=m,e[28]=b,e[29]=E):E=e[29],E}const mr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Vo="bg-sidebar-accent text-sidebar-foreground",_r="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function og(t){const e=F.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=$c(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Ce("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Vo:_r;let u;e[3]!==c?(u=ie(mr,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Bc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ge,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Ce("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Vo:_r;let v;e[16]!==g?(v=ie(mr,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Pc,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Xe,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(Ge,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let k;e[26]!==N?(k=ie("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=k):k=e[27];const R=!l,E=l?0:-1,B=!l,A=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==A?(T=ie(mr,_r,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",A),e[28]=A,e[29]=T):T=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(la,{size:16}),e[30]=y):y=e[30];let C;e[31]!==r||e[32]!==R||e[33]!==E||e[34]!==B||e[35]!==T?(C=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:R,tabIndex:E,"aria-hidden":B,className:T,children:y})}),e[31]=r,e[32]=R,e[33]=E,e[34]=B,e[35]=T,e[36]=C):C=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Xe,{side:"bottom",children:"New task"}),e[37]=j):j=e[37];let D;e[38]!==C?(D=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ge,{delayDuration:300,children:[C,j]})}),e[38]=C,e[39]=D):D=e[39];let M;e[40]!==k||e[41]!==D?(M=o.jsx("div",{className:k,children:D}),e[40]=k,e[41]=D,e[42]=M):M=e[42];let I;return e[43]!==w||e[44]!==M||e[45]!==m?(I=o.jsxs(o.Fragment,{children:[m,w,M]}),e[43]=w,e[44]=M,e[45]=m,e[46]=I):I=e[46],I}function ag(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function lg(t){const e=F.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=ie("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(cg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function cg(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}function hg(t){const e=F.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(qs,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ca,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(dg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Gs,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Ys,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function dg(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}const ug=6;function fg(t){const e=F.c(20),{virtualMcpId:s,taskId:i}=t,r=Lt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=La(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=bc({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:w}=ag(a,S,ug);d=w,u=N=>{const k=a.find(E=>E.id===N),R=S===N&&h;if(Ce("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:k?.kind??null,was_active:R}),N==="automations"){const E=Sc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:E}),replace:!0});return}c(N)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(lg,{title:N.title,icon:N.icon,active:v(N),onClick:()=>u(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(hg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function mg(t){const e=F.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=ie("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Yl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function _g(t){const e=F.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(Nu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(ku({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(oe,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(br,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(ls,{asChild:!0,children:o.jsx(oe,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(cs,{align:"end",children:o.jsx(kt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(as,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const pg=new Set(["failure","timed_out","cancelled","action_required"]);function gg(t){return t.status==="completed"&&pg.has(t.conclusion)}function vg(t){return t.status==="queued"||t.status==="in_progress"}function xg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(gg).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(vg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function bg(){return Xt().branchStatus}const Sg=6e4,yg=3e4;function wg(t){const e=F.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=We(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Sg,refetchIntervalInBackground:!1,staleTime:yg,select:Cg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ps(l)}function Cg(t){const e=Js(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function kg(t){const e=F.c(42),{virtualMcpId:s}=t,{org:i}=be(),r=Nt(s),{currentBranch:n}=xt(),a=_s(),l=r?.metadata?.githubRepo??null,h=bg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=$a(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const w=Ha(x),N=l?.connectionId??"",k=l?.owner??"",R=l?.name??"",E=p&&p.state==="open"?p.number:null;let B;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==k||e[18]!==R||e[19]!==E?(B={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:k,repo:R,prNumber:E},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=k,e[18]=R,e[19]=E,e[20]=B):B=e[20];const A=wg(B);if(!l?.connectionId||!n)return null;let T;e[21]!==h||e[22]!==w.data||e[23]!==p||e[24]!==m.isPending||e[25]!==A.data?(T=xg({branchStatus:h,pr:p,checks:w.data??[],reviews:A.data??null,loading:m.isPending}),e[21]=h,e[22]=w.data,e[23]=p,e[24]=m.isPending,e[25]=A.data,e[26]=T):T=e[26];const y=T;let C;e[27]!==a?(C=U=>a.sendMessage({parts:[{type:"text",text:U}]}),e[27]=a,e[28]=C):C=e[28];const j=C,D=a.isStreaming;let M;e[29]!==n||e[30]!==y||e[31]!==D||e[32]!==p||e[33]!==j?(M=U=>{if(!D)switch(U){case"commit-and-push":{j(gu({branch:n}));return}case"create-pr":{j(vu({branch:n}));return}case"reopen":{p&&j(xu({prNumber:p.number}));return}case"rebase":{j(bu({branch:n}));return}case"fix-checks":{p&&j(yu({prNumber:p.number,failingChecks:y.meta?.failingChecks??[]}));return}case"mark-ready":{p&&j(wu({prNumber:p.number}));return}case"resolve-comments":{p&&j(Cu({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=y,e[31]=D,e[32]=p,e[33]=j,e[34]=M):M=e[34];const I=M;let O;e[35]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(mg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=O):O=e[35];const q=p?.number;let H;return e[36]!==y||e[37]!==D||e[38]!==I||e[39]!==j||e[40]!==q?(H=o.jsxs(o.Fragment,{children:[O,o.jsx(Ng,{button:y,isStreaming:D,onActivate:I,prNumber:q,send:j})]}),e[36]=y,e[37]=D,e[38]=I,e[39]=j,e[40]=q,e[41]=H):H=e[41],H}function Ng(t){const e=F.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(_g,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx(Ko,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(Nh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(oe,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(Ko,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function Ko(t){const e=F.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ye,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Xe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Jc,{children:o.jsxs(Ge,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function jg(t){const e=F.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(gr.Right,{children:o.jsx(kg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const ts=P.createContext(null);function Cn(){return P.use(ts)}function qo(t){const e=F.c(7),{children:s}=t,{taskId:i}=xt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(Ee.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Aa,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ut,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Ee.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Go(t){const e=F.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function Eg(t){const e=F.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ac,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Yo(t){const e=F.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=be(),{currentBranch:l}=xt(),{data:h}=Ei.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Ot,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=We(u),{mutate:f}=dn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:Tg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Zu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function Tg(t){console.error("[auto-start-vm] failed:",t)}function Rg(){const t=F.c(96),e=fa(),s=Lt(),{org:i}=be(),r=Fc()?.tasksOpen??!1;Zc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Xl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=nn(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Fh(a.taskId??"",d),_=Nt(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Gt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=Hc(g,S),{setOpenMobile:w,openMobile:N}=qc(),k=w,R=P.useRef(null);let E,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const W=Y=>{Vc(Y)&&Y.shiftKey&&Y.code==="KeyS"&&!Y.repeat&&(Y.preventDefault(),R.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},B=[],t[12]=E,t[13]=B):(E=t[12],B=t[13]),P.useEffect(E,B);const A=d;let T;t[14]!==_||t[15]!==d?(T={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=T):T=t[16];const y=T;if(f.status==="creating"||f.status==="loading"){let W;t[17]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Be,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=W):W=t[17];let Y;return t[18]!==y?(Y=o.jsx(ts,{value:y,children:W}),t[18]=y,t[19]=Y):Y=t[19],Y}if(f.status==="error"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=W):W=t[20];let Y;t[21]!==f.error.message?(Y=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[W,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=Y):Y=t[22];let $;return t[23]!==y||t[24]!==Y?($=o.jsx(ts,{value:y,children:Y}),t[23]=y,t[24]=Y,t[25]=$):$=t[25],$}if(!_){let W;t[26]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx($s,{size:48,className:"text-muted-foreground"}),t[26]=W):W=t[26];const Y=`The agent "${d}" does not exist in this organization.`;let $;t[27]!==s||t[28]!==l?($=o.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=$):$=t[29];let K;t[30]!==Y||t[31]!==$?(K=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Fs,{image:W,title:"Agent not found",description:Y,actions:$})})}),t[30]=Y,t[31]=$,t[32]=K):K=t[32];let L;return t[33]!==y||t[34]!==K?(L=o.jsx(ts,{value:y,children:K}),t[33]=y,t[34]=K,t[35]=L):L=t[35],L}if(e){let W;t[36]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx(Gc,{className:"sr-only",children:"Navigation"}),t[36]=W):W=t[36];let Y;t[37]!==k?(Y=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Wc,{onClose:()=>k(!1)})}),t[37]=k,t[38]=Y):Y=t[38];let $;t[39]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Uc,{})}),t[39]=$):$=t[39];let K;t[40]!==Y?(K=o.jsxs(Yc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[W,o.jsxs("div",{className:"flex h-full",children:[Y,$]})]}),t[40]=Y,t[41]=K):K=t[41];let L;t[42]!==N||t[43]!==k||t[44]!==K?(L=o.jsx(Xc,{open:N,onOpenChange:k,children:K}),t[42]=N,t[43]=k,t[44]=K,t[45]=L):L=t[45];const Z=L,te=_?.metadata?.vmMap;let se;t[46]!==x.createNewTask?(se=o.jsx(Go,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=se):se=t[47];let X;t[48]!==k?(X=o.jsx(Eg,{onOpenSidebar:()=>k(!0)}),t[48]=k,t[49]=X):X=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(qo,{})}),t[50]=he):he=t[50];let fe;t[51]!==b||t[52]!==Z||t[53]!==te||t[54]!==se||t[55]!==X||t[56]!==d?(fe=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:te,children:[se,X,he,Z]}),t[51]=b,t[52]=Z,t[53]=te,t[54]=se,t[55]=X,t[56]=d,t[57]=fe):fe=t[57];let de;t[58]!==A||t[59]!==fe?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Ee.Provider,{virtualMcpId:A,children:fe},A)}),t[58]=A,t[59]=fe,t[60]=de):de=t[60];let ue;return t[61]!==y||t[62]!==de?(ue=o.jsx(ts,{value:y,children:de}),t[61]=y,t[62]=de,t[63]=ue):ue=t[63],ue}const C=r?void 0:x.createNewTask;let j;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==C?(j=o.jsx(gr.Toggles,{children:o.jsx(og,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:C})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=C,t[67]=j):j=t[67];let D;t[68]!==x.taskId||t[69]!==d?(D=o.jsx(gr.Tabs,{children:o.jsx(fg,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=D):D=t[70];const M=_?.metadata?.vmMap;let I;t[71]!==_?(I=o.jsx(jg,{virtualMcp:_}),t[71]=_,t[72]=I):I=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Go,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let q;t[75]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(qo,{}),t[75]=q):q=t[75];let H;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(H=o.jsx(ng,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:q}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=H):H=t[80];let U;t[81]!==b||t[82]!==M||t[83]!==I||t[84]!==O||t[85]!==H||t[86]!==d?(U=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:M,children:[I,O,H]}),t[81]=b,t[82]=M,t[83]=I,t[84]=O,t[85]=H,t[86]=d,t[87]=U):U=t[87];let Q;t[88]!==A||t[89]!==D||t[90]!==U?(Q=o.jsxs(Ee.Provider,{virtualMcpId:A,children:[D,U]},A),t[88]=A,t[89]=D,t[90]=U,t[91]=Q):Q=t[91];let ee;return t[92]!==y||t[93]!==j||t[94]!==Q?(ee=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(ts,{value:y,children:[j,Q]})}),t[92]=y,t[93]=j,t[94]=Q,t[95]=ee):ee=t[95],ee}function O1(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Rg,{})}),t[0]=e):e=t[0],e}export{O1 as default,Cn as useInsetContext};
182
+ `);if(Me.trim()){M(!0);try{Ke(),Ce("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Me.length}),await b(["studio-automation-manager"]),g(!0),await v({tiptapDoc:Oa({managerAgentId:ia.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Me})})}finally{M(!1)}}},U=e.models?.credentialId||_||"",Q=e.models?.thinking?.id||m?.modelId||"",ee=e.models?.tier??"",W=Zo({defaultValues:{name:e.name,active:e.active,credential_id:U,model_id:Q,tier:ee}}),Y=W.watch("active"),$=W.watch("credential_id"),K=W.watch("model_id"),{models:L,isLoading:Z}=zc($||void 0),te=L.find(re=>re.modelId===K)??null,se=W.watch("tier"),X=["fast","smart","thinking"].find(re=>p.chat[re]?.modelId===K&&p.chat[re]?.keyId===$),he=se||X||"smart",fe=re=>{const Me=p.chat[re];Me&&(W.setValue("credential_id",Me.keyId),W.setValue("model_id",Me.modelId),W.setValue("tier",re),me("credential_id"),me("model_id"),me("tier"),G())},de=P.useRef(null),ue=P.useRef(new Set),ve=P.useRef(0),De=P.useRef(null),Ue=3e4,Ke=()=>{De.current&&(clearTimeout(De.current),De.current=null),de.current!==null&&(Ce("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(ue.current),save_count:ve.current,edit_duration_ms:Date.now()-de.current}),de.current=null,ue.current=new Set,ve.current=0)},Qe=P.useRef(new Set),me=re=>{Qe.current.add(re)},Tt=async()=>{const re=Array.from(Qe.current);if(!(re.length>0)&&!O.current)return!0;const bs=O.current;O.current=!1,Qe.current=new Set;const rt=W.getValues(),Pl=q.current;try{const Ss=rt.credential_id&&rt.model_id?rt.credential_id:"",Wi=rt.credential_id&&rt.model_id?rt.model_id:"",kn=p.enabled?rt.tier||X:rt.tier||void 0,Ll={id:t,name:rt.name,active:rt.active,models:{credentialId:Ss,thinking:{id:Wi},...kn?{tier:kn}:{}},messages:nc(Pl),temperature:0};await a.mutateAsync(Ll),de.current===null&&(de.current=Date.now());for(const Ol of re)ue.current.add(Ol);return bs&&ue.current.add("messages"),ve.current+=1,De.current&&clearTimeout(De.current),De.current=setTimeout(Ke,Ue),Ss!==rt.credential_id&&W.setValue("credential_id",Ss),Wi!==rt.model_id&&W.setValue("model_id",Wi),!0}catch{O.current=!0;for(const Ss of re)Qe.current.add(Ss);return!1}},{schedule:G,flush:ne}=Ra({save:Tt}),_e=re=>{re&&me(re),G()},St=re=>{if(q.current=re,k(re),!I.current){I.current=!0;return}O.current=!0,G()},Hi=async()=>{Ce("automation_test_clicked",{automation_id:t,agent_id:r});const re=await ne();if(Ke(),!re)return;if(!N){ge.error("No instructions configured for this automation");return}p.enabled?f(he):te&&$&&d({...te,keyId:$}),g(!0),x({...S,toolApprovalLevel:"auto"});const Me=jn(N);u({message:{tiptapDoc:N,parts:Me},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(oe,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Ia,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx(Ht,{control:W.control,name:"name",render:({field:re})=>o.jsx(gs,{...re,onChange:Me=>{re.onChange(Me),_e("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(xr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ht,{control:W.control,name:"active",render:({field:re})=>o.jsx(vr,{checked:re.value,onCheckedChange:Me=>{re.onChange(Me),me("active"),setTimeout(()=>ne(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Y?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(pa,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Up,{automationId:t,open:R,onOpenChange:E,onCustomSelect:()=>{A(!0),j(!1),y("")},onEventSelect:()=>{j(!0),A(!1)}})]}),e.triggers.length===0&&!B?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>E(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(re=>o.jsx(Vp,{trigger:re,automationId:t,connectionName:re.connection_id?c.get(re.connection_id):void 0},re.id))}),B&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Bs,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:T,onChange:re=>y(re.target.value),onBlur:async()=>{const re=T.trim();if(!(!re||!Os(re)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:re}),Ce("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ge.success("Starter added"),A(!1),y("")}catch{ge.error("Failed to add starter")}},onKeyDown:async re=>{const Me=T.trim();re.key==="Enter"&&Me&&Os(Me)&&re.target.blur(),re.key==="Escape"&&(A(!1),y(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),T&&!Os(T)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Be,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{A(!1),y("")},children:o.jsx(hs,{size:13})})]}),C&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Be,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(qp,{automationId:t,onDone:()=>j(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:D||!N,onClick:H,children:[o.jsx(Ta,{size:13}),"Improve"]})]}),o.jsx(ec,{tiptapDoc:N,setTiptapDoc:St,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(tc,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[p.enabled?o.jsx(sc,{tier:he,onSelect:fe}):o.jsx(Dh,{model:te,isLoading:Z,credentialId:$||null,onCredentialChange:re=>{W.setValue("credential_id",re??""),W.setValue("model_id",""),W.setValue("tier",""),me("credential_id"),me("model_id"),me("tier"),G()},onModelChange:re=>{W.setValue("model_id",re.modelId),W.setValue("tier",""),me("tier"),_e("model_id")},placeholder:"Model"}),o.jsxs(Ge,{children:[o.jsx(Ye,{asChild:!0,children:o.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Hi,disabled:!r,children:[o.jsx(uc,{size:16}),"Test"]})}),o.jsx(Xe,{children:"Test Automation"})]})]})]})})]})]})]})}function Zp(t){const e=F.c(5),{tabId:s}=t;let i;e[0]!==s?(i=na(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ht,{children:o.jsx(ht.Content,{children:o.jsx(ht.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Qp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Qp(t){const e=F.c(8),{id:s}=t,i=Lt(),{data:r,isLoading:n}=Ah(s);let a;e[0]!==i?(a=()=>i({to:".",search:eg,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Jp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function eg(t){return{...t,main:"automations"}}function tg(t){const e=F.c(20),{virtualMcpId:s}=t,i=Lt(),{data:r}=Bh(s),n=r===void 0?[]:r,{create:a}=Xs(),{selectedModel:l,credentialId:h}=Ti(),[c,u]=P.useState(""),d=c.toLowerCase(),f=n.filter(T=>T.name.toLowerCase().includes(d));let _;e[0]!==i?(_=T=>i({to:".",search:y=>({...y,main:"automation:"+T}),replace:!0}),e[0]=i,e[1]=_):_=e[1];const m=_,p=async()=>{if(a.isPending)return;Ce("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const T=l?.modelId&&h?{credentialId:h,modelId:l.modelId}:null,y=await a.mutateAsync(Lh(s,T));m(y.id)},g=ht,v=ht,b=ht;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ht.Title,{children:"Automations"}),e[2]=S):S=e[2];const x=n.length>0&&o.jsx(Oh,{value:c,onChange:u,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(ds,{size:14}),e[3]=w):w=e[3];let N;e[4]!==a.isPending||e[5]!==p?(N=o.jsxs(oe,{size:"sm",onClick:p,disabled:a.isPending,children:[w,"New automation"]}),e[4]=a.isPending,e[5]=p,e[6]=N):N=e[6];let k;e[7]!==x||e[8]!==N?(k=o.jsxs("div",{className:"flex flex-col gap-6",children:[S,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[x,N]})]}),e[7]=x,e[8]=N,e[9]=k):k=e[9];const R=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Fs,{image:o.jsx(Hs,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(oe,{size:"sm",onClick:p,disabled:a.isPending,children:[o.jsx(ds,{size:14}),"New automation"]})})}):f.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Fs,{image:o.jsx(Hs,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${c}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:f.map(T=>o.jsx(Ph,{automation:T,onClick:()=>m(T.id)},T.id))});let E;e[10]!==R||e[11]!==b.Body||e[12]!==k?(E=o.jsxs(b.Body,{children:[k,R]}),e[10]=R,e[11]=b.Body,e[12]=k,e[13]=E):E=e[13];let B;e[14]!==E||e[15]!==v.Content?(B=o.jsx(v.Content,{children:E}),e[14]=E,e[15]=v.Content,e[16]=B):B=e[16];let A;return e[17]!==g||e[18]!==B?(A=o.jsx(g,{children:B}),e[17]=g,e[18]=B,e[19]=A):A=e[19],A}function sg(t){const e=F.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(tg,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Uo=P.lazy(()=>Gl(()=>import("./project-app-view-Di4yF5Oz.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function ig(t){const e=F.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=La(r);if(vc(n)){let m;return e[3]!==i?(m=o.jsx(qn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Lu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(sg,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Op,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(bf,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Zp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=xc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Uo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Uo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx(qn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function rg(t){const e=F.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ta.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=ea(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(ma,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function ng(t){const e=F.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Pn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=ta.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=ea(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const B=d.current;if(!B)return;const A=Pn(r,n),T=A.chat>0&&A.chat<100?u:A.chat,y=A.chat>0&&A.chat<100?100-u:A.main;B.setLayout([T,y])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Aa,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(rg,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ih,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=ie("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=N):N=e[19];let k;e[20]!==i||e[21]!==s?(k=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ut,{children:o.jsx(ig,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=k):k=e[22];let R;e[23]!==h.main||e[24]!==k?(R=o.jsx(ma,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:k}),e[23]=h.main,e[24]=k,e[25]=R):R=e[25];let E;return e[26]!==R||e[27]!==m||e[28]!==b?(E=o.jsxs(rh,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,R]},m),e[26]=R,e[27]=m,e[28]=b,e[29]=E):E=e[29],E}const mr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Vo="bg-sidebar-accent text-sidebar-foreground",_r="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function og(t){const e=F.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=$c(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Ce("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?Vo:_r;let u;e[3]!==c?(u=ie(mr,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Bc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ge,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Ce("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?Vo:_r;let v;e[16]!==g?(v=ie(mr,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Pc,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Xe,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(Ge,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let k;e[26]!==N?(k=ie("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=k):k=e[27];const R=!l,E=l?0:-1,B=!l,A=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==A?(T=ie(mr,_r,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",A),e[28]=A,e[29]=T):T=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(la,{size:16}),e[30]=y):y=e[30];let C;e[31]!==r||e[32]!==R||e[33]!==E||e[34]!==B||e[35]!==T?(C=o.jsx(Ye,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:R,tabIndex:E,"aria-hidden":B,className:T,children:y})}),e[31]=r,e[32]=R,e[33]=E,e[34]=B,e[35]=T,e[36]=C):C=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Xe,{side:"bottom",children:"New task"}),e[37]=j):j=e[37];let D;e[38]!==C?(D=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ge,{delayDuration:300,children:[C,j]})}),e[38]=C,e[39]=D):D=e[39];let M;e[40]!==k||e[41]!==D?(M=o.jsx("div",{className:k,children:D}),e[40]=k,e[41]=D,e[42]=M):M=e[42];let I;return e[43]!==w||e[44]!==M||e[45]!==m?(I=o.jsxs(o.Fragment,{children:[m,w,M]}),e[43]=w,e[44]=M,e[45]=m,e[46]=I):I=e[46],I}function ag(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function lg(t){const e=F.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=ie("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(cg,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function cg(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}function hg(t){const e=F.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(qs,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ca,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(dg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Gs,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Ys,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function dg(t){const e=F.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ua,{className:"size-4"}),e[4]=i):i=e[4],i}const ug=6;function fg(t){const e=F.c(20),{virtualMcpId:s,taskId:i}=t,r=Lt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=La(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=bc({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:w}=ag(a,S,ug);d=w,u=N=>{const k=a.find(E=>E.id===N),R=S===N&&h;if(Ce("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:k?.kind??null,was_active:R}),N==="automations"){const E=Sc({activeTab:l,mainOpen:h});r({to:".",search:B=>({...B,main:E}),replace:!0});return}c(N)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(lg,{title:N.title,icon:N.icon,active:v(N),onClick:()=>u(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(hg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function mg(t){const e=F.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=ie("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Yl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function _g(t){const e=F.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(Nu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(ku({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(oe,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(br,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(ls,{asChild:!0,children:o.jsx(oe,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(cs,{align:"end",children:o.jsx(kt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(as,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const pg=new Set(["failure","timed_out","cancelled","action_required"]);function gg(t){return t.status==="completed"&&pg.has(t.conclusion)}function vg(t){return t.status==="queued"||t.status==="in_progress"}function xg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(gg).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(vg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function bg(){return Xt().branchStatus}const Sg=6e4,yg=3e4;function wg(t){const e=F.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=We(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:Sg,refetchIntervalInBackground:!1,staleTime:yg,select:Cg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ps(l)}function Cg(t){const e=Js(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function kg(t){const e=F.c(42),{virtualMcpId:s}=t,{org:i}=be(),r=Nt(s),{currentBranch:n}=xt(),a=_s(),l=r?.metadata?.githubRepo??null,h=bg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=$a(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const w=Ha(x),N=l?.connectionId??"",k=l?.owner??"",R=l?.name??"",E=p&&p.state==="open"?p.number:null;let B;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==k||e[18]!==R||e[19]!==E?(B={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:k,repo:R,prNumber:E},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=k,e[18]=R,e[19]=E,e[20]=B):B=e[20];const A=wg(B);if(!l?.connectionId||!n)return null;let T;e[21]!==h||e[22]!==w.data||e[23]!==p||e[24]!==m.isPending||e[25]!==A.data?(T=xg({branchStatus:h,pr:p,checks:w.data??[],reviews:A.data??null,loading:m.isPending}),e[21]=h,e[22]=w.data,e[23]=p,e[24]=m.isPending,e[25]=A.data,e[26]=T):T=e[26];const y=T;let C;e[27]!==a?(C=U=>a.sendMessage({parts:[{type:"text",text:U}]}),e[27]=a,e[28]=C):C=e[28];const j=C,D=a.isStreaming;let M;e[29]!==n||e[30]!==y||e[31]!==D||e[32]!==p||e[33]!==j?(M=U=>{if(!D)switch(U){case"commit-and-push":{j(gu({branch:n}));return}case"create-pr":{j(vu({branch:n}));return}case"reopen":{p&&j(xu({prNumber:p.number}));return}case"rebase":{j(bu({branch:n}));return}case"fix-checks":{p&&j(yu({prNumber:p.number,failingChecks:y.meta?.failingChecks??[]}));return}case"mark-ready":{p&&j(wu({prNumber:p.number}));return}case"resolve-comments":{p&&j(Cu({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=y,e[31]=D,e[32]=p,e[33]=j,e[34]=M):M=e[34];const I=M;let O;e[35]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(mg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=O):O=e[35];const q=p?.number;let H;return e[36]!==y||e[37]!==D||e[38]!==I||e[39]!==j||e[40]!==q?(H=o.jsxs(o.Fragment,{children:[O,o.jsx(Ng,{button:y,isStreaming:D,onActivate:I,prNumber:q,send:j})]}),e[36]=y,e[37]=D,e[38]=I,e[39]=j,e[40]=q,e[41]=H):H=e[41],H}function Ng(t){const e=F.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(_g,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx(Ko,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(Nh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(oe,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx(Ko,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function Ko(t){const e=F.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(Ye,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Xe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Jc,{children:o.jsxs(Ge,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function jg(t){const e=F.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(gr.Right,{children:o.jsx(kg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const ts=P.createContext(null);function Cn(){return P.use(ts)}function qo(t){const e=F.c(7),{children:s}=t,{taskId:i}=xt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(Ee.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Aa,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ut,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Ee.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Go(t){const e=F.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function Eg(t){const e=F.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(ac,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Yo(t){const e=F.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=be(),{currentBranch:l}=xt(),{data:h}=Ei.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Ot,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=We(u),{mutate:f}=dn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:Tg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Zu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function Tg(t){console.error("[auto-start-vm] failed:",t)}function Rg(){const t=F.c(96),e=fa(),s=Lt(),{org:i}=be(),r=Fc()?.tasksOpen??!1;Zc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Xl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=nn(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??sa(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Fh(a.taskId??"",d),_=Nt(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Gt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=Hc(g,S),{setOpenMobile:w,openMobile:N}=qc(),k=w,R=P.useRef(null);let E,B;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const W=Y=>{Vc(Y)&&Y.shiftKey&&Y.code==="KeyS"&&!Y.repeat&&(Y.preventDefault(),R.current?.())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},B=[],t[12]=E,t[13]=B):(E=t[12],B=t[13]),P.useEffect(E,B);const A=d;let T;t[14]!==_||t[15]!==d?(T={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=T):T=t[16];const y=T;if(f.status==="creating"||f.status==="loading"){let W;t[17]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Be,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=W):W=t[17];let Y;return t[18]!==y?(Y=o.jsx(ts,{value:y,children:W}),t[18]=y,t[19]=Y):Y=t[19],Y}if(f.status==="error"){let W;t[20]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=W):W=t[20];let Y;t[21]!==f.error.message?(Y=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[W,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=Y):Y=t[22];let $;return t[23]!==y||t[24]!==Y?($=o.jsx(ts,{value:y,children:Y}),t[23]=y,t[24]=Y,t[25]=$):$=t[25],$}if(!_){let W;t[26]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx($s,{size:48,className:"text-muted-foreground"}),t[26]=W):W=t[26];const Y=`The agent "${d}" does not exist in this organization.`;let $;t[27]!==s||t[28]!==l?($=o.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=$):$=t[29];let K;t[30]!==Y||t[31]!==$?(K=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Fs,{image:W,title:"Agent not found",description:Y,actions:$})})}),t[30]=Y,t[31]=$,t[32]=K):K=t[32];let L;return t[33]!==y||t[34]!==K?(L=o.jsx(ts,{value:y,children:K}),t[33]=y,t[34]=K,t[35]=L):L=t[35],L}if(e){let W;t[36]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx(Gc,{className:"sr-only",children:"Navigation"}),t[36]=W):W=t[36];let Y;t[37]!==k?(Y=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Wc,{onClose:()=>k(!1)})}),t[37]=k,t[38]=Y):Y=t[38];let $;t[39]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Uc,{})}),t[39]=$):$=t[39];let K;t[40]!==Y?(K=o.jsxs(Yc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[W,o.jsxs("div",{className:"flex h-full",children:[Y,$]})]}),t[40]=Y,t[41]=K):K=t[41];let L;t[42]!==N||t[43]!==k||t[44]!==K?(L=o.jsx(Xc,{open:N,onOpenChange:k,children:K}),t[42]=N,t[43]=k,t[44]=K,t[45]=L):L=t[45];const Z=L,te=_?.metadata?.vmMap;let se;t[46]!==x.createNewTask?(se=o.jsx(Go,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=se):se=t[47];let X;t[48]!==k?(X=o.jsx(Eg,{onOpenSidebar:()=>k(!0)}),t[48]=k,t[49]=X):X=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(qo,{})}),t[50]=he):he=t[50];let fe;t[51]!==b||t[52]!==Z||t[53]!==te||t[54]!==se||t[55]!==X||t[56]!==d?(fe=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:te,children:[se,X,he,Z]}),t[51]=b,t[52]=Z,t[53]=te,t[54]=se,t[55]=X,t[56]=d,t[57]=fe):fe=t[57];let de;t[58]!==A||t[59]!==fe?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Ee.Provider,{virtualMcpId:A,children:fe},A)}),t[58]=A,t[59]=fe,t[60]=de):de=t[60];let ue;return t[61]!==y||t[62]!==de?(ue=o.jsx(ts,{value:y,children:de}),t[61]=y,t[62]=de,t[63]=ue):ue=t[63],ue}const C=r?void 0:x.createNewTask;let j;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==C?(j=o.jsx(gr.Toggles,{children:o.jsx(og,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:C})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=C,t[67]=j):j=t[67];let D;t[68]!==x.taskId||t[69]!==d?(D=o.jsx(gr.Tabs,{children:o.jsx(fg,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=D):D=t[70];const M=_?.metadata?.vmMap;let I;t[71]!==_?(I=o.jsx(jg,{virtualMcp:_}),t[71]=_,t[72]=I):I=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Go,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let q;t[75]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(qo,{}),t[75]=q):q=t[75];let H;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(H=o.jsx(ng,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:q}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=H):H=t[80];let U;t[81]!==b||t[82]!==M||t[83]!==I||t[84]!==O||t[85]!==H||t[86]!==d?(U=o.jsxs(Yo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:M,children:[I,O,H]}),t[81]=b,t[82]=M,t[83]=I,t[84]=O,t[85]=H,t[86]=d,t[87]=U):U=t[87];let Q;t[88]!==A||t[89]!==D||t[90]!==U?(Q=o.jsxs(Ee.Provider,{virtualMcpId:A,children:[D,U]},A),t[88]=A,t[89]=D,t[90]=U,t[91]=Q):Q=t[91];let ee;return t[92]!==y||t[93]!==j||t[94]!==Q?(ee=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(ts,{value:y,children:[j,Q]})}),t[92]=y,t[93]=j,t[94]=Q,t[95]=ee):ee=t[95],ee}function O1(){const t=F.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Be,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Rg,{})}),t[0]=e):e=t[0],e}export{O1 as default,Cn as useInsetContext};