decocms 2.312.0 → 2.312.1

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 (195) hide show
  1. package/dist/client/assets/{AlertCircle-DgIbjZFP.js → AlertCircle-ERuf6aAv.js} +1 -1
  2. package/dist/client/assets/{Archive-C3oinC0s.js → Archive-CI9Epn9-.js} +1 -1
  3. package/dist/client/assets/{ArrowNarrowLeft-VswvJrav.js → ArrowNarrowLeft-BKXifKxP.js} +1 -1
  4. package/dist/client/assets/{ArrowUpRight-pHL6O-19.js → ArrowUpRight-BVXRPr5x.js} +1 -1
  5. package/dist/client/assets/{Check-aa9K7ozq.js → Check-Dw-NNjqo.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-D3x4CQc4.js → CheckCircle-DDlK7D0f.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-COohyJel.js → ChevronDown-CKzufdMF.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-BkYTpADa.js → ChevronRight-DHugiPa5.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-CvIufmOE.js → ChevronUp-ftnK3X6N.js} +1 -1
  10. package/dist/client/assets/{Container-BwxK1zsB.js → Container-CBjPTaAm.js} +1 -1
  11. package/dist/client/assets/{DotsVertical-DmOpiu7I.js → DotsVertical-2sZM-_B-.js} +1 -1
  12. package/dist/client/assets/{LayoutLeft-CqVDbbUj.js → LayoutLeft-DbGS7aH0.js} +1 -1
  13. package/dist/client/assets/{LinkExternal01-D3EwQo2i.js → LinkExternal01-BB8PEfNz.js} +1 -1
  14. package/dist/client/assets/{Lock01-3Z5YegUt.js → Lock01-BtdrYKDm.js} +1 -1
  15. package/dist/client/assets/{Palette-BmNvJ0d9.js → Palette-CBvID2VE.js} +1 -1
  16. package/dist/client/assets/{Play-C-f37c5A.js → Play-2WAveRPh.js} +1 -1
  17. package/dist/client/assets/{Plus-DY7vA0mY.js → Plus-D0grveYD.js} +1 -1
  18. package/dist/client/assets/{RefreshCcw01-D3efDqWQ.js → RefreshCcw01-BF_TovZP.js} +1 -1
  19. package/dist/client/assets/{SearchMd-BP8uZLZv.js → SearchMd-9Lp0KuHW.js} +1 -1
  20. package/dist/client/assets/{Settings02-CoMmXn-C.js → Settings02-kS8gRV3C.js} +1 -1
  21. package/dist/client/assets/{Shield01-C7wSpsYO.js → Shield01-BT26kZxz.js} +1 -1
  22. package/dist/client/assets/{Star01-C6jUiq1l.js → Star01-r_zmzcnE.js} +1 -1
  23. package/dist/client/assets/{Sun-Dp0B2a5M.js → Sun-CqquG-7-.js} +1 -1
  24. package/dist/client/assets/{Tool01-DLlBXWXE.js → Tool01-CZrEw9GG.js} +1 -1
  25. package/dist/client/assets/{Trash01-Bm2xp20o.js → Trash01-BfewA6Ab.js} +1 -1
  26. package/dist/client/assets/{User01-DRdPMx3w.js → User01-DB87Ecsr.js} +1 -1
  27. package/dist/client/assets/{Users03-BL_5hYu_.js → Users03-BgtpPlOT.js} +1 -1
  28. package/dist/client/assets/{X-BEU0MHUr.js → X-MkRobXsq.js} +1 -1
  29. package/dist/client/assets/{XCircle-J7xeYsqG.js → XCircle-BLjPn4jt.js} +1 -1
  30. package/dist/client/assets/{XClose-Ds1dTxMH.js → XClose-Cr0_UGK3.js} +1 -1
  31. package/dist/client/assets/{Zap-B4-wkcyX.js → Zap-DRgyzoAR.js} +1 -1
  32. package/dist/client/assets/{ZapSquare-Br7mI2dC.js → ZapSquare-5AS1CTub.js} +1 -1
  33. package/dist/client/assets/{accordion-C6T2-sSh.js → accordion-Vcv9vx8b.js} +1 -1
  34. package/dist/client/assets/{agent-icon-B5Lepjyg.js → agent-icon-CHawCeGj.js} +1 -1
  35. package/dist/client/assets/{agents-list-BxHllP9U.js → agents-list-Bp1nGcHn.js} +1 -1
  36. package/dist/client/assets/{ai-providers-d9GuTz8R.js → ai-providers-B9DIEKIu.js} +1 -1
  37. package/dist/client/assets/{alert-dialog-BCbgR3di.js → alert-dialog-BrfyOA8d.js} +1 -1
  38. package/dist/client/assets/{auth-catchall-MxSymLX3.js → auth-catchall-2HftXMlZ.js} +1 -1
  39. package/dist/client/assets/{automation-list-row-BWnR0Wjj.js → automation-list-row-eIHh56lV.js} +1 -1
  40. package/dist/client/assets/{automations-Bz7nADNi.js → automations-41UlbdiX.js} +1 -1
  41. package/dist/client/assets/{avatar-B-WvEQQh.js → avatar-DFG27SpR.js} +1 -1
  42. package/dist/client/assets/{badge-CNmz6zWn.js → badge-CyXlfcBA.js} +1 -1
  43. package/dist/client/assets/{brand-context-8zg2xn8H.js → brand-context-Dy4Broqm.js} +1 -1
  44. package/dist/client/assets/{card-BYgw1vi2.js → card-b9f3cSc7.js} +1 -1
  45. package/dist/client/assets/{chat-context-aSv7zVBn.js → chat-context-CBEjrtlA.js} +1 -1
  46. package/dist/client/assets/{checkbox-C2spUlz3.js → checkbox-B-5dNGXU.js} +1 -1
  47. package/dist/client/assets/{collection-detail-B-dCse2_.js → collection-detail-60PTYGbo.js} +1 -1
  48. package/dist/client/assets/{collection-display-button-l-NTxSUK.js → collection-display-button-2Q1qlgg7.js} +1 -1
  49. package/dist/client/assets/{collection-search-BfemXUsr.js → collection-search-CF_YUmub.js} +1 -1
  50. package/dist/client/assets/{collection-search-D8_CBVzq.js → collection-search-CeOmn4VX.js} +1 -1
  51. package/dist/client/assets/{collection-table-wrapper-0n-5l4UJ.js → collection-table-wrapper-BCrWxTNq.js} +1 -1
  52. package/dist/client/assets/{collection-tabs-CqzKmYGm.js → collection-tabs-BzOEZ7_c.js} +1 -1
  53. package/dist/client/assets/{collections-Cuocn47g.js → collections-DfDlNVfw.js} +1 -1
  54. package/dist/client/assets/{command-BQRe_Fje.js → command-1vgVMo-o.js} +1 -1
  55. package/dist/client/assets/{connection-card-BAH-_mNT.js → connection-card-CWY5aJHR.js} +1 -1
  56. package/dist/client/assets/{connection-detail-DI72xr4q.js → connection-detail-J3WYkO2_.js} +1 -1
  57. package/dist/client/assets/{connection-form-helpers-BZl_1Yqu.js → connection-form-helpers-V_S7kOM3.js} +1 -1
  58. package/dist/client/assets/{connections-DJhXDLUO.js → connections-Ci7EQIuw.js} +1 -1
  59. package/dist/client/assets/{constants-B0----Qm.js → constants-Bpr1SrBK.js} +1 -1
  60. package/dist/client/assets/{constants-CIP80jF-.js → constants-BxAwlKEt.js} +1 -1
  61. package/dist/client/assets/{dialog-C_RX-AQt.js → dialog-BFONggAc.js} +1 -1
  62. package/dist/client/assets/{domain-settings-DNYks8cr.js → domain-settings-DR2YXCNC.js} +1 -1
  63. package/dist/client/assets/{drawer-XcInLzwE.js → drawer-DPE2UfDW.js} +1 -1
  64. package/dist/client/assets/{dropdown-menu-5TLJbEBI.js → dropdown-menu-BdpYdHvo.js} +1 -1
  65. package/dist/client/assets/{dynamic-plugin-layout-DERb69N2.js → dynamic-plugin-layout-jhvTbKwm.js} +1 -1
  66. package/dist/client/assets/{empty-state-Cp10WCIm.js → empty-state-C8B-PY4B.js} +1 -1
  67. package/dist/client/assets/{empty-state-C2KaC_Qh.js → empty-state-Ds_81ifx.js} +1 -1
  68. package/dist/client/assets/{extract-connection-data-C288mPce.js → extract-connection-data-BbuEAUmV.js} +1 -1
  69. package/dist/client/assets/{features-DrzEH5fg.js → features-DhCStbTJ.js} +1 -1
  70. package/dist/client/assets/{form-0EbWbv9V.js → form-B8LulHdI.js} +1 -1
  71. package/dist/client/assets/{general-DBYHhZW6.js → general-bOTHD-QQ.js} +1 -1
  72. package/dist/client/assets/{index-CDPuXQh9.js → index-BHPgwaHi.js} +1 -1
  73. package/dist/client/assets/{index-C7cQ6LLR.js → index-BKHWKQ7T.js} +1 -1
  74. package/dist/client/assets/{index-uHvJMymL.js → index-Bix1l1uh.js} +1 -1
  75. package/dist/client/assets/{index-DisG42x6.js → index-C4_Nt78h.js} +1 -1
  76. package/dist/client/assets/{index-BZ56DfF3.js → index-CAJfUS9H.js} +3 -3
  77. package/dist/client/assets/{index-Cze3SONv.js → index-CVjB3eh1.js} +1 -1
  78. package/dist/client/assets/{index-Bt1fPbef.js → index-CaonkSAJ.js} +1 -1
  79. package/dist/client/assets/{index-xUCBR4Jh.js → index-CoMcjeGv.js} +2 -2
  80. package/dist/client/assets/{index-Cwjty6pU.js → index-DB-1u_Lp.js} +1 -1
  81. package/dist/client/assets/{index-URPAEU-i.js → index-DDhZDmpn.js} +1 -1
  82. package/dist/client/assets/{index-XNLf7Fjv.js → index-DVXn-o-d.js} +1 -1
  83. package/dist/client/assets/{index-HWD0WtFK.js → index-DZpCM_Ye.js} +1 -1
  84. package/dist/client/assets/{index-BYYBAht5.js → index-DcvDT1BH.js} +1 -1
  85. package/dist/client/assets/{index-CmsyCfFn.js → index-Du6DwcIl.js} +1 -1
  86. package/dist/client/assets/{index-DL0cg4Sy.js → index-_a3sfx9A.js} +2 -2
  87. package/dist/client/assets/{index-DDUrBgzN.js → index-tuSBNy7Z.js} +1 -1
  88. package/dist/client/assets/{infiniteQueryObserver-DCVrd5pN.js → infiniteQueryObserver-CCfSTQJW.js} +1 -1
  89. package/dist/client/assets/{input-CCf4EPNk.js → input-CLyArZAZ.js} +1 -1
  90. package/dist/client/assets/{integration-icon-F29rJiGn.js → integration-icon-BHVwtvVd.js} +1 -1
  91. package/dist/client/assets/{label-BrmLejNm.js → label-DaQ778PR.js} +1 -1
  92. package/dist/client/assets/{layout-DVLgQZef.js → layout-36aJdu5h.js} +1 -1
  93. package/dist/client/assets/{lean-canvas-recruit-modal-51wnfw_w.js → lean-canvas-recruit-modal-Cp7w5Yzr.js} +1 -1
  94. package/dist/client/assets/{login-g5WUE_1m.js → login-DWlC4uSb.js} +1 -1
  95. package/dist/client/assets/{members-CjNcZZkJ.js → members-Dt2WHe5e.js} +1 -1
  96. package/dist/client/assets/{monaco-editor-B4gYKZgx.js → monaco-editor-BTpSpiaS.js} +1 -1
  97. package/dist/client/assets/{monitoring-stats-row-Ce8KaHuJ.js → monitoring-stats-row-5ybqv9s5.js} +1 -1
  98. package/dist/client/assets/{oauth-callback-Be7SkbaR.js → oauth-callback-6h8lqTVI.js} +1 -1
  99. package/dist/client/assets/{oauth-callback-ai-provider-DGE3iQ3P.js → oauth-callback-ai-provider-sCU77ITv.js} +1 -1
  100. package/dist/client/assets/{onboarding-Dp8uaKFQ.js → onboarding-CYUS6d_c.js} +1 -1
  101. package/dist/client/assets/{org-layout-CbmnnWes.js → org-layout-Cjg2_QgT.js} +1 -1
  102. package/dist/client/assets/{org-plugin-layout-OWKU4NF6.js → org-plugin-layout-gpAiuBtf.js} +1 -1
  103. package/dist/client/assets/{pair-CR5fdfUV.js → pair-Dfx2VDcu.js} +1 -1
  104. package/dist/client/assets/{plugin-empty-state-BGGc2TrB.js → plugin-empty-state-CKebWDOa.js} +1 -1
  105. package/dist/client/assets/{plugin-header-CuM9tImh.js → plugin-header-BnX3_uiT.js} +1 -1
  106. package/dist/client/assets/{plugin-layout-BUbR1Rtp.js → plugin-layout-D9RO_KiG.js} +1 -1
  107. package/dist/client/assets/{popover-EwlTcjqV.js → popover-CjkpEiTE.js} +1 -1
  108. package/dist/client/assets/{profile-unqFgTVV.js → profile-DIAEi3Wh.js} +1 -1
  109. package/dist/client/assets/{project-app-view-BGEyiVSD.js → project-app-view-STAPzbR7.js} +1 -1
  110. package/dist/client/assets/registry--_J6xL4O.js +2 -0
  111. package/dist/client/assets/{registry-layout-BhuMc8jd.js → registry-layout-57KSjOXo.js} +1 -1
  112. package/dist/client/assets/{required-auth-layout-BF8p72H7.js → required-auth-layout-BThC9-U7.js} +1 -1
  113. package/dist/client/assets/{reset-password-BcpO6RRm.js → reset-password-B_VWu4fY.js} +1 -1
  114. package/dist/client/assets/{roles-vMp1SmX5.js → roles-BzMjZN1X.js} +1 -1
  115. package/dist/client/assets/{scroll-area-CELk3Mmw.js → scroll-area-fh9U9MHB.js} +1 -1
  116. package/dist/client/assets/{search-input-Dn4Pg53J.js → search-input-BQvqnxrN.js} +1 -1
  117. package/dist/client/assets/{select-BsEzdOFM.js → select-Wcqz-g0G.js} +1 -1
  118. package/dist/client/assets/{select-model-CMvi5mKv.js → select-model-DNKOCT1K.js} +1 -1
  119. package/dist/client/assets/{settings-layout-SPkXrn6W.js → settings-layout-CwUUNdaO.js} +1 -1
  120. package/dist/client/assets/{settings-section-B0IdECpp.js → settings-section-JVAjMEt8.js} +1 -1
  121. package/dist/client/assets/{shell-layout-D69vTgwv.js → shell-layout-Bz9lZQVY.js} +1 -1
  122. package/dist/client/assets/{sidebar-CEaAddWO.js → sidebar-DAeODPsL.js} +1 -1
  123. package/dist/client/assets/{skeleton-BydKNGdG.js → skeleton-BLclv8kT.js} +1 -1
  124. package/dist/client/assets/{spinner-CMg2UHyb.js → spinner-DnlGnBXF.js} +1 -1
  125. package/dist/client/assets/{sso-CU_2tH9M.js → sso-BrXmJ2I4.js} +1 -1
  126. package/dist/client/assets/{store-DmMo4dqP.js → store-DUXn21Np.js} +1 -1
  127. package/dist/client/assets/store-registry-DOxHwGOb.js +2 -0
  128. package/dist/client/assets/{switch-CpPJgX3Z.js → switch-Ckms2ja4.js} +1 -1
  129. package/dist/client/assets/{table-DvshqBHZ.js → table-CwjuFSQ3.js} +1 -1
  130. package/dist/client/assets/{tabs-XVsrMooL.js → tabs-1aaQ63Sr.js} +1 -1
  131. package/dist/client/assets/{task-status-B72j4SrB.js → task-status-B4sbD0o1.js} +1 -1
  132. package/dist/client/assets/{textarea-BYbT4tbc.js → textarea-BYfjo1_E.js} +1 -1
  133. package/dist/client/assets/{toggle-group-CEAl71x-.js → toggle-group-D-6M9i6u.js} +1 -1
  134. package/dist/client/assets/{tools-list-bFM-v0FI.js → tools-list-CeAP-pSC.js} +1 -1
  135. package/dist/client/assets/{tooltip-AWuCEA2U.js → tooltip-C0fjlVcO.js} +1 -1
  136. package/dist/client/assets/{types-CU4jWLjn.js → types-CGIbyQGc.js} +1 -1
  137. package/dist/client/assets/{use-ai-providers-B1OI2CIf.js → use-ai-providers-B9KrhoJu.js} +1 -1
  138. package/dist/client/assets/{use-collections-D0B-JFQ7.js → use-collections-DiZ2ax9f.js} +1 -1
  139. package/dist/client/assets/{use-connection-CtIj_RJA.js → use-connection-CjuTRKXt.js} +1 -1
  140. package/dist/client/assets/{use-copy-D_gDWAbg.js → use-copy-v_lAeoPt.js} +1 -1
  141. package/dist/client/assets/{use-create-virtual-mcp-poFHUu8W.js → use-create-virtual-mcp-BeCJlwzK.js} +1 -1
  142. package/dist/client/assets/{use-debounced-autosave-BGxMMdPD.js → use-debounced-autosave-Bx5zX-oh.js} +1 -1
  143. package/dist/client/assets/{use-decopilot-events-hoK9fHvn.js → use-decopilot-events-CTbEMJUR.js} +1 -1
  144. package/dist/client/assets/{use-delete-connection-BhlBi1FW.js → use-delete-connection-H0_N4AfS.js} +1 -1
  145. package/dist/client/assets/{use-infinite-scroll-C2jLxN9Z.js → use-infinite-scroll-CdQPwmSi.js} +1 -1
  146. package/dist/client/assets/{use-list-state-Cr5c0njZ.js → use-list-state-DEafJAl0.js} +1 -1
  147. package/dist/client/assets/{use-mcp-tools-CuCdREA6.js → use-mcp-tools-BhYfGuEe.js} +1 -1
  148. package/dist/client/assets/{use-members-CBm8zooS.js → use-members-D_vrkLzO.js} +1 -1
  149. package/dist/client/assets/{use-navigate-to-agent-DuZ9B5bJ.js → use-navigate-to-agent-Dgy6Vgnk.js} +1 -1
  150. package/dist/client/assets/{use-org-auth-client-B_jHxryd.js → use-org-auth-client-DIKSrkdJ.js} +1 -1
  151. package/dist/client/assets/{use-org-sso-D3NSe5ZU.js → use-org-sso-CjA-iSSa.js} +1 -1
  152. package/dist/client/assets/{use-organization-roles-CRKenEoR.js → use-organization-roles-Bg01cmKR.js} +1 -1
  153. package/dist/client/assets/{use-organization-settings-C_omnexa.js → use-organization-settings-BSGABThn.js} +1 -1
  154. package/dist/client/assets/{use-registry-connections--_PoD42X.js → use-registry-connections-CRSTloWi.js} +1 -1
  155. package/dist/client/assets/{use-status-sounds-aVa-jCse.js → use-status-sounds-CNQgHBud.js} +1 -1
  156. package/dist/client/assets/{use-tasks-COHzjoMD.js → use-tasks-DpLDw0OJ.js} +1 -1
  157. package/dist/client/assets/{use-view-mode-CUKpn6Nl.js → use-view-mode-838CJJ99.js} +1 -1
  158. package/dist/client/assets/{use-virtual-mcp-DTEHzUSp.js → use-virtual-mcp-BcU_WFds.js} +1 -1
  159. package/dist/client/assets/useInfiniteQuery-B5TQbcQA.js +1 -0
  160. package/dist/client/assets/useSuspenseInfiniteQuery-DNcETcP6.js +1 -0
  161. package/dist/client/assets/{user-DFc_JDuu.js → user-DCWmkhjg.js} +1 -1
  162. package/dist/client/assets/{view-mode-toggle-DOq6DEUm.js → view-mode-toggle-C_UCqkmc.js} +1 -1
  163. package/dist/client/assets/{workflow-Cq_1R0yx.js → workflow-1eErmNbJ.js} +1 -1
  164. package/dist/client/assets/workflow-detail-JCbLYsbu.js +1 -0
  165. package/dist/client/index.html +1 -1
  166. package/dist/server/cli.js +1 -1
  167. package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
  168. package/dist/server/node_modules/ansi-styles/index.js +223 -0
  169. package/dist/server/node_modules/ansi-styles/license +9 -0
  170. package/dist/server/node_modules/ansi-styles/package.json +54 -0
  171. package/dist/server/node_modules/ansi-styles/readme.md +173 -0
  172. package/dist/server/node_modules/cli-cursor/index.d.ts +47 -0
  173. package/dist/server/node_modules/cli-cursor/index.js +39 -0
  174. package/dist/server/node_modules/cli-cursor/license +9 -0
  175. package/dist/server/node_modules/cli-cursor/package.json +49 -0
  176. package/dist/server/node_modules/cli-cursor/readme.md +51 -0
  177. package/dist/server/node_modules/get-east-asian-width/index.d.ts +60 -0
  178. package/dist/server/node_modules/get-east-asian-width/index.js +30 -0
  179. package/dist/server/node_modules/get-east-asian-width/license +9 -0
  180. package/dist/server/node_modules/get-east-asian-width/lookup-data.js +18 -0
  181. package/dist/server/node_modules/get-east-asian-width/lookup.js +135 -0
  182. package/dist/server/node_modules/get-east-asian-width/package.json +71 -0
  183. package/dist/server/node_modules/get-east-asian-width/readme.md +65 -0
  184. package/dist/server/node_modules/get-east-asian-width/utilities.js +24 -0
  185. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  186. package/dist/server/node_modules/is-fullwidth-code-point/index.js +12 -0
  187. package/dist/server/node_modules/is-fullwidth-code-point/license +9 -0
  188. package/dist/server/node_modules/is-fullwidth-code-point/package.json +53 -0
  189. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +31 -0
  190. package/package.json +1 -1
  191. package/dist/client/assets/registry-H-erkkte.js +0 -2
  192. package/dist/client/assets/store-registry-ukqdTlTM.js +0 -2
  193. package/dist/client/assets/useInfiniteQuery-CpIDGdPN.js +0 -1
  194. package/dist/client/assets/useSuspenseInfiniteQuery-LpJXXkIA.js +0 -1
  195. package/dist/client/assets/workflow-detail-5bk-KUIV.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-BGEyiVSD.js","assets/index-DL0cg4Sy.js","assets/index-DF1nphze.css","assets/pair-CR5fdfUV.js","assets/agent-icon-B5Lepjyg.js","assets/AlertCircle-DgIbjZFP.js","assets/Tool01-DLlBXWXE.js","assets/Archive-C3oinC0s.js","assets/XClose-Ds1dTxMH.js","assets/RefreshCcw01-D3efDqWQ.js","assets/ArrowNarrowLeft-VswvJrav.js","assets/XCircle-J7xeYsqG.js","assets/ArrowUpRight-pHL6O-19.js","assets/ZapSquare-Br7mI2dC.js","assets/Users03-BL_5hYu_.js","assets/CheckCircle-D3x4CQc4.js","assets/Check-aa9K7ozq.js","assets/ChevronDown-COohyJel.js","assets/ChevronRight-BkYTpADa.js","assets/ChevronUp-CvIufmOE.js","assets/DotsVertical-DmOpiu7I.js","assets/Container-BwxK1zsB.js","assets/Star01-C6jUiq1l.js","assets/Palette-BmNvJ0d9.js","assets/SearchMd-BP8uZLZv.js","assets/LayoutLeft-CqVDbbUj.js","assets/LinkExternal01-D3EwQo2i.js","assets/Lock01-3Z5YegUt.js","assets/Sun-Dp0B2a5M.js","assets/Play-C-f37c5A.js","assets/Plus-DY7vA0mY.js","assets/Settings02-CoMmXn-C.js","assets/Shield01-C7wSpsYO.js","assets/Trash01-Bm2xp20o.js","assets/User01-DRdPMx3w.js","assets/X-BEU0MHUr.js","assets/Zap-B4-wkcyX.js","assets/index-HWD0WtFK.js","assets/use-copy-D_gDWAbg.js","assets/tooltip-AWuCEA2U.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-C_RX-AQt.js","assets/content-blocks-o63cs2vh.js","assets/types-CU4jWLjn.js","assets/constants-CIP80jF-.js","assets/chat-context-aSv7zVBn.js","assets/use-virtual-mcp-DTEHzUSp.js","assets/use-collections-D0B-JFQ7.js","assets/use-ai-providers-B1OI2CIf.js","assets/use-decopilot-events-hoK9fHvn.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-COHzjoMD.js","assets/use-organization-settings-C_omnexa.js","assets/shell-layout-D69vTgwv.js","assets/required-auth-layout-BF8p72H7.js","assets/use-org-sso-D3NSe5ZU.js","assets/integration-icon-F29rJiGn.js","assets/use-mcp-tools-CuCdREA6.js"])))=>i.map(i=>d[i]);
2
- import{o as hs,r as B,p as Pl,q as Al,e as $,s as pe,K as Ps,n as Uo,a as Vo,c as se,j as o,l as Te,B as ie,E as Rt,b as Ci,v as oi,f as It,d as Jr,w as Bl,x as _e,y as Ll,V as Ol,t as ye,z as Ko,C as zl,D as zt,F as $l,G as bn,L as Fl,H as Li,I as Zs,J as at,M as qo,P as Hl,_ as Wl,Q as Go,R as Yo,T as Ul,g as Vl}from"./index-DL0cg4Sy.js";import{C as Ne,u as Kl,w as ql,A as Gl,T as Yl,a as Xl,S as Jl}from"./index-xUCBR4Jh.js";import{I as ds}from"./integration-icon-F29rJiGn.js";import{S as Pt,u as $e,g as Xo,a as Jo}from"./constants-CIP80jF-.js";import{u as yt,a as Zl}from"./use-virtual-mcp-DTEHzUSp.js";import{a as Ql}from"./Users03-BL_5hYu_.js";import{u as Zo,a as _t,b as Zr,c as us,t as ec,d as Sn}from"./chat-context-aSv7zVBn.js";import{i as As}from"./AlertCircle-DgIbjZFP.js";import{i as tc}from"./CheckCircle-D3x4CQc4.js";import{a as yn,n as sc}from"./ZapSquare-Br7mI2dC.js";import{i as ic,a as rc,b as nc,c as ki,d as oc}from"./XCircle-J7xeYsqG.js";import{s as as,i as ac}from"./XClose-Ds1dTxMH.js";import{c as lc,r as cc,p as Qo,f as wn,a as hc,F as dc,t as Cn,M as Qr,G as ea,L as uc,i as fc,b as mc,d as _c,e as pc}from"./pair-CR5fdfUV.js";import{C as gc,a as kn,b as Nn,c as vc,d as xc,e as bc,f as Sc}from"./command-BQRe_Fje.js";import{P as Ws,a as Us,b as Vs}from"./popover-EwlTcjqV.js";import{i as Ts,a as Bs,b as yc,c as wc,p as Ni,g as ji,d as en,e as ta,h as cr,f as Oi,j as jn,A as En,k as tn,l as Cc,m as kc,n as Nc,t as jc,o as Ec,q as ai,r as sa,s as ia,u as ra,v as Tn,w as Tc,x as Rs,y as Rc,z as na,B as oa}from"./agent-icon-B5Lepjyg.js";import{u as fs,a as Dc}from"./use-mcp-tools-CuCdREA6.js";import{u as Mc}from"./use-ai-providers-B1OI2CIf.js";import{g as Ut,d as Rn,u as Ic,b as hr,e as Pc,f as Ac,c as Bc,T as Lc}from"./index-Cze3SONv.js";import{u as Ei,i as Oc}from"./shell-layout-D69vTgwv.js";import{u as zc,c as $c,d as Fc,e as Hc}from"./sidebar-CEaAddWO.js";import{u as aa,T as We,a as Ue,b as Ve,c as Wc}from"./tooltip-AWuCEA2U.js";import{u as Uc}from"./use-status-sounds-aVa-jCse.js";import{E as Ls}from"./empty-state-Cp10WCIm.js";import{A as Vc,a as Kc,b as qc,c as Gc,R as la,d as Yc,e as Xc}from"./accordion-C6T2-sSh.js";import{u as Ti,a as sn,b as Jc}from"./use-connection-CtIj_RJA.js";import{g as Zc}from"./constants-B0----Qm.js";import{u as Qc,g as eh}from"./types-CU4jWLjn.js";import{u as ca,G as th}from"./lean-canvas-recruit-modal-51wnfw_w.js";import{U as ha}from"./user-DFc_JDuu.js";import{T as sh,u as da}from"./tools-list-bFM-v0FI.js";import{u as ih}from"./unwrap-tool-result-BYXdCQMg.js";import{s as ua,g as rh}from"./connection-slug-eyAPH6o3.js";import{A as fa,a as ma,b as _a,c as pa,d as ga,e as va,f as xa,g as ba}from"./alert-dialog-BCbgR3di.js";import{D as nh,a as rn,b as nn,c as Sa,d as ya}from"./dialog-C_RX-AQt.js";import{C as oh,a as Dn}from"./card-BYgw1vi2.js";import{I as ms}from"./input-CCf4EPNk.js";import{L as Ds}from"./label-BrmLejNm.js";import{S as es,a as ts,b as ss,c as is,d as Mt}from"./select-BsEzdOFM.js";import{S as dr}from"./switch-CpPJgX3Z.js";import{T as Mn}from"./textarea-BYbT4tbc.js";import{i as li}from"./Play-C-f37c5A.js";import{s as ls}from"./Plus-DY7vA0mY.js";import{a as ah}from"./Settings02-CoMmXn-C.js";import{t as wa,i as lh}from"./Tool01-DLlBXWXE.js";import{s as ur}from"./Trash01-Bm2xp20o.js";import{u as pi}from"./use-debounced-autosave-BGxMMdPD.js";import{S as Ca}from"./scroll-area-CELk3Mmw.js";import{i as ka,a as ch}from"./SearchMd-BP8uZLZv.js";import{i as hh}from"./LayoutLeft-CqVDbbUj.js";import{P as ot}from"./index-Cwjty6pU.js";import{C as dh}from"./collection-tabs-CqzKmYGm.js";import{C as uh}from"./checkbox-C2spUlz3.js";import{u as fh,T as zi,a as mh,b as _h,c as $i}from"./tabs-XVsrMooL.js";import{D as ph,a as gh,b as vh}from"./drawer-XcInLzwE.js";import{i as Ri}from"./Check-aa9K7ozq.js";import{n as Vt}from"./LinkExternal01-D3EwQo2i.js";import{S as xh}from"./spinner-CMg2UHyb.js";import{D as rs,a as ns,b as os,c as St,d as bh,e as Sh,f as yh}from"./dropdown-menu-5TLJbEBI.js";import{t as fr}from"./ChevronDown-COohyJel.js";import{i as Na}from"./RefreshCcw01-D3efDqWQ.js";import{V as wh}from"./view-mode-toggle-DOq6DEUm.js";import{u as Ks,a as Ch,b as kh,c as Nh,A as jh,d as Eh}from"./automation-list-row-BWnR0Wjj.js";import{i as Os}from"./Zap-B4-wkcyX.js";import{S as Th}from"./search-input-Dn4Pg53J.js";import"./use-navigate-to-agent-DuZ9B5bJ.js";import"./use-tasks-COHzjoMD.js";import"./use-collections-D0B-JFQ7.js";import"./collection-search-BfemXUsr.js";import"./form-0EbWbv9V.js";import"./Star01-C6jUiq1l.js";import"./Lock01-3Z5YegUt.js";import"./X-BEU0MHUr.js";import"./toggle-group-CEAl71x-.js";import"./select-model-CMvi5mKv.js";import"./skeleton-BydKNGdG.js";import"./ai-providers-logos-DD3qZ33J.js";import"./avatar-B-WvEQQh.js";import"./User01-DRdPMx3w.js";import"./settings-section-B0IdECpp.js";import"./ArrowUpRight-pHL6O-19.js";import"./index-HWD0WtFK.js";import"./index-uHvJMymL.js";import"./question-004-sINsf4GQ.js";import"./connection-card-BAH-_mNT.js";import"./use-registry-connections--_PoD42X.js";import"./use-organization-settings-C_omnexa.js";import"./useInfiniteQuery-CpIDGdPN.js";import"./infiniteQueryObserver-DCVrd5pN.js";import"./extract-connection-data-C288mPce.js";import"./Container-BwxK1zsB.js";import"./connection-form-helpers-BZl_1Yqu.js";import"./use-infinite-scroll-C2jLxN9Z.js";import"./useSuspenseInfiniteQuery-LpJXXkIA.js";import"./badge-CNmz6zWn.js";import"./ChevronRight-BkYTpADa.js";import"./use-decopilot-events-hoK9fHvn.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-D_gDWAbg.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-Dp0B2a5M.js";import"./index-CDPuXQh9.js";import"./Archive-C3oinC0s.js";import"./ArrowNarrowLeft-VswvJrav.js";import"./ChevronUp-CvIufmOE.js";import"./DotsVertical-DmOpiu7I.js";import"./Palette-BmNvJ0d9.js";import"./Shield01-C7wSpsYO.js";import"./index-BYYBAht5.js";import"./collection-search-D8_CBVzq.js";import"./use-create-virtual-mcp-poFHUu8W.js";import"./task-status-B72j4SrB.js";import"./required-auth-layout-BF8p72H7.js";import"./use-org-sso-D3NSe5ZU.js";import"./collections-Cuocn47g.js";function Rh(t,e){const s=hs(e);return Dh({filters:{...t,status:"pending"}},s).length}function In(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Dh(t={},e){const s=hs(e).getMutationCache(),i=B.useRef(t),r=B.useRef(null);return r.current===null&&(r.current=In(s,t)),B.useEffect(()=>{i.current=t}),B.useSyncExternalStore(B.useCallback(n=>s.subscribe(()=>{const a=Pl(r.current,In(s,i.current));r.current!==a&&(r.current=a,Al.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Mh(t,e){const s=$.c(40),{org:i,locator:r}=pe();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Pt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=$e(n),l=hs();let h;s[3]!==t||s[4]!==i.id?(h=Ps.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=Uo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const C=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(C.isError){const w=C.content,j=Array.isArray(w)&&w[0]&&typeof w[0]=="object"?w[0].text??"Create failed":"Create failed";throw new Error(j)}return C.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:Ps.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=Vo(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]),B.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 C;return s[32]!==x?(C={status:"error",error:x},s[32]=x,s[33]=C):C=s[33],C}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 gs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Pn(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 Ih(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Ph(t){const e=$.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Ah),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 Ah(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 Bh(t){const e=$.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 C;return e[27]!==x||e[28]!==f?(C=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=C):C=e[29],C}function Lh(t){const e=$.c(19),{part:s}=t,i=s.input?.agent_id,r=yt(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(ds,{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=se("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(Te,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(ic,{size:12,className:"text-destructive"}):c?o.jsx(As,{size:12,className:"text-warning"}):o.jsx(tc,{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 Oh(t){const e=$.c(58),{onClose:s,back:i,className:r}=t,[n,a]=B.useState(null),{messages:l}=Zo(),{tasks:h,taskId:c}=_t(),{selectedModel:u,selectedVirtualMcp:d}=Zr();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=V=>V.id===c,e[17]=c,e[18]=N):N=e[18];const w=h.find(N),j=lc(l),R=[...l].reverse().find(Yh),A=R?.metadata?.usage,D=R?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,M=A?.contextTokens??A?.totalTokens??0,y=D&&D>0?(M/D*100).toFixed(1):null,T=l;let E;e[19]!==T?(E=T.filter(Gh).reduce(qh,0),e[19]=T,e[20]=E):E=e[20];const k=E,P=l;let I;e[21]!==P?(I=P.filter(Kh).reduce(Vh,0),e[21]=P,e[22]=I):I=e[22];const z=I,H=Math.max(0,j.totalTokens-k-z),F=l[0],U=l.at(-1),ee=F?.metadata?.created_at??w?.created_at,te=U?.metadata?.created_at??w?.updated_at,J=l.filter(Uh),W=l.flatMap(Hh),L=u?.modelId?Ih(u.modelId):"—",q=d?.title??"Decopilot",X=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:J.length},{label:"Agent",value:q},{label:"Model",value:L},{label:"Context Limit",value:D?gs(D):"—"},{label:"Session Tokens (billed)",value:j.totalTokens>0?gs(j.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:j.inputTokens>0?gs(j.inputTokens):"0"},{label:"Output Tokens",value:j.outputTokens>0?gs(j.outputTokens):"0"},{label:"Reasoning Tokens",value:j.reasoningTokens>0?gs(j.reasoningTokens):"0"},{label:"Cost",value:j.cost>0?`$${j.cost<.001?j.cost.toFixed(6):j.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Pn(ee)},{label:"Last Activity",value:Pn(te)}];if(!w&&J.length===0){let V;e[23]!==r?(V=se("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=V):V=e[24];let ce;e[25]===Symbol.for("react.memo_cache_sentinel")?(ce=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ce):ce=e[25];let ue;e[26]!==i?(ue=i?o.jsx(yn,{size:14,className:"text-muted-foreground"}):o.jsx(as,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let he;e[28]!==s||e[29]!==ue?(he=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ce,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=he):he=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=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]=fe):fe=e[31];let me;e[32]!==V||e[33]!==he?(me=o.jsxs("div",{className:V,children:[he,fe]}),e[32]=V,e[33]=he,e[34]=me):me=e[34],S=me;break e}e[35]!==r?(v=se("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 Y;e[37]===Symbol.for("react.memo_cache_sentinel")?(Y=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=Y):Y=e[37];let oe;e[38]!==i?(oe=i?o.jsx(yn,{size:14}):o.jsx(as,{size:14}),e[38]=i,e[39]=oe):oe=e[39],e[40]!==s||e[41]!==oe?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,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:oe})]}),e[40]=s,e[41]=oe,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=W.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:W.map(Fh)})]}),m=o.jsx(Ph,{items:X});let K;e[43]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=K):K=e[43],e[44]!==z||e[45]!==H||e[46]!==k?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[K,o.jsx(Bh,{userTokens:k,assistantTokens:z,otherTokens:H})]}),e[44]=z,e[45]=H,e[46]=k,e[47]=p):p=e[47],g=J.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:J.map(V=>{const ce=V.metadata?.created_at,ue=n?.id===V.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:V),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:se("shrink-0 font-medium",V.role==="user"?"text-chart-1":"text-chart-2"),children:V.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:V.id})]}),ce&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ce).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[V.role==="assistant"&&(()=>{const he=V.metadata?._request;if(!he)return null;const fe=he.systemSections??[],me=Math.max(1,...fe.map($h)),Qe=fe.reduce(zh,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:[he.activeTools??0," / ",he.tools??0," ","tools active"]})]}),fe.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(Qe/4).toLocaleString()," ","tok"]})]}),fe.map((Ge,rt)=>{const gt=Ge.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${rt}`,Ie=Ge.chars/me*100,Gt=Math.round(Ge.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:gt}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Gt.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:`${Ie}%`}})})]},rt)})]})]})})(),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(V,null,2)})]})]},V.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 C;return e[54]!==v||e[55]!==b||e[56]!==x?(C=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=C):C=e[57],C}function zh(t,e){return t+e.chars}function $h(t){return t.chars}function Fh(t,e){return o.jsx(Lh,{part:t},e)}function Hh(t){return(t.parts??[]).filter(Wh)}function Wh(t){return t.type==="tool-subtask"}function Uh(t){return t.role!=="system"}function Vh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kh(t){return t.role==="assistant"}function qh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gh(t){return t.role==="user"}function Yh(t){return t.role==="assistant"&&t.metadata?.usage}const An=["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"],Bn=["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 Xh(){const t=An[Math.floor(Math.random()*An.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Jh(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 Zh(t){const e=$.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 _=$e(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:sd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=fs(g);let x,C;e[11]!==r||e[12]!==a?(C=new Set(Object.keys(a?.[r]??{})),x=[...C].sort().map(td),e[11]=r,e[12]=a,e[13]=x,e[14]=C):(x=e[13],C=e[14]);const N=x;let w;if(e[15]!==v||e[16]!==C){const D=Array.isArray(v)?v:v?.branches??[];let M;e[18]!==C?(M=y=>!C.has(y.name),e[18]=C,e[19]=M):M=e[19],w=D.filter(ed).filter(M).map(Qh),e[15]=v,e[16]=C,e[17]=w}else w=e[17];const j=w,R=Array.isArray(v)?null:v?.default_branch??null;let A;return e[20]!==R||e[21]!==S||e[22]!==b||e[23]!==j||e[24]!==N?(A={yours:N,others:j,defaultBase:R,isLoading:b,isError:S},e[20]=R,e[21]=S,e[22]=b,e[23]=j,e[24]=N,e[25]=A):A=e[25],A}function Qh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ed(t){return typeof t.name=="string"}function td(t){return{name:t,source:"yours"}}function sd(t){return Jh(t)}function id(t){const e=$.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=B.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}=Zh(_);let b;e[9]!==u?(b=k=>{u(k),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Ts,{className:"h-3.5 w-3.5"}),e[11]=C):C=e[11];let N;e[12]!==x?(N=o.jsx(Ws,{asChild:!0,children:o.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[C,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=N):N=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(xc,{placeholder:"Search branches…"}),e[14]=w):w=e[14];let j;e[15]!==S?(j=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:[w,o.jsx(ie,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(Xh()),children:"New"})]}),e[15]=S,e[16]=j):j=e[16];let R;e[17]!==v?(R=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]=R):R=e[18];let A;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(A=!v&&!g&&m.length===0&&p.length===0&&o.jsx(gc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=A):A=e[23];let D;e[24]!==S||e[25]!==m?(D=m.length>0&&o.jsx(kn,{heading:"Your branches",children:m.map(k=>o.jsxs(Nn,{value:k.name,onSelect:()=>S(k.name),children:[o.jsx(Ts,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:k.name})]},k.name))}),e[24]=S,e[25]=m,e[26]=D):D=e[26];let M;e[27]!==p||e[28]!==S?(M=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(vc,{}),o.jsx(kn,{heading:"Other branches in repo",children:p.map(k=>o.jsxs(Nn,{value:k.name,onSelect:()=>S(k.name),children:[o.jsx(Ts,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:k.name}),k.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",k.author]})]},k.name))})]}),e[27]=p,e[28]=S,e[29]=M):M=e[29];let y;e[30]!==M||e[31]!==R||e[32]!==A||e[33]!==D?(y=o.jsxs(bc,{children:[R,A,D,M]}),e[30]=M,e[31]=R,e[32]=A,e[33]=D,e[34]=y):y=e[34];let T;e[35]!==y||e[36]!==j?(T=o.jsx(Us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Sc,{children:[j,y]})}),e[35]=y,e[36]=j,e[37]=T):T=e[37];let E;return e[38]!==d||e[39]!==T||e[40]!==N?(E=o.jsxs(Vs,{open:d,onOpenChange:f,children:[N,T]}),e[38]=d,e[39]=T,e[40]=N,e[41]=E):E=e[41],E}function rd(){const t=$.c(27),{org:e}=pe(),{selectedVirtualMcp:s}=Zr(),{data:i}=Ci.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=_t();let a;t[0]!==e.id?(a=Xo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=yt(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(Ql,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(ds,{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(id,{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(Ne.IceBreakers,{})}),t[24]=x):x=t[24];let C;return t[25]!==S?(C=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]=C):C=t[26],C}function nd(){const t=$.c(26),{org:e}=pe(),s=Mc(),{isChatEmpty:i}=Zo(),[r,n]=B.useState("chat"),a=Kl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Ne,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Ne.Main,{className:"flex flex-col items-center",children:o.jsx(Ne.EmptyState,{children:o.jsx(Ne.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&&!ql(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(Ne.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=se("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(Ne.Main,{children:o.jsx(rd,{})}),o.jsx(Ne.Footer,{children:o.jsx(Ne.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ne.Main,{children:o.jsx(Ne.Messages,{})}),o.jsx(Ne.Footer,{children:o.jsx(Ne.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=se("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(Oh,{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(Ne,{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 ja(){const t=$.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Ne.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Rt,{fallback:e,children:o.jsx(B.Suspense,{fallback:o.jsx(Ne.Skeleton,{}),children:o.jsx(nd,{})})}),t[1]=s):s=t[1],s}async function od(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 Ea=["VM_START"],Qs=new Map,ad=t=>`${t.virtualMcpId}::${t.branch??""}`,Fi=new Set,gi={mark:(t,e)=>Fi.add(`${t}::${e}`),clear:(t,e)=>Fi.delete(`${t}::${e}`),isStopped:(t,e)=>Fi.has(`${t}::${e}`)};function on(t){const e=hs();return Vo({mutationKey:Ea,mutationFn:async s=>{s.branch&&gi.clear(s.virtualMcpId,s.branch);const i=ad(s),r=Qs.get(i);if(r)return r;const n=(async()=>(await od(t,"VM_START",s)).structuredContent)();Qs.set(i,n);try{return await n}finally{Qs.get(i)===n&&Qs.delete(i)}},onSuccess:()=>{oi(e)}})}function Ta(t,e){const s=$.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ea,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],Rh(i)>0}const ld={settings:wc,automations:yc,env:Bs,preview:rc,git:Ts};function Ln(t){const e=Ni(t);if(e.type==="icon"){const s=ji(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Hi(t){if(t.kind==="system")return{kind:"component",Component:ld[t.tabId]};const e=Ln(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=Ln(s.icon);return i||{kind:"fallback"}}function cd(t){const{org:e}=pe(),s=$e({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),{data:i}=Bl({queryKey:Ps.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 Ra(t){const e=$.c(8),s=It();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jr(i),n=yt(t.virtualMcpId),a=cd(t.taskId),{currentBranch:l}=_t(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Ut(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ti(m),{activeTab:g,mainOpen:v}=cc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(hd)}:null}),b=Qo(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 R of f){const A=wn(R.appId,R.toolName);x.set(A,{id:A,title:R.toolName,appId:R.appId,iconKey:R.toolName})}for(const R of d){const A=wn(R.connectionId,R.toolName);x.set(A,{id:A,title:R.label||R.toolName,appId:R.connectionId,iconKey:R.toolName,iconUrl:R.icon??null})}let C;e[2]!==p?(C=R=>({id:R.id,title:R.title,kind:"agent",icon:Hi({tabId:R.id,kind:"agent",appId:R.view.appId,connections:p})}),e[2]=p,e[3]=C):C=e[3];const N=[...u.map(C),...Array.from(x.values()).map(R=>({id:R.id,title:R.title,kind:"expanded",icon:Hi({tabId:R.iconKey,kind:"expanded",appId:R.appId,iconUrl:R.iconUrl,connections:p})})),...S.map(R=>({id:R.id,title:R.title,kind:"system",icon:Hi({tabId:R.id,kind:"system",connections:p})}))];let w;return e[4]!==g||e[5]!==v||e[6]!==s?(w=R=>{const A=hc({clickedId:R,activeTab:g,mainOpen:v});s({to:".",search:D=>({...D,main:A}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=w):w=e[7],{activeTab:g,mainOpen:v,setActiveTab:w,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:N}}function hd(t){return{id:t.id}}function Da(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-STAPzbR7.js","assets/index-_a3sfx9A.js","assets/index-DF1nphze.css","assets/pair-Dfx2VDcu.js","assets/agent-icon-CHawCeGj.js","assets/AlertCircle-ERuf6aAv.js","assets/Tool01-CZrEw9GG.js","assets/Archive-CI9Epn9-.js","assets/XClose-Cr0_UGK3.js","assets/RefreshCcw01-BF_TovZP.js","assets/ArrowNarrowLeft-BKXifKxP.js","assets/XCircle-BLjPn4jt.js","assets/ArrowUpRight-BVXRPr5x.js","assets/ZapSquare-5AS1CTub.js","assets/Users03-BgtpPlOT.js","assets/CheckCircle-DDlK7D0f.js","assets/Check-Dw-NNjqo.js","assets/ChevronDown-CKzufdMF.js","assets/ChevronRight-DHugiPa5.js","assets/ChevronUp-ftnK3X6N.js","assets/DotsVertical-2sZM-_B-.js","assets/Container-CBjPTaAm.js","assets/Star01-r_zmzcnE.js","assets/Palette-CBvID2VE.js","assets/SearchMd-9Lp0KuHW.js","assets/LayoutLeft-DbGS7aH0.js","assets/LinkExternal01-BB8PEfNz.js","assets/Lock01-BtdrYKDm.js","assets/Sun-CqquG-7-.js","assets/Play-2WAveRPh.js","assets/Plus-D0grveYD.js","assets/Settings02-kS8gRV3C.js","assets/Shield01-BT26kZxz.js","assets/Trash01-BfewA6Ab.js","assets/User01-DB87Ecsr.js","assets/X-MkRobXsq.js","assets/Zap-DRgyzoAR.js","assets/index-DZpCM_Ye.js","assets/use-copy-v_lAeoPt.js","assets/tooltip-C0fjlVcO.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BFONggAc.js","assets/content-blocks-o63cs2vh.js","assets/types-CGIbyQGc.js","assets/constants-BxAwlKEt.js","assets/chat-context-CBEjrtlA.js","assets/use-virtual-mcp-BcU_WFds.js","assets/use-collections-DiZ2ax9f.js","assets/use-ai-providers-B9KrhoJu.js","assets/use-decopilot-events-CTbEMJUR.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DpLDw0OJ.js","assets/use-organization-settings-BSGABThn.js","assets/shell-layout-Bz9lZQVY.js","assets/required-auth-layout-BThC9-U7.js","assets/use-org-sso-CjA-iSSa.js","assets/integration-icon-BHVwtvVd.js","assets/use-mcp-tools-BhYfGuEe.js"])))=>i.map(i=>d[i]);
2
+ import{o as hs,r as B,p as Pl,q as Al,e as $,s as pe,K as Ps,n as Uo,a as Vo,c as se,j as o,l as Te,B as ie,E as Rt,b as Ci,v as oi,f as It,d as Jr,w as Bl,x as _e,y as Ll,V as Ol,t as ye,z as Ko,C as zl,D as zt,F as $l,G as bn,L as Fl,H as Li,I as Zs,J as at,M as qo,P as Hl,_ as Wl,Q as Go,R as Yo,T as Ul,g as Vl}from"./index-_a3sfx9A.js";import{C as Ne,u as Kl,w as ql,A as Gl,T as Yl,a as Xl,S as Jl}from"./index-CoMcjeGv.js";import{I as ds}from"./integration-icon-BHVwtvVd.js";import{S as Pt,u as $e,g as Xo,a as Jo}from"./constants-BxAwlKEt.js";import{u as yt,a as Zl}from"./use-virtual-mcp-BcU_WFds.js";import{a as Ql}from"./Users03-BgtpPlOT.js";import{u as Zo,a as _t,b as Zr,c as us,t as ec,d as Sn}from"./chat-context-CBEjrtlA.js";import{i as As}from"./AlertCircle-ERuf6aAv.js";import{i as tc}from"./CheckCircle-DDlK7D0f.js";import{a as yn,n as sc}from"./ZapSquare-5AS1CTub.js";import{i as ic,a as rc,b as nc,c as ki,d as oc}from"./XCircle-BLjPn4jt.js";import{s as as,i as ac}from"./XClose-Cr0_UGK3.js";import{c as lc,r as cc,p as Qo,f as wn,a as hc,F as dc,t as Cn,M as Qr,G as ea,L as uc,i as fc,b as mc,d as _c,e as pc}from"./pair-Dfx2VDcu.js";import{C as gc,a as kn,b as Nn,c as vc,d as xc,e as bc,f as Sc}from"./command-1vgVMo-o.js";import{P as Ws,a as Us,b as Vs}from"./popover-CjkpEiTE.js";import{i as Ts,a as Bs,b as yc,c as wc,p as Ni,g as ji,d as en,e as ta,h as cr,f as Oi,j as jn,A as En,k as tn,l as Cc,m as kc,n as Nc,t as jc,o as Ec,q as ai,r as sa,s as ia,u as ra,v as Tn,w as Tc,x as Rs,y as Rc,z as na,B as oa}from"./agent-icon-CHawCeGj.js";import{u as fs,a as Dc}from"./use-mcp-tools-BhYfGuEe.js";import{u as Mc}from"./use-ai-providers-B9KrhoJu.js";import{g as Ut,d as Rn,u as Ic,b as hr,e as Pc,f as Ac,c as Bc,T as Lc}from"./index-CVjB3eh1.js";import{u as Ei,i as Oc}from"./shell-layout-Bz9lZQVY.js";import{u as zc,c as $c,d as Fc,e as Hc}from"./sidebar-DAeODPsL.js";import{u as aa,T as We,a as Ue,b as Ve,c as Wc}from"./tooltip-C0fjlVcO.js";import{u as Uc}from"./use-status-sounds-CNQgHBud.js";import{E as Ls}from"./empty-state-C8B-PY4B.js";import{A as Vc,a as Kc,b as qc,c as Gc,R as la,d as Yc,e as Xc}from"./accordion-Vcv9vx8b.js";import{u as Ti,a as sn,b as Jc}from"./use-connection-CjuTRKXt.js";import{g as Zc}from"./constants-Bpr1SrBK.js";import{u as Qc,g as eh}from"./types-CGIbyQGc.js";import{u as ca,G as th}from"./lean-canvas-recruit-modal-Cp7w5Yzr.js";import{U as ha}from"./user-DCWmkhjg.js";import{T as sh,u as da}from"./tools-list-CeAP-pSC.js";import{u as ih}from"./unwrap-tool-result-BYXdCQMg.js";import{s as ua,g as rh}from"./connection-slug-eyAPH6o3.js";import{A as fa,a as ma,b as _a,c as pa,d as ga,e as va,f as xa,g as ba}from"./alert-dialog-BrfyOA8d.js";import{D as nh,a as rn,b as nn,c as Sa,d as ya}from"./dialog-BFONggAc.js";import{C as oh,a as Dn}from"./card-b9f3cSc7.js";import{I as ms}from"./input-CLyArZAZ.js";import{L as Ds}from"./label-DaQ778PR.js";import{S as es,a as ts,b as ss,c as is,d as Mt}from"./select-Wcqz-g0G.js";import{S as dr}from"./switch-Ckms2ja4.js";import{T as Mn}from"./textarea-BYfjo1_E.js";import{i as li}from"./Play-2WAveRPh.js";import{s as ls}from"./Plus-D0grveYD.js";import{a as ah}from"./Settings02-kS8gRV3C.js";import{t as wa,i as lh}from"./Tool01-CZrEw9GG.js";import{s as ur}from"./Trash01-BfewA6Ab.js";import{u as pi}from"./use-debounced-autosave-Bx5zX-oh.js";import{S as Ca}from"./scroll-area-fh9U9MHB.js";import{i as ka,a as ch}from"./SearchMd-9Lp0KuHW.js";import{i as hh}from"./LayoutLeft-DbGS7aH0.js";import{P as ot}from"./index-DB-1u_Lp.js";import{C as dh}from"./collection-tabs-BzOEZ7_c.js";import{C as uh}from"./checkbox-B-5dNGXU.js";import{u as fh,T as zi,a as mh,b as _h,c as $i}from"./tabs-1aaQ63Sr.js";import{D as ph,a as gh,b as vh}from"./drawer-DPE2UfDW.js";import{i as Ri}from"./Check-Dw-NNjqo.js";import{n as Vt}from"./LinkExternal01-BB8PEfNz.js";import{S as xh}from"./spinner-DnlGnBXF.js";import{D as rs,a as ns,b as os,c as St,d as bh,e as Sh,f as yh}from"./dropdown-menu-BdpYdHvo.js";import{t as fr}from"./ChevronDown-CKzufdMF.js";import{i as Na}from"./RefreshCcw01-BF_TovZP.js";import{V as wh}from"./view-mode-toggle-C_UCqkmc.js";import{u as Ks,a as Ch,b as kh,c as Nh,A as jh,d as Eh}from"./automation-list-row-eIHh56lV.js";import{i as Os}from"./Zap-DRgyzoAR.js";import{S as Th}from"./search-input-BQvqnxrN.js";import"./use-navigate-to-agent-Dgy6Vgnk.js";import"./use-tasks-DpLDw0OJ.js";import"./use-collections-DiZ2ax9f.js";import"./collection-search-CF_YUmub.js";import"./form-B8LulHdI.js";import"./Star01-r_zmzcnE.js";import"./Lock01-BtdrYKDm.js";import"./X-MkRobXsq.js";import"./toggle-group-D-6M9i6u.js";import"./select-model-DNKOCT1K.js";import"./skeleton-BLclv8kT.js";import"./ai-providers-logos-DD3qZ33J.js";import"./avatar-DFG27SpR.js";import"./User01-DB87Ecsr.js";import"./settings-section-JVAjMEt8.js";import"./ArrowUpRight-BVXRPr5x.js";import"./index-DZpCM_Ye.js";import"./index-Bix1l1uh.js";import"./question-004-sINsf4GQ.js";import"./connection-card-CWY5aJHR.js";import"./use-registry-connections-CRSTloWi.js";import"./use-organization-settings-BSGABThn.js";import"./useInfiniteQuery-B5TQbcQA.js";import"./infiniteQueryObserver-CCfSTQJW.js";import"./extract-connection-data-BbuEAUmV.js";import"./Container-CBjPTaAm.js";import"./connection-form-helpers-V_S7kOM3.js";import"./use-infinite-scroll-CdQPwmSi.js";import"./useSuspenseInfiniteQuery-DNcETcP6.js";import"./badge-CyXlfcBA.js";import"./ChevronRight-DHugiPa5.js";import"./use-decopilot-events-CTbEMJUR.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-v_lAeoPt.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-CqquG-7-.js";import"./index-BHPgwaHi.js";import"./Archive-CI9Epn9-.js";import"./ArrowNarrowLeft-BKXifKxP.js";import"./ChevronUp-ftnK3X6N.js";import"./DotsVertical-2sZM-_B-.js";import"./Palette-CBvID2VE.js";import"./Shield01-BT26kZxz.js";import"./index-DcvDT1BH.js";import"./collection-search-CeOmn4VX.js";import"./use-create-virtual-mcp-BeCJlwzK.js";import"./task-status-B4sbD0o1.js";import"./required-auth-layout-BThC9-U7.js";import"./use-org-sso-CjA-iSSa.js";import"./collections-DfDlNVfw.js";function Rh(t,e){const s=hs(e);return Dh({filters:{...t,status:"pending"}},s).length}function In(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Dh(t={},e){const s=hs(e).getMutationCache(),i=B.useRef(t),r=B.useRef(null);return r.current===null&&(r.current=In(s,t)),B.useEffect(()=>{i.current=t}),B.useSyncExternalStore(B.useCallback(n=>s.subscribe(()=>{const a=Pl(r.current,In(s,i.current));r.current!==a&&(r.current=a,Al.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Mh(t,e){const s=$.c(40),{org:i,locator:r}=pe();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Pt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=$e(n),l=hs();let h;s[3]!==t||s[4]!==i.id?(h=Ps.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=Uo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const C=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(C.isError){const w=C.content,j=Array.isArray(w)&&w[0]&&typeof w[0]=="object"?w[0].text??"Create failed":"Create failed";throw new Error(j)}return C.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:Ps.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=Vo(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]),B.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 C;return s[32]!==x?(C={status:"error",error:x},s[32]=x,s[33]=C):C=s[33],C}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 gs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Pn(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 Ih(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Ph(t){const e=$.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Ah),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 Ah(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 Bh(t){const e=$.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 C;return e[27]!==x||e[28]!==f?(C=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=C):C=e[29],C}function Lh(t){const e=$.c(19),{part:s}=t,i=s.input?.agent_id,r=yt(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(ds,{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=se("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(Te,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(ic,{size:12,className:"text-destructive"}):c?o.jsx(As,{size:12,className:"text-warning"}):o.jsx(tc,{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 Oh(t){const e=$.c(58),{onClose:s,back:i,className:r}=t,[n,a]=B.useState(null),{messages:l}=Zo(),{tasks:h,taskId:c}=_t(),{selectedModel:u,selectedVirtualMcp:d}=Zr();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=V=>V.id===c,e[17]=c,e[18]=N):N=e[18];const w=h.find(N),j=lc(l),R=[...l].reverse().find(Yh),A=R?.metadata?.usage,D=R?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,M=A?.contextTokens??A?.totalTokens??0,y=D&&D>0?(M/D*100).toFixed(1):null,T=l;let E;e[19]!==T?(E=T.filter(Gh).reduce(qh,0),e[19]=T,e[20]=E):E=e[20];const k=E,P=l;let I;e[21]!==P?(I=P.filter(Kh).reduce(Vh,0),e[21]=P,e[22]=I):I=e[22];const z=I,H=Math.max(0,j.totalTokens-k-z),F=l[0],U=l.at(-1),ee=F?.metadata?.created_at??w?.created_at,te=U?.metadata?.created_at??w?.updated_at,J=l.filter(Uh),W=l.flatMap(Hh),L=u?.modelId?Ih(u.modelId):"—",q=d?.title??"Decopilot",X=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:J.length},{label:"Agent",value:q},{label:"Model",value:L},{label:"Context Limit",value:D?gs(D):"—"},{label:"Session Tokens (billed)",value:j.totalTokens>0?gs(j.totalTokens):"0"},{label:"Usage",value:y!==null?`${y}%`:"—"},{label:"Input Tokens",value:j.inputTokens>0?gs(j.inputTokens):"0"},{label:"Output Tokens",value:j.outputTokens>0?gs(j.outputTokens):"0"},{label:"Reasoning Tokens",value:j.reasoningTokens>0?gs(j.reasoningTokens):"0"},{label:"Cost",value:j.cost>0?`$${j.cost<.001?j.cost.toFixed(6):j.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Pn(ee)},{label:"Last Activity",value:Pn(te)}];if(!w&&J.length===0){let V;e[23]!==r?(V=se("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=V):V=e[24];let ce;e[25]===Symbol.for("react.memo_cache_sentinel")?(ce=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ce):ce=e[25];let ue;e[26]!==i?(ue=i?o.jsx(yn,{size:14,className:"text-muted-foreground"}):o.jsx(as,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let he;e[28]!==s||e[29]!==ue?(he=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ce,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=he):he=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=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]=fe):fe=e[31];let me;e[32]!==V||e[33]!==he?(me=o.jsxs("div",{className:V,children:[he,fe]}),e[32]=V,e[33]=he,e[34]=me):me=e[34],S=me;break e}e[35]!==r?(v=se("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 Y;e[37]===Symbol.for("react.memo_cache_sentinel")?(Y=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=Y):Y=e[37];let oe;e[38]!==i?(oe=i?o.jsx(yn,{size:14}):o.jsx(as,{size:14}),e[38]=i,e[39]=oe):oe=e[39],e[40]!==s||e[41]!==oe?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[Y,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:oe})]}),e[40]=s,e[41]=oe,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=W.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:W.map(Fh)})]}),m=o.jsx(Ph,{items:X});let K;e[43]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=K):K=e[43],e[44]!==z||e[45]!==H||e[46]!==k?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[K,o.jsx(Bh,{userTokens:k,assistantTokens:z,otherTokens:H})]}),e[44]=z,e[45]=H,e[46]=k,e[47]=p):p=e[47],g=J.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:J.map(V=>{const ce=V.metadata?.created_at,ue=n?.id===V.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:V),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:se("shrink-0 font-medium",V.role==="user"?"text-chart-1":"text-chart-2"),children:V.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:V.id})]}),ce&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ce).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[V.role==="assistant"&&(()=>{const he=V.metadata?._request;if(!he)return null;const fe=he.systemSections??[],me=Math.max(1,...fe.map($h)),Qe=fe.reduce(zh,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:[he.activeTools??0," / ",he.tools??0," ","tools active"]})]}),fe.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(Qe/4).toLocaleString()," ","tok"]})]}),fe.map((Ge,rt)=>{const gt=Ge.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${rt}`,Ie=Ge.chars/me*100,Gt=Math.round(Ge.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:gt}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Gt.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:`${Ie}%`}})})]},rt)})]})]})})(),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(V,null,2)})]})]},V.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 C;return e[54]!==v||e[55]!==b||e[56]!==x?(C=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=C):C=e[57],C}function zh(t,e){return t+e.chars}function $h(t){return t.chars}function Fh(t,e){return o.jsx(Lh,{part:t},e)}function Hh(t){return(t.parts??[]).filter(Wh)}function Wh(t){return t.type==="tool-subtask"}function Uh(t){return t.role!=="system"}function Vh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kh(t){return t.role==="assistant"}function qh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gh(t){return t.role==="user"}function Yh(t){return t.role==="assistant"&&t.metadata?.usage}const An=["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"],Bn=["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 Xh(){const t=An[Math.floor(Math.random()*An.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Jh(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 Zh(t){const e=$.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 _=$e(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:sd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=fs(g);let x,C;e[11]!==r||e[12]!==a?(C=new Set(Object.keys(a?.[r]??{})),x=[...C].sort().map(td),e[11]=r,e[12]=a,e[13]=x,e[14]=C):(x=e[13],C=e[14]);const N=x;let w;if(e[15]!==v||e[16]!==C){const D=Array.isArray(v)?v:v?.branches??[];let M;e[18]!==C?(M=y=>!C.has(y.name),e[18]=C,e[19]=M):M=e[19],w=D.filter(ed).filter(M).map(Qh),e[15]=v,e[16]=C,e[17]=w}else w=e[17];const j=w,R=Array.isArray(v)?null:v?.default_branch??null;let A;return e[20]!==R||e[21]!==S||e[22]!==b||e[23]!==j||e[24]!==N?(A={yours:N,others:j,defaultBase:R,isLoading:b,isError:S},e[20]=R,e[21]=S,e[22]=b,e[23]=j,e[24]=N,e[25]=A):A=e[25],A}function Qh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ed(t){return typeof t.name=="string"}function td(t){return{name:t,source:"yours"}}function sd(t){return Jh(t)}function id(t){const e=$.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=B.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}=Zh(_);let b;e[9]!==u?(b=k=>{u(k),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let C;e[11]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Ts,{className:"h-3.5 w-3.5"}),e[11]=C):C=e[11];let N;e[12]!==x?(N=o.jsx(Ws,{asChild:!0,children:o.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[C,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=N):N=e[13];let w;e[14]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(xc,{placeholder:"Search branches…"}),e[14]=w):w=e[14];let j;e[15]!==S?(j=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:[w,o.jsx(ie,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(Xh()),children:"New"})]}),e[15]=S,e[16]=j):j=e[16];let R;e[17]!==v?(R=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]=R):R=e[18];let A;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(A=!v&&!g&&m.length===0&&p.length===0&&o.jsx(gc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=A):A=e[23];let D;e[24]!==S||e[25]!==m?(D=m.length>0&&o.jsx(kn,{heading:"Your branches",children:m.map(k=>o.jsxs(Nn,{value:k.name,onSelect:()=>S(k.name),children:[o.jsx(Ts,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:k.name})]},k.name))}),e[24]=S,e[25]=m,e[26]=D):D=e[26];let M;e[27]!==p||e[28]!==S?(M=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(vc,{}),o.jsx(kn,{heading:"Other branches in repo",children:p.map(k=>o.jsxs(Nn,{value:k.name,onSelect:()=>S(k.name),children:[o.jsx(Ts,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:k.name}),k.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",k.author]})]},k.name))})]}),e[27]=p,e[28]=S,e[29]=M):M=e[29];let y;e[30]!==M||e[31]!==R||e[32]!==A||e[33]!==D?(y=o.jsxs(bc,{children:[R,A,D,M]}),e[30]=M,e[31]=R,e[32]=A,e[33]=D,e[34]=y):y=e[34];let T;e[35]!==y||e[36]!==j?(T=o.jsx(Us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(Sc,{children:[j,y]})}),e[35]=y,e[36]=j,e[37]=T):T=e[37];let E;return e[38]!==d||e[39]!==T||e[40]!==N?(E=o.jsxs(Vs,{open:d,onOpenChange:f,children:[N,T]}),e[38]=d,e[39]=T,e[40]=N,e[41]=E):E=e[41],E}function rd(){const t=$.c(27),{org:e}=pe(),{selectedVirtualMcp:s}=Zr(),{data:i}=Ci.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=_t();let a;t[0]!==e.id?(a=Xo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=yt(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(Ql,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(ds,{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(id,{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(Ne.IceBreakers,{})}),t[24]=x):x=t[24];let C;return t[25]!==S?(C=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]=C):C=t[26],C}function nd(){const t=$.c(26),{org:e}=pe(),s=Mc(),{isChatEmpty:i}=Zo(),[r,n]=B.useState("chat"),a=Kl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Ne,{className:"animate-in fade-in-0 duration-200",children:o.jsx(Ne.Main,{className:"flex flex-col items-center",children:o.jsx(Ne.EmptyState,{children:o.jsx(Ne.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&&!ql(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(Ne.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=se("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(Ne.Main,{children:o.jsx(rd,{})}),o.jsx(Ne.Footer,{children:o.jsx(Ne.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ne.Main,{children:o.jsx(Ne.Messages,{})}),o.jsx(Ne.Footer,{children:o.jsx(Ne.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=se("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(Oh,{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(Ne,{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 ja(){const t=$.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(Ne.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Rt,{fallback:e,children:o.jsx(B.Suspense,{fallback:o.jsx(Ne.Skeleton,{}),children:o.jsx(nd,{})})}),t[1]=s):s=t[1],s}async function od(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 Ea=["VM_START"],Qs=new Map,ad=t=>`${t.virtualMcpId}::${t.branch??""}`,Fi=new Set,gi={mark:(t,e)=>Fi.add(`${t}::${e}`),clear:(t,e)=>Fi.delete(`${t}::${e}`),isStopped:(t,e)=>Fi.has(`${t}::${e}`)};function on(t){const e=hs();return Vo({mutationKey:Ea,mutationFn:async s=>{s.branch&&gi.clear(s.virtualMcpId,s.branch);const i=ad(s),r=Qs.get(i);if(r)return r;const n=(async()=>(await od(t,"VM_START",s)).structuredContent)();Qs.set(i,n);try{return await n}finally{Qs.get(i)===n&&Qs.delete(i)}},onSuccess:()=>{oi(e)}})}function Ta(t,e){const s=$.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ea,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],Rh(i)>0}const ld={settings:wc,automations:yc,env:Bs,preview:rc,git:Ts};function Ln(t){const e=Ni(t);if(e.type==="icon"){const s=ji(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Hi(t){if(t.kind==="system")return{kind:"component",Component:ld[t.tabId]};const e=Ln(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=Ln(s.icon);return i||{kind:"fallback"}}function cd(t){const{org:e}=pe(),s=$e({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),{data:i}=Bl({queryKey:Ps.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 Ra(t){const e=$.c(8),s=It();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jr(i),n=yt(t.virtualMcpId),a=cd(t.taskId),{currentBranch:l}=_t(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Ut(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ti(m),{activeTab:g,mainOpen:v}=cc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(hd)}:null}),b=Qo(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 R of f){const A=wn(R.appId,R.toolName);x.set(A,{id:A,title:R.toolName,appId:R.appId,iconKey:R.toolName})}for(const R of d){const A=wn(R.connectionId,R.toolName);x.set(A,{id:A,title:R.label||R.toolName,appId:R.connectionId,iconKey:R.toolName,iconUrl:R.icon??null})}let C;e[2]!==p?(C=R=>({id:R.id,title:R.title,kind:"agent",icon:Hi({tabId:R.id,kind:"agent",appId:R.view.appId,connections:p})}),e[2]=p,e[3]=C):C=e[3];const N=[...u.map(C),...Array.from(x.values()).map(R=>({id:R.id,title:R.title,kind:"expanded",icon:Hi({tabId:R.iconKey,kind:"expanded",appId:R.appId,iconUrl:R.iconUrl,connections:p})})),...S.map(R=>({id:R.id,title:R.title,kind:"system",icon:Hi({tabId:R.id,kind:"system",connections:p})}))];let w;return e[4]!==g||e[5]!==v||e[6]!==s?(w=R=>{const A=hc({clickedId:R,activeTab:g,mainOpen:v});s({to:".",search:D=>({...D,main:A}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=w):w=e[7],{activeTab:g,mainOpen:v,setActiveTab:w,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:N}}function hd(t){return{id:t.id}}function Da(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 dd(t){const e=$.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]=B.useState(!1),[g,v]=B.useState("icons"),[b,S]=B.useState(""),[x,C]=B.useState("blue");let N;e[0]!==s?(N=Ni(s),e[0]=s,e[1]=N):N=e[1];const w=N,j=w.type==="icon"||w.type==="url"&&w.color?w.color:x;let R;e[2]!==i||e[3]!==j?(R=Ie=>{i(Oi(Ie,j))},e[2]=i,e[3]=j,e[4]=R):R=e[4];const A=R;let D;e[5]!==i||e[6]!==r||e[7]!==w.name||e[8]!==w.type||e[9]!==w.url?(D=Ie=>{C(Ie),r?.(Ie),w.type==="icon"?i(Oi(w.name,Ie)):w.type==="url"&&i(jn(w.url,Ie))},e[5]=i,e[6]=r,e[7]=w.name,e[8]=w.type,e[9]=w.url,e[10]=D):D=e[10];const M=D;let y;e[11]!==i||e[12]!==j?(y=Ie=>{i(jn(Ie,j)),p(!1)},e[11]=i,e[12]=j,e[13]=y):y=e[13];const T=y;let E;e[14]!==i||e[15]!==j?(E=()=>{const Ie=en(),Gt=Ie[Math.floor(Math.random()*Ie.length)];i(Oi(Gt,j))},e[14]=i,e[15]=j,e[16]=E):E=e[16];const k=E;let P,I,z,H,F,U,ee,te;if(e[17]!==l||e[18]!==_||e[19]!==m||e[20]!==d){const Ie={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};I=Vs,U=_?!1:m,ee=p,P=Ws,F=!0,te="button",z=_,H=se("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",Ie[d],l),e[17]=l,e[18]=_,e[19]=m,e[20]=d,e[21]=P,e[22]=I,e[23]=z,e[24]=H,e[25]=F,e[26]=U,e[27]=ee,e[28]=te}else P=e[21],I=e[22],z=e[23],H=e[24],F=e[25],U=e[26],ee=e[27],te=e[28];let J;e[29]!==h||e[30]!==n||e[31]!==d||e[32]!==s?(J=o.jsx(En,{icon:s,name:n,size:d,className:h}),e[29]=h,e[30]=n,e[31]=d,e[32]=s,e[33]=J):J=e[33];let W;e[34]!==_||e[35]!==f?(W=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(tn,{size:16,className:"text-white"})}),e[34]=_,e[35]=f,e[36]=W):W=e[36];let L;e[37]!==z||e[38]!==H||e[39]!==J||e[40]!==W||e[41]!==te?(L=o.jsxs("button",{type:te,disabled:z,className:H,children:[J,W]}),e[37]=z,e[38]=H,e[39]=J,e[40]=W,e[41]=te,e[42]=L):L=e[42];let q;e[43]!==P||e[44]!==F||e[45]!==L?(q=o.jsx(P,{asChild:F,children:L}),e[43]=P,e[44]=F,e[45]=L,e[46]=q):q=e[46];let X;e[47]!==n||e[48]!==s?(X=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(En,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=X):X=e[49];let Y;e[50]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>v("icons"),e[50]=Y):Y=e[50];const oe=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let K;e[51]!==oe?(K=se("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",oe),e[51]=oe,e[52]=K):K=e[52];let V;e[53]!==K?(V=o.jsx("button",{type:"button",onClick:Y,className:K,children:"Icons"}),e[53]=K,e[54]=V):V=e[54];let ce;e[55]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>v("upload"),e[55]=ce):ce=e[55];const ue=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let he;e[56]!==ue?(he=se("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ue),e[56]=ue,e[57]=he):he=e[57];let fe;e[58]!==he?(fe=o.jsx("button",{type:"button",onClick:ce,className:he,children:"Upload"}),e[58]=he,e[59]=fe):fe=e[59];let me;e[60]===Symbol.for("react.memo_cache_sentinel")?(me=o.jsx("div",{className:"flex-1"}),e[60]=me):me=e[60];let Qe;e[61]!==V||e[62]!==fe?(Qe=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[V,fe,me]}),e[61]=V,e[62]=fe,e[63]=Qe):Qe=e[63];let Ge;e[64]!==M||e[65]!==k||e[66]!==A||e[67]!==T||e[68]!==w.name||e[69]!==w.type||e[70]!==b||e[71]!==j||e[72]!==g?(Ge=g==="icons"?o.jsx(_d,{search:b,onSearchChange:S,selectedColor:j,onColorChange:M,onSelectIcon:A,onRandom:k,currentIconName:w.type==="icon"?w.name:null}):o.jsx(pd,{onUpload:T}),e[64]=M,e[65]=k,e[66]=A,e[67]=T,e[68]=w.name,e[69]=w.type,e[70]=b,e[71]=j,e[72]=g,e[73]=Ge):Ge=e[73];let rt;e[74]!==X||e[75]!==Qe||e[76]!==Ge?(rt=o.jsx(Us,{align:"start",className:"w-80 p-0",onOpenAutoFocus:ud,children:o.jsxs("div",{className:"flex flex-col",children:[X,Qe,Ge]})}),e[74]=X,e[75]=Qe,e[76]=Ge,e[77]=rt):rt=e[77];let gt;return e[78]!==I||e[79]!==U||e[80]!==ee||e[81]!==q||e[82]!==rt?(gt=o.jsxs(I,{open:U,onOpenChange:ee,children:[q,rt]}),e[78]=I,e[79]=U,e[80]=ee,e[81]=q,e[82]=rt,e[83]=gt):gt=e[83],gt}function ud(t){return t.preventDefault()}function fd(t){const e=$.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=B.useState(!1);let a,l,h,c,u,d,f;if(e[0]!==r||e[1]!==s){const b=ta(s);l=Vs,d=r,f=n,a=Ws,u=!0,h="button",c=se("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=kc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:se("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(Us,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:md,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 md(t){return t.preventDefault()}function _d(t){const e=$.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=en(),C=ta(r);u=s.trim()?x.filter(M=>{const y=cr(M),T=s.toLowerCase();return y.includes(T)||M.toLowerCase().includes(T)}):x,m="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(ka,{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 w;e[15]!==i?(w=M=>i(M.target.value),e[15]=i,e[16]=w):w=e[16];let j;e[17]!==s||e[18]!==w?(j=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(ms,{value:s,onChange:w,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=w,e[19]=j):j=e[19];let R;e[20]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(Cc,{size:14,className:"text-muted-foreground"}),e[20]=R):R=e[20];let A;e[21]!==l?(A=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:R}),e[21]=l,e[22]=A):A=e[22];let D;e[23]!==n||e[24]!==r?(D=o.jsx(fd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=D):D=e[25],e[26]!==A||e[27]!==D||e[28]!==j?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[j,A,D]}),e[26]=A,e[27]=D,e[28]=j,e[29]=p):p=e[29],c=Ca,_="h-56",d="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(M=>{const y=ji(M);return y?o.jsx("button",{type:"button",onClick:()=>a(M),className:se("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===M?se(C.bg,C.text):se(C.text,"hover:bg-accent")),title:M,children:o.jsx(y,{size:18})},M):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 pd(t){const e=$.c(27),{onUpload:s}=t,i=B.useRef(null);let r;e[0]!==s?(r=N=>{const w=N.target.files?.[0];if(!w)return;if(w.size>2097152){_e.error("Image must be smaller than 2MB"),N.target.value="";return}const j=new FileReader;j.onerror=()=>{_e.error("Failed to read image file"),i.current&&(i.current.value="")},j.onloadend=()=>{j.readyState===FileReader.DONE&&j.result&&s(j.result),i.current&&(i.current.value="")},j.readAsDataURL(w)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=B.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(nc,{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(ms,{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(ie,{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 C;return e[24]!==x||e[25]!==u?(C=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,_,x]}),e[24]=x,e[25]=u,e[26]=C):C=e[26],C}function gd(t){const e=$.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Ni(s);if(n.type==="icon"){const a=ji(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(hh,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function vd(t){const e=$.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=B.useState(!1),[h,c]=B.useState("");let u;e[0]!==s?(u=Ni(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,C,N,w,j,R,A,D;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const I=en();g=h.trim()?I.filter(J=>{const W=h.toLowerCase();return cr(J).includes(W)||J.toLowerCase().includes(W)}):I,p=Vs,v=n?!1:a,b=l;const z=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let H;e[24]!==r||e[25]!==z?(H=se("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",z,r),e[24]=r,e[25]=z,e[26]=H):H=e[26];let F;e[27]!==s?(F=o.jsx(gd,{value:s}),e[27]=s,e[28]=F):F=e[28],e[29]!==n||e[30]!==H||e[31]!==F?(S=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:H,children:F})}),e[29]=n,e[30]=H,e[31]=F,e[32]=S):S=e[32],m=Us,R="start",A="w-64 p-0",D=xd,w="flex flex-col";let U;e[33]===Symbol.for("react.memo_cache_sentinel")?(U=o.jsx(ka,{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 ee;e[34]===Symbol.for("react.memo_cache_sentinel")?(ee=J=>c(J.target.value),e[34]=ee):ee=e[34],e[35]!==h?(j=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[U,o.jsx(ms,{value:h,onChange:ee,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=j):j=e[36],_=Ca,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let te;e[37]!==f||e[38]!==i?(te=J=>{const W=ji(J);return W?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${J}`),l(!1)},className:se("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===J?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:cr(J),children:o.jsx(W,{size:16})},J):null},e[37]=f,e[38]=i,e[39]=te):te=e[39],C=g.map(te),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]=C,e[18]=N,e[19]=w,e[20]=j,e[21]=R,e[22]=A,e[23]=D}else _=e[9],m=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],C=e[17],N=e[18],w=e[19],j=e[20],R=e[21],A=e[22],D=e[23];let M;e[40]!==x||e[41]!==C?(M=o.jsx("div",{className:x,children:C}),e[40]=x,e[41]=C,e[42]=M):M=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 T;e[45]!==_||e[46]!==M||e[47]!==y||e[48]!==N?(T=o.jsxs(_,{className:N,children:[M,y]}),e[45]=_,e[46]=M,e[47]=y,e[48]=N,e[49]=T):T=e[49];let E;e[50]!==T||e[51]!==w||e[52]!==j?(E=o.jsxs("div",{className:w,children:[j,T]}),e[50]=T,e[51]=w,e[52]=j,e[53]=E):E=e[53];let k;e[54]!==m||e[55]!==E||e[56]!==R||e[57]!==A||e[58]!==D?(k=o.jsx(m,{align:R,className:A,onOpenAutoFocus:D,children:E}),e[54]=m,e[55]=E,e[56]=R,e[57]=A,e[58]=D,e[59]=k):k=e[59];let P;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==k?(P=o.jsxs(p,{open:v,onOpenChange:b,children:[S,k]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=k,e[65]=P):P=e[65],P}function xd(t){return t.preventDefault()}function ci(){const t=$.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(Te,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Wi(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(Ll,{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 bd(t){const e=$.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=se("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(uh,{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 an(t){const e=$.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(Sd);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(bd,{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 Sd(t){return t.id}function yd(t){const e=$.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=pe();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=$e(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Dc(c);let d;e[6]!==u.tools?(d=u.tools.map(wd),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(an,{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 wd(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(sh,{annotations:t.annotations,_meta:t._meta})}}function Cd(t){const e=$.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=pe();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=$e(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Qc(c);let d;e[6]!==u.resources?(d=u.resources.map(kd),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(an,{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 kd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Nd(t){const e=$.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=pe();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=$e(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=fh(c);let d;e[6]!==u.prompts?(d=u.prompts.map(jd),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(an,{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 jd(t){return{id:t.name,name:t.name,description:t.description}}function Ed(t){const e=$.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(ds,{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 C;e[16]!==v||e[17]!==x?(C=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]=C):C=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 w;e[20]!==f?(w=P=>f(P),e[20]=f,e[21]=w):w=e[21];let j;e[22]!==i||e[23]!==w?(j=o.jsx(dh,{tabs:N,activeTab:i,onTabChange:w}),e[22]=i,e[23]=w,e[24]=j):j=e[24];const R=m?"Deselect all":"Select all";let A;e[25]!==g||e[26]!==R?(A=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:R}),e[25]=g,e[26]=R,e[27]=A):A=e[27];let D;e[28]!==A||e[29]!==j?(D=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[j,A]}),e[28]=A,e[29]=j,e[30]=D):D=e[30];let M;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(M=i==="tools"&&o.jsx(Rt,{fallback:Wi("Tools not supported by this server"),children:o.jsx(B.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(yd,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(P,I)=>a(r,P,I)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=M):M=e[35];let y;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(y=i==="resources"&&o.jsx(Rt,{fallback:Wi("Resources not supported by this server"),children:o.jsx(B.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(Cd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(P,I)=>l(r,P,I)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=y):y=e[40];let T;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(T=i==="prompts"&&o.jsx(Rt,{fallback:Wi("Prompts not supported by this server"),children:o.jsx(B.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(Nd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(P,I)=>h(r,P,I)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=T):T=e[45];let E;e[46]!==M||e[47]!==y||e[48]!==T?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[M,y,T]}),e[46]=M,e[47]=y,e[48]=T,e[49]=E):E=e[49];let k;return e[50]!==D||e[51]!==E||e[52]!==C?(k=o.jsxs(o.Fragment,{children:[C,D,E]}),e[50]=D,e[51]=E,e[52]=C,e[53]=k):k=e[53],k}function Td(t){const e=$.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=da(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(Nc,{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(ie,{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 Rd(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 On(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Dd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Md(t){const e=$.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]=B.useReducer(Dd,h),d=sn(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let _;e[3]!==f?(_=Rd(f),e[3]=f,e[4]=_):_=e[4];const m=_;let p;e[5]!==n||e[6]!==m?(p=(U,ee,te,J)=>{const W=m[U]?.[ee];let L;W===null?L=J.filter(X=>X!==te):W?.includes(te)?L=W.filter(X=>X!==te):(L=[...W??[],te],L.length===J.length&&(L=null));const q={...m};q[U]?q[U]={...q[U]}:q[U]={tools:null,resources:null,prompts:null},q[U][ee]=L,n.setValue("connections",On(q),{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,ee)=>{const J=m[U]?.[ee]===null?[]:null,W={...m};W[U]?W[U]={...W[U]}:W[U]={tools:null,resources:null,prompts:null},W[U][ee]=J,n.setValue("connections",On(W),{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,ee,te)=>g(U,"tools",ee,te),e[11]=g,e[12]=S):S=e[12];const x=S;let C;e[13]!==g?(C=(U,ee,te)=>g(U,"resources",ee,te),e[13]=g,e[14]=C):C=e[14];const N=C;let w;e[15]!==g?(w=(U,ee,te)=>g(U,"prompts",ee,te),e[15]=g,e[16]=w):w=e[16];const j=w;let R;e[17]!==b?(R=U=>b(U,"tools"),e[17]=b,e[18]=R):R=e[18];const A=R;let D;e[19]!==b?(D=U=>b(U,"resources"),e[19]=b,e[20]=D):D=e[20];const M=D;let y;e[21]!==b?(y=U=>b(U,"prompts"),e[21]=b,e[22]=y):y=e[22];const T=y;if(!r||!d)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ci,{}),e[23]=E):E=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=U=>u({type:"SET_ACTIVE_TAB",payload:U}),e[24]=k):k=e[24];let P;e[25]!==d||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==T||e[30]!==M||e[31]!==A||e[32]!==j||e[33]!==N||e[34]!==x?(P=o.jsx(Ed,{currentConnection:d,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:x,toggleResource:N,togglePrompt:j,toggleAllTools:A,toggleAllResources:M,toggleAllPrompts:T,onTabChange:k},r),e[25]=d,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=T,e[30]=M,e[31]=A,e[32]=j,e[33]=N,e[34]=x,e[35]=P):P=e[35];let I;e[36]!==l||e[37]!==r||e[38]!==P?(I=o.jsx(B.Suspense,{fallback:E,children:o.jsx(Td,{connectionId:r,onAuthenticate:l,children:P})}),e[36]=l,e[37]=r,e[38]=P,e[39]=I):I=e[39];let z;e[40]!==i?(z=o.jsx(nh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(ie,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=z):z=e[41];let H;e[42]!==I||e[43]!==z?(H=o.jsxs(rn,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[I,z]}),e[42]=I,e[43]=z,e[44]=H):H=e[44];let F;return e[45]!==i||e[46]!==s||e[47]!==H?(F=o.jsx(nn,{open:s,onOpenChange:i,children:H}),e[45]=i,e[46]=s,e[47]=H,e[48]=F):F=e[48],F}const Ui={tools:null,resources:null,prompts:null},Id=Ol.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Pd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Ad(t){const e=$.c(11),{url:s,agentId:i}=t,[r,n]=B.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{ye("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),_e.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(Ri,{size:20,className:"text-green-600"}):o.jsx(ki,{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(ie,{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 Bd(t){const e=$.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{ye("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=ua(i),f=Pd(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"),_e.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(ie,{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 Ld(t){const e=$.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=B.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{ye("agent_connect_action",{agent_id:r,action:"install_claude_code"});const _=ua(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),_e.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(Ri,{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(ie,{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 Od({virtualMcp:t}){const{org:e}=pe(),s=$e({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),[i,r]=B.useState(null),[n,a]=B.useState(!1),[l,h]=B.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),ye("agent_typegen_key_generated",{agent_id:c})}catch{ye("agent_typegen_key_failed",{agent_id:c}),_e.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{ye("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(d),h(!0),_e.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(ie,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(Te,{size:14,className:"animate-spin"}):o.jsx(ch,{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(ie,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ri,{size:12,className:"text-green-600"}):o.jsx(ki,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(zd,{apiKey:i,agentId:c})]})}function zd(t){const e=$.c(21),{apiKey:s,agentId:i}=t,[r,n]=B.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()=>{ye("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?(_=se({"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(Ri,{size:12,className:"text-green-600"}):o.jsx(ki,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==b?(S=o.jsx(ie,{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 $d(t){const e=$.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(B.Suspense,{fallback:i,children:o.jsx(Od,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Fd(t){const e=$.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=pe(),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=aa();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(Ad,{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(Bd,{url:h.href,serverName:u,agentId:r.id}),m=o.jsx(Ld,{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($d,{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 w;e[23]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(ph,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=w):w=e[23];let j;e[24]!==S?(j=o.jsx(gh,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[w,S]})}),e[24]=S,e[25]=j):j=e[25];let R;return e[26]!==i||e[27]!==s||e[28]!==j?(R=o.jsx(vh,{open:s,onOpenChange:i,children:j}),e[26]=i,e[27]=s,e[28]=j,e[29]=R):R=e[29],R}let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Sa,{children:o.jsx(ya,{children:"Connect"})}),e[30]=x):x=e[30];let C;e[31]!==S?(C=o.jsxs(rn,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[x,S]}),e[31]=S,e[32]=C):C=e[32];let N;return e[33]!==i||e[34]!==s||e[35]!==C?(N=o.jsx(nn,{open:s,onOpenChange:i,children:C}),e[33]=i,e[34]=s,e[35]=C,e[36]=N):N=e[36],N}function Hd(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 Wd(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0,instructionsLength:null},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1,instructionsLength:e.instructionsLength??s.instructionsLength}}case"reset":return null}}function Ud(t){const e=$.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=sn(s),{org:u}=pe();if(!c)return null;let d;e[0]!==c?(d=rh(c),e[0]=c,e[1]=d):d=e[1];const f=d;let _;e[2]!==s?(_=o.jsx(Gd,{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(qd,{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(B.Suspense,{fallback:_,children:m}),e[19]=_,e[20]=m,e[21]=p):p=e[21],p}const zn="__new_instance__";async function Vd(t,e){const s=t?.idToken??null;if(s){const r=$n(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 $n(e)}function $n(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 Kd(t){const e=$.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=Ti(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===zn?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(ts,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(ss,{})}),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(Mt,{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(Mt,{value:zn,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(is,{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(es,{value:i,onValueChange:c,children:[u,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=m):m=e[22],m}function qd(t){const e=$.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=da(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let C;e[2]!==x?(C=se("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=C):C=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 w;e[7]!==n||e[8]!==i?(w=o.jsx(ds,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=w):w=e[9];let j;e[10]!==i?(j=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=j):j=e[11];let R;e[12]!==r||e[13]!==S?(R=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]=R):R=e[14];let A;e[15]!==j||e[16]!==R?(A=o.jsxs("div",{className:"flex-1 min-w-0",children:[j,R]}),e[15]=j,e[16]=R,e[17]=A):A=e[17];let D;e[18]!==s||e[19]!==S||e[20]!==_?(D=S?o.jsx(ie,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:J=>{J.preventDefault(),J.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(We,{delayDuration:0,children:[o.jsx(Ue,{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(ah,{size:16})})}),o.jsx(Ve,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=D):D=e[21];let M;e[22]!==N||e[23]!==w||e[24]!==A||e[25]!==D?(M=o.jsxs(Fl,{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:[w,A,D]}),e[22]=N,e[23]=w,e[24]=A,e[25]=D,e[26]=M):M=e[26];let y;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==m||e[31]!==u?(y=c&&o.jsx(Kd,{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 T;e[33]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(Ec,{size:13}),e[33]=T):T=e[33];let E;e[34]!==d?(E=o.jsx(Ue,{asChild:!0,children:o.jsx(ie,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,"aria-label":"Configure resources",children:T})}),e[34]=d,e[35]=E):E=e[35];let k;e[36]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(Ve,{side:"bottom",children:"Configure resources"}),e[36]=k):k=e[36];let P;e[37]!==E?(P=o.jsxs(We,{delayDuration:0,children:[E,k]}),e[37]=E,e[38]=P):P=e[38];let I;e[39]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(as,{size:13}),e[39]=I):I=e[39];let z;e[40]!==f?(z=o.jsx(Ue,{asChild:!0,children:o.jsx(ie,{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]=z):z=e[41];let H;e[42]===Symbol.for("react.memo_cache_sentinel")?(H=o.jsx(Ve,{side:"bottom",children:"Remove"}),e[42]=H):H=e[42];let F;e[43]!==z?(F=o.jsxs(We,{delayDuration:0,children:[z,H]}),e[43]=z,e[44]=F):F=e[44];let U;e[45]!==P||e[46]!==F?(U=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[P,F]}),e[45]=P,e[46]=F,e[47]=U):U=e[47];let ee;e[48]!==y||e[49]!==U?(ee=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]=ee):ee=e[50];let te;return e[51]!==M||e[52]!==ee||e[53]!==C?(te=o.jsxs("div",{className:C,children:[M,ee]}),e[51]=M,e[52]=ee,e[53]=C,e[54]=te):te=e[54],te}function Gd(t){const e=$.c(17),{connection_id:s}=t,i=sn(s);if(!i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ma,{}),e[0]=d):d=e[0],d}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(ds,{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 Ma(){const t=$.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 Yd({virtualMcpId:t,form:e,flushAndSave:s}){const{org:i}=pe(),r=$e({connectionId:Pt,orgId:i.id,orgSlug:i.slug}),n=yt(t),a=(n?.connections??[]).map(y=>y.connection_id).sort(),{data:l}=Uo({queryKey:Ps.projectConnectionDetails(t,a),enabled:a.length>0,queryFn:async()=>await Promise.all(a.map(async T=>{try{const E=await r.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:T}}),{item:k}=ih(E),P=(k?.tools??[]).filter(I=>!!eh(I._meta)).map(I=>({name:I.name,description:I.description}));return{fetchOk:!0,id:T,title:k?.title??T,icon:k?.icon??null,uiTools:P}}catch{return{fetchOk:!1,id:T,title:T,icon:null,uiTools:[]}}}))}),h=(l??[]).filter(y=>y.uiTools.length>0),c=new Set(dc),u=e.watch("metadata.ui.pinnedViews")??[],d=e.watch("metadata.ui.layout")??null,f=d?.defaultMainView??null,_=d?.chatDefaultOpen??!1,m=!f||f.type==="chat"?"chat":f.type==="instructions"||f.type==="connections"||f.type==="layout"?"settings":c.has(f.type)?f.type:`${f.type}:${f.id??""}:${f.toolName??""}`,p=y=>{const[T,E,k]=y.split(":");return T?T==="chat"?{type:T}:c.has(T)?{type:T}:T==="ext-apps"&&E?{type:"ext-apps",id:E,toolName:k||void 0}:null:null},g=y=>{e.setValue("metadata.ui.pinnedViews",y,{shouldDirty:!0})},v=y=>{e.setValue("metadata.ui.layout",{...d,...y},{shouldDirty:!0})},b=B.useRef(!1);if(l&&l.length>0&&!b.current){b.current=!0;const y=new Set((l??[]).filter(k=>k.fetchOk).map(k=>k.id)),T=new Set(h.flatMap(k=>k.uiTools.map(P=>`${k.id}:${P.name}`))),E=u.filter(k=>!y.has(k.connectionId)||T.has(`${k.connectionId}:${k.toolName}`));E.length!==u.length&&(g(E),f?.type==="ext-apps"&&!E.some(k=>k.connectionId===f.id&&k.toolName===f.toolName)&&v({defaultMainView:{type:"chat"}}))}const S=(y,T)=>{if(u.some(k=>k.connectionId===y&&k.toolName===T)){const k=u.filter(I=>!(I.connectionId===y&&I.toolName===T));g(k);const P=`ext-apps:${y}:${T}`;m===P&&v({defaultMainView:{type:"chat"}})}else g([...u,{connectionId:y,toolName:T,label:Cn(T),icon:null}]);s()},x=(y,T,E)=>{g(u.map(k=>k.connectionId===y&&k.toolName===T?{...k,label:E}:k))},C=()=>{s()},N=(y,T,E)=>{g(u.map(k=>k.connectionId===y&&k.toolName===T?{...k,icon:E}:k)),s()},w=y=>{v({defaultMainView:p(y)}),s()},j=a.length===0,R=l&&h.length===0,A=!!Ut(n),D=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];A&&(D.push({value:"env",label:"Terminal"}),D.push({value:"preview",label:"Preview"}));for(const y of u)D.push({value:`ext-apps:${y.connectionId}:${y.toolName}`,label:y.label||y.toolName});const M=h.length>0||j||R;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(oh,{className:"p-6 gap-5",children:[o.jsxs(Dn,{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(Ds,{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(es,{value:m,onValueChange:w,children:[o.jsx(ts,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(ss,{})}),o.jsx(is,{children:D.map(y=>o.jsx(Mt,{value:y.value,className:"capitalize",children:y.label},y.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(Ds,{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(We,{delayDuration:0,children:[o.jsx(Ue,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(dr,{checked:m==="chat"?!0:_,disabled:m==="chat",onCheckedChange:y=>{v({chatDefaultOpen:y}),s()}})})}),m==="chat"&&o.jsx(Ve,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),M&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Dn,{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(Ds,{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."})]})}),j&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),R&&!j&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),h.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:h.map((y,T)=>o.jsxs("div",{children:[T>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(ds,{icon:y.icon,name:y.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:y.title})]}),o.jsx("div",{className:"space-y-1.5",children:y.uiTools.map(E=>{const k=u.some(I=>I.connectionId===y.id&&I.toolName===E.name),P=u.find(I=>I.connectionId===y.id&&I.toolName===E.name);return o.jsxs("div",{className:se("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",k?"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(vd,{value:P?.icon??null,onChange:I=>N(y.id,E.name,I),disabled:!k}),o.jsx(ms,{value:k&&P?P.label:Cn(E.name),onChange:I=>x(y.id,E.name,I.target.value),onBlur:C,className:"h-7 text-sm w-40",disabled:!k,readOnly:!k})]}),o.jsx(dr,{checked:k,onCheckedChange:()=>S(y.id,E.name)})]},E.name)})})]},y.id))})]})]})]})]})}function Xd({virtualMcp:t,hideOwnTitle:e}){const{org:s}=pe(),i=Zl(),r=Jc(),n=hs(),a=$e({connectionId:Pt,orgId:s.id,orgSlug:s.slug}),l=Ko({resolver:zl(Id),defaultValues:t}),h=l.watch("connections"),c=!!Ut(t),[u,d]=B.useReducer(Hd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,_]=B.useState(!1),[m,p]=B.useState(!1),{createNewTask:g,setChatOpen:v}=Ei(),{sendMessage:b}=us(),S=ca(),x=async()=>{if(m)return;const L=l.getValues("metadata.instructions");if(L?.trim()){p(!0);try{A(),ye("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await S(["studio-agent-manager"]),v(!0),await b({tiptapDoc:Da({managerAgentId:Jo.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{p(!1)}}},C=()=>{A(),ye("agent_test_clicked",{agent_id:t.id}),g()},[N,w]=B.useReducer(Wd,null),j=()=>{N!==null&&(ye("agent_updated",{agent_id:t.id,fields:Array.from(N.fields),instructions_length:N.instructionsLength,save_count:N.saveCount,edit_duration_ms:Date.now()-N.start}),w({type:"reset"}))},{schedule:R,flush:A}=pi({delayMs:3e4,save:async()=>j()}),D=async()=>{const L=Object.keys(l.control._formState.dirtyFields);if(L.length===0)return;const q=L.includes("metadata"),X=l.getValues();l.reset(X,{keepValues:!0}),await i.update.mutateAsync({id:t.id,data:X}),w({type:"accumulate",now:Date.now(),fields:L,instructionsLength:q?X.metadata?.instructions?.length??0:null}),R()},{schedule:M,flush:y}=pi({save:D});B.useEffect(()=>{const L=l.watch(()=>M());return()=>L.unsubscribe()},[]);const T=()=>{ye("connections_dialog_opened",{source:"agent_settings",mode:"add"}),d({type:"SET_ADD_DIALOG_OPEN",payload:!0})},E=async L=>{const q=l.getValues("connections");if(q.some(oe=>oe.connection_id===L))return;l.setValue("connections",[...q,{connection_id:L,selected_tools:Ui.tools,selected_resources:Ui.resources,selected_prompts:Ui.prompts}],{shouldDirty:!0}),d({type:"SET_ADD_DIALOG_OPEN",payload:!1});const X=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),Y=await bn({url:X.href,token:null,orgId:s.id});Y.supportsOAuth&&!Y.isAuthenticated&&await H(L)},k=L=>{const X=l.getValues("connections").filter(Y=>Y.connection_id!==L);l.setValue("connections",X,{shouldDirty:!0})},P=(L,q)=>{const X=l.getValues("connections");if(X.some(Y=>Y.connection_id===q)){_e.error("This instance is already added to the agent");return}l.setValue("connections",X.map(Y=>Y.connection_id===L?{...Y,connection_id:q}:Y),{shouldDirty:!0})},I=async L=>{if(l.getValues("connections").find(X=>X.connection_id===L))try{const X=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:Y}=X.structuredContent??{};if(!Y)return;const oe=Y.title.replace(/\s*\(.*?\)\s*$/,""),K=Zc("conn"),V=`${oe} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:K,title:V,description:Y.description??null,connection_type:Y.connection_type,connection_url:Y.connection_url??null,connection_token:null,icon:Y.icon??null,app_name:Y.app_name??null,app_id:Y.app_id??null,connection_headers:Y.connection_headers??null});const ce=new URL(`/api/${s.slug}/mcp/${K}`,window.location.origin),ue=await bn({url:ce.href,token:null,orgId:s.id});if(ue.supportsOAuth&&!ue.isAuthenticated){const he=await H(K);if(!he){await r.delete.mutateAsync(K);return}await r.update.mutateAsync({id:K,data:{title:`${oe} (${he})`}})}P(L,K),_e.success("New instance created")}catch(X){console.error("Failed to create instance:",X),_e.error("Failed to create instance")}},z=L=>{d({type:"OPEN_SETTINGS",payload:L})},H=async L=>{const{token:q,tokenInfo:X,error:Y}=await $l({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(Y||!q)return _e.error(`Authentication failed: ${Y}`),null;if(X)try{const K=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:X.accessToken,refreshToken:X.refreshToken,expiresIn:X.expiresIn,scope:X.scope,clientId:X.clientId,clientSecret:X.clientSecret,tokenEndpoint:X.tokenEndpoint})});if(!K.ok)console.error("Failed to save OAuth token:",await K.text()),await r.update.mutateAsync({id:L,data:{connection_token:q}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(V){console.warn("Failed to refresh connection tools after OAuth:",V)}}catch(K){console.error("Error saving OAuth token:",K),await r.update.mutateAsync({id:L,data:{connection_token:q}})}else await r.update.mutateAsync({id:L,data:{connection_token:q}});const oe=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await n.invalidateQueries({queryKey:Ps.isMCPAuthenticated(oe.href,null)}),_e.success("Authentication successful"),Vd(X,q)},F=()=>{const L=l.getValues("metadata.instructions")??"",q=`<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 mr.get()},set promptLabel(t){mr.set(t)},get tooMuchOutput(){return _r.get()},set tooMuchOutput(t){_r.set(t)}}}_verifyIntegers(...t){for(ct of t)if(ct===1/0||isNaN(ct)||ct%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(ct of t)if(ct&&(ct===1/0||isNaN(ct)||ct%1!==0||ct<0))throw new Error("This API only accepts positive integers")}};var kp=2,Np=1,jp=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(kp,Math.floor(u/t.css.cell.width)),rows:Math.max(Np,Math.floor(c/t.css.cell.height))}}};function Ep({source:t,onReady:e,onSelectionChange:s,className:i}){const r=B.useRef(null),n=B.useRef(null),a=B.useRef(s);a.current=s;const l=Kt(),h=B.useRef(t);return h.current=t,Ku((c,u)=>{c===h.current&&n.current?.write(u)}),B.useEffect(()=>{const c=r.current;if(!c)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new Cp({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 jp;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:se("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function Tp(){const t=$.c(2),s=xn()?.entity;let i;return t[0]!==s?(i=Ut(s),t[0]=s,t[1]=i):i=t[1],i}const Rp={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"}},Dp=["dev","start"];function Mp({daemonOpen:t=!1}){const{org:e}=pe(),s=xn(),i=hs(),{data:r}=Ci.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=_t(),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]=B.useState(null),[_,m]=B.useState(""),[p,g]=B.useState(""),[v,b]=B.useState(!1),[S,x]=B.useState(new Set),C=B.useRef(!1),N=B.useRef(Date.now()),[w,j]=B.useState("setup"),[R,A]=B.useState([]),D=B.useRef(new Map),{sendMessage:M}=us(),{setChatOpen:y}=Ei(),[T,E]=B.useState(!1),k=B.useRef(null),P=Z=>{j(Z),E(!1),k.current=null},I=(Z,re,ge)=>{Z===w&&(E(re),k.current=re?ge:null)},z=()=>{const Z=k.current?.();if(!Z)return;y(!0),M({parts:[{type:"text",text:`<server-logs>
180
180
  ${Z}
181
181
  </server-logs>`}]}),D.current.get(w)?.clearSelection()},H=$e({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),F=Kt(),U=Ta(s?.entity?.id,n??void 0),ee=F.suspended?"suspended":F.notFound?"creating":u?"running":U?"creating":"idle",te=d??ee;if(B.useEffect(()=>{d==="creating"&&ee==="running"&&f(null),d==="stopping"&&ee==="idle"&&f(null)},[ee,d]),S.size>0){let Z=!1;const re=new Set(S);for(const ge of S)F.activeProcesses.includes(ge)||(re.delete(ge),Z=!0);Z&&x(re)}const J=on(H),{mutate:W,isPending:L}=J,q=s?.entity?.id,X=F.notFound?c?.vmId??null:null,Y=B.useRef(null);B.useEffect(()=>{if(!X||!q||L||Y.current===X)return;Y.current=X;const Z={virtualMcpId:q};n&&(Z.branch=n),W(Z,{onError:re=>{console.error("[env] reprovision VM_START failed",re)}})},[X,q,n,L,W]);const oe=B.useRef(!1);B.useEffect(()=>{if(F.scripts.length>0&&!oe.current){oe.current=!0;for(const Z of Dp)if(F.scripts.includes(Z)){A([Z]),P(Z);break}}},[F.scripts]);const K=async(Z,re)=>{const ge=await H.callTool({name:Z,arguments:re}),At=ge.content;if(At?.[0]?.text?.startsWith("Error:"))throw new Error(At[0].text);return ge.structuredContent??ge},V=async Z=>{if(!(v||!u||!q||!n)){b(!0);try{const re=new URLSearchParams({virtualMcpId:q,branch:n}).toString(),ge=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/exec/${encodeURIComponent(Z)}?${re}`,{method:"POST"});if(!ge.ok)throw new Error(`Exec failed: ${ge.statusText}`)}finally{b(!1)}}},ce=async Z=>{if(!(!u||!q||!n)&&!S.has(Z)){x(re=>{const ge=new Set(re);return ge.add(Z),ge});try{const re=new URLSearchParams({virtualMcpId:q,branch:n}).toString(),ge=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/kill/${encodeURIComponent(Z)}?${re}`,{method:"POST"});if(!ge.ok)throw new Error(`Kill failed: ${ge.statusText}`)}catch{x(re=>{const ge=new Set(re);return ge.delete(Z),ge}),_e.error(`Failed to stop ${Z}`)}}},ue=Z=>{R.includes(Z)||A(re=>[...re,Z]),P(Z),V(Z)},he=async()=>{if(!C.current){C.current=!0,s?.entity?.id&&n&&gi.clear(s.entity.id,n),N.current=Date.now(),f("creating"),m("Connecting..."),g(""),oe.current=!1,A([]),P("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const Z={virtualMcpId:s.entity.id};n&&(Z.branch=n);const re=await K("VM_START",Z);if(!re.vmId||!re.branch)throw new Error("Invalid VM response — missing fields");n||a(re.branch),m(""),oi(i)}catch(Z){f("error"),g(Z instanceof Error?Z.message:"Failed to start VM")}finally{C.current=!1}}},fe=async()=>{const Z=u?.branch??n;f("stopping");const re=s?.entity?.id;if(re&&Z&&gi.mark(re,Z),re&&Z)try{await H.callTool({name:"VM_DELETE",arguments:{virtualMcpId:re,branch:Z}})}catch{}oi(i)},me=Tp(),Qe=s?.entity?.metadata?.runtime,Ge="__none__",rt=Object.keys(Rp),gt=async(Z,re)=>{if(s?.entity)try{await H.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...Qe,[Z]:re}}}}}),oi(i)}catch{_e.error("Failed to update setting")}};if(te==="idle"||te==="stopping"){const Z=te==="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:[me&&o.jsxs("a",{href:`https://github.com/${me.owner}/${me.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(th,{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:[me.owner,"/",me.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",me.owner,"/",me.name]})]}),o.jsx(Vt,{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(Ds,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(es,{value:Qe?.selected??Ge,onValueChange:re=>gt("selected",re===Ge?null:re),children:[o.jsx(ts,{id:"env-runtime",className:"w-28",children:o.jsx(ss,{placeholder:"None"})}),o.jsxs(is,{children:[o.jsx(Mt,{value:Ge,children:"None"}),rt.map(re=>o.jsx(Mt,{value:re,children:re},re))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ds,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(ms,{id:"env-port",placeholder:"3001",className:"w-20 h-8",defaultValue:Qe?.port??"",onBlur:re=>gt("port",re.target.value||null)})]}),o.jsxs(ie,{onClick:he,disabled:Z,children:[Z?o.jsx(Te,{size:14,className:"animate-spin"}):o.jsx(li,{size:14}),Z?"Stopping...":"Run"]})]})]})})}if(te==="creating"){const Z=F.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(Te,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:Z}),o.jsx(uc,{since:N.current})]})}if(te==="error")return o.jsx(Oa,{errorMsg:p,onRetry:he});if(te==="suspended")return o.jsx(La,{onResume:he});const Ie=["setup",...R,...t?["daemon"]:[]],Gt=F.scripts.filter(Z=>!R.includes(Z));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:[Ie.map(Z=>o.jsx("button",{type:"button",onClick:()=>P(Z),className:se("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",w===Z?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:Z},Z)),Gt.length>0&&o.jsxs(rs,{children:[o.jsx(ns,{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(ls,{size:14})})}),o.jsx(os,{align:"start",children:Gt.map(Z=>o.jsx(St,{onClick:()=>ue(Z),children:Z},Z))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:u?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(We,{children:[o.jsx(Ue,{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(Ve,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(rs,{children:[o.jsx(ns,{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(fr,{size:10})})}),o.jsx(os,{align:"center",children:o.jsxs(St,{onClick:fe,children:[o.jsx(Tn,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[T&&o.jsxs("button",{type:"button",onClick:z,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(Tc,{size:12}),"Add to chat"]}),w!=="setup"&&w!=="daemon"&&R.includes(w)&&(()=>{const Z=F.activeProcesses.includes(w),re=S.has(w),ge=Z&&!re,At=v||re,Dl=()=>V(w),Ml=()=>ce(w),Il=v?"Running...":re?"Stopping...":Z?"Restart":"Run";return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:At,onClick:Dl,className:se("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",ge?"rounded-l-md border-r-0":"rounded-md"),children:[At?o.jsx(Te,{size:12,className:"animate-spin"}):o.jsx(li,{size:12}),Il]}),ge&&o.jsxs(rs,{children:[o.jsx(ns,{asChild:!0,children:o.jsx("button",{type:"button",disabled:At,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(fr,{size:12})})}),o.jsx(os,{align:"end",children:o.jsxs(St,{onClick:Ml,children:[o.jsx(Tn,{size:12}),"Stop"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:Ie.map(Z=>o.jsx("div",{className:se("h-full",w===Z?"block":"hidden"),children:F.hasData(Z)||Z==="setup"||Z==="daemon"?o.jsx(Ep,{source:Z,onReady:re=>{D.current.set(Z,re)},onSelectionChange:(re,ge)=>I(Z,re,ge),className:"h-full"}):o.jsx(Ls,{className:"h-full",image:null,title:`Script "${Z}" not running`,description:`Click Run to start "${Z}".`,actions:o.jsxs(ie,{variant:"outline",size:"sm",disabled:v,onClick:()=>V(Z),children:[v?o.jsx(Te,{size:14,className:"animate-spin"}):o.jsx(li,{size:14}),"Run"]})})},Z))})]})})}function Ip(t){const e=$.c(1);let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Mp,{}),e[0]=s):s=e[0],s}function Is(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Pp(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 Ap(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 Bp(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 Lp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Op=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function zp(t){const e=$.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Ks(),[h,c]=B.useState(!1),u=i??h;let d;e[0]!==r?(d=D=>{r?r(D):c(D)},e[0]=r,e[1]=d):d=e[1];const f=d;let _;e[2]!==l||e[3]!==s||e[4]!==f?(_=async D=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:D}),_e.success("Starter added"),f(!1)}catch(M){const y=M,T=y instanceof Error?y.message:"Failed to add starter";_e.error(T)}},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(ns,{asChild:!0,children:o.jsxs(ie,{variant:"outline",size:"sm",children:[o.jsx(ls,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(bh,{className:"gap-2.5",children:[o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==m?(v=Op.map(D=>o.jsxs(St,{className:"gap-2.5",onSelect:()=>m(D.cron),disabled:l.isPending,children:[o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",D.label]},D.cron)),e[8]=l,e[9]=m,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(Sh,{children:[g,o.jsx(yh,{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(Rs,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let C;e[17]!==S?(C=o.jsxs(St,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=C):C=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 w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=w):w=e[22];let j;e[23]!==N?(j=o.jsxs(St,{className:"gap-2.5",onSelect:N,children:[w,"Event"]}),e[23]=N,e[24]=j):j=e[24];let R;e[25]!==j||e[26]!==b||e[27]!==C?(R=o.jsxs(os,{align:"end",className:"w-[200px]",children:[b,C,j]}),e[25]=j,e[26]=b,e[27]=C,e[28]=R):R=e[28];let A;return e[29]!==f||e[30]!==u||e[31]!==R?(A=o.jsxs(rs,{open:u,onOpenChange:f,children:[p,R]}),e[29]=f,e[30]=u,e[31]=R,e[32]=A):A=e[32],A}function $p(t){const e=$.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Ks(),[l,h]=B.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?Bp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const u=c,[d,f]=B.useState(u?.count??1),[_,m]=B.useState(!1),[p,g]=B.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}),_e.success("Starter removed")}catch{_e.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 C;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(C=async()=>{const F=p.trim();if(!F||!Is(F)||F===s.cron_expression){m(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:F}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),m(!1)}catch{_e.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]=C):C=e[12];const N=C;let w;e[13]!==n||e[14]!==i||e[15]!==u||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(w=async F=>{if(!u)return;const U=Math.max(1,F),ee=Ap(U,u.unit);if(ee!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:ee}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{_e.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]=w):w=e[19];const j=w;let R;e[20]!==b?(R=b?o.jsx(Rs,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=R):R=e[21];let A;e[22]!==r||e[23]!==d||e[24]!==p||e[25]!==j||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?(A=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:F=>f(parseInt(F.target.value)||1),onBlur:()=>j(d),onKeyDown:F=>{F.key==="Enter"&&F.target.blur(),F.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:Lp(u.unit,d)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:F=>g(F.target.value),onBlur:N,onKeyDown:F=>{F.key==="Enter"&&F.target.blur(),F.key==="Escape"&&(m(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!Is(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?Pp(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(Fp).join(", ")})]}),e[22]=r,e[23]=d,e[24]=p,e[25]=j,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]=A):A=e[34];let D;e[35]!==v?(D=v&&o.jsx(Te,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=D):D=e[36];let M;e[37]!==u||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(M=b&&!u&&!_&&o.jsx(ie,{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(lh,{size:13,className:"text-muted-foreground"})}),e[37]=u,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=M):M=e[41];let y;e[42]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(ie,{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(as,{size:13,className:"text-muted-foreground"})}),e[42]=y):y=e[42];let T;e[43]!==D||e[44]!==M?(T=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[D,M,y]}),e[43]=D,e[44]=M,e[45]=T):T=e[45];let E;e[46]!==T||e[47]!==R||e[48]!==A?(E=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[R,A,T]}),e[46]=T,e[47]=R,e[48]=A,e[49]=E):E=e[49];let k;e[50]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsxs(_a,{children:[o.jsx(pa,{children:"Remove Starter"}),o.jsx(ga,{children:"Are you sure you want to remove this starter?"})]}),e[50]=k):k=e[50];let P;e[51]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx(xa,{children:"Cancel"}),e[51]=P):P=e[51];let I;e[52]!==x?(I=o.jsxs(ma,{children:[k,o.jsxs(va,{children:[P,o.jsx(ba,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=I):I=e[53];let z;e[54]!==l||e[55]!==I?(z=o.jsx(fa,{open:l,onOpenChange:h,children:I}),e[54]=l,e[55]=I,e[56]=z):z=e[56];let H;return e[57]!==E||e[58]!==z?(H=o.jsxs(o.Fragment,{children:[E,z]}),e[57]=E,e[58]=z,e[59]=H):H=e[59],H}function Fp(t){const[e,s]=t;return`${e}: ${s}`}function Hp(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},i=new Set(s.fields);for(const r of e.fields)i.add(r);return{...s,fields:i,saveCount:s.saveCount+1}}case"reset":return null}}function Wp(t){const e=$.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=Ti(r),[a,l]=B.useState(),[h,c]=B.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[d,f]=B.useState(u),{triggerAdd:_}=Ks(),{data:m,isLoading:p}=Ch(a);let g,v,b,S,x,C;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 j=m?.find(I=>I.type===h);let R;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==d?(R=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:d}),ye("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),_e.success("Event trigger added"),i()}catch{_e.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]=R):R=e[23],g=R,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let A,D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),A=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=A,e[25]=D):(A=e[24],D=e[25]);let M;e[26]===Symbol.for("react.memo_cache_sentinel")?(M=o.jsx(as,{size:13}),e[26]=M):M=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[D,A,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:M})]}),e[27]=i,e[28]=b):b=e[28];const y=a??"";let T;e[29]===Symbol.for("react.memo_cache_sentinel")?(T=I=>{l(I),c(void 0),f({})},e[29]=T):T=e[29];let E;e[30]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ts,{className:"w-full",children:o.jsx(ss,{placeholder:"Select connection..."})}),e[30]=E):E=e[30];let k;e[31]!==n?(k=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(Kp),e[31]=n,e[32]=k):k=e[32];let P;e[33]!==k?(P=o.jsx(is,{children:k}),e[33]=k,e[34]=P):P=e[34],e[35]!==y||e[36]!==P?(S=o.jsxs(es,{value:y,onValueChange:T,children:[E,P]}),e[35]=y,e[36]=P,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==m?(x=a&&o.jsxs(es,{value:h??"",onValueChange:I=>{c(I),f({})},children:[o.jsx(ts,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Te,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(ss,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(is,{children:m?.map(Vp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=m,e[42]=x):x=e[42],C=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(I=>{const[z,H]=I;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[z,H.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",H.description]})]}),H.enum?o.jsxs(es,{value:d[z]??"",onValueChange:F=>f(U=>({...U,[z]:F})),children:[o.jsx(ts,{className:"w-full",children:o.jsx(ss,{placeholder:`Select ${z}...`})}),o.jsx(is,{children:H.enum.map(Up)})]}):o.jsx("input",{type:"text",value:d[z]??"",onChange:F=>f(U=>({...U,[z]:F.target.value})),placeholder:H.description??z,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},z)})}),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]=C}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],C=e[16];let N;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(N=a&&h&&o.jsx(ie,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Te,{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 w;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==C||e[53]!==N?(w=o.jsxs("div",{className:v,children:[b,S,x,C,N]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=C,e[53]=N,e[54]=w):w=e[54],w}function Up(t){return o.jsx(Mt,{value:t,children:t},t)}function Vp(t){return o.jsx(Mt,{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 Kp(t){return o.jsx(Mt,{value:t.id,children:t.title},t.id)}function qp({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=pe(),{update:a,triggerAdd:l}=Ks(),h=Ti(),c=new Map(h.map(K=>[K.id,K.title])),{createTaskWithMessage:u}=_t(),{setSimpleModeTier:d}=Zr(),{setChatOpen:f}=Ei(),{sendMessage:_}=us(),m=ca(),[p,g]=Hl(),v=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[b,S]=B.useState(v),[x,C]=B.useState(!1),[N,w]=B.useState(!1),[j,R]=B.useState(""),[A,D]=B.useState(!1),[M,y]=B.useState(!1),[T,E]=B.useState(!1),[k,P]=B.useState(!1),I=async()=>{if(M)return;const V=Sn(b).filter(ce=>ce.type==="text").map(ce=>ce.text).join(`
182
- `);if(V.trim()){y(!0);try{X(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:V.length}),await m(["studio-automation-manager"]),f(!0),await _({tiptapDoc:Da({managerAgentId:Jo.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:V})})}finally{y(!1)}}},z=e.models?.tier??"smart",H=Ko({defaultValues:{name:e.name,active:e.active,tier:z}}),F=H.watch("active"),[U,ee]=B.useReducer(Hp,null),te=()=>{U!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(U.fields),save_count:U.saveCount,edit_duration_ms:Date.now()-U.start}),ee({type:"reset"}))},J=async()=>{const K=H.control._formState.dirtyFields,V=Object.keys(K);if(V.length===0&&!k)return!0;const ce=H.getValues(),ue=H.control._defaultValues;H.reset(ce,{keepValues:!0});const he=k;P(!1);const fe={id:t,name:ce.name,active:ce.active,models:{tier:ce.tier},messages:ec(b),temperature:0};try{await a.mutateAsync(fe)}catch{return H.reset(ue,{keepValues:!0}),he&&P(!0),!1}const me=[...V];return he&&me.push("messages"),ee({type:"accumulate",now:Date.now(),fields:me}),q(),!0},{schedule:W,flush:L}=pi({save:J}),{schedule:q,flush:X}=pi({delayMs:3e4,save:async()=>te()});B.useEffect(()=>{const K=H.watch(()=>W());return()=>K.unsubscribe()},[]);const Y=K=>{if(S(K),!T){E(!0);return}P(!0),W()},oe=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const K=await L();if(X(),!K)return;if(!b){_e.error("No instructions configured for this automation");return}d(H.getValues("tier")),f(!0),g({...p,toolApprovalLevel:"auto"});const V=Sn(b);u({message:{tiptapDoc:b,parts:V},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(ie,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Na,{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(zt,{control:H.control,name:"name",render:({field:K})=>o.jsx(ms,{...K,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(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(ur,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(zt,{control:H.control,name:"active",render:({field:K})=>o.jsx(dr,{checked:K.value,onCheckedChange:V=>{K.onChange(V),L()},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:F?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ha,{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(zp,{automationId:t,open:x,onOpenChange:C,onCustomSelect:()=>{w(!0),D(!1),R("")},onEventSelect:()=>{D(!0),w(!1)}})]}),e.triggers.length===0&&!N?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:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(K=>o.jsx($p,{trigger:K,automationId:t,connectionName:K.connection_id?c.get(K.connection_id):void 0},K.id))}),N&&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(Rs,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:j,onChange:K=>R(K.target.value),onBlur:async()=>{const K=j.trim();if(!(!K||!Is(K)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:K}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),_e.success("Starter added"),w(!1),R("")}catch{_e.error("Failed to add starter")}},onKeyDown:async K=>{const V=j.trim();K.key==="Enter"&&V&&Is(V)&&K.target.blur(),K.key==="Escape"&&(w(!1),R(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Is(j)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Te,{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:()=>{w(!1),R("")},children:o.jsx(as,{size:13})})]}),A&&o.jsx(B.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(Te,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Wp,{automationId:t,onDone:()=>D(!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(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:M||!b,onClick:I,children:[o.jsx(wa,{size:13}),"Improve"]})]}),o.jsx(Yl,{tiptapDoc:b,setTiptapDoc:Y,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(Xl,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(Jl,{tier:H.watch("tier"),onSelect:K=>H.setValue("tier",K,{shouldDirty:!0})}),o.jsxs(We,{children:[o.jsx(Ue,{asChild:!0,children:o.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:oe,disabled:!r,children:[o.jsx(ac,{size:16}),"Test"]})}),o.jsx(Ve,{children:"Test Automation"})]})]})]})})]})]})]})}function Gp(t){const e=$.c(5),{tabId:s}=t;let i;e[0]!==s?(i=Qo(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(Te,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ot,{children:o.jsx(ot.Content,{children:o.jsx(ot.Body,{children:o.jsx(B.Suspense,{fallback:n,children:o.jsx(Yp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Yp(t){const e=$.c(8),{id:s}=t,i=It(),{data:r,isLoading:n}=kh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Xp,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(Te,{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(qp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Xp(t){return{...t,main:"automations"}}function Jp(t){const e=$.c(20),{virtualMcpId:s}=t,i=It(),{data:r}=Nh(s),n=r===void 0?[]:r,{create:a}=Ks(),[l,h]=B.useState(""),c=l.toLowerCase(),u=n.filter(A=>A.name.toLowerCase().includes(c));let d;e[0]!==i?(d=A=>i({to:".",search:D=>({...D,main:"automation:"+A}),replace:!0}),e[0]=i,e[1]=d):d=e[1];const f=d,_=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const A=await a.mutateAsync(Eh(s));f(A.id)},m=ot,p=ot,g=ot;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ot.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(Th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ls,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(ie,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let C;e[7]!==b||e[8]!==x?(C=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=C):C=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{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(ie,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(ls,{size:14}),"New automation"]})})}):u.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(A=>o.jsx(jh,{automation:A,onClick:()=>f(A.id)},A.id))});let w;e[10]!==N||e[11]!==g.Body||e[12]!==C?(w=o.jsxs(g.Body,{children:[C,N]}),e[10]=N,e[11]=g.Body,e[12]=C,e[13]=w):w=e[13];let j;e[14]!==w||e[15]!==p.Content?(j=o.jsx(p.Content,{children:w}),e[14]=w,e[15]=p.Content,e[16]=j):j=e[16];let R;return e[17]!==m||e[18]!==j?(R=o.jsx(m,{children:j}),e[17]=m,e[18]=j,e[19]=R):R=e[19],R}function Zp(t){const e=$.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(Te,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(B.Suspense,{fallback:i,children:o.jsx(Jp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Oo=B.lazy(()=>Wl(()=>import("./project-app-view-BGEyiVSD.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,57])).then(t=>({default:t.AppViewContent})));function Tl(t){const e=$.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}=Ra(r);if(fc(n)){let m;return e[3]!==i?(m=o.jsx(Fn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Tu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(Zp,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Ip,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(_f,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Gp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=mc(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(Te,{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(B.Suspense,{fallback:g,children:o.jsx(Oo,{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(Te,{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(B.Suspense,{fallback:m,children:o.jsx(Oo,{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(Fn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function Qp(t){const e=$.c(7),{children:s,defaultSize:i}=t,[,r]=B.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Yo.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=Go(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(la,{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 eg(t){const e=$.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Rn(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=Yo.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=Go(c,45),d=B.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const A=d.current;if(!A)return;const D=Rn(r,n),M=D.chat>0&&D.chat<100?u:D.chat,y=D.chat>0&&D.chat<100?100-u:D.main;A.setLayout([M,y])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),B.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(ja,{}),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(Qp,{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(Yc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C={overflow:"visible"},e[18]=C):C=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=se("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 w;e[20]!==i||e[21]!==s?(w=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(Rt,{children:o.jsx(Tl,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=w):w=e[22];let j;e[23]!==h.main||e[24]!==w?(j=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:C,collapsible:!0,collapsedSize:0,minSize:20,children:w}),e[23]=h.main,e[24]=w,e[25]=j):j=e[25];let R;return e[26]!==j||e[27]!==m||e[28]!==b?(R=o.jsxs(Xc,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,j]},m),e[26]=j,e[27]=m,e[28]=b,e[29]=R):R=e[29],R}const ar="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",zo="bg-sidebar-accent text-sidebar-foreground",lr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function tg(t){const e=$.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Ic(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("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?zo:lr;let u;e[3]!==c?(u=se(ar,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Rc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ue,{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(Ve,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(We,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("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?zo:lr;let v;e[16]!==g?(v=se(ar,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(na,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ue,{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(Ve,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let C;e[24]!==S?(C=o.jsxs(We,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=C):C=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let w;e[26]!==N?(w=se("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=w):w=e[27];const j=!l,R=l?0:-1,A=!l,D=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let M;e[28]!==D?(M=se(ar,lr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",D),e[28]=D,e[29]=M):M=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(tn,{size:16}),e[30]=y):y=e[30];let T;e[31]!==r||e[32]!==j||e[33]!==R||e[34]!==A||e[35]!==M?(T=o.jsx(Ue,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:j,tabIndex:R,"aria-hidden":A,className:M,children:y})}),e[31]=r,e[32]=j,e[33]=R,e[34]=A,e[35]=M,e[36]=T):T=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Ve,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let k;e[38]!==T?(k=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(We,{delayDuration:300,children:[T,E]})}),e[38]=T,e[39]=k):k=e[39];let P;e[40]!==w||e[41]!==k?(P=o.jsx("div",{className:w,children:k}),e[40]=w,e[41]=k,e[42]=P):P=e[42];let I;return e[43]!==C||e[44]!==P||e[45]!==m?(I=o.jsxs(o.Fragment,{children:[m,C,P]}),e[43]=C,e[44]=P,e[45]=m,e[46]=I):I=e[46],I}function sg(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 ig(t){const e=$.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=se("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(rg,{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 rg(t){const e=$.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(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function ng(t){const e=$.c(13),{overflow:s,onSelect:i}=t,[r,n]=B.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(Ws,{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(sa,{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(og,{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(Us,{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(Vs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function og(t){const e=$.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(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const ag=6;function Rl(t){const e=$.c(20),{virtualMcpId:s,taskId:i}=t,r=It();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}=Ra(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=_c({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:C}=sg(a,S,ag);d=C,u=N=>{const w=a.find(R=>R.id===N),j=S===N&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:w?.kind??null,was_active:j}),N==="automations"){const R=pc({activeTab:l,mainOpen:h});r({to:".",search:A=>({...A,main:R}),replace:!0});return}c(N)},f="flex items-center min-w-0 gap-0.5",_=x.map(N=>o.jsx(ig,{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(ng,{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 lg(t){const e=$.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=se("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(Ul,{"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 cg(t){const e=$.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(vu({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(gu({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(ie,{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(fr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(ns,{asChild:!0,children:o.jsx(ie,{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(os,{align:"end",children:o.jsx(St,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(rs,{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 hg=new Set(["failure","timed_out","cancelled","action_required"]);function dg(t){return t.status==="completed"&&hg.has(t.conclusion)}function ug(t){return t.status==="queued"||t.status==="in_progress"}function fg(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(dg).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(ug);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 mg(){const t=$.c(3),{lifecycle:e,branch:s}=Kt();let i;return t[0]!==s||t[1]!==e?(i=_g(e,s),t[0]=s,t[1]=e,t[2]=i):i=t[2],i}function _g(t,e){switch(t.phase){case"idle":return{kind:"initializing"};case"cloning":return{kind:"cloning"};case"clone-failed":return{kind:"clone-failed",error:t.error};case"checking-out":return{kind:"checking-out",to:t.to}}return e.kind==="ready"?e:{kind:"initializing"}}const pg=6e4,gg=3e4;function vg(t){const e=$.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=$e(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:pg,refetchIntervalInBackground:!1,staleTime:gg,select:xg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],fs(l)}function xg(t){const e=qs(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 bg(t){const e=$.c(42),{virtualMcpId:s}=t,{org:i}=pe(),r=yt(s),{currentBranch:n}=_t(),a=us(),l=r?.metadata?.githubRepo??null,h=mg(),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=Ia(_),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 C=Aa(x),N=l?.connectionId??"",w=l?.owner??"",j=l?.name??"",R=p&&p.state==="open"?p.number:null;let A;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==w||e[18]!==j||e[19]!==R?(A={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:w,repo:j,prNumber:R},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=w,e[18]=j,e[19]=R,e[20]=A):A=e[20];const D=vg(A);if(!l?.connectionId||!n)return null;let M;e[21]!==h||e[22]!==C.data||e[23]!==p||e[24]!==m.isPending||e[25]!==D.data?(M=fg({branchStatus:h,pr:p,checks:C.data??[],reviews:D.data??null,loading:m.isPending}),e[21]=h,e[22]=C.data,e[23]=p,e[24]=m.isPending,e[25]=D.data,e[26]=M):M=e[26];const y=M;let T;e[27]!==a?(T=U=>a.sendMessage({parts:[{type:"text",text:U}]}),e[27]=a,e[28]=T):T=e[28];const E=T,k=a.isStreaming;let P;e[29]!==n||e[30]!==y||e[31]!==k||e[32]!==p||e[33]!==E?(P=U=>{if(!k)switch(U){case"commit-and-push":{E(cu({branch:n}));return}case"create-pr":{E(hu({branch:n}));return}case"reopen":{p&&E(du({prNumber:p.number}));return}case"rebase":{E(uu({branch:n}));return}case"fix-checks":{p&&E(mu({prNumber:p.number,failingChecks:y.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(_u({prNumber:p.number}));return}case"resolve-comments":{p&&E(pu({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=y,e[31]=k,e[32]=p,e[33]=E,e[34]=P):P=e[34];const I=P;let z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=o.jsx(lg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=z):z=e[35];const H=p?.number;let F;return e[36]!==y||e[37]!==k||e[38]!==I||e[39]!==E||e[40]!==H?(F=o.jsxs(o.Fragment,{children:[z,o.jsx(Sg,{button:y,isStreaming:k,onActivate:I,prNumber:H,send:E})]}),e[36]=y,e[37]=k,e[38]=I,e[39]=E,e[40]=H,e[41]=F):F=e[41],F}function Sg(t){const e=$.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(cg,{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($o,{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(xh,{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(ie,{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($o,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function $o(t){const e=$.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(Ue,{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(Ve,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Wc,{children:o.jsxs(We,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function yg(t){const e=$.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(hr.Right,{children:o.jsx(bg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Zt=B.createContext(null);function xn(){return B.use(Zt)}function Fo(t){const e=$.c(7),{children:s}=t,{taskId:i}=_t();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(Ne.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(ja,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Rt,{fallback:r,children:o.jsx(B.Suspense,{fallback:n,children:o.jsx(Ne.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Ho(t){const e=$.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],B.useLayoutEffect(r),null}function wg(t){const e=$.c(23),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:n,onToggleMain:a,onNewTask:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(sc,{size:20}),e[0]=h):h=e[0];let c;e[1]!==s?(c=o.jsx("button",{type:"button",onClick:s,className:"flex size-8 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:h}),e[1]=s,e[2]=c):c=e[2];let u;e[3]!==r||e[4]!==i?(u=o.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:o.jsx(Rl,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=u):u=e[5];const d=!n,f=n?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let _;e[6]!==f?(_=se("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",f),e[6]=f,e[7]=_):_=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx(na,{size:16}),e[8]=m):m=e[8];let p;e[9]!==a||e[10]!==d||e[11]!==_?(p=o.jsx("button",{type:"button",onClick:a,"aria-pressed":d,className:_,title:"Chat",children:m}),e[9]=a,e[10]=d,e[11]=_,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(tn,{size:16}),e[13]=g):g=e[13];let v;e[14]!==l?(v=o.jsx("button",{type:"button",onClick:l,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors",title:"New task",children:g}),e[14]=l,e[15]=v):v=e[15];let b;e[16]!==v||e[17]!==p?(b=o.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,v]}),e[16]=v,e[17]=p,e[18]=b):b=e[18];let S;return e[19]!==b||e[20]!==c||e[21]!==u?(S=o.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[c,u,b]}),e[19]=b,e[20]=c,e[21]=u,e[22]=S):S=e[22],S}function Wo(t){const e=$.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=pe(),{currentBranch:l}=_t(),{data:h}=Ci.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Pt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=$e(u),{mutate:f}=on(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=B.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:Cg}))}},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]),B.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Vu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function Cg(t){console.error("[auto-start-vm] failed:",t)}function kg(){const t=$.c(107),e=aa(),s=It(),{org:i}=pe(),r=Pc()?.tasksOpen??!1;Uc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Vl(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=Jr(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Mh(a.taskId??"",d),_=yt(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=_&&Ut(_),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=Ac(g,S),{setOpenMobile:C,openMobile:N}=zc(),w=C,j=B.useRef(null);let R,A;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const J=W=>{Oc(W)&&W.shiftKey&&W.code==="KeyS"&&!W.repeat&&(W.preventDefault(),j.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},A=[],t[12]=R,t[13]=A):(R=t[12],A=t[13]),B.useEffect(R,A);const D=d;let M;t[14]!==_||t[15]!==d?(M={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=M):M=t[16];const y=M;if(f.status==="creating"||f.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=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(Te,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let W;return t[18]!==y?(W=o.jsx(Zt,{value:y,children:J}),t[18]=y,t[19]=W):W=t[19],W}if(f.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let W;t[21]!==f.error.message?(W=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:[J,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=W):W=t[22];let L;return t[23]!==y||t[24]!==W?(L=o.jsx(Zt,{value:y,children:W}),t[23]=y,t[24]=W,t[25]=L):L=t[25],L}if(!_){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx(As,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const W=`The agent "${d}" does not exist in this organization.`;let L;t[27]!==s||t[28]!==l?(L=o.jsx(ie,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=L):L=t[29];let q;t[30]!==W||t[31]!==L?(q=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(Ls,{image:J,title:"Agent not found",description:W,actions:L})})}),t[30]=W,t[31]=L,t[32]=q):q=t[32];let X;return t[33]!==y||t[34]!==q?(X=o.jsx(Zt,{value:y,children:q}),t[33]=y,t[34]=q,t[35]=X):X=t[35],X}if(e){let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx($c,{className:"sr-only",children:"Navigation"}),t[36]=J):J=t[36];let W;t[37]!==w?(W=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(Bc,{onClose:()=>w(!1)})}),t[37]=w,t[38]=W):W=t[38];let L;t[39]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Lc,{})}),t[39]=L):L=t[39];let q;t[40]!==W?(q=o.jsxs(Fc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[J,o.jsxs("div",{className:"flex h-full",children:[W,L]})]}),t[40]=W,t[41]=q):q=t[41];let X;t[42]!==N||t[43]!==w||t[44]!==q?(X=o.jsx(Hc,{open:N,onOpenChange:w,children:q}),t[42]=N,t[43]=w,t[44]=q,t[45]=X):X=t[45];const Y=X,oe=_?.metadata?.vmMap;let K;t[46]!==x.createNewTask?(K=o.jsx(Ho,{onNewTaskRef:j,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=K):K=t[47];let V;t[48]!==w?(V=()=>w(!0),t[48]=w,t[49]=V):V=t[49];let ce;t[50]!==D||t[51]!==x.createNewTask||t[52]!==x.mainOpen||t[53]!==x.taskId||t[54]!==x.toggleMain||t[55]!==V?(ce=o.jsx(wg,{onOpenSidebar:V,virtualMcpId:D,taskId:x.taskId,mainOpen:x.mainOpen,onToggleMain:x.toggleMain,onNewTask:x.createNewTask}),t[50]=D,t[51]=x.createNewTask,t[52]=x.mainOpen,t[53]=x.taskId,t[54]=x.toggleMain,t[55]=V,t[56]=ce):ce=t[56];let ue;t[57]!==D||t[58]!==x.mainOpen||t[59]!==x.taskId?(ue=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:x.mainOpen?o.jsx(Rt,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(Te,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Tl,{taskId:x.taskId,virtualMcpId:D})})}):o.jsx(Fo,{})}),t[57]=D,t[58]=x.mainOpen,t[59]=x.taskId,t[60]=ue):ue=t[60];let he;t[61]!==b||t[62]!==Y||t[63]!==oe||t[64]!==K||t[65]!==ce||t[66]!==ue||t[67]!==d?(he=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:oe,children:[K,ce,ue,Y]}),t[61]=b,t[62]=Y,t[63]=oe,t[64]=K,t[65]=ce,t[66]=ue,t[67]=d,t[68]=he):he=t[68];let fe;t[69]!==D||t[70]!==he?(fe=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Ne.Provider,{virtualMcpId:D,children:he},D)}),t[69]=D,t[70]=he,t[71]=fe):fe=t[71];let me;return t[72]!==y||t[73]!==fe?(me=o.jsx(Zt,{value:y,children:fe}),t[72]=y,t[73]=fe,t[74]=me):me=t[74],me}const T=r?void 0:x.createNewTask;let E;t[75]!==x.chatOpen||t[76]!==x.toggleChat||t[77]!==T?(E=o.jsx(hr.Toggles,{children:o.jsx(tg,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:T})}),t[75]=x.chatOpen,t[76]=x.toggleChat,t[77]=T,t[78]=E):E=t[78];let k;t[79]!==x.taskId||t[80]!==d?(k=o.jsx(hr.Tabs,{children:o.jsx(Rl,{virtualMcpId:d,taskId:x.taskId})}),t[79]=x.taskId,t[80]=d,t[81]=k):k=t[81];const P=_?.metadata?.vmMap;let I;t[82]!==_?(I=o.jsx(yg,{virtualMcp:_}),t[82]=_,t[83]=I):I=t[83];let z;t[84]!==x.createNewTask?(z=o.jsx(Ho,{onNewTaskRef:j,createNewTask:x.createNewTask}),t[84]=x.createNewTask,t[85]=z):z=t[85];let H;t[86]===Symbol.for("react.memo_cache_sentinel")?(H=o.jsx(Fo,{}),t[86]=H):H=t[86];let F;t[87]!==x.chatOpen||t[88]!==x.mainOpen||t[89]!==x.taskId||t[90]!==d?(F=o.jsx(eg,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:H}),t[87]=x.chatOpen,t[88]=x.mainOpen,t[89]=x.taskId,t[90]=d,t[91]=F):F=t[91];let U;t[92]!==b||t[93]!==P||t[94]!==I||t[95]!==z||t[96]!==F||t[97]!==d?(U=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:P,children:[I,z,F]}),t[92]=b,t[93]=P,t[94]=I,t[95]=z,t[96]=F,t[97]=d,t[98]=U):U=t[98];let ee;t[99]!==D||t[100]!==k||t[101]!==U?(ee=o.jsxs(Ne.Provider,{virtualMcpId:D,children:[k,U]},D),t[99]=D,t[100]=k,t[101]=U,t[102]=ee):ee=t[102];let te;return t[103]!==y||t[104]!==E||t[105]!==ee?(te=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Zt,{value:y,children:[E,ee]})}),t[103]=y,t[104]=E,t[105]=ee,t[106]=te):te=t[106],te}function B1(){const t=$.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Te,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(kg,{})}),t[0]=e):e=t[0],e}export{B1 as default,xn as useInsetContext};
182
+ `);if(V.trim()){y(!0);try{X(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:V.length}),await m(["studio-automation-manager"]),f(!0),await _({tiptapDoc:Da({managerAgentId:Jo.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:V})})}finally{y(!1)}}},z=e.models?.tier??"smart",H=Ko({defaultValues:{name:e.name,active:e.active,tier:z}}),F=H.watch("active"),[U,ee]=B.useReducer(Hp,null),te=()=>{U!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(U.fields),save_count:U.saveCount,edit_duration_ms:Date.now()-U.start}),ee({type:"reset"}))},J=async()=>{const K=H.control._formState.dirtyFields,V=Object.keys(K);if(V.length===0&&!k)return!0;const ce=H.getValues(),ue=H.control._defaultValues;H.reset(ce,{keepValues:!0});const he=k;P(!1);const fe={id:t,name:ce.name,active:ce.active,models:{tier:ce.tier},messages:ec(b),temperature:0};try{await a.mutateAsync(fe)}catch{return H.reset(ue,{keepValues:!0}),he&&P(!0),!1}const me=[...V];return he&&me.push("messages"),ee({type:"accumulate",now:Date.now(),fields:me}),q(),!0},{schedule:W,flush:L}=pi({save:J}),{schedule:q,flush:X}=pi({delayMs:3e4,save:async()=>te()});B.useEffect(()=>{const K=H.watch(()=>W());return()=>K.unsubscribe()},[]);const Y=K=>{if(S(K),!T){E(!0);return}P(!0),W()},oe=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const K=await L();if(X(),!K)return;if(!b){_e.error("No instructions configured for this automation");return}d(H.getValues("tier")),f(!0),g({...p,toolApprovalLevel:"auto"});const V=Sn(b);u({message:{tiptapDoc:b,parts:V},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(ie,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(Na,{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(zt,{control:H.control,name:"name",render:({field:K})=>o.jsx(ms,{...K,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(ie,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(ur,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(zt,{control:H.control,name:"active",render:({field:K})=>o.jsx(dr,{checked:K.value,onCheckedChange:V=>{K.onChange(V),L()},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:F?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ha,{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(zp,{automationId:t,open:x,onOpenChange:C,onCustomSelect:()=>{w(!0),D(!1),R("")},onEventSelect:()=>{D(!0),w(!1)}})]}),e.triggers.length===0&&!N?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:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(K=>o.jsx($p,{trigger:K,automationId:t,connectionName:K.connection_id?c.get(K.connection_id):void 0},K.id))}),N&&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(Rs,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:j,onChange:K=>R(K.target.value),onBlur:async()=>{const K=j.trim();if(!(!K||!Is(K)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:K}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),_e.success("Starter added"),w(!1),R("")}catch{_e.error("Failed to add starter")}},onKeyDown:async K=>{const V=j.trim();K.key==="Enter"&&V&&Is(V)&&K.target.blur(),K.key==="Escape"&&(w(!1),R(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Is(j)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Te,{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:()=>{w(!1),R("")},children:o.jsx(as,{size:13})})]}),A&&o.jsx(B.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(Te,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Wp,{automationId:t,onDone:()=>D(!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(ie,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:M||!b,onClick:I,children:[o.jsx(wa,{size:13}),"Improve"]})]}),o.jsx(Yl,{tiptapDoc:b,setTiptapDoc:Y,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(Xl,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(Jl,{tier:H.watch("tier"),onSelect:K=>H.setValue("tier",K,{shouldDirty:!0})}),o.jsxs(We,{children:[o.jsx(Ue,{asChild:!0,children:o.jsxs(ie,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:oe,disabled:!r,children:[o.jsx(ac,{size:16}),"Test"]})}),o.jsx(Ve,{children:"Test Automation"})]})]})]})})]})]})]})}function Gp(t){const e=$.c(5),{tabId:s}=t;let i;e[0]!==s?(i=Qo(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(Te,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ot,{children:o.jsx(ot.Content,{children:o.jsx(ot.Body,{children:o.jsx(B.Suspense,{fallback:n,children:o.jsx(Yp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Yp(t){const e=$.c(8),{id:s}=t,i=It(),{data:r,isLoading:n}=kh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Xp,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(Te,{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(qp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Xp(t){return{...t,main:"automations"}}function Jp(t){const e=$.c(20),{virtualMcpId:s}=t,i=It(),{data:r}=Nh(s),n=r===void 0?[]:r,{create:a}=Ks(),[l,h]=B.useState(""),c=l.toLowerCase(),u=n.filter(A=>A.name.toLowerCase().includes(c));let d;e[0]!==i?(d=A=>i({to:".",search:D=>({...D,main:"automation:"+A}),replace:!0}),e[0]=i,e[1]=d):d=e[1];const f=d,_=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const A=await a.mutateAsync(Eh(s));f(A.id)},m=ot,p=ot,g=ot;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ot.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(Th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ls,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(ie,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let C;e[7]!==b||e[8]!==x?(C=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=C):C=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{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(ie,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(ls,{size:14}),"New automation"]})})}):u.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(A=>o.jsx(jh,{automation:A,onClick:()=>f(A.id)},A.id))});let w;e[10]!==N||e[11]!==g.Body||e[12]!==C?(w=o.jsxs(g.Body,{children:[C,N]}),e[10]=N,e[11]=g.Body,e[12]=C,e[13]=w):w=e[13];let j;e[14]!==w||e[15]!==p.Content?(j=o.jsx(p.Content,{children:w}),e[14]=w,e[15]=p.Content,e[16]=j):j=e[16];let R;return e[17]!==m||e[18]!==j?(R=o.jsx(m,{children:j}),e[17]=m,e[18]=j,e[19]=R):R=e[19],R}function Zp(t){const e=$.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(Te,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(B.Suspense,{fallback:i,children:o.jsx(Jp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Oo=B.lazy(()=>Wl(()=>import("./project-app-view-STAPzbR7.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,57])).then(t=>({default:t.AppViewContent})));function Tl(t){const e=$.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}=Ra(r);if(fc(n)){let m;return e[3]!==i?(m=o.jsx(Fn,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Tu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(Zp,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Ip,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(_f,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Gp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=mc(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(Te,{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(B.Suspense,{fallback:g,children:o.jsx(Oo,{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(Te,{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(B.Suspense,{fallback:m,children:o.jsx(Oo,{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(Fn,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function Qp(t){const e=$.c(7),{children:s,defaultSize:i}=t,[,r]=B.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Yo.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=Go(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(la,{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 eg(t){const e=$.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Rn(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=Yo.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=Go(c,45),d=B.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const A=d.current;if(!A)return;const D=Rn(r,n),M=D.chat>0&&D.chat<100?u:D.chat,y=D.chat>0&&D.chat<100?100-u:D.main;A.setLayout([M,y])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),B.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(ja,{}),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(Qp,{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(Yc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C={overflow:"visible"},e[18]=C):C=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=se("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 w;e[20]!==i||e[21]!==s?(w=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(Rt,{children:o.jsx(Tl,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=w):w=e[22];let j;e[23]!==h.main||e[24]!==w?(j=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:C,collapsible:!0,collapsedSize:0,minSize:20,children:w}),e[23]=h.main,e[24]=w,e[25]=j):j=e[25];let R;return e[26]!==j||e[27]!==m||e[28]!==b?(R=o.jsxs(Xc,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,j]},m),e[26]=j,e[27]=m,e[28]=b,e[29]=R):R=e[29],R}const ar="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",zo="bg-sidebar-accent text-sidebar-foreground",lr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function tg(t){const e=$.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Ic(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("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?zo:lr;let u;e[3]!==c?(u=se(ar,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Rc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(Ue,{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(Ve,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(We,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("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?zo:lr;let v;e[16]!==g?(v=se(ar,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(na,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ue,{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(Ve,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let C;e[24]!==S?(C=o.jsxs(We,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=C):C=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let w;e[26]!==N?(w=se("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=w):w=e[27];const j=!l,R=l?0:-1,A=!l,D=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let M;e[28]!==D?(M=se(ar,lr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",D),e[28]=D,e[29]=M):M=e[29];let y;e[30]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(tn,{size:16}),e[30]=y):y=e[30];let T;e[31]!==r||e[32]!==j||e[33]!==R||e[34]!==A||e[35]!==M?(T=o.jsx(Ue,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:j,tabIndex:R,"aria-hidden":A,className:M,children:y})}),e[31]=r,e[32]=j,e[33]=R,e[34]=A,e[35]=M,e[36]=T):T=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Ve,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let k;e[38]!==T?(k=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(We,{delayDuration:300,children:[T,E]})}),e[38]=T,e[39]=k):k=e[39];let P;e[40]!==w||e[41]!==k?(P=o.jsx("div",{className:w,children:k}),e[40]=w,e[41]=k,e[42]=P):P=e[42];let I;return e[43]!==C||e[44]!==P||e[45]!==m?(I=o.jsxs(o.Fragment,{children:[m,C,P]}),e[43]=C,e[44]=P,e[45]=m,e[46]=I):I=e[46],I}function sg(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 ig(t){const e=$.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=se("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(rg,{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 rg(t){const e=$.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(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function ng(t){const e=$.c(13),{overflow:s,onSelect:i}=t,[r,n]=B.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(Ws,{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(sa,{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(og,{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(Us,{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(Vs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function og(t){const e=$.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(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const ag=6;function Rl(t){const e=$.c(20),{virtualMcpId:s,taskId:i}=t,r=It();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}=Ra(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=_c({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:C}=sg(a,S,ag);d=C,u=N=>{const w=a.find(R=>R.id===N),j=S===N&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:w?.kind??null,was_active:j}),N==="automations"){const R=pc({activeTab:l,mainOpen:h});r({to:".",search:A=>({...A,main:R}),replace:!0});return}c(N)},f="flex items-center min-w-0 gap-0.5",_=x.map(N=>o.jsx(ig,{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(ng,{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 lg(t){const e=$.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=se("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(Ul,{"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 cg(t){const e=$.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(vu({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(gu({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(ie,{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(fr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(ns,{asChild:!0,children:o.jsx(ie,{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(os,{align:"end",children:o.jsx(St,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(rs,{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 hg=new Set(["failure","timed_out","cancelled","action_required"]);function dg(t){return t.status==="completed"&&hg.has(t.conclusion)}function ug(t){return t.status==="queued"||t.status==="in_progress"}function fg(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(dg).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(ug);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 mg(){const t=$.c(3),{lifecycle:e,branch:s}=Kt();let i;return t[0]!==s||t[1]!==e?(i=_g(e,s),t[0]=s,t[1]=e,t[2]=i):i=t[2],i}function _g(t,e){switch(t.phase){case"idle":return{kind:"initializing"};case"cloning":return{kind:"cloning"};case"clone-failed":return{kind:"clone-failed",error:t.error};case"checking-out":return{kind:"checking-out",to:t.to}}return e.kind==="ready"?e:{kind:"initializing"}}const pg=6e4,gg=3e4;function vg(t){const e=$.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=$e(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:pg,refetchIntervalInBackground:!1,staleTime:gg,select:xg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],fs(l)}function xg(t){const e=qs(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 bg(t){const e=$.c(42),{virtualMcpId:s}=t,{org:i}=pe(),r=yt(s),{currentBranch:n}=_t(),a=us(),l=r?.metadata?.githubRepo??null,h=mg(),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=Ia(_),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 C=Aa(x),N=l?.connectionId??"",w=l?.owner??"",j=l?.name??"",R=p&&p.state==="open"?p.number:null;let A;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==w||e[18]!==j||e[19]!==R?(A={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:w,repo:j,prNumber:R},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=w,e[18]=j,e[19]=R,e[20]=A):A=e[20];const D=vg(A);if(!l?.connectionId||!n)return null;let M;e[21]!==h||e[22]!==C.data||e[23]!==p||e[24]!==m.isPending||e[25]!==D.data?(M=fg({branchStatus:h,pr:p,checks:C.data??[],reviews:D.data??null,loading:m.isPending}),e[21]=h,e[22]=C.data,e[23]=p,e[24]=m.isPending,e[25]=D.data,e[26]=M):M=e[26];const y=M;let T;e[27]!==a?(T=U=>a.sendMessage({parts:[{type:"text",text:U}]}),e[27]=a,e[28]=T):T=e[28];const E=T,k=a.isStreaming;let P;e[29]!==n||e[30]!==y||e[31]!==k||e[32]!==p||e[33]!==E?(P=U=>{if(!k)switch(U){case"commit-and-push":{E(cu({branch:n}));return}case"create-pr":{E(hu({branch:n}));return}case"reopen":{p&&E(du({prNumber:p.number}));return}case"rebase":{E(uu({branch:n}));return}case"fix-checks":{p&&E(mu({prNumber:p.number,failingChecks:y.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(_u({prNumber:p.number}));return}case"resolve-comments":{p&&E(pu({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=y,e[31]=k,e[32]=p,e[33]=E,e[34]=P):P=e[34];const I=P;let z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=o.jsx(lg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=z):z=e[35];const H=p?.number;let F;return e[36]!==y||e[37]!==k||e[38]!==I||e[39]!==E||e[40]!==H?(F=o.jsxs(o.Fragment,{children:[z,o.jsx(Sg,{button:y,isStreaming:k,onActivate:I,prNumber:H,send:E})]}),e[36]=y,e[37]=k,e[38]=I,e[39]=E,e[40]=H,e[41]=F):F=e[41],F}function Sg(t){const e=$.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(cg,{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($o,{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(xh,{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(ie,{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($o,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function $o(t){const e=$.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(Ue,{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(Ve,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Wc,{children:o.jsxs(We,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function yg(t){const e=$.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(hr.Right,{children:o.jsx(bg,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Zt=B.createContext(null);function xn(){return B.use(Zt)}function Fo(t){const e=$.c(7),{children:s}=t,{taskId:i}=_t();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(Ne.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(ja,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Rt,{fallback:r,children:o.jsx(B.Suspense,{fallback:n,children:o.jsx(Ne.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Ho(t){const e=$.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],B.useLayoutEffect(r),null}function wg(t){const e=$.c(23),{onOpenSidebar:s,virtualMcpId:i,taskId:r,mainOpen:n,onToggleMain:a,onNewTask:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(sc,{size:20}),e[0]=h):h=e[0];let c;e[1]!==s?(c=o.jsx("button",{type:"button",onClick:s,className:"flex size-8 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:h}),e[1]=s,e[2]=c):c=e[2];let u;e[3]!==r||e[4]!==i?(u=o.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto [scrollbar-width:none]",children:o.jsx(Rl,{virtualMcpId:i,taskId:r})}),e[3]=r,e[4]=i,e[5]=u):u=e[5];const d=!n,f=n?"text-foreground/60 hover:bg-accent hover:text-foreground":"bg-accent text-foreground";let _;e[6]!==f?(_=se("flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",f),e[6]=f,e[7]=_):_=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx(na,{size:16}),e[8]=m):m=e[8];let p;e[9]!==a||e[10]!==d||e[11]!==_?(p=o.jsx("button",{type:"button",onClick:a,"aria-pressed":d,className:_,title:"Chat",children:m}),e[9]=a,e[10]=d,e[11]=_,e[12]=p):p=e[12];let g;e[13]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(tn,{size:16}),e[13]=g):g=e[13];let v;e[14]!==l?(v=o.jsx("button",{type:"button",onClick:l,className:"flex size-7 shrink-0 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors",title:"New task",children:g}),e[14]=l,e[15]=v):v=e[15];let b;e[16]!==v||e[17]!==p?(b=o.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[p,v]}),e[16]=v,e[17]=p,e[18]=b):b=e[18];let S;return e[19]!==b||e[20]!==c||e[21]!==u?(S=o.jsxs("div",{className:"shrink-0 flex items-center gap-1 px-2 h-12 bg-background border-b border-border",children:[c,u,b]}),e[19]=b,e[20]=c,e[21]=u,e[22]=S):S=e[22],S}function Wo(t){const e=$.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=pe(),{currentBranch:l}=_t(),{data:h}=Ci.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Pt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=$e(u),{mutate:f}=on(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=B.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:Cg}))}},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]),B.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Vu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function Cg(t){console.error("[auto-start-vm] failed:",t)}function kg(){const t=$.c(107),e=aa(),s=It(),{org:i}=pe(),r=Pc()?.tasksOpen??!1;Uc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Vl(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=Jr(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Mh(a.taskId??"",d),_=yt(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=_&&Ut(_),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=Ac(g,S),{setOpenMobile:C,openMobile:N}=zc(),w=C,j=B.useRef(null);let R,A;t[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const J=W=>{Oc(W)&&W.shiftKey&&W.code==="KeyS"&&!W.repeat&&(W.preventDefault(),j.current?.())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},A=[],t[12]=R,t[13]=A):(R=t[12],A=t[13]),B.useEffect(R,A);const D=d;let M;t[14]!==_||t[15]!==d?(M={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=M):M=t[16];const y=M;if(f.status==="creating"||f.status==="loading"){let J;t[17]===Symbol.for("react.memo_cache_sentinel")?(J=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(Te,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=J):J=t[17];let W;return t[18]!==y?(W=o.jsx(Zt,{value:y,children:J}),t[18]=y,t[19]=W):W=t[19],W}if(f.status==="error"){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=J):J=t[20];let W;t[21]!==f.error.message?(W=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:[J,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=W):W=t[22];let L;return t[23]!==y||t[24]!==W?(L=o.jsx(Zt,{value:y,children:W}),t[23]=y,t[24]=W,t[25]=L):L=t[25],L}if(!_){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx(As,{size:48,className:"text-muted-foreground"}),t[26]=J):J=t[26];const W=`The agent "${d}" does not exist in this organization.`;let L;t[27]!==s||t[28]!==l?(L=o.jsx(ie,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=L):L=t[29];let q;t[30]!==W||t[31]!==L?(q=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(Ls,{image:J,title:"Agent not found",description:W,actions:L})})}),t[30]=W,t[31]=L,t[32]=q):q=t[32];let X;return t[33]!==y||t[34]!==q?(X=o.jsx(Zt,{value:y,children:q}),t[33]=y,t[34]=q,t[35]=X):X=t[35],X}if(e){let J;t[36]===Symbol.for("react.memo_cache_sentinel")?(J=o.jsx($c,{className:"sr-only",children:"Navigation"}),t[36]=J):J=t[36];let W;t[37]!==w?(W=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(Bc,{onClose:()=>w(!1)})}),t[37]=w,t[38]=W):W=t[38];let L;t[39]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Lc,{})}),t[39]=L):L=t[39];let q;t[40]!==W?(q=o.jsxs(Fc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[J,o.jsxs("div",{className:"flex h-full",children:[W,L]})]}),t[40]=W,t[41]=q):q=t[41];let X;t[42]!==N||t[43]!==w||t[44]!==q?(X=o.jsx(Hc,{open:N,onOpenChange:w,children:q}),t[42]=N,t[43]=w,t[44]=q,t[45]=X):X=t[45];const Y=X,oe=_?.metadata?.vmMap;let K;t[46]!==x.createNewTask?(K=o.jsx(Ho,{onNewTaskRef:j,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=K):K=t[47];let V;t[48]!==w?(V=()=>w(!0),t[48]=w,t[49]=V):V=t[49];let ce;t[50]!==D||t[51]!==x.createNewTask||t[52]!==x.mainOpen||t[53]!==x.taskId||t[54]!==x.toggleMain||t[55]!==V?(ce=o.jsx(wg,{onOpenSidebar:V,virtualMcpId:D,taskId:x.taskId,mainOpen:x.mainOpen,onToggleMain:x.toggleMain,onNewTask:x.createNewTask}),t[50]=D,t[51]=x.createNewTask,t[52]=x.mainOpen,t[53]=x.taskId,t[54]=x.toggleMain,t[55]=V,t[56]=ce):ce=t[56];let ue;t[57]!==D||t[58]!==x.mainOpen||t[59]!==x.taskId?(ue=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:x.mainOpen?o.jsx(Rt,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong. Try refreshing."}),children:o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(Te,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(Tl,{taskId:x.taskId,virtualMcpId:D})})}):o.jsx(Fo,{})}),t[57]=D,t[58]=x.mainOpen,t[59]=x.taskId,t[60]=ue):ue=t[60];let he;t[61]!==b||t[62]!==Y||t[63]!==oe||t[64]!==K||t[65]!==ce||t[66]!==ue||t[67]!==d?(he=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:oe,children:[K,ce,ue,Y]}),t[61]=b,t[62]=Y,t[63]=oe,t[64]=K,t[65]=ce,t[66]=ue,t[67]=d,t[68]=he):he=t[68];let fe;t[69]!==D||t[70]!==he?(fe=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(Ne.Provider,{virtualMcpId:D,children:he},D)}),t[69]=D,t[70]=he,t[71]=fe):fe=t[71];let me;return t[72]!==y||t[73]!==fe?(me=o.jsx(Zt,{value:y,children:fe}),t[72]=y,t[73]=fe,t[74]=me):me=t[74],me}const T=r?void 0:x.createNewTask;let E;t[75]!==x.chatOpen||t[76]!==x.toggleChat||t[77]!==T?(E=o.jsx(hr.Toggles,{children:o.jsx(tg,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:T})}),t[75]=x.chatOpen,t[76]=x.toggleChat,t[77]=T,t[78]=E):E=t[78];let k;t[79]!==x.taskId||t[80]!==d?(k=o.jsx(hr.Tabs,{children:o.jsx(Rl,{virtualMcpId:d,taskId:x.taskId})}),t[79]=x.taskId,t[80]=d,t[81]=k):k=t[81];const P=_?.metadata?.vmMap;let I;t[82]!==_?(I=o.jsx(yg,{virtualMcp:_}),t[82]=_,t[83]=I):I=t[83];let z;t[84]!==x.createNewTask?(z=o.jsx(Ho,{onNewTaskRef:j,createNewTask:x.createNewTask}),t[84]=x.createNewTask,t[85]=z):z=t[85];let H;t[86]===Symbol.for("react.memo_cache_sentinel")?(H=o.jsx(Fo,{}),t[86]=H):H=t[86];let F;t[87]!==x.chatOpen||t[88]!==x.mainOpen||t[89]!==x.taskId||t[90]!==d?(F=o.jsx(eg,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:H}),t[87]=x.chatOpen,t[88]=x.mainOpen,t[89]=x.taskId,t[90]=d,t[91]=F):F=t[91];let U;t[92]!==b||t[93]!==P||t[94]!==I||t[95]!==z||t[96]!==F||t[97]!==d?(U=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:P,children:[I,z,F]}),t[92]=b,t[93]=P,t[94]=I,t[95]=z,t[96]=F,t[97]=d,t[98]=U):U=t[98];let ee;t[99]!==D||t[100]!==k||t[101]!==U?(ee=o.jsxs(Ne.Provider,{virtualMcpId:D,children:[k,U]},D),t[99]=D,t[100]=k,t[101]=U,t[102]=ee):ee=t[102];let te;return t[103]!==y||t[104]!==E||t[105]!==ee?(te=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Zt,{value:y,children:[E,ee]})}),t[103]=y,t[104]=E,t[105]=ee,t[106]=te):te=t[106],te}function B1(){const t=$.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(B.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Te,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(kg,{})}),t[0]=e):e=t[0],e}export{B1 as default,xn as useInsetContext};