decocms 2.300.1 → 2.300.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/client/assets/{AlertCircle-CtSiN7Dh.js → AlertCircle-CDtbI_oO.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-CjMD5YtT.js → ArrowNarrowLeft-CJ8McWmC.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-VGEco3p8.js → ArrowUpRight-CfmSEQdr.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-BOjQcSoZ.js → CheckCircle-BfnVNP63.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-B21GyFLP.js → ChevronDown-BKNJxAvQ.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-C7fFXCXU.js → ChevronRight-DmLVJ7rn.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-DLJe-Ifh.js → ChevronUp-CsX2yfUc.js} +1 -1
  8. package/dist/client/assets/{Container-DVwtR0PY.js → Container-DASuUdbK.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-_1yE4PFi.js → DotsVertical-CiluvdTj.js} +1 -1
  10. package/dist/client/assets/{LinkExternal01-BeNjIA73.js → LinkExternal01-CPmlMGsQ.js} +1 -1
  11. package/dist/client/assets/{Lock01-y9D26Lk9.js → Lock01-BjCX4hvk.js} +1 -1
  12. package/dist/client/assets/{Palette-xIvgAE_U.js → Palette-CmFr12m3.js} +1 -1
  13. package/dist/client/assets/{Play-esUCyQh5.js → Play-AcQdYeyW.js} +1 -1
  14. package/dist/client/assets/{Plus-8zlfW9Nb.js → Plus-DkESyBkp.js} +1 -1
  15. package/dist/client/assets/{RefreshCcw01-DV-_PfmV.js → RefreshCcw01-DLpzNYLg.js} +1 -1
  16. package/dist/client/assets/{SearchMd-BgpZuBQH.js → SearchMd-RHgmu5nb.js} +1 -1
  17. package/dist/client/assets/{Settings02-B2DHZxlV.js → Settings02-BgsL1r4k.js} +1 -1
  18. package/dist/client/assets/{Shield01-CewVSi37.js → Shield01-BndBIezR.js} +1 -1
  19. package/dist/client/assets/{Star01-DupDdRAe.js → Star01-CRQ6Bc0M.js} +1 -1
  20. package/dist/client/assets/{Sun-B1MYWGMj.js → Sun-DKXWmMuG.js} +1 -1
  21. package/dist/client/assets/{Tool01-73PH4njb.js → Tool01-CRyHj4QJ.js} +1 -1
  22. package/dist/client/assets/{Trash01-_-2EAUWH.js → Trash01-CfK96-qY.js} +1 -1
  23. package/dist/client/assets/{User01-DLnrd0WJ.js → User01-KY-MO20F.js} +1 -1
  24. package/dist/client/assets/{Users03-CtQ_adLe.js → Users03-BCFGwdah.js} +1 -1
  25. package/dist/client/assets/{X-DavTUkoo.js → X-ZLJ81KrS.js} +1 -1
  26. package/dist/client/assets/{XCircle-BKeTm8Ww.js → XCircle-B2dZZ7-3.js} +1 -1
  27. package/dist/client/assets/{XClose-BpjQA_dF.js → XClose-DXU_tOKb.js} +1 -1
  28. package/dist/client/assets/{Zap-DT_tBFfJ.js → Zap-25qc4enN.js} +1 -1
  29. package/dist/client/assets/{ZapSquare-BL-_ZEqM.js → ZapSquare-D6uI2CIK.js} +1 -1
  30. package/dist/client/assets/{accordion-pRq2Jalt.js → accordion-D3bxaM5e.js} +1 -1
  31. package/dist/client/assets/{agent-icon-DnE1m294.js → agent-icon-Y41Xl4RB.js} +1 -1
  32. package/dist/client/assets/{agents-list-BoAFCp78.js → agents-list-mS9MVQZN.js} +1 -1
  33. package/dist/client/assets/ai-providers-BRoGM2rY.js +1 -0
  34. package/dist/client/assets/ai-providers-logos-DD3qZ33J.js +1 -0
  35. package/dist/client/assets/{alert-dialog-DvcLf48w.js → alert-dialog-DnoDZh7l.js} +1 -1
  36. package/dist/client/assets/{auth-catchall-CAJD1PoQ.js → auth-catchall-BoFlqYg1.js} +1 -1
  37. package/dist/client/assets/{automation-list-row-DsEcFwqj.js → automation-list-row-CAHW7UMQ.js} +1 -1
  38. package/dist/client/assets/{automations-0IJqtFMr.js → automations-PZEFUnMk.js} +1 -1
  39. package/dist/client/assets/{avatar-B1YFr91G.js → avatar-C1td1Be6.js} +1 -1
  40. package/dist/client/assets/{badge-BnwDLyJj.js → badge-BQ5WsTn4.js} +1 -1
  41. package/dist/client/assets/{brand-context-D5_IL-aX.js → brand-context-DIIOMD2x.js} +1 -1
  42. package/dist/client/assets/{card-Hve9iIpZ.js → card-DQYOkC6d.js} +1 -1
  43. package/dist/client/assets/{chat-context-C2vjARhO.js → chat-context-hgW5gAmm.js} +1 -1
  44. package/dist/client/assets/{checkbox-DmWLCJJH.js → checkbox-DkmOdGV4.js} +1 -1
  45. package/dist/client/assets/{collection-detail-D8wvqyeL.js → collection-detail-tXsv3iGO.js} +1 -1
  46. package/dist/client/assets/{collection-display-button-CQ2KlZSu.js → collection-display-button-8PlYmXiO.js} +1 -1
  47. package/dist/client/assets/{collection-search-DffILLk0.js → collection-search-B7ehvlGW.js} +1 -1
  48. package/dist/client/assets/{collection-search-D_mJKf_N.js → collection-search-CqdVjZKz.js} +1 -1
  49. package/dist/client/assets/{collection-table-wrapper-fO254CQy.js → collection-table-wrapper-DtBSTmHD.js} +1 -1
  50. package/dist/client/assets/{collection-tabs-Bcs-_tfj.js → collection-tabs-BymkuH-J.js} +1 -1
  51. package/dist/client/assets/{collections-CISD8jzc.js → collections-DusXIGhy.js} +1 -1
  52. package/dist/client/assets/{command-CsVFknP_.js → command-BCmTpu4J.js} +1 -1
  53. package/dist/client/assets/{connection-card-aTu5Xl4N.js → connection-card-Bfng1y5O.js} +1 -1
  54. package/dist/client/assets/{connection-detail-BUr0xwe0.js → connection-detail-BvkQKjE1.js} +1 -1
  55. package/dist/client/assets/{connection-form-helpers-BEHWki2e.js → connection-form-helpers-DmVfKyR2.js} +1 -1
  56. package/dist/client/assets/{connections-BJwQ4V76.js → connections-BOpJFAVW.js} +1 -1
  57. package/dist/client/assets/{constants-DZ5y4NEu.js → constants-Da2DvZbd.js} +1 -1
  58. package/dist/client/assets/{constants-BwurOShK.js → constants-Dm-yPW31.js} +1 -1
  59. package/dist/client/assets/{dialog-BSlhJimL.js → dialog-D0LCITx0.js} +1 -1
  60. package/dist/client/assets/{domain-settings-D65HSgmV.js → domain-settings-D2GqzT5W.js} +1 -1
  61. package/dist/client/assets/{drawer-DwurUbp0.js → drawer-DWuqMoty.js} +1 -1
  62. package/dist/client/assets/{dropdown-menu-Dn3K1Gpo.js → dropdown-menu-BooeaeZW.js} +1 -1
  63. package/dist/client/assets/{dynamic-plugin-layout-uzPcJgAD.js → dynamic-plugin-layout-BBI0fzcH.js} +1 -1
  64. package/dist/client/assets/{empty-state-B4R6bbr3.js → empty-state-DtXUXgFg.js} +1 -1
  65. package/dist/client/assets/{empty-state-DbgILpoj.js → empty-state-V_MWZYVh.js} +1 -1
  66. package/dist/client/assets/{extract-connection-data-Bp5NDOhQ.js → extract-connection-data-JkyrF-5k.js} +1 -1
  67. package/dist/client/assets/{features-MuQDQTKd.js → features-BRMl1rr6.js} +1 -1
  68. package/dist/client/assets/{form-DTt4fIHo.js → form-3xE0OqGj.js} +1 -1
  69. package/dist/client/assets/{general-C7YvzevF.js → general-CkXiaAh9.js} +1 -1
  70. package/dist/client/assets/{index-DRnP8Xhy.js → index-BOmAbn3-.js} +2 -2
  71. package/dist/client/assets/{index-CbEM9IOV.js → index-BSli4TIm.js} +1 -1
  72. package/dist/client/assets/{index-Day-HjXR.js → index-BUabcSp1.js} +1 -1
  73. package/dist/client/assets/{index-D1LVHcIe.js → index-BXOHXvkd.js} +1 -1
  74. package/dist/client/assets/{index-uTtq-reU.js → index-Bh9ip1xM.js} +1 -1
  75. package/dist/client/assets/{index-COQkJrV6.js → index-By-OUdid.js} +1 -1
  76. package/dist/client/assets/{index-h0Ny6VA2.js → index-C2XzR7MH.js} +1 -1
  77. package/dist/client/assets/index-CUHQFzXU.js +1 -0
  78. package/dist/client/assets/{index-DHKldY3y.js → index-CdUEwHcT.js} +1 -1
  79. package/dist/client/assets/{index-BZwRn_mX.js → index-Cm97pdLv.js} +1 -1
  80. package/dist/client/assets/{index-ygN6PiaU.js → index-D1vwSlce.js} +1 -1
  81. package/dist/client/assets/{index-XlHohbXo.js → index-D2cvrx8-.js} +1 -1
  82. package/dist/client/assets/{index-DBY00Q2Z.js → index-Db1yn84L.js} +3 -3
  83. package/dist/client/assets/{index-BJz9Oj-t.js → index-DcLrVfh1.js} +1 -1
  84. package/dist/client/assets/{index-BTM4S0x-.js → index-DqWkjFjy.js} +1 -1
  85. package/dist/client/assets/{index-D9wcQMm5.js → index-oZ72eHkF.js} +1 -1
  86. package/dist/client/assets/{infiniteQueryObserver-BFZ15R1_.js → infiniteQueryObserver-ruN3KSWZ.js} +1 -1
  87. package/dist/client/assets/{input-liZY-axz.js → input-DFMPKZJm.js} +1 -1
  88. package/dist/client/assets/{integration-icon-Cz-seBmA.js → integration-icon-Bu4bZk46.js} +1 -1
  89. package/dist/client/assets/{label-CrXFAdsO.js → label-DZwWOqq7.js} +1 -1
  90. package/dist/client/assets/{layout-bMTJXFfz.js → layout-DktxHUWV.js} +1 -1
  91. package/dist/client/assets/{lean-canvas-recruit-modal-DZ6knxg9.js → lean-canvas-recruit-modal-KLORFsWq.js} +1 -1
  92. package/dist/client/assets/{login-CWW3hrOg.js → login-Qjtx70Ay.js} +1 -1
  93. package/dist/client/assets/{members-DKWnDmHd.js → members-CB5ygrXY.js} +1 -1
  94. package/dist/client/assets/{monaco-editor-Cx68yuxi.js → monaco-editor-BMXf_ICC.js} +1 -1
  95. package/dist/client/assets/{monitoring-stats-row-BFqk7UYd.js → monitoring-stats-row-hB6Djn4O.js} +1 -1
  96. package/dist/client/assets/{oauth-callback-nz50ugwL.js → oauth-callback-Cgk_ji97.js} +1 -1
  97. package/dist/client/assets/{oauth-callback-ai-provider-ONRq40Il.js → oauth-callback-ai-provider-BWQb53Zq.js} +1 -1
  98. package/dist/client/assets/{onboarding-CbZyKtbC.js → onboarding-BJq0uANa.js} +1 -1
  99. package/dist/client/assets/{org-layout-DkS2FRIV.js → org-layout-BOmngSEh.js} +1 -1
  100. package/dist/client/assets/{org-plugin-layout-DnoycXXu.js → org-plugin-layout-DYC_-fTx.js} +1 -1
  101. package/dist/client/assets/{pair-rqe3skqp.js → pair-Ds1EbiW2.js} +1 -1
  102. package/dist/client/assets/{plugin-empty-state-DAJtqa_X.js → plugin-empty-state-D34qTA46.js} +1 -1
  103. package/dist/client/assets/{plugin-header-DnTysGuR.js → plugin-header-D19z2yPe.js} +1 -1
  104. package/dist/client/assets/{plugin-layout-Zl5kAJLg.js → plugin-layout-DBmHNWl4.js} +1 -1
  105. package/dist/client/assets/{popover-B6ijC2Zf.js → popover-Cvs9u_0D.js} +1 -1
  106. package/dist/client/assets/{profile-Wj3GJkbr.js → profile-_mVuN_Pw.js} +1 -1
  107. package/dist/client/assets/{project-app-view-DufFnF1s.js → project-app-view-BWTIFTZt.js} +1 -1
  108. package/dist/client/assets/registry-BYjdxPj0.js +2 -0
  109. package/dist/client/assets/{registry-layout-BvfKYFzg.js → registry-layout-BiMLaZ5I.js} +1 -1
  110. package/dist/client/assets/{required-auth-layout-CKQlCfyf.js → required-auth-layout-CGJ5rk5i.js} +1 -1
  111. package/dist/client/assets/{reset-password-4dmtvYgx.js → reset-password-CaWZrhgz.js} +1 -1
  112. package/dist/client/assets/{roles-DlsIbipv.js → roles-ychtuZ_l.js} +1 -1
  113. package/dist/client/assets/{scroll-area-D_0eTXQI.js → scroll-area-DaS5ALMq.js} +1 -1
  114. package/dist/client/assets/{search-input-CbBz2_I7.js → search-input-C4vXNPxO.js} +1 -1
  115. package/dist/client/assets/{select-DwQCWni4.js → select-Czs_bVht.js} +1 -1
  116. package/dist/client/assets/{select-model-CSzGroxj.js → select-model-BAqBST4u.js} +1 -1
  117. package/dist/client/assets/{settings-layout-D2TzHadG.js → settings-layout-CKeL2zhm.js} +1 -1
  118. package/dist/client/assets/{settings-section-CVNbjkC4.js → settings-section-D1IZyeMZ.js} +1 -1
  119. package/dist/client/assets/{shell-layout-BK74oWLU.js → shell-layout-C3cZnoYI.js} +1 -1
  120. package/dist/client/assets/{skeleton-DnMJGIDK.js → skeleton-DFL6A56z.js} +1 -1
  121. package/dist/client/assets/{sso-ByZblLmU.js → sso-C4f0AfMQ.js} +1 -1
  122. package/dist/client/assets/{store-D02KrT4m.js → store-CEIp74Dt.js} +1 -1
  123. package/dist/client/assets/store-registry-B0W6zcCj.js +2 -0
  124. package/dist/client/assets/{switch-BwYbkaPM.js → switch-CgZ8SLcM.js} +1 -1
  125. package/dist/client/assets/{table-dOL69UsN.js → table-bZ3KC8o2.js} +1 -1
  126. package/dist/client/assets/{tabs-CGg7lV45.js → tabs-CQg6na0A.js} +1 -1
  127. package/dist/client/assets/{task-status-DAgh3LfT.js → task-status-ZLGfD6LC.js} +1 -1
  128. package/dist/client/assets/{textarea-CkxfQbxI.js → textarea-dZeCqaKZ.js} +1 -1
  129. package/dist/client/assets/{toggle-group-C5VhmQig.js → toggle-group-BWbe6Sle.js} +1 -1
  130. package/dist/client/assets/{tools-list-CwM3RxlF.js → tools-list-Cs00fcMQ.js} +1 -1
  131. package/dist/client/assets/{tooltip-CUw8WpYG.js → tooltip-f4eQJmkn.js} +1 -1
  132. package/dist/client/assets/{types-slR7lXH6.js → types-BxKF_I-u.js} +1 -1
  133. package/dist/client/assets/{use-ai-providers-DespFg1Y.js → use-ai-providers-CTaSMN44.js} +1 -1
  134. package/dist/client/assets/{use-collections-CDG0ivO9.js → use-collections-ciAA_3Td.js} +1 -1
  135. package/dist/client/assets/{use-connection-DDedfw7l.js → use-connection-DcySEqVV.js} +1 -1
  136. package/dist/client/assets/{use-copy-Czy0YFNn.js → use-copy-VDNca3ax.js} +1 -1
  137. package/dist/client/assets/{use-create-virtual-mcp-Bhi93QNY.js → use-create-virtual-mcp-BosIHDl_.js} +1 -1
  138. package/dist/client/assets/{use-decopilot-events-DkzJQYGR.js → use-decopilot-events-CJG2rWbg.js} +1 -1
  139. package/dist/client/assets/{use-delete-connection-CG2J3Cjn.js → use-delete-connection-BHdNUeNC.js} +1 -1
  140. package/dist/client/assets/{use-infinite-scroll-qjXoMT8U.js → use-infinite-scroll-Cd7090oj.js} +1 -1
  141. package/dist/client/assets/{use-list-state-D2VmPCpI.js → use-list-state-B_mnqmDh.js} +1 -1
  142. package/dist/client/assets/{use-mcp-tools-nd8RTEJZ.js → use-mcp-tools-C9cj3BH6.js} +1 -1
  143. package/dist/client/assets/{use-members-BWz4qY4v.js → use-members-YqP0IEDf.js} +1 -1
  144. package/dist/client/assets/{use-navigate-to-agent-Dj0boPYr.js → use-navigate-to-agent-KmcfdsLb.js} +1 -1
  145. package/dist/client/assets/{use-org-auth-client-_7iLBAbg.js → use-org-auth-client-DKAFGF5X.js} +1 -1
  146. package/dist/client/assets/{use-org-sso-CXTYwYuw.js → use-org-sso-BUVEFfyx.js} +1 -1
  147. package/dist/client/assets/{use-organization-roles-BmJJrwum.js → use-organization-roles-BY88cyRn.js} +1 -1
  148. package/dist/client/assets/{use-organization-settings-C516uAxZ.js → use-organization-settings-BrpxY44K.js} +1 -1
  149. package/dist/client/assets/{use-registry-connections-BH65PVKK.js → use-registry-connections-C5Res-NO.js} +1 -1
  150. package/dist/client/assets/{use-status-sounds-COJng9ez.js → use-status-sounds-DF_LdFlX.js} +1 -1
  151. package/dist/client/assets/{use-tasks-BMtiaufW.js → use-tasks-DjQnA3sr.js} +1 -1
  152. package/dist/client/assets/{use-view-mode-B3HPjSsa.js → use-view-mode-pmOkpC-l.js} +1 -1
  153. package/dist/client/assets/{use-virtual-mcp-Dkco3wCF.js → use-virtual-mcp-D8YFOZwW.js} +1 -1
  154. package/dist/client/assets/useInfiniteQuery-z1Rh4SPR.js +1 -0
  155. package/dist/client/assets/useSuspenseInfiniteQuery-DmArxoRp.js +1 -0
  156. package/dist/client/assets/{user-BCVAIUhB.js → user-BG2r6Yob.js} +1 -1
  157. package/dist/client/assets/{view-mode-toggle-Bbj9P-zr.js → view-mode-toggle-iIz_yTY4.js} +1 -1
  158. package/dist/client/assets/workflow-detail-hy-jKDKn.js +1 -0
  159. package/dist/client/assets/{workflow-DZKRFLJh.js → workflow-w5_7cK4m.js} +1 -1
  160. package/dist/client/index.html +1 -1
  161. package/dist/server/cli.js +1 -1
  162. package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
  163. package/dist/server/node_modules/ansi-styles/index.js +223 -0
  164. package/dist/server/node_modules/ansi-styles/license +9 -0
  165. package/dist/server/node_modules/ansi-styles/package.json +54 -0
  166. package/dist/server/node_modules/ansi-styles/readme.md +173 -0
  167. package/dist/server/node_modules/environment/index.d.ts +74 -0
  168. package/dist/server/node_modules/environment/index.js +47 -0
  169. package/dist/server/node_modules/environment/license +9 -0
  170. package/dist/server/node_modules/environment/package.json +74 -0
  171. package/dist/server/node_modules/environment/readme.md +94 -0
  172. package/dist/server/node_modules/escape-string-regexp/index.d.ts +18 -0
  173. package/dist/server/node_modules/escape-string-regexp/index.js +11 -0
  174. package/dist/server/node_modules/escape-string-regexp/license +9 -0
  175. package/dist/server/node_modules/escape-string-regexp/package.json +43 -0
  176. package/dist/server/node_modules/escape-string-regexp/readme.md +29 -0
  177. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  178. package/dist/server/node_modules/is-fullwidth-code-point/index.js +12 -0
  179. package/dist/server/node_modules/is-fullwidth-code-point/license +9 -0
  180. package/dist/server/node_modules/is-fullwidth-code-point/package.json +53 -0
  181. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +31 -0
  182. package/dist/server/node_modules/string-width/index.d.ts +39 -0
  183. package/dist/server/node_modules/string-width/index.js +82 -0
  184. package/dist/server/node_modules/string-width/license +9 -0
  185. package/dist/server/node_modules/string-width/package.json +64 -0
  186. package/dist/server/node_modules/string-width/readme.md +66 -0
  187. package/package.json +1 -1
  188. package/dist/client/assets/ai-providers-CAEYBEbx.js +0 -1
  189. package/dist/client/assets/ai-providers-logos-D6a8kmGH.js +0 -1
  190. package/dist/client/assets/index-CKNbLfs9.js +0 -1
  191. package/dist/client/assets/registry-D49ZAHvu.js +0 -2
  192. package/dist/client/assets/store-registry-C02mfQOQ.js +0 -2
  193. package/dist/client/assets/useInfiniteQuery-mbgOLEDd.js +0 -1
  194. package/dist/client/assets/useSuspenseInfiniteQuery-DZGLPMRe.js +0 -1
  195. package/dist/client/assets/workflow-detail-Bm0PdrL9.js +0 -1
  196. package/dist/server/node_modules/xtend/.jshintrc +0 -30
  197. package/dist/server/node_modules/xtend/LICENSE +0 -20
  198. package/dist/server/node_modules/xtend/README.md +0 -32
  199. package/dist/server/node_modules/xtend/immutable.js +0 -19
  200. package/dist/server/node_modules/xtend/mutable.js +0 -17
  201. package/dist/server/node_modules/xtend/package.json +0 -55
  202. package/dist/server/node_modules/xtend/test.js +0 -103
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DufFnF1s.js","assets/index-DRnP8Xhy.js","assets/index-B4J1yAvl.css","assets/pair-rqe3skqp.js","assets/agent-icon-DnE1m294.js","assets/AlertCircle-CtSiN7Dh.js","assets/Tool01-73PH4njb.js","assets/XClose-BpjQA_dF.js","assets/RefreshCcw01-DV-_PfmV.js","assets/ArrowNarrowLeft-CjMD5YtT.js","assets/XCircle-BKeTm8Ww.js","assets/ArrowUpRight-VGEco3p8.js","assets/ZapSquare-BL-_ZEqM.js","assets/Users03-CtQ_adLe.js","assets/CheckCircle-BOjQcSoZ.js","assets/ChevronDown-B21GyFLP.js","assets/ChevronRight-C7fFXCXU.js","assets/ChevronUp-DLJe-Ifh.js","assets/DotsVertical-_1yE4PFi.js","assets/Container-DVwtR0PY.js","assets/Star01-DupDdRAe.js","assets/Palette-xIvgAE_U.js","assets/SearchMd-BgpZuBQH.js","assets/index-D1LVHcIe.js","assets/tooltip-CUw8WpYG.js","assets/X-DavTUkoo.js","assets/LinkExternal01-BeNjIA73.js","assets/Lock01-y9D26Lk9.js","assets/Sun-B1MYWGMj.js","assets/Play-esUCyQh5.js","assets/Plus-8zlfW9Nb.js","assets/Settings02-B2DHZxlV.js","assets/Shield01-CewVSi37.js","assets/Trash01-_-2EAUWH.js","assets/User01-DLnrd0WJ.js","assets/Zap-DT_tBFfJ.js","assets/index-COQkJrV6.js","assets/use-copy-Czy0YFNn.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-BSlhJimL.js","assets/content-blocks-o63cs2vh.js","assets/types-slR7lXH6.js","assets/constants-DZ5y4NEu.js","assets/chat-context-C2vjARhO.js","assets/use-virtual-mcp-Dkco3wCF.js","assets/use-collections-CDG0ivO9.js","assets/use-ai-providers-DespFg1Y.js","assets/use-decopilot-events-DkzJQYGR.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-BMtiaufW.js","assets/use-organization-settings-C516uAxZ.js","assets/shell-layout-BK74oWLU.js","assets/required-auth-layout-CKQlCfyf.js","assets/use-org-sso-CXTYwYuw.js","assets/integration-icon-Cz-seBmA.js","assets/use-mcp-tools-nd8RTEJZ.js"])))=>i.map(i=>d[i]);
2
- import{o as Ht,r as A,p as jl,q as El,e as V,s as ye,K as As,n as Wo,a as Uo,c as te,j as o,l as Me,B as se,E as Qt,b as Si,v as ni,f as Mt,d as Yr,w as Tl,x as me,y as Rl,V as Dl,t as Se,z as Vo,C as Ml,D as Xt,F as Il,G as vn,L as Bl,H as Ai,I as Js,J as ct,M as Ko,P as Al,_ as Pl,Q as qo,R as Go,T as Ll,g as Ol}from"./index-DRnP8Xhy.js";import{C as je,u as zl,w as $l,A as Fl,T as Hl,a as Wl}from"./index-DHKldY3y.js";import{I as ds}from"./integration-icon-Cz-seBmA.js";import{S as It,u as Fe,g as Yo,a as Xo}from"./constants-DZ5y4NEu.js";import{u as gt,a as Ul}from"./use-virtual-mcp-Dkco3wCF.js";import{a as Vl}from"./Users03-CtQ_adLe.js";import{u as Jo,a as lt,b as yi,c as wi,t as Kl,d as xn}from"./chat-context-C2vjARhO.js";import{i as as}from"./AlertCircle-CtSiN7Dh.js";import{i as ql}from"./CheckCircle-BOjQcSoZ.js";import{n as bn,a as Gl}from"./ZapSquare-BL-_ZEqM.js";import{i as Yl,a as Xl,b as Jl,c as Ci,d as Zl}from"./XCircle-BKeTm8Ww.js";import{s as ls,i as Ql}from"./XClose-BpjQA_dF.js";import{c as ec,r as tc,p as Zo,f as Sn,a as sc,F as ic,t as yn,M as Xr,G as Qo,L as rc,i as nc,b as oc,d as ac,e as lc}from"./pair-rqe3skqp.js";import{C as cc,a as wn,b as Cn,c as hc,d as dc,e as uc,f as fc}from"./command-CsVFknP_.js";import{P as Hs,a as Ws,b as Us}from"./popover-B6ijC2Zf.js";import{i as Rs,a as mi,b as mc,c as _c,p as ki,g as Ni,d as Jr,e as ea,h as ar,f as Pi,j as kn,A as Nn,k as ta,l as pc,m as gc,n as vc,t as xc,o as bc,q as sa,r as ia,s as ra,u as na,v as jn,w as Sc,x as Ds,y as yc,z as wc,B as Cc,C as oa}from"./agent-icon-DnE1m294.js";import{u as us,a as kc}from"./use-mcp-tools-nd8RTEJZ.js";import{u as Nc,a as jc}from"./use-ai-providers-DespFg1Y.js";import{g as Bt,c as En,u as Ec,b as lr,d as Tc,e as Rc,f as Dc,T as Mc}from"./index-BJz9Oj-t.js";import{u as Zr,i as Ic}from"./shell-layout-BK74oWLU.js";import{i as Bc,P as at,u as Ac,c as Pc,d as Lc,e as Oc}from"./index-D1LVHcIe.js";import{u as aa,T as Ve,a as Ke,b as qe,c as zc}from"./tooltip-CUw8WpYG.js";import{u as $c}from"./use-status-sounds-COJng9ez.js";import{E as Ps}from"./empty-state-DbgILpoj.js";import{A as Fc,a as Hc,b as Wc,c as Uc,R as la,d as Vc,e as Kc}from"./accordion-pRq2Jalt.js";import{u as ji,a as Qr,b as qc}from"./use-connection-DDedfw7l.js";import{g as Gc}from"./constants-BwurOShK.js";import{u as Yc,g as Xc}from"./types-slR7lXH6.js";import{U as ca}from"./user-BCVAIUhB.js";import{T as Jc,u as ha}from"./tools-list-CwM3RxlF.js";import{u as Li}from"./unwrap-tool-result-BYXdCQMg.js";import{s as da,g as Zc}from"./connection-slug-eyAPH6o3.js";import{A as ua,a as fa,b as ma,c as _a,d as pa,e as ga,f as va,g as xa}from"./alert-dialog-DvcLf48w.js";import{D as Qc,a as en,b as tn,c as ba,d as Sa}from"./dialog-BSlhJimL.js";import{C as eh,a as Tn}from"./card-Hve9iIpZ.js";import{I as fs}from"./input-liZY-axz.js";import{L as Ms}from"./label-CrXFAdsO.js";import{S as es,a as ts,b as ss,c as is,d as Dt}from"./select-DwQCWni4.js";import{S as cr}from"./switch-BwYbkaPM.js";import{T as Rn}from"./textarea-CkxfQbxI.js";import{i as oi}from"./Play-esUCyQh5.js";import{s as cs}from"./Plus-8zlfW9Nb.js";import{a as th}from"./Settings02-B2DHZxlV.js";import{t as ya}from"./Tool01-73PH4njb.js";import{s as hr}from"./Trash01-_-2EAUWH.js";import{S as wa}from"./scroll-area-D_0eTXQI.js";import{i as Ca,a as sh}from"./SearchMd-BgpZuBQH.js";import{C as ih}from"./collection-tabs-Bcs-_tfj.js";import{C as rh}from"./checkbox-DmWLCJJH.js";import{u as nh,T as Oi,a as oh,b as ah,c as zi}from"./tabs-CGg7lV45.js";import{D as lh,a as ch,b as hh}from"./drawer-DwurUbp0.js";import{i as Ei,t as dr}from"./ChevronDown-B21GyFLP.js";import{n as Wt}from"./LinkExternal01-BeNjIA73.js";import{S as dh}from"./index-COQkJrV6.js";import{D as rs,a as ns,b as os,c as yt,d as uh,e as fh,f as mh}from"./dropdown-menu-Dn3K1Gpo.js";import{i as ka}from"./RefreshCcw01-DV-_PfmV.js";import{V as _h}from"./view-mode-toggle-Bbj9P-zr.js";import{G as ph}from"./lean-canvas-recruit-modal-DZ6knxg9.js";import{M as gh}from"./select-model-CSzGroxj.js";import{u as Vs,a as vh,b as xh,c as bh,A as Sh,d as yh}from"./automation-list-row-DsEcFwqj.js";import{i as Ls}from"./Zap-DT_tBFfJ.js";import{S as wh}from"./search-input-CbBz2_I7.js";import"./use-navigate-to-agent-Dj0boPYr.js";import"./use-tasks-BMtiaufW.js";import"./use-collections-CDG0ivO9.js";import"./collection-search-D_mJKf_N.js";import"./form-DTt4fIHo.js";import"./Star01-DupDdRAe.js";import"./Lock01-y9D26Lk9.js";import"./X-DavTUkoo.js";import"./toggle-group-C5VhmQig.js";import"./index-BTM4S0x-.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-D6a8kmGH.js";import"./connection-card-aTu5Xl4N.js";import"./use-registry-connections-BH65PVKK.js";import"./use-organization-settings-C516uAxZ.js";import"./useInfiniteQuery-mbgOLEDd.js";import"./infiniteQueryObserver-BFZ15R1_.js";import"./extract-connection-data-Bp5NDOhQ.js";import"./Container-DVwtR0PY.js";import"./connection-form-helpers-BEHWki2e.js";import"./use-infinite-scroll-qjXoMT8U.js";import"./useSuspenseInfiniteQuery-DZGLPMRe.js";import"./badge-BnwDLyJj.js";import"./ChevronRight-C7fFXCXU.js";import"./use-decopilot-events-DkzJQYGR.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-Czy0YFNn.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-B1MYWGMj.js";import"./index-BZwRn_mX.js";import"./ArrowNarrowLeft-CjMD5YtT.js";import"./ArrowUpRight-VGEco3p8.js";import"./ChevronUp-DLJe-Ifh.js";import"./DotsVertical-_1yE4PFi.js";import"./Palette-xIvgAE_U.js";import"./Shield01-CewVSi37.js";import"./User01-DLnrd0WJ.js";import"./skeleton-DnMJGIDK.js";import"./avatar-B1YFr91G.js";import"./index-D9wcQMm5.js";import"./collection-search-DffILLk0.js";import"./use-create-virtual-mcp-Bhi93QNY.js";import"./task-status-DAgh3LfT.js";import"./required-auth-layout-CKQlCfyf.js";import"./use-org-sso-CXTYwYuw.js";import"./collections-CISD8jzc.js";import"./settings-section-CVNbjkC4.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Ch(t,e){const s=Ht(e);return kh({filters:{...t,status:"pending"}},s).length}function Dn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function kh(t={},e){const s=Ht(e).getMutationCache(),i=A.useRef(t),r=A.useRef(null);return r.current===null&&(r.current=Dn(s,t)),A.useEffect(()=>{i.current=t}),A.useSyncExternalStore(A.useCallback(n=>s.subscribe(()=>{const a=jl(r.current,Dn(s,i.current));r.current!==a&&(r.current=a,El.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Nh(t,e){const s=V.c(39),{org:i,locator:r}=ye();let n;s[0]!==i.id?(n={connectionId:It,orgId:i.id},s[0]=i.id,s[1]=n):n=s[1];const a=Fe(n),l=Ht();let h;s[2]!==t||s[3]!==i.id?(h=As.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=h):h=s[4];let c;s[5]!==a||s[6]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=c):c=s[7];const d=t.length>0;let u;s[8]!==h||s[9]!==c||s[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,retry:!1,refetchOnWindowFocus:!1},s[8]=h,s[9]=c,s[10]=d,s[11]=u):u=s[11];const m=Wo(u);let _;s[12]!==a||s[13]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const y=w.content,k=Array.isArray(y)&&y[0]&&typeof y[0]=="object"?y[0].text??"Create failed":"Create failed";throw new Error(k)}return w.structuredContent.item},s[12]=a,s[13]=e,s[14]=_):_=s[14];let f;s[15]!==r||s[16]!==i.id||s[17]!==m||s[18]!==l?(f=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:As.tasksPrefix(r)}),m.refetch()},s[15]=r,s[16]=i.id,s[17]=m,s[18]=l,s[19]=f):f=s[19];let p;s[20]!==_||s[21]!==f?(p={mutationFn:_,onSuccess:f},s[20]=_,s[21]=f,s[22]=p):p=s[22];const g=Uo(p);let v,b;if(s[23]!==g||s[24]!==t||s[25]!==m.data||s[26]!==m.isSuccess?(v=()=>{t&&(!m.isSuccess||m.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,m.isSuccess,m.data,g],s[23]=g,s[24]=t,s[25]=m.data,s[26]=m.isSuccess,s[27]=v,s[28]=b):(v=s[27],b=s[28]),A.useEffect(v,b),!t){let x;return s[29]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[29]=x):x=s[29],x}if(m.isLoading){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[30]=x):x=s[30],x}if(m.isError){const x=m.error;let w;return s[31]!==x?(w={status:"error",error:x},s[31]=x,s[32]=w):w=s[32],w}if(m.isSuccess&&m.data){let x;return s[33]!==m.data?(x={status:"ready",task:m.data},s[33]=m.data,s[34]=x):x=s[34],x}if(g.isPending||m.isSuccess&&!m.data){let x;return s[35]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[35]=x):x=s[35],x}if(g.isError){let x;return s[36]!==g.error?(x={status:"error",error:g.error},s[36]=g.error,s[37]=x):x=s[37],x}let S;return s[38]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[38]=S):S=s[38],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Mn(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 jh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Eh(t){const e=V.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Th),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 Th(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 Rh(t){const e=V.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 d;e[2]!==l?(d=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let m;e[6]!==c||e[7]!==d||e[8]!==u?(m=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=m):m=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 f;e[11]!==a?(f=a.toFixed(1),e[11]=a,e[12]=f):f=e[12];let p;e[13]!==f?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",f,"%"]})]}),e[13]=f,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==m?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[m,x]}),e[27]=x,e[28]=m,e[29]=w):w=e[29],w}function Dh(t){const e=V.c(19),{part:s}=t,i=s.input?.agent_id,r=gt(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 d;e[0]!==a||e[1]!==n?(d=o.jsx(ds,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=d):d=e[2];const u=h?"text-destructive":"text-foreground";let m;e[3]!==u?(m=te("shrink-0 font-medium",u),e[3]=u,e[4]=m):m=e[4];let _;e[5]!==n||e[6]!==m?(_=o.jsx("span",{className:m,children:n}),e[5]=n,e[6]=m,e[7]=_):_=e[7];let f;e[8]!==s.input?(f=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]=f):f=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(Me,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(Yl,{size:12,className:"text-destructive"}):c?o.jsx(as,{size:12,className:"text-warning"}):o.jsx(ql,{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]!==d||e[15]!==_||e[16]!==f||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,_,f,p]}),e[14]=d,e[15]=_,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function Mh(t){const e=V.c(58),{onClose:s,back:i,className:r}=t,[n,a]=A.useState(null),{messages:l}=Jo(),{tasks:h,taskId:c}=lt(),{selectedModel:d,selectedVirtualMcp:u}=yi();let m,_,f,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==d||e[6]!==u?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=Q=>Q.id===c,e[17]=c,e[18]=N):N=e[18];const y=h.find(N),k=ec(l),j=[...l].reverse().find(Fh),M=j?.metadata?.usage,D=j?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,T=M?.contextTokens??M?.totalTokens??0,C=D&&D>0?(T/D*100).toFixed(1):null,R=l;let E;e[19]!==R?(E=R.filter($h).reduce(zh,0),e[19]=R,e[20]=E):E=e[20];const L=E,z=l;let B;e[21]!==z?(B=z.filter(Oh).reduce(Lh,0),e[21]=z,e[22]=B):B=e[22];const O=B,$=Math.max(0,k.totalTokens-L-O),W=l[0],I=l.at(-1),F=W?.metadata?.created_at??y?.created_at,U=I?.metadata?.created_at??y?.updated_at,K=l.filter(Ph),G=l.flatMap(Bh),P=d?.modelId?jh(d.modelId):"—",Z=u?.title??"Decopilot",Y=[{label:"Session",value:y?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:Z},{label:"Model",value:P},{label:"Context Limit",value:D?vs(D):"—"},{label:"Session Tokens (billed)",value:k.totalTokens>0?vs(k.totalTokens):"0"},{label:"Usage",value:C!==null?`${C}%`:"—"},{label:"Input Tokens",value:k.inputTokens>0?vs(k.inputTokens):"0"},{label:"Output Tokens",value:k.outputTokens>0?vs(k.outputTokens):"0"},{label:"Reasoning Tokens",value:k.reasoningTokens>0?vs(k.reasoningTokens):"0"},{label:"Cost",value:k.cost>0?`$${k.cost<.001?k.cost.toFixed(6):k.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Mn(F)},{label:"Last Activity",value:Mn(U)}];if(!y&&K.length===0){let Q;e[23]!==r?(Q=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=Q):Q=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let de;e[26]!==i?(de=i?o.jsx(bn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=de):de=e[27];let ue;e[28]!==s||e[29]!==de?(ue=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:de})]}),e[28]=s,e[29]=de,e[30]=ue):ue=e[30];let we;e[31]===Symbol.for("react.memo_cache_sentinel")?(we=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]=we):we=e[31];let Xe;e[32]!==Q||e[33]!==ue?(Xe=o.jsxs("div",{className:Q,children:[ue,we]}),e[32]=Q,e[33]=ue,e[34]=Xe):Xe=e[34],S=Xe;break e}e[35]!==r?(v=te("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 ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=ee):ee=e[37];let ce;e[38]!==i?(ce=i?o.jsx(bn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ce):ce=e[39],e[40]!==s||e[41]!==ce?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[ee,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:ce})]}),e[40]=s,e[41]=ce,e[42]=b):b=e[42],m="flex flex-col gap-8 p-6",_=G.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:G.map(Ih)})]}),f=o.jsx(Eh,{items:Y});let ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(ie=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ie):ie=e[43],e[44]!==O||e[45]!==$||e[46]!==L?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ie,o.jsx(Rh,{userTokens:L,assistantTokens:O,otherTokens:$})]}),e[44]=O,e[45]=$,e[46]=L,e[47]=p):p=e[47],g=K.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:K.map(Q=>{const he=Q.metadata?.created_at,de=n?.id===Q.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(de?null:Q),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:te("shrink-0 font-medium",Q.role==="user"?"text-chart-1":"text-chart-2"),children:Q.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:Q.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),de&&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(Q,null,2)})]},Q.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=d,e[6]=u?.title,e[7]=c,e[8]=h,e[9]=m,e[10]=_,e[11]=f,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else m=e[9],_=e[10],f=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]!==m||e[49]!==_||e[50]!==f||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:m,children:[_,f,p,g]}),e[48]=m,e[49]=_,e[50]=f,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Ih(t,e){return o.jsx(Dh,{part:t},e)}function Bh(t){return(t.parts??[]).filter(Ah)}function Ah(t){return t.type==="tool-subtask"}function Ph(t){return t.role!=="system"}function Lh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Oh(t){return t.role==="assistant"}function zh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function $h(t){return t.role==="user"}function Fh(t){return t.role==="assistant"&&t.metadata?.usage}const In=["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 Hh(){const t=In[Math.floor(Math.random()*In.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Wh(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 Uh(t){const e=V.c(25),{orgId:s,userId:i,connectionId:r,vmMap:n,owner:a,repo:l,enabled:h}=t,c=h===void 0?!0:h,d=r??null;let u;e[0]!==s||e[1]!==d?(u={connectionId:d,orgId:s},e[0]=s,e[1]=d,e[2]=u):u=e[2];const m=Fe(u);let _;e[3]!==a||e[4]!==l?(_={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=_):_=e[5];const f=c&&!!r&&!!a&&!!l;let p;e[6]!==m||e[7]!==_||e[8]!==f?(p={client:m,toolName:"list_branches",toolArguments:_,enabled:f,staleTime:3e4,select:Gh},e[6]=m,e[7]=_,e[8]=f,e[9]=p):p=e[9];const{data:g,isLoading:v,isError:b}=us(p);let S,x;e[10]!==i||e[11]!==n?(x=new Set(Object.keys(n?.[i]??{})),S=[...x].sort().map(qh),e[10]=i,e[11]=n,e[12]=S,e[13]=x):(S=e[12],x=e[13]);const w=S;let N;if(e[14]!==g||e[15]!==x){const M=Array.isArray(g)?g:g?.branches??[];let D;e[17]!==x?(D=T=>!x.has(T.name),e[17]=x,e[18]=D):D=e[18],N=M.filter(Kh).filter(D).map(Vh),e[14]=g,e[15]=x,e[16]=N}else N=e[16];const y=N,k=Array.isArray(g)?null:g?.default_branch??null;let j;return e[19]!==k||e[20]!==b||e[21]!==v||e[22]!==y||e[23]!==w?(j={yours:w,others:y,defaultBase:k,isLoading:v,isError:b},e[19]=k,e[20]=b,e[21]=v,e[22]=y,e[23]=w,e[24]=j):j=e[24],j}function Vh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Kh(t){return typeof t.name=="string"}function qh(t){return{name:t,source:"yours"}}function Gh(t){return Wh(t)}function Yh(t){const e=V.c(41),{orgId:s,userId:i,connectionId:r,owner:n,repo:a,vmMap:l,value:h,onChange:c}=t,[d,u]=A.useState(!1);let m;e[0]!==r||e[1]!==d||e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==i||e[6]!==l?(m={orgId:s,userId:i,connectionId:r,vmMap:l,owner:n,repo:a,enabled:d},e[0]=r,e[1]=d,e[2]=s,e[3]=n,e[4]=a,e[5]=i,e[6]=l,e[7]=m):m=e[7];const{yours:_,others:f,isLoading:p,isError:g}=Uh(m);let v;e[8]!==c?(v=E=>{c(E),u(!1)},e[8]=c,e[9]=v):v=e[9];const b=v,S=h??"Select branch…";let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[10]=x):x=e[10];let w;e[11]!==S?(w=o.jsx(Hs,{asChild:!0,children:o.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[x,o.jsx("span",{className:"max-w-[200px] truncate",children:S})]})}),e[11]=S,e[12]=w):w=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(dc,{placeholder:"Search branches…"}),e[13]=N):N=e[13];let y;e[14]!==b?(y=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:[N,o.jsx(se,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>b(Hh()),children:"New"})]}),e[14]=b,e[15]=y):y=e[15];let k;e[16]!==g?(k=g&&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[16]=g,e[17]=k):k=e[17];let j;e[18]!==g||e[19]!==p||e[20]!==f.length||e[21]!==_.length?(j=!g&&!p&&_.length===0&&f.length===0&&o.jsx(cc,{children:"No branches found."}),e[18]=g,e[19]=p,e[20]=f.length,e[21]=_.length,e[22]=j):j=e[22];let M;e[23]!==b||e[24]!==_?(M=_.length>0&&o.jsx(wn,{heading:"Your branches",children:_.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=b,e[24]=_,e[25]=M):M=e[25];let D;e[26]!==f||e[27]!==b?(D=f.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{}),o.jsx(wn,{heading:"Other branches in repo",children:f.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=f,e[27]=b,e[28]=D):D=e[28];let T;e[29]!==D||e[30]!==k||e[31]!==j||e[32]!==M?(T=o.jsxs(uc,{children:[k,j,M,D]}),e[29]=D,e[30]=k,e[31]=j,e[32]=M,e[33]=T):T=e[33];let C;e[34]!==T||e[35]!==y?(C=o.jsx(Ws,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(fc,{children:[y,T]})}),e[34]=T,e[35]=y,e[36]=C):C=e[36];let R;return e[37]!==d||e[38]!==C||e[39]!==w?(R=o.jsxs(Us,{open:d,onOpenChange:u,children:[w,C]}),e[37]=d,e[38]=C,e[39]=w,e[40]=R):R=e[40],R}function Xh(){const t=V.c(26),{org:e}=ye(),{selectedVirtualMcp:s}=yi(),{data:i}=Si.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=lt();let a;t[0]!==e.id?(a=Yo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=gt(h.id),d=i?.user?.id??"",u=c?.metadata?.githubRepo??null,m=!!u?.connectionId&&!!d;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Vl,{size:32}),t[2]=_):_=t[2];let f;t[3]!==h.icon||t[4]!==h.title?(f=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]=f):f=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]!==u||t[13]!==e.id||t[14]!==n||t[15]!==m||t[16]!==d?(b=m&&o.jsx("div",{className:"mt-2",children:o.jsx(Yh,{orgId:e.id,userId:d,connectionId:u.connectionId,owner:u.owner,repo:u.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=n,t[15]=m,t[16]=d,t[17]=b):b=t[17];let S;t[18]!==f||t[19]!==p||t[20]!==v||t[21]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[f,p,v,b]}),t[18]=f,t[19]=p,t[20]=v,t[21]=b,t[22]=S):S=t[22];let x;t[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[23]=x):x=t[23];let w;return t[24]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[24]=S,t[25]=w):w=t[25],w}function Jh(){const t=V.c(26),{org:e}=ye(),s=Nc(),{isChatEmpty:i}=Jo(),[r,n]=A.useState("chat"),a=zl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.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&&!$l(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(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const d=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let u;t[10]!==d?(u=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",d),t[10]=d,t[11]=u):u=t[11];let m;t[12]!==i?(m=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(Xh,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=m):m=t[13];let _;t[14]!==u||t[15]!==m?(_=o.jsx("div",{className:u,children:m}),t[14]=u,t[15]=m,t[16]=_):_=t[16];const f=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==f?(p=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[17]=f,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Mh,{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(je,{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 Na(){const t=V.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Qt,{fallback:e,children:o.jsx(A.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(Jh,{})})}),t[1]=s):s=t[1],s}async function Zh(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 ja=["VM_START"],Zs=new Map,Qh=t=>`${t.virtualMcpId}::${t.branch??""}`;function sn(t){const e=Ht();return Uo({mutationKey:ja,mutationFn:async s=>{const i=Qh(s),r=Zs.get(i);if(r)return r;const n=(async()=>(await Zh(t,"VM_START",s)).structuredContent)();Zs.set(i,n);try{return await n}finally{Zs.get(i)===n&&Zs.delete(i)}},onSuccess:()=>{ni(e)}})}function Ea(t,e){const s=V.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:ja,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],Ch(i)>0}const ed={settings:_c,automations:mc,env:mi,preview:Xl,git:Rs};function An(t){const e=ki(t);if(e.type==="icon"){const s=Ni(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function $i(t){if(t.kind==="system")return{kind:"component",Component:ed[t.tabId]};const e=An(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=An(s.icon);return i||{kind:"fallback"}}function td(t){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),{data:i}=Tl({queryKey:As.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 Ta(t){const e=V.c(8),s=Mt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Yr(i),n=gt(t.virtualMcpId),a=td(t.taskId),{currentBranch:l}=lt(),h=n?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],m=a?.expanded_tools??[],_=!!(n&&Bt(n));let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f={includeVirtual:!0},e[1]=f):f=e[1];const p=ji(f),{activeTab:g,mainOpen:v}=tc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(sd)}:null}),b=Zo(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 j of m){const M=Sn(j.appId,j.toolName);x.set(M,{id:M,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of u){const M=Sn(j.connectionId,j.toolName);x.set(M,{id:M,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let w;e[2]!==p?(w=j=>({id:j.id,title:j.title,kind:"agent",icon:$i({tabId:j.id,kind:"agent",appId:j.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const N=[...d.map(w),...Array.from(x.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:$i({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:p})})),...S.map(j=>({id:j.id,title:j.title,kind:"system",icon:$i({tabId:j.id,kind:"system",connections:p})}))];let y;return e[4]!==g||e[5]!==v||e[6]!==s?(y=j=>{const M=sc({clickedId:j,activeTab:g,mainOpen:v});s({to:".",search:D=>({...D,main:M}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=y):y=e[7],{activeTab:g,mainOpen:v,setActiveTab:y,systemTabs:S,layoutTabs:d,expandedTools:m,automationTabParsed:b,tabs:N}}function sd(t){return{id:t.id}}function id(t){const e=V.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:d}=t,u=a===void 0?"lg":a,m=c===void 0?!0:c,_=d===void 0?!1:d,[f,p]=A.useState(!1),[g,v]=A.useState("icons"),[b,S]=A.useState(""),[x,w]=A.useState("blue");let N;e[0]!==s?(N=ki(s),e[0]=s,e[1]=N):N=e[1];const y=N,k=y.type==="icon"||y.type==="url"&&y.color?y.color:x;let j;e[2]!==i||e[3]!==k?(j=_e=>{i(Pi(_e,k))},e[2]=i,e[3]=k,e[4]=j):j=e[4];const M=j;let D;e[5]!==i||e[6]!==r||e[7]!==y.name||e[8]!==y.type||e[9]!==y.url?(D=_e=>{w(_e),r?.(_e),y.type==="icon"?i(Pi(y.name,_e)):y.type==="url"&&i(kn(y.url,_e))},e[5]=i,e[6]=r,e[7]=y.name,e[8]=y.type,e[9]=y.url,e[10]=D):D=e[10];const T=D;let C;e[11]!==i||e[12]!==k?(C=_e=>{i(kn(_e,k)),p(!1)},e[11]=i,e[12]=k,e[13]=C):C=e[13];const R=C;let E;e[14]!==i||e[15]!==k?(E=()=>{const _e=Jr(),Vt=_e[Math.floor(Math.random()*_e.length)];i(Pi(Vt,k))},e[14]=i,e[15]=k,e[16]=E):E=e[16];const L=E;let z,B,O,$,W,I,F,U;if(e[17]!==l||e[18]!==_||e[19]!==f||e[20]!==u){const _e={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Us,I=_?!1:f,F=p,z=Hs,W=!0,U="button",O=_,$=te("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",_e[u],l),e[17]=l,e[18]=_,e[19]=f,e[20]=u,e[21]=z,e[22]=B,e[23]=O,e[24]=$,e[25]=W,e[26]=I,e[27]=F,e[28]=U}else z=e[21],B=e[22],O=e[23],$=e[24],W=e[25],I=e[26],F=e[27],U=e[28];let K;e[29]!==h||e[30]!==n||e[31]!==u||e[32]!==s?(K=o.jsx(Nn,{icon:s,name:n,size:u,className:h}),e[29]=h,e[30]=n,e[31]=u,e[32]=s,e[33]=K):K=e[33];let G;e[34]!==_||e[35]!==m?(G=m&&!_&&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(ta,{size:16,className:"text-white"})}),e[34]=_,e[35]=m,e[36]=G):G=e[36];let P;e[37]!==O||e[38]!==$||e[39]!==K||e[40]!==G||e[41]!==U?(P=o.jsxs("button",{type:U,disabled:O,className:$,children:[K,G]}),e[37]=O,e[38]=$,e[39]=K,e[40]=G,e[41]=U,e[42]=P):P=e[42];let Z;e[43]!==z||e[44]!==W||e[45]!==P?(Z=o.jsx(z,{asChild:W,children:P}),e[43]=z,e[44]=W,e[45]=P,e[46]=Z):Z=e[46];let Y;e[47]!==n||e[48]!==s?(Y=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(Nn,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=Y):Y=e[49];let ee;e[50]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>v("icons"),e[50]=ee):ee=e[50];const ce=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ie;e[51]!==ce?(ie=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ce),e[51]=ce,e[52]=ie):ie=e[52];let Q;e[53]!==ie?(Q=o.jsx("button",{type:"button",onClick:ee,className:ie,children:"Icons"}),e[53]=ie,e[54]=Q):Q=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const de=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[56]!==de?(ue=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",de),e[56]=de,e[57]=ue):ue=e[57];let we;e[58]!==ue?(we=o.jsx("button",{type:"button",onClick:he,className:ue,children:"Upload"}),e[58]=ue,e[59]=we):we=e[59];let Xe;e[60]===Symbol.for("react.memo_cache_sentinel")?(Xe=o.jsx("div",{className:"flex-1"}),e[60]=Xe):Xe=e[60];let He;e[61]!==Q||e[62]!==we?(He=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[Q,we,Xe]}),e[61]=Q,e[62]=we,e[63]=He):He=e[63];let ne;e[64]!==T||e[65]!==L||e[66]!==M||e[67]!==R||e[68]!==y.name||e[69]!==y.type||e[70]!==b||e[71]!==k||e[72]!==g?(ne=g==="icons"?o.jsx(ad,{search:b,onSearchChange:S,selectedColor:k,onColorChange:T,onSelectIcon:M,onRandom:L,currentIconName:y.type==="icon"?y.name:null}):o.jsx(ld,{onUpload:R}),e[64]=T,e[65]=L,e[66]=M,e[67]=R,e[68]=y.name,e[69]=y.type,e[70]=b,e[71]=k,e[72]=g,e[73]=ne):ne=e[73];let ve;e[74]!==Y||e[75]!==He||e[76]!==ne?(ve=o.jsx(Ws,{align:"start",className:"w-80 p-0",onOpenAutoFocus:rd,children:o.jsxs("div",{className:"flex flex-col",children:[Y,He,ne]})}),e[74]=Y,e[75]=He,e[76]=ne,e[77]=ve):ve=e[77];let tt;return e[78]!==B||e[79]!==I||e[80]!==F||e[81]!==Z||e[82]!==ve?(tt=o.jsxs(B,{open:I,onOpenChange:F,children:[Z,ve]}),e[78]=B,e[79]=I,e[80]=F,e[81]=Z,e[82]=ve,e[83]=tt):tt=e[83],tt}function rd(t){return t.preventDefault()}function nd(t){const e=V.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=A.useState(!1);let a,l,h,c,d,u,m;if(e[0]!==r||e[1]!==s){const b=ea(s);l=Us,u=r,m=n,a=Hs,d=!0,h="button",c=te("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]=d,e[7]=u,e[8]=m}else a=e[2],l=e[3],h=e[4],c=e[5],d=e[6],u=e[7],m=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 f;e[12]!==a||e[13]!==d||e[14]!==_?(f=o.jsx(a,{asChild:d,children:_}),e[12]=a,e[13]=d,e[14]=_,e[15]=f):f=e[15];let p;e[16]!==i||e[17]!==s?(p=gc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:te("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(Ws,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:od,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]!==u||e[23]!==m||e[24]!==f||e[25]!==g?(v=o.jsxs(l,{open:u,onOpenChange:m,children:[f,g]}),e[21]=l,e[22]=u,e[23]=m,e[24]=f,e[25]=g,e[26]=v):v=e[26],v}function od(t){return t.preventDefault()}function ad(t){const e=V.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,m,_,f,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=Jr(),w=ea(r);d=s.trim()?x.filter(T=>{const C=ar(T),R=s.toLowerCase();return C.includes(R)||T.toLowerCase().includes(R)}):x,f="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ca,{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 y;e[15]!==i?(y=T=>i(T.target.value),e[15]=i,e[16]=y):y=e[16];let k;e[17]!==s||e[18]!==y?(k=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(fs,{value:s,onChange:y,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=y,e[19]=k):k=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(pc,{size:14,className:"text-muted-foreground"}),e[20]=j):j=e[20];let M;e[21]!==l?(M=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:j}),e[21]=l,e[22]=M):M=e[22];let D;e[23]!==n||e[24]!==r?(D=o.jsx(nd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=D):D=e[25],e[26]!==M||e[27]!==D||e[28]!==k?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[k,M,D]}),e[26]=M,e[27]=D,e[28]=k,e[29]=p):p=e[29],c=wa,_="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",m=d.map(T=>{const C=Ni(T);return C?o.jsx("button",{type:"button",onClick:()=>a(T),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===T?te(w.bg,w.text):te(w.text,"hover:bg-accent")),title:T,children:o.jsx(C,{size:18})},T):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=d,e[9]=u,e[10]=m,e[11]=_,e[12]=f,e[13]=p}else c=e[7],d=e[8],u=e[9],m=e[10],_=e[11],f=e[12],p=e[13];let g;e[30]!==u||e[31]!==m?(g=o.jsx("div",{className:u,children:m}),e[30]=u,e[31]=m,e[32]=g):g=e[32];let v;e[33]!==d.length?(v=d.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.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]!==f||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:f,children:[p,b]}),e[40]=f,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function ld(t){const e=V.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=N=>{const y=N.target.files?.[0];if(!y)return;if(y.size>2097152){me.error("Image must be smaller than 2MB"),N.target.value="";return}const k=new FileReader;k.onerror=()=>{me.error("Failed to read image file"),i.current&&(i.current.value="")},k.onloadend=()=>{k.readyState===FileReader.DONE&&k.result&&s(k.result),i.current&&(i.current.value="")},k.readAsDataURL(y)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=A.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 d;e[5]!==n?(d=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=d):d=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsxs("button",{type:"button",onClick:u,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(Jl,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=m):m=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 f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=N=>l(N.target.value),e[10]=f):f=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(fs,{value:a,onChange:f,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(se,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let w;return e[24]!==x||e[25]!==d?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,m,_,x]}),e[24]=x,e[25]=d,e[26]=w):w=e[26],w}function cd(t){const e=V.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=ki(s);if(n.type==="icon"){const a=Ni(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(Bc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function hd(t){const e=V.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=ki(s),e[0]=s,e[1]=d):d=e[1];const u=d,m=u.type==="icon"?u.name:null;let _,f,p,g,v,b,S,x,w,N,y,k,j,M,D;if(e[2]!==r||e[3]!==m||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=Jr();g=h.trim()?B.filter(K=>{const G=h.toLowerCase();return ar(K).includes(G)||K.toLowerCase().includes(G)}):B,p=Us,v=n?!1:a,b=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let $;e[24]!==r||e[25]!==O?($=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=$):$=e[26];let W;e[27]!==s?(W=o.jsx(cd,{value:s}),e[27]=s,e[28]=W):W=e[28],e[29]!==n||e[30]!==$||e[31]!==W?(S=o.jsx(Hs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:$,children:W})}),e[29]=n,e[30]=$,e[31]=W,e[32]=S):S=e[32],f=Ws,j="start",M="w-64 p-0",D=dd,y="flex flex-col";let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(Ca,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=I):I=e[33];let F;e[34]===Symbol.for("react.memo_cache_sentinel")?(F=K=>c(K.target.value),e[34]=F):F=e[34],e[35]!==h?(k=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[I,o.jsx(fs,{value:h,onChange:F,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=k):k=e[36],_=wa,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let U;e[37]!==m||e[38]!==i?(U=K=>{const G=Ni(K);return G?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:ar(K),children:o.jsx(G,{size:16})},K):null},e[37]=m,e[38]=i,e[39]=U):U=e[39],w=g.map(U),e[2]=r,e[3]=m,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=f,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=w,e[18]=N,e[19]=y,e[20]=k,e[21]=j,e[22]=M,e[23]=D}else _=e[9],f=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],w=e[17],N=e[18],y=e[19],k=e[20],j=e[21],M=e[22],D=e[23];let T;e[40]!==x||e[41]!==w?(T=o.jsx("div",{className:x,children:w}),e[40]=x,e[41]=w,e[42]=T):T=e[42];let C;e[43]!==g.length?(C=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]=C):C=e[44];let R;e[45]!==_||e[46]!==T||e[47]!==C||e[48]!==N?(R=o.jsxs(_,{className:N,children:[T,C]}),e[45]=_,e[46]=T,e[47]=C,e[48]=N,e[49]=R):R=e[49];let E;e[50]!==R||e[51]!==y||e[52]!==k?(E=o.jsxs("div",{className:y,children:[k,R]}),e[50]=R,e[51]=y,e[52]=k,e[53]=E):E=e[53];let L;e[54]!==f||e[55]!==E||e[56]!==j||e[57]!==M||e[58]!==D?(L=o.jsx(f,{align:j,className:M,onOpenAutoFocus:D,children:E}),e[54]=f,e[55]=E,e[56]=j,e[57]=M,e[58]=D,e[59]=L):L=e[59];let z;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==L?(z=o.jsxs(p,{open:v,onOpenChange:b,children:[S,L]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=L,e[65]=z):z=e[65],z}function dd(t){return t.preventDefault()}function ai(){const t=V.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(Me,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Fi(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(Rl,{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 ud(t){const e=V.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=te("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 d;e[5]!==s.tags?(d=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];let m;e[10]!==s.description?(m=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=m):m=e[11];let _;e[12]!==u||e[13]!==m?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,m]}),e[12]=u,e[13]=m,e[14]=_):_=e[14];let f;e[15]!==n||e[16]!==i||e[17]!==r?(f=o.jsx(rh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=f):f=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==f?(p=o.jsxs("label",{className:h,children:[_,f]}),e[19]=h,e[20]=_,e[21]=f,e[22]=p):p=e[22],p}function rn(t){const e=V.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 u=s.map(fd);if(s.length===0){let m;e[8]!==n?(m=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]=m):m=e[9],c=m;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(m=>o.jsx(ud,{item:m,isSelected:i===null||i?.includes(m.id),onToggle:()=>r(m.id,u),disabled:a},m.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 d;return e[10]!==l||e[11]!==h?(d=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function fd(t){return t.id}function md(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=kc(c);let u;e[5]!==d.tools?(u=d.tools.map(_d),e[5]=d.tools,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function _d(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(Jc,{annotations:t.annotations,_meta:t._meta})}}function pd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=Yc(c);let u;e[5]!==d.resources?(u=d.resources.map(gd),e[5]=d.resources,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function gd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function vd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=nh(c);let u;e[5]!==d.prompts?(u=d.prompts.map(xd),e[5]=d.prompts,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function xd(t){return{id:t.name,name:t.name,description:t.description}}function bd(t){const e=V.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:m}=t,_=n[r],f=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?d(r):u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=d,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 w;e[16]!==v||e[17]!==x?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let y;e[20]!==m?(y=z=>m(z),e[20]=m,e[21]=y):y=e[21];let k;e[22]!==i||e[23]!==y?(k=o.jsx(ih,{tabs:N,activeTab:i,onTabChange:y}),e[22]=i,e[23]=y,e[24]=k):k=e[24];const j=f?"Deselect all":"Select all";let M;e[25]!==g||e[26]!==j?(M=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:j}),e[25]=g,e[26]=j,e[27]=M):M=e[27];let D;e[28]!==M||e[29]!==k?(D=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[k,M]}),e[28]=M,e[29]=k,e[30]=D):D=e[30];let T;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(T=i==="tools"&&o.jsx(Qt,{fallback:Fi("Tools not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(md,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(z,B)=>a(r,z,B)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=T):T=e[35];let C;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(C=i==="resources"&&o.jsx(Qt,{fallback:Fi("Resources not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(pd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(z,B)=>l(r,z,B)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=C):C=e[40];let R;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(R=i==="prompts"&&o.jsx(Qt,{fallback:Fi("Prompts not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(vd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(z,B)=>h(r,z,B)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=R):R=e[45];let E;e[46]!==T||e[47]!==C||e[48]!==R?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,C,R]}),e[46]=T,e[47]=C,e[48]=R,e[49]=E):E=e[49];let L;return e[50]!==D||e[51]!==E||e[52]!==w?(L=o.jsxs(o.Fragment,{children:[w,D,E]}),e[50]=D,e[51]=E,e[52]=w,e[53]=L):L=e[53],L}function Sd(t){const e=V.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=ha(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(vc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=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]=d):d=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&o.jsx(se,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let m;return e[7]!==u?(m=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,d,u]}),e[7]=u,e[8]=m):m=e[8],m}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function yd(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 Pn(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function wd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Cd(t){const e=V.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,d]=A.useReducer(wd,h),u=Qr(r??"");let m;e[1]!==a?(m=a??[],e[1]=a,e[2]=m):m=e[2];let _;e[3]!==m?(_=yd(m),e[3]=m,e[4]=_):_=e[4];const f=_;let p;e[5]!==n||e[6]!==f?(p=(I,F,U,K)=>{const G=f[I]?.[F];let P;G===null?P=K.filter(Y=>Y!==U):G?.includes(U)?P=G.filter(Y=>Y!==U):(P=[...G??[],U],P.length===K.length&&(P=null));const Z={...f};Z[I]?Z[I]={...Z[I]}:Z[I]={tools:null,resources:null,prompts:null},Z[I][F]=P,n.setValue("connections",Pn(Z),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=f,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==f?(v=(I,F)=>{const K=f[I]?.[F]===null?[]:null,G={...f};G[I]?G[I]={...G[I]}:G[I]={tools:null,resources:null,prompts:null},G[I][F]=K,n.setValue("connections",Pn(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=f,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(I,F,U)=>g(I,"tools",F,U),e[11]=g,e[12]=S):S=e[12];const x=S;let w;e[13]!==g?(w=(I,F,U)=>g(I,"resources",F,U),e[13]=g,e[14]=w):w=e[14];const N=w;let y;e[15]!==g?(y=(I,F,U)=>g(I,"prompts",F,U),e[15]=g,e[16]=y):y=e[16];const k=y;let j;e[17]!==b?(j=I=>b(I,"tools"),e[17]=b,e[18]=j):j=e[18];const M=j;let D;e[19]!==b?(D=I=>b(I,"resources"),e[19]=b,e[20]=D):D=e[20];const T=D;let C;e[21]!==b?(C=I=>b(I,"prompts"),e[21]=b,e[22]=C):C=e[22];const R=C;if(!r||!u)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ai,{}),e[23]=E):E=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=I=>d({type:"SET_ACTIVE_TAB",payload:I}),e[24]=L):L=e[24];let z;e[25]!==u||e[26]!==c.activeTab||e[27]!==f||e[28]!==r||e[29]!==R||e[30]!==T||e[31]!==M||e[32]!==k||e[33]!==N||e[34]!==x?(z=o.jsx(bd,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:f,toggleTool:x,toggleResource:N,togglePrompt:k,toggleAllTools:M,toggleAllResources:T,toggleAllPrompts:R,onTabChange:L},r),e[25]=u,e[26]=c.activeTab,e[27]=f,e[28]=r,e[29]=R,e[30]=T,e[31]=M,e[32]=k,e[33]=N,e[34]=x,e[35]=z):z=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==z?(B=o.jsx(A.Suspense,{fallback:E,children:o.jsx(Sd,{connectionId:r,onAuthenticate:l,children:z})}),e[36]=l,e[37]=r,e[38]=z,e[39]=B):B=e[39];let O;e[40]!==i?(O=o.jsx(Qc,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(se,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let $;e[42]!==B||e[43]!==O?($=o.jsxs(en,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,O]}),e[42]=B,e[43]=O,e[44]=$):$=e[44];let W;return e[45]!==i||e[46]!==s||e[47]!==$?(W=o.jsx(tn,{open:s,onOpenChange:i,children:$}),e[45]=i,e[46]=s,e[47]=$,e[48]=W):W=e[48],W}const Hi={tools:null,resources:null,prompts:null},kd=Dl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Nd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function jd(t){const e=V.c(11),{url:s,agentId:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Se("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),me.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(Ei,{size:20,className:"text-green-600"}):o.jsx(Ci,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==h||e[9]!==d?(u=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,d]}),e[7]=l,e[8]=h,e[9]=d,e[10]=u):u=e[10],u}function Ed(t){const e=V.c(9),{url:s,serverName:i,agentId:r,organizationId:n}=t;let a;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(a=()=>{Se("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=da(i),_=Nd(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor","x-org-id":n}},null,2)),f=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(_)}`;window.open(f,"_blank"),me.success("Opening Cursor...")},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let h,c;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=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%)"}}),c=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[5]=h,e[6]=c):(h=e[5],c=e[6]);let d;return e[7]!==l?(d=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,c]}),e[7]=l,e[8]=d):d=e[8],d}function Td(t){const e=V.c(13),{url:s,serverName:i,agentId:r,organizationId:n}=t,[a,l]=A.useState(!1);let h;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(h=async()=>{Se("agent_connect_action",{agent_id:r,action:"install_claude_code"});const f=da(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code","x-org-id":n}},null,2),v=`claude mcp add-json "${f}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),me.success("Claude Code command copied to clipboard"),setTimeout(()=>l(!1),2e3)},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=h):h=e[4];const c=h;let d;e[5]!==a?(d=a?o.jsx(Ei,{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[5]=a,e[6]=d):d=e[6];const u=a?"Copied!":"Install on Claude Code";let m;e[7]!==u?(m=o.jsx("span",{className:"text-xs font-medium",children:u}),e[7]=u,e[8]=m):m=e[8];let _;return e[9]!==c||e[10]!==d||e[11]!==m?(_=o.jsxs(se,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,m]}),e[9]=c,e[10]=d,e[11]=m,e[12]=_):_=e[12],_}function Rd({virtualMcp:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),[i,r]=A.useState(null),[n,a]=A.useState(!1),[l,h]=A.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,u=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,m=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),Se("agent_typegen_key_generated",{agent_id:c})}catch{Se("agent_typegen_key_failed",{agent_id:c}),me.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{Se("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),me.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(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:n,children:[n?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(sh,{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:u}),o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Dd,{apiKey:i,agentId:c})]})}function Dd(t){const e=V.c(21),{apiKey:s,agentId:i}=t,[r,n]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-BWTIFTZt.js","assets/index-BOmAbn3-.js","assets/index-B4J1yAvl.css","assets/pair-Ds1EbiW2.js","assets/agent-icon-Y41Xl4RB.js","assets/AlertCircle-CDtbI_oO.js","assets/Tool01-CRyHj4QJ.js","assets/XClose-DXU_tOKb.js","assets/RefreshCcw01-DLpzNYLg.js","assets/ArrowNarrowLeft-CJ8McWmC.js","assets/XCircle-B2dZZ7-3.js","assets/ArrowUpRight-CfmSEQdr.js","assets/ZapSquare-D6uI2CIK.js","assets/Users03-BCFGwdah.js","assets/CheckCircle-BfnVNP63.js","assets/ChevronDown-BKNJxAvQ.js","assets/ChevronRight-DmLVJ7rn.js","assets/ChevronUp-CsX2yfUc.js","assets/DotsVertical-CiluvdTj.js","assets/Container-DASuUdbK.js","assets/Star01-CRQ6Bc0M.js","assets/Palette-CmFr12m3.js","assets/SearchMd-RHgmu5nb.js","assets/index-BXOHXvkd.js","assets/tooltip-f4eQJmkn.js","assets/X-ZLJ81KrS.js","assets/LinkExternal01-CPmlMGsQ.js","assets/Lock01-BjCX4hvk.js","assets/Sun-DKXWmMuG.js","assets/Play-AcQdYeyW.js","assets/Plus-DkESyBkp.js","assets/Settings02-BgsL1r4k.js","assets/Shield01-BndBIezR.js","assets/Trash01-CfK96-qY.js","assets/User01-KY-MO20F.js","assets/Zap-25qc4enN.js","assets/index-By-OUdid.js","assets/use-copy-VDNca3ax.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-D0LCITx0.js","assets/content-blocks-o63cs2vh.js","assets/types-BxKF_I-u.js","assets/constants-Da2DvZbd.js","assets/chat-context-hgW5gAmm.js","assets/use-virtual-mcp-D8YFOZwW.js","assets/use-collections-ciAA_3Td.js","assets/use-ai-providers-CTaSMN44.js","assets/use-decopilot-events-CJG2rWbg.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DjQnA3sr.js","assets/use-organization-settings-BrpxY44K.js","assets/shell-layout-C3cZnoYI.js","assets/required-auth-layout-CGJ5rk5i.js","assets/use-org-sso-BUVEFfyx.js","assets/integration-icon-Bu4bZk46.js","assets/use-mcp-tools-C9cj3BH6.js"])))=>i.map(i=>d[i]);
2
+ import{o as Ht,r as A,p as jl,q as El,e as V,s as ye,K as As,n as Wo,a as Uo,c as te,j as o,l as Me,B as se,E as Qt,b as Si,v as ni,f as Mt,d as Yr,w as Tl,x as me,y as Rl,V as Dl,t as Se,z as Vo,C as Ml,D as Xt,F as Il,G as vn,L as Bl,H as Ai,I as Js,J as ct,M as Ko,P as Al,_ as Pl,Q as qo,R as Go,T as Ll,g as Ol}from"./index-BOmAbn3-.js";import{C as je,u as zl,w as $l,A as Fl,T as Hl,a as Wl}from"./index-CdUEwHcT.js";import{I as ds}from"./integration-icon-Bu4bZk46.js";import{S as It,u as Fe,g as Yo,a as Xo}from"./constants-Da2DvZbd.js";import{u as gt,a as Ul}from"./use-virtual-mcp-D8YFOZwW.js";import{a as Vl}from"./Users03-BCFGwdah.js";import{u as Jo,a as lt,b as yi,c as wi,t as Kl,d as xn}from"./chat-context-hgW5gAmm.js";import{i as as}from"./AlertCircle-CDtbI_oO.js";import{i as ql}from"./CheckCircle-BfnVNP63.js";import{n as bn,a as Gl}from"./ZapSquare-D6uI2CIK.js";import{i as Yl,a as Xl,b as Jl,c as Ci,d as Zl}from"./XCircle-B2dZZ7-3.js";import{s as ls,i as Ql}from"./XClose-DXU_tOKb.js";import{c as ec,r as tc,p as Zo,f as Sn,a as sc,F as ic,t as yn,M as Xr,G as Qo,L as rc,i as nc,b as oc,d as ac,e as lc}from"./pair-Ds1EbiW2.js";import{C as cc,a as wn,b as Cn,c as hc,d as dc,e as uc,f as fc}from"./command-BCmTpu4J.js";import{P as Hs,a as Ws,b as Us}from"./popover-Cvs9u_0D.js";import{i as Rs,a as mi,b as mc,c as _c,p as ki,g as Ni,d as Jr,e as ea,h as ar,f as Pi,j as kn,A as Nn,k as ta,l as pc,m as gc,n as vc,t as xc,o as bc,q as sa,r as ia,s as ra,u as na,v as jn,w as Sc,x as Ds,y as yc,z as wc,B as Cc,C as oa}from"./agent-icon-Y41Xl4RB.js";import{u as us,a as kc}from"./use-mcp-tools-C9cj3BH6.js";import{u as Nc,a as jc}from"./use-ai-providers-CTaSMN44.js";import{g as Bt,c as En,u as Ec,b as lr,d as Tc,e as Rc,f as Dc,T as Mc}from"./index-DcLrVfh1.js";import{u as Zr,i as Ic}from"./shell-layout-C3cZnoYI.js";import{i as Bc,P as at,u as Ac,c as Pc,d as Lc,e as Oc}from"./index-BXOHXvkd.js";import{u as aa,T as Ve,a as Ke,b as qe,c as zc}from"./tooltip-f4eQJmkn.js";import{u as $c}from"./use-status-sounds-DF_LdFlX.js";import{E as Ps}from"./empty-state-V_MWZYVh.js";import{A as Fc,a as Hc,b as Wc,c as Uc,R as la,d as Vc,e as Kc}from"./accordion-D3bxaM5e.js";import{u as ji,a as Qr,b as qc}from"./use-connection-DcySEqVV.js";import{g as Gc}from"./constants-Dm-yPW31.js";import{u as Yc,g as Xc}from"./types-BxKF_I-u.js";import{U as ca}from"./user-BG2r6Yob.js";import{T as Jc,u as ha}from"./tools-list-Cs00fcMQ.js";import{u as Li}from"./unwrap-tool-result-BYXdCQMg.js";import{s as da,g as Zc}from"./connection-slug-eyAPH6o3.js";import{A as ua,a as fa,b as ma,c as _a,d as pa,e as ga,f as va,g as xa}from"./alert-dialog-DnoDZh7l.js";import{D as Qc,a as en,b as tn,c as ba,d as Sa}from"./dialog-D0LCITx0.js";import{C as eh,a as Tn}from"./card-DQYOkC6d.js";import{I as fs}from"./input-DFMPKZJm.js";import{L as Ms}from"./label-DZwWOqq7.js";import{S as es,a as ts,b as ss,c as is,d as Dt}from"./select-Czs_bVht.js";import{S as cr}from"./switch-CgZ8SLcM.js";import{T as Rn}from"./textarea-dZeCqaKZ.js";import{i as oi}from"./Play-AcQdYeyW.js";import{s as cs}from"./Plus-DkESyBkp.js";import{a as th}from"./Settings02-BgsL1r4k.js";import{t as ya}from"./Tool01-CRyHj4QJ.js";import{s as hr}from"./Trash01-CfK96-qY.js";import{S as wa}from"./scroll-area-DaS5ALMq.js";import{i as Ca,a as sh}from"./SearchMd-RHgmu5nb.js";import{C as ih}from"./collection-tabs-BymkuH-J.js";import{C as rh}from"./checkbox-DkmOdGV4.js";import{u as nh,T as Oi,a as oh,b as ah,c as zi}from"./tabs-CQg6na0A.js";import{D as lh,a as ch,b as hh}from"./drawer-DWuqMoty.js";import{i as Ei,t as dr}from"./ChevronDown-BKNJxAvQ.js";import{n as Wt}from"./LinkExternal01-CPmlMGsQ.js";import{S as dh}from"./index-By-OUdid.js";import{D as rs,a as ns,b as os,c as yt,d as uh,e as fh,f as mh}from"./dropdown-menu-BooeaeZW.js";import{i as ka}from"./RefreshCcw01-DLpzNYLg.js";import{V as _h}from"./view-mode-toggle-iIz_yTY4.js";import{G as ph}from"./lean-canvas-recruit-modal-KLORFsWq.js";import{M as gh}from"./select-model-BAqBST4u.js";import{u as Vs,a as vh,b as xh,c as bh,A as Sh,d as yh}from"./automation-list-row-CAHW7UMQ.js";import{i as Ls}from"./Zap-25qc4enN.js";import{S as wh}from"./search-input-C4vXNPxO.js";import"./use-navigate-to-agent-KmcfdsLb.js";import"./use-tasks-DjQnA3sr.js";import"./use-collections-ciAA_3Td.js";import"./collection-search-CqdVjZKz.js";import"./form-3xE0OqGj.js";import"./Star01-CRQ6Bc0M.js";import"./Lock01-BjCX4hvk.js";import"./X-ZLJ81KrS.js";import"./toggle-group-BWbe6Sle.js";import"./index-DqWkjFjy.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-Bfng1y5O.js";import"./use-registry-connections-C5Res-NO.js";import"./use-organization-settings-BrpxY44K.js";import"./useInfiniteQuery-z1Rh4SPR.js";import"./infiniteQueryObserver-ruN3KSWZ.js";import"./extract-connection-data-JkyrF-5k.js";import"./Container-DASuUdbK.js";import"./connection-form-helpers-DmVfKyR2.js";import"./use-infinite-scroll-Cd7090oj.js";import"./useSuspenseInfiniteQuery-DmArxoRp.js";import"./badge-BQ5WsTn4.js";import"./ChevronRight-DmLVJ7rn.js";import"./use-decopilot-events-CJG2rWbg.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-VDNca3ax.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-DKXWmMuG.js";import"./index-Cm97pdLv.js";import"./ArrowNarrowLeft-CJ8McWmC.js";import"./ArrowUpRight-CfmSEQdr.js";import"./ChevronUp-CsX2yfUc.js";import"./DotsVertical-CiluvdTj.js";import"./Palette-CmFr12m3.js";import"./Shield01-BndBIezR.js";import"./User01-KY-MO20F.js";import"./skeleton-DFL6A56z.js";import"./avatar-C1td1Be6.js";import"./index-oZ72eHkF.js";import"./collection-search-B7ehvlGW.js";import"./use-create-virtual-mcp-BosIHDl_.js";import"./task-status-ZLGfD6LC.js";import"./required-auth-layout-CGJ5rk5i.js";import"./use-org-sso-BUVEFfyx.js";import"./collections-DusXIGhy.js";import"./settings-section-D1IZyeMZ.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Ch(t,e){const s=Ht(e);return kh({filters:{...t,status:"pending"}},s).length}function Dn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function kh(t={},e){const s=Ht(e).getMutationCache(),i=A.useRef(t),r=A.useRef(null);return r.current===null&&(r.current=Dn(s,t)),A.useEffect(()=>{i.current=t}),A.useSyncExternalStore(A.useCallback(n=>s.subscribe(()=>{const a=jl(r.current,Dn(s,i.current));r.current!==a&&(r.current=a,El.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Nh(t,e){const s=V.c(39),{org:i,locator:r}=ye();let n;s[0]!==i.id?(n={connectionId:It,orgId:i.id},s[0]=i.id,s[1]=n):n=s[1];const a=Fe(n),l=Ht();let h;s[2]!==t||s[3]!==i.id?(h=As.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=h):h=s[4];let c;s[5]!==a||s[6]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=c):c=s[7];const d=t.length>0;let u;s[8]!==h||s[9]!==c||s[10]!==d?(u={queryKey:h,queryFn:c,enabled:d,retry:!1,refetchOnWindowFocus:!1},s[8]=h,s[9]=c,s[10]=d,s[11]=u):u=s[11];const m=Wo(u);let _;s[12]!==a||s[13]!==e?(_=async x=>{const w=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(w.isError){const y=w.content,k=Array.isArray(y)&&y[0]&&typeof y[0]=="object"?y[0].text??"Create failed":"Create failed";throw new Error(k)}return w.structuredContent.item},s[12]=a,s[13]=e,s[14]=_):_=s[14];let f;s[15]!==r||s[16]!==i.id||s[17]!==m||s[18]!==l?(f=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:As.tasksPrefix(r)}),m.refetch()},s[15]=r,s[16]=i.id,s[17]=m,s[18]=l,s[19]=f):f=s[19];let p;s[20]!==_||s[21]!==f?(p={mutationFn:_,onSuccess:f},s[20]=_,s[21]=f,s[22]=p):p=s[22];const g=Uo(p);let v,b;if(s[23]!==g||s[24]!==t||s[25]!==m.data||s[26]!==m.isSuccess?(v=()=>{t&&(!m.isSuccess||m.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,m.isSuccess,m.data,g],s[23]=g,s[24]=t,s[25]=m.data,s[26]=m.isSuccess,s[27]=v,s[28]=b):(v=s[27],b=s[28]),A.useEffect(v,b),!t){let x;return s[29]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[29]=x):x=s[29],x}if(m.isLoading){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[30]=x):x=s[30],x}if(m.isError){const x=m.error;let w;return s[31]!==x?(w={status:"error",error:x},s[31]=x,s[32]=w):w=s[32],w}if(m.isSuccess&&m.data){let x;return s[33]!==m.data?(x={status:"ready",task:m.data},s[33]=m.data,s[34]=x):x=s[34],x}if(g.isPending||m.isSuccess&&!m.data){let x;return s[35]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[35]=x):x=s[35],x}if(g.isError){let x;return s[36]!==g.error?(x={status:"error",error:g.error},s[36]=g.error,s[37]=x):x=s[37],x}let S;return s[38]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[38]=S):S=s[38],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Mn(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 jh(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Eh(t){const e=V.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Th),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 Th(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 Rh(t){const e=V.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 d;e[2]!==l?(d=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=d):d=e[3];let u;e[4]!==h?(u=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=u):u=e[5];let m;e[6]!==c||e[7]!==d||e[8]!==u?(m=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,d,u]}),e[6]=c,e[7]=d,e[8]=u,e[9]=m):m=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 f;e[11]!==a?(f=a.toFixed(1),e[11]=a,e[12]=f):f=e[12];let p;e[13]!==f?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",f,"%"]})]}),e[13]=f,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let w;return e[27]!==x||e[28]!==m?(w=o.jsxs("div",{className:"flex flex-col gap-2",children:[m,x]}),e[27]=x,e[28]=m,e[29]=w):w=e[29],w}function Dh(t){const e=V.c(19),{part:s}=t,i=s.input?.agent_id,r=gt(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 d;e[0]!==a||e[1]!==n?(d=o.jsx(ds,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=d):d=e[2];const u=h?"text-destructive":"text-foreground";let m;e[3]!==u?(m=te("shrink-0 font-medium",u),e[3]=u,e[4]=m):m=e[4];let _;e[5]!==n||e[6]!==m?(_=o.jsx("span",{className:m,children:n}),e[5]=n,e[6]=m,e[7]=_):_=e[7];let f;e[8]!==s.input?(f=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]=f):f=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(Me,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(Yl,{size:12,className:"text-destructive"}):c?o.jsx(as,{size:12,className:"text-warning"}):o.jsx(ql,{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]!==d||e[15]!==_||e[16]!==f||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,_,f,p]}),e[14]=d,e[15]=_,e[16]=f,e[17]=p,e[18]=g):g=e[18],g}function Mh(t){const e=V.c(58),{onClose:s,back:i,className:r}=t,[n,a]=A.useState(null),{messages:l}=Jo(),{tasks:h,taskId:c}=lt(),{selectedModel:d,selectedVirtualMcp:u}=yi();let m,_,f,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==d||e[6]!==u?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=Q=>Q.id===c,e[17]=c,e[18]=N):N=e[18];const y=h.find(N),k=ec(l),j=[...l].reverse().find(Fh),M=j?.metadata?.usage,D=j?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,T=M?.contextTokens??M?.totalTokens??0,C=D&&D>0?(T/D*100).toFixed(1):null,R=l;let E;e[19]!==R?(E=R.filter($h).reduce(zh,0),e[19]=R,e[20]=E):E=e[20];const L=E,z=l;let B;e[21]!==z?(B=z.filter(Oh).reduce(Lh,0),e[21]=z,e[22]=B):B=e[22];const O=B,$=Math.max(0,k.totalTokens-L-O),W=l[0],I=l.at(-1),F=W?.metadata?.created_at??y?.created_at,U=I?.metadata?.created_at??y?.updated_at,K=l.filter(Ph),G=l.flatMap(Bh),P=d?.modelId?jh(d.modelId):"—",Z=u?.title??"Decopilot",Y=[{label:"Session",value:y?.title??"New chat"},{label:"Messages",value:K.length},{label:"Agent",value:Z},{label:"Model",value:P},{label:"Context Limit",value:D?vs(D):"—"},{label:"Session Tokens (billed)",value:k.totalTokens>0?vs(k.totalTokens):"0"},{label:"Usage",value:C!==null?`${C}%`:"—"},{label:"Input Tokens",value:k.inputTokens>0?vs(k.inputTokens):"0"},{label:"Output Tokens",value:k.outputTokens>0?vs(k.outputTokens):"0"},{label:"Reasoning Tokens",value:k.reasoningTokens>0?vs(k.reasoningTokens):"0"},{label:"Cost",value:k.cost>0?`$${k.cost<.001?k.cost.toFixed(6):k.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:Mn(F)},{label:"Last Activity",value:Mn(U)}];if(!y&&K.length===0){let Q;e[23]!==r?(Q=te("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=Q):Q=e[24];let he;e[25]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=he):he=e[25];let de;e[26]!==i?(de=i?o.jsx(bn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=de):de=e[27];let ue;e[28]!==s||e[29]!==de?(ue=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[he,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:de})]}),e[28]=s,e[29]=de,e[30]=ue):ue=e[30];let we;e[31]===Symbol.for("react.memo_cache_sentinel")?(we=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]=we):we=e[31];let Xe;e[32]!==Q||e[33]!==ue?(Xe=o.jsxs("div",{className:Q,children:[ue,we]}),e[32]=Q,e[33]=ue,e[34]=Xe):Xe=e[34],S=Xe;break e}e[35]!==r?(v=te("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 ee;e[37]===Symbol.for("react.memo_cache_sentinel")?(ee=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=ee):ee=e[37];let ce;e[38]!==i?(ce=i?o.jsx(bn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ce):ce=e[39],e[40]!==s||e[41]!==ce?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[ee,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:ce})]}),e[40]=s,e[41]=ce,e[42]=b):b=e[42],m="flex flex-col gap-8 p-6",_=G.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:G.map(Ih)})]}),f=o.jsx(Eh,{items:Y});let ie;e[43]===Symbol.for("react.memo_cache_sentinel")?(ie=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ie):ie=e[43],e[44]!==O||e[45]!==$||e[46]!==L?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[ie,o.jsx(Rh,{userTokens:L,assistantTokens:O,otherTokens:$})]}),e[44]=O,e[45]=$,e[46]=L,e[47]=p):p=e[47],g=K.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:K.map(Q=>{const he=Q.metadata?.created_at,de=n?.id===Q.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(de?null:Q),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:te("shrink-0 font-medium",Q.role==="user"?"text-chart-1":"text-chart-2"),children:Q.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:Q.id})]}),he&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(he).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),de&&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(Q,null,2)})]},Q.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=d,e[6]=u?.title,e[7]=c,e[8]=h,e[9]=m,e[10]=_,e[11]=f,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else m=e[9],_=e[10],f=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]!==m||e[49]!==_||e[50]!==f||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:m,children:[_,f,p,g]}),e[48]=m,e[49]=_,e[50]=f,e[51]=p,e[52]=g,e[53]=x):x=e[53];let w;return e[54]!==v||e[55]!==b||e[56]!==x?(w=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=w):w=e[57],w}function Ih(t,e){return o.jsx(Dh,{part:t},e)}function Bh(t){return(t.parts??[]).filter(Ah)}function Ah(t){return t.type==="tool-subtask"}function Ph(t){return t.role!=="system"}function Lh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Oh(t){return t.role==="assistant"}function zh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function $h(t){return t.role==="user"}function Fh(t){return t.role==="assistant"&&t.metadata?.usage}const In=["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 Hh(){const t=In[Math.floor(Math.random()*In.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Wh(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 Uh(t){const e=V.c(25),{orgId:s,userId:i,connectionId:r,vmMap:n,owner:a,repo:l,enabled:h}=t,c=h===void 0?!0:h,d=r??null;let u;e[0]!==s||e[1]!==d?(u={connectionId:d,orgId:s},e[0]=s,e[1]=d,e[2]=u):u=e[2];const m=Fe(u);let _;e[3]!==a||e[4]!==l?(_={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=_):_=e[5];const f=c&&!!r&&!!a&&!!l;let p;e[6]!==m||e[7]!==_||e[8]!==f?(p={client:m,toolName:"list_branches",toolArguments:_,enabled:f,staleTime:3e4,select:Gh},e[6]=m,e[7]=_,e[8]=f,e[9]=p):p=e[9];const{data:g,isLoading:v,isError:b}=us(p);let S,x;e[10]!==i||e[11]!==n?(x=new Set(Object.keys(n?.[i]??{})),S=[...x].sort().map(qh),e[10]=i,e[11]=n,e[12]=S,e[13]=x):(S=e[12],x=e[13]);const w=S;let N;if(e[14]!==g||e[15]!==x){const M=Array.isArray(g)?g:g?.branches??[];let D;e[17]!==x?(D=T=>!x.has(T.name),e[17]=x,e[18]=D):D=e[18],N=M.filter(Kh).filter(D).map(Vh),e[14]=g,e[15]=x,e[16]=N}else N=e[16];const y=N,k=Array.isArray(g)?null:g?.default_branch??null;let j;return e[19]!==k||e[20]!==b||e[21]!==v||e[22]!==y||e[23]!==w?(j={yours:w,others:y,defaultBase:k,isLoading:v,isError:b},e[19]=k,e[20]=b,e[21]=v,e[22]=y,e[23]=w,e[24]=j):j=e[24],j}function Vh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Kh(t){return typeof t.name=="string"}function qh(t){return{name:t,source:"yours"}}function Gh(t){return Wh(t)}function Yh(t){const e=V.c(41),{orgId:s,userId:i,connectionId:r,owner:n,repo:a,vmMap:l,value:h,onChange:c}=t,[d,u]=A.useState(!1);let m;e[0]!==r||e[1]!==d||e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==i||e[6]!==l?(m={orgId:s,userId:i,connectionId:r,vmMap:l,owner:n,repo:a,enabled:d},e[0]=r,e[1]=d,e[2]=s,e[3]=n,e[4]=a,e[5]=i,e[6]=l,e[7]=m):m=e[7];const{yours:_,others:f,isLoading:p,isError:g}=Uh(m);let v;e[8]!==c?(v=E=>{c(E),u(!1)},e[8]=c,e[9]=v):v=e[9];const b=v,S=h??"Select branch…";let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[10]=x):x=e[10];let w;e[11]!==S?(w=o.jsx(Hs,{asChild:!0,children:o.jsxs(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[x,o.jsx("span",{className:"max-w-[200px] truncate",children:S})]})}),e[11]=S,e[12]=w):w=e[12];let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(dc,{placeholder:"Search branches…"}),e[13]=N):N=e[13];let y;e[14]!==b?(y=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:[N,o.jsx(se,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>b(Hh()),children:"New"})]}),e[14]=b,e[15]=y):y=e[15];let k;e[16]!==g?(k=g&&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[16]=g,e[17]=k):k=e[17];let j;e[18]!==g||e[19]!==p||e[20]!==f.length||e[21]!==_.length?(j=!g&&!p&&_.length===0&&f.length===0&&o.jsx(cc,{children:"No branches found."}),e[18]=g,e[19]=p,e[20]=f.length,e[21]=_.length,e[22]=j):j=e[22];let M;e[23]!==b||e[24]!==_?(M=_.length>0&&o.jsx(wn,{heading:"Your branches",children:_.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name})]},E.name))}),e[23]=b,e[24]=_,e[25]=M):M=e[25];let D;e[26]!==f||e[27]!==b?(D=f.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(hc,{}),o.jsx(wn,{heading:"Other branches in repo",children:f.map(E=>o.jsxs(Cn,{value:E.name,onSelect:()=>b(E.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:E.name}),E.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",E.author]})]},E.name))})]}),e[26]=f,e[27]=b,e[28]=D):D=e[28];let T;e[29]!==D||e[30]!==k||e[31]!==j||e[32]!==M?(T=o.jsxs(uc,{children:[k,j,M,D]}),e[29]=D,e[30]=k,e[31]=j,e[32]=M,e[33]=T):T=e[33];let C;e[34]!==T||e[35]!==y?(C=o.jsx(Ws,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(fc,{children:[y,T]})}),e[34]=T,e[35]=y,e[36]=C):C=e[36];let R;return e[37]!==d||e[38]!==C||e[39]!==w?(R=o.jsxs(Us,{open:d,onOpenChange:u,children:[w,C]}),e[37]=d,e[38]=C,e[39]=w,e[40]=R):R=e[40],R}function Xh(){const t=V.c(26),{org:e}=ye(),{selectedVirtualMcp:s}=yi(),{data:i}=Si.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=lt();let a;t[0]!==e.id?(a=Yo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=gt(h.id),d=i?.user?.id??"",u=c?.metadata?.githubRepo??null,m=!!u?.connectionId&&!!d;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Vl,{size:32}),t[2]=_):_=t[2];let f;t[3]!==h.icon||t[4]!==h.title?(f=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]=f):f=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]!==u||t[13]!==e.id||t[14]!==n||t[15]!==m||t[16]!==d?(b=m&&o.jsx("div",{className:"mt-2",children:o.jsx(Yh,{orgId:e.id,userId:d,connectionId:u.connectionId,owner:u.owner,repo:u.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=u,t[13]=e.id,t[14]=n,t[15]=m,t[16]=d,t[17]=b):b=t[17];let S;t[18]!==f||t[19]!==p||t[20]!==v||t[21]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[f,p,v,b]}),t[18]=f,t[19]=p,t[20]=v,t[21]=b,t[22]=S):S=t[22];let x;t[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[23]=x):x=t[23];let w;return t[24]!==S?(w=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[24]=S,t[25]=w):w=t[25],w}function Jh(){const t=V.c(26),{org:e}=ye(),s=Nc(),{isChatEmpty:i}=Jo(),[r,n]=A.useState("chat"),a=zl();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.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&&!$l(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(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const d=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let u;t[10]!==d?(u=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",d),t[10]=d,t[11]=u):u=t[11];let m;t[12]!==i?(m=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(Xh,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=m):m=t[13];let _;t[14]!==u||t[15]!==m?(_=o.jsx("div",{className:u,children:m}),t[14]=u,t[15]=m,t[16]=_):_=t[16];const f=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==f?(p=te("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",f),t[17]=f,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Mh,{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(je,{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 Na(){const t=V.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Qt,{fallback:e,children:o.jsx(A.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(Jh,{})})}),t[1]=s):s=t[1],s}async function Zh(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 ja=["VM_START"],Zs=new Map,Qh=t=>`${t.virtualMcpId}::${t.branch??""}`;function sn(t){const e=Ht();return Uo({mutationKey:ja,mutationFn:async s=>{const i=Qh(s),r=Zs.get(i);if(r)return r;const n=(async()=>(await Zh(t,"VM_START",s)).structuredContent)();Zs.set(i,n);try{return await n}finally{Zs.get(i)===n&&Zs.delete(i)}},onSuccess:()=>{ni(e)}})}function Ea(t,e){const s=V.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:ja,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],Ch(i)>0}const ed={settings:_c,automations:mc,env:mi,preview:Xl,git:Rs};function An(t){const e=ki(t);if(e.type==="icon"){const s=Ni(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function $i(t){if(t.kind==="system")return{kind:"component",Component:ed[t.tabId]};const e=An(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=An(s.icon);return i||{kind:"fallback"}}function td(t){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),{data:i}=Tl({queryKey:As.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 Ta(t){const e=V.c(8),s=Mt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Yr(i),n=gt(t.virtualMcpId),a=td(t.taskId),{currentBranch:l}=lt(),h=n?.metadata?.ui??null,c=h?.layout??null,d=c?.tabs??[],u=h?.pinnedViews??[],m=a?.expanded_tools??[],_=!!(n&&Bt(n));let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f={includeVirtual:!0},e[1]=f):f=e[1];const p=ji(f),{activeTab:g,mainOpen:v}=tc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:d.map(sd)}:null}),b=Zo(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 j of m){const M=Sn(j.appId,j.toolName);x.set(M,{id:M,title:j.toolName,appId:j.appId,iconKey:j.toolName})}for(const j of u){const M=Sn(j.connectionId,j.toolName);x.set(M,{id:M,title:j.label||j.toolName,appId:j.connectionId,iconKey:j.toolName,iconUrl:j.icon??null})}let w;e[2]!==p?(w=j=>({id:j.id,title:j.title,kind:"agent",icon:$i({tabId:j.id,kind:"agent",appId:j.view.appId,connections:p})}),e[2]=p,e[3]=w):w=e[3];const N=[...d.map(w),...Array.from(x.values()).map(j=>({id:j.id,title:j.title,kind:"expanded",icon:$i({tabId:j.iconKey,kind:"expanded",appId:j.appId,iconUrl:j.iconUrl,connections:p})})),...S.map(j=>({id:j.id,title:j.title,kind:"system",icon:$i({tabId:j.id,kind:"system",connections:p})}))];let y;return e[4]!==g||e[5]!==v||e[6]!==s?(y=j=>{const M=sc({clickedId:j,activeTab:g,mainOpen:v});s({to:".",search:D=>({...D,main:M}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=y):y=e[7],{activeTab:g,mainOpen:v,setActiveTab:y,systemTabs:S,layoutTabs:d,expandedTools:m,automationTabParsed:b,tabs:N}}function sd(t){return{id:t.id}}function id(t){const e=V.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:d}=t,u=a===void 0?"lg":a,m=c===void 0?!0:c,_=d===void 0?!1:d,[f,p]=A.useState(!1),[g,v]=A.useState("icons"),[b,S]=A.useState(""),[x,w]=A.useState("blue");let N;e[0]!==s?(N=ki(s),e[0]=s,e[1]=N):N=e[1];const y=N,k=y.type==="icon"||y.type==="url"&&y.color?y.color:x;let j;e[2]!==i||e[3]!==k?(j=_e=>{i(Pi(_e,k))},e[2]=i,e[3]=k,e[4]=j):j=e[4];const M=j;let D;e[5]!==i||e[6]!==r||e[7]!==y.name||e[8]!==y.type||e[9]!==y.url?(D=_e=>{w(_e),r?.(_e),y.type==="icon"?i(Pi(y.name,_e)):y.type==="url"&&i(kn(y.url,_e))},e[5]=i,e[6]=r,e[7]=y.name,e[8]=y.type,e[9]=y.url,e[10]=D):D=e[10];const T=D;let C;e[11]!==i||e[12]!==k?(C=_e=>{i(kn(_e,k)),p(!1)},e[11]=i,e[12]=k,e[13]=C):C=e[13];const R=C;let E;e[14]!==i||e[15]!==k?(E=()=>{const _e=Jr(),Vt=_e[Math.floor(Math.random()*_e.length)];i(Pi(Vt,k))},e[14]=i,e[15]=k,e[16]=E):E=e[16];const L=E;let z,B,O,$,W,I,F,U;if(e[17]!==l||e[18]!==_||e[19]!==f||e[20]!==u){const _e={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Us,I=_?!1:f,F=p,z=Hs,W=!0,U="button",O=_,$=te("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",_e[u],l),e[17]=l,e[18]=_,e[19]=f,e[20]=u,e[21]=z,e[22]=B,e[23]=O,e[24]=$,e[25]=W,e[26]=I,e[27]=F,e[28]=U}else z=e[21],B=e[22],O=e[23],$=e[24],W=e[25],I=e[26],F=e[27],U=e[28];let K;e[29]!==h||e[30]!==n||e[31]!==u||e[32]!==s?(K=o.jsx(Nn,{icon:s,name:n,size:u,className:h}),e[29]=h,e[30]=n,e[31]=u,e[32]=s,e[33]=K):K=e[33];let G;e[34]!==_||e[35]!==m?(G=m&&!_&&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(ta,{size:16,className:"text-white"})}),e[34]=_,e[35]=m,e[36]=G):G=e[36];let P;e[37]!==O||e[38]!==$||e[39]!==K||e[40]!==G||e[41]!==U?(P=o.jsxs("button",{type:U,disabled:O,className:$,children:[K,G]}),e[37]=O,e[38]=$,e[39]=K,e[40]=G,e[41]=U,e[42]=P):P=e[42];let Z;e[43]!==z||e[44]!==W||e[45]!==P?(Z=o.jsx(z,{asChild:W,children:P}),e[43]=z,e[44]=W,e[45]=P,e[46]=Z):Z=e[46];let Y;e[47]!==n||e[48]!==s?(Y=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(Nn,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=Y):Y=e[49];let ee;e[50]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>v("icons"),e[50]=ee):ee=e[50];const ce=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ie;e[51]!==ce?(ie=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ce),e[51]=ce,e[52]=ie):ie=e[52];let Q;e[53]!==ie?(Q=o.jsx("button",{type:"button",onClick:ee,className:ie,children:"Icons"}),e[53]=ie,e[54]=Q):Q=e[54];let he;e[55]===Symbol.for("react.memo_cache_sentinel")?(he=()=>v("upload"),e[55]=he):he=e[55];const de=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let ue;e[56]!==de?(ue=te("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",de),e[56]=de,e[57]=ue):ue=e[57];let we;e[58]!==ue?(we=o.jsx("button",{type:"button",onClick:he,className:ue,children:"Upload"}),e[58]=ue,e[59]=we):we=e[59];let Xe;e[60]===Symbol.for("react.memo_cache_sentinel")?(Xe=o.jsx("div",{className:"flex-1"}),e[60]=Xe):Xe=e[60];let He;e[61]!==Q||e[62]!==we?(He=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[Q,we,Xe]}),e[61]=Q,e[62]=we,e[63]=He):He=e[63];let ne;e[64]!==T||e[65]!==L||e[66]!==M||e[67]!==R||e[68]!==y.name||e[69]!==y.type||e[70]!==b||e[71]!==k||e[72]!==g?(ne=g==="icons"?o.jsx(ad,{search:b,onSearchChange:S,selectedColor:k,onColorChange:T,onSelectIcon:M,onRandom:L,currentIconName:y.type==="icon"?y.name:null}):o.jsx(ld,{onUpload:R}),e[64]=T,e[65]=L,e[66]=M,e[67]=R,e[68]=y.name,e[69]=y.type,e[70]=b,e[71]=k,e[72]=g,e[73]=ne):ne=e[73];let ve;e[74]!==Y||e[75]!==He||e[76]!==ne?(ve=o.jsx(Ws,{align:"start",className:"w-80 p-0",onOpenAutoFocus:rd,children:o.jsxs("div",{className:"flex flex-col",children:[Y,He,ne]})}),e[74]=Y,e[75]=He,e[76]=ne,e[77]=ve):ve=e[77];let tt;return e[78]!==B||e[79]!==I||e[80]!==F||e[81]!==Z||e[82]!==ve?(tt=o.jsxs(B,{open:I,onOpenChange:F,children:[Z,ve]}),e[78]=B,e[79]=I,e[80]=F,e[81]=Z,e[82]=ve,e[83]=tt):tt=e[83],tt}function rd(t){return t.preventDefault()}function nd(t){const e=V.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=A.useState(!1);let a,l,h,c,d,u,m;if(e[0]!==r||e[1]!==s){const b=ea(s);l=Us,u=r,m=n,a=Hs,d=!0,h="button",c=te("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]=d,e[7]=u,e[8]=m}else a=e[2],l=e[3],h=e[4],c=e[5],d=e[6],u=e[7],m=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 f;e[12]!==a||e[13]!==d||e[14]!==_?(f=o.jsx(a,{asChild:d,children:_}),e[12]=a,e[13]=d,e[14]=_,e[15]=f):f=e[15];let p;e[16]!==i||e[17]!==s?(p=gc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:te("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(Ws,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:od,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]!==u||e[23]!==m||e[24]!==f||e[25]!==g?(v=o.jsxs(l,{open:u,onOpenChange:m,children:[f,g]}),e[21]=l,e[22]=u,e[23]=m,e[24]=f,e[25]=g,e[26]=v):v=e[26],v}function od(t){return t.preventDefault()}function ad(t){const e=V.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,d,u,m,_,f,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=Jr(),w=ea(r);d=s.trim()?x.filter(T=>{const C=ar(T),R=s.toLowerCase();return C.includes(R)||T.toLowerCase().includes(R)}):x,f="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Ca,{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 y;e[15]!==i?(y=T=>i(T.target.value),e[15]=i,e[16]=y):y=e[16];let k;e[17]!==s||e[18]!==y?(k=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(fs,{value:s,onChange:y,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=y,e[19]=k):k=e[19];let j;e[20]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(pc,{size:14,className:"text-muted-foreground"}),e[20]=j):j=e[20];let M;e[21]!==l?(M=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:j}),e[21]=l,e[22]=M):M=e[22];let D;e[23]!==n||e[24]!==r?(D=o.jsx(nd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=D):D=e[25],e[26]!==M||e[27]!==D||e[28]!==k?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[k,M,D]}),e[26]=M,e[27]=D,e[28]=k,e[29]=p):p=e[29],c=wa,_="h-56",u="grid grid-cols-9 gap-0.5 px-2 pb-2",m=d.map(T=>{const C=Ni(T);return C?o.jsx("button",{type:"button",onClick:()=>a(T),className:te("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===T?te(w.bg,w.text):te(w.text,"hover:bg-accent")),title:T,children:o.jsx(C,{size:18})},T):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=d,e[9]=u,e[10]=m,e[11]=_,e[12]=f,e[13]=p}else c=e[7],d=e[8],u=e[9],m=e[10],_=e[11],f=e[12],p=e[13];let g;e[30]!==u||e[31]!==m?(g=o.jsx("div",{className:u,children:m}),e[30]=u,e[31]=m,e[32]=g):g=e[32];let v;e[33]!==d.length?(v=d.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=d.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]!==f||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:f,children:[p,b]}),e[40]=f,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function ld(t){const e=V.c(27),{onUpload:s}=t,i=A.useRef(null);let r;e[0]!==s?(r=N=>{const y=N.target.files?.[0];if(!y)return;if(y.size>2097152){me.error("Image must be smaller than 2MB"),N.target.value="";return}const k=new FileReader;k.onerror=()=>{me.error("Failed to read image file"),i.current&&(i.current.value="")},k.onloadend=()=>{k.readyState===FileReader.DONE&&k.result&&s(k.result),i.current&&(i.current.value="")},k.readAsDataURL(y)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=A.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 d;e[5]!==n?(d=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=d):d=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.click(),e[7]=u):u=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsxs("button",{type:"button",onClick:u,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(Jl,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=m):m=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 f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=N=>l(N.target.value),e[10]=f):f=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(fs,{value:a,onChange:f,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(se,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let w;return e[24]!==x||e[25]!==d?(w=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[d,m,_,x]}),e[24]=x,e[25]=d,e[26]=w):w=e[26],w}function cd(t){const e=V.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=ki(s);if(n.type==="icon"){const a=Ni(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(Bc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function hd(t){const e=V.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=A.useState(!1),[h,c]=A.useState("");let d;e[0]!==s?(d=ki(s),e[0]=s,e[1]=d):d=e[1];const u=d,m=u.type==="icon"?u.name:null;let _,f,p,g,v,b,S,x,w,N,y,k,j,M,D;if(e[2]!==r||e[3]!==m||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=Jr();g=h.trim()?B.filter(K=>{const G=h.toLowerCase();return ar(K).includes(G)||K.toLowerCase().includes(G)}):B,p=Us,v=n?!1:a,b=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let $;e[24]!==r||e[25]!==O?($=te("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=$):$=e[26];let W;e[27]!==s?(W=o.jsx(cd,{value:s}),e[27]=s,e[28]=W):W=e[28],e[29]!==n||e[30]!==$||e[31]!==W?(S=o.jsx(Hs,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:$,children:W})}),e[29]=n,e[30]=$,e[31]=W,e[32]=S):S=e[32],f=Ws,j="start",M="w-64 p-0",D=dd,y="flex flex-col";let I;e[33]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(Ca,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=I):I=e[33];let F;e[34]===Symbol.for("react.memo_cache_sentinel")?(F=K=>c(K.target.value),e[34]=F):F=e[34],e[35]!==h?(k=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[I,o.jsx(fs,{value:h,onChange:F,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=k):k=e[36],_=wa,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let U;e[37]!==m||e[38]!==i?(U=K=>{const G=Ni(K);return G?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${K}`),l(!1)},className:te("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",m===K?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:ar(K),children:o.jsx(G,{size:16})},K):null},e[37]=m,e[38]=i,e[39]=U):U=e[39],w=g.map(U),e[2]=r,e[3]=m,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=f,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=w,e[18]=N,e[19]=y,e[20]=k,e[21]=j,e[22]=M,e[23]=D}else _=e[9],f=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],w=e[17],N=e[18],y=e[19],k=e[20],j=e[21],M=e[22],D=e[23];let T;e[40]!==x||e[41]!==w?(T=o.jsx("div",{className:x,children:w}),e[40]=x,e[41]=w,e[42]=T):T=e[42];let C;e[43]!==g.length?(C=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]=C):C=e[44];let R;e[45]!==_||e[46]!==T||e[47]!==C||e[48]!==N?(R=o.jsxs(_,{className:N,children:[T,C]}),e[45]=_,e[46]=T,e[47]=C,e[48]=N,e[49]=R):R=e[49];let E;e[50]!==R||e[51]!==y||e[52]!==k?(E=o.jsxs("div",{className:y,children:[k,R]}),e[50]=R,e[51]=y,e[52]=k,e[53]=E):E=e[53];let L;e[54]!==f||e[55]!==E||e[56]!==j||e[57]!==M||e[58]!==D?(L=o.jsx(f,{align:j,className:M,onOpenAutoFocus:D,children:E}),e[54]=f,e[55]=E,e[56]=j,e[57]=M,e[58]=D,e[59]=L):L=e[59];let z;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==L?(z=o.jsxs(p,{open:v,onOpenChange:b,children:[S,L]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=L,e[65]=z):z=e[65],z}function dd(t){return t.preventDefault()}function ai(){const t=V.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(Me,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Fi(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(Rl,{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 ud(t){const e=V.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=te("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 d;e[5]!==s.tags?(d=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=d):d=e[6];let u;e[7]!==c||e[8]!==d?(u=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,d]}),e[7]=c,e[8]=d,e[9]=u):u=e[9];let m;e[10]!==s.description?(m=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=m):m=e[11];let _;e[12]!==u||e[13]!==m?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[u,m]}),e[12]=u,e[13]=m,e[14]=_):_=e[14];let f;e[15]!==n||e[16]!==i||e[17]!==r?(f=o.jsx(rh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=f):f=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==f?(p=o.jsxs("label",{className:h,children:[_,f]}),e[19]=h,e[20]=_,e[21]=f,e[22]=p):p=e[22],p}function rn(t){const e=V.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 u=s.map(fd);if(s.length===0){let m;e[8]!==n?(m=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]=m):m=e[9],c=m;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(m=>o.jsx(ud,{item:m,isSelected:i===null||i?.includes(m.id),onToggle:()=>r(m.id,u),disabled:a},m.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 d;return e[10]!==l||e[11]!==h?(d=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=d):d=e[12],d}function fd(t){return t.id}function md(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=kc(c);let u;e[5]!==d.tools?(u=d.tools.map(_d),e[5]=d.tools,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function _d(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(Jc,{annotations:t.annotations,_meta:t._meta})}}function pd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=Yc(c);let u;e[5]!==d.resources?(u=d.resources.map(gd),e[5]=d.resources,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function gd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function vd(t){const e=V.c(12),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ye();let l;e[0]!==s||e[1]!==a.id?(l={connectionId:s,orgId:a.id},e[0]=s,e[1]=a.id,e[2]=l):l=e[2];const h=Fe(l);let c;e[3]!==h?(c={client:h},e[3]=h,e[4]=c):c=e[4];const{data:d}=nh(c);let u;e[5]!==d.prompts?(u=d.prompts.map(xd),e[5]=d.prompts,e[6]=u):u=e[6];const m=u;let _;return e[7]!==n||e[8]!==m||e[9]!==r||e[10]!==i?(_=o.jsx(rn,{items:m,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[7]=n,e[8]=m,e[9]=r,e[10]=i,e[11]=_):_=e[11],_}function xd(t){return{id:t.name,name:t.name,description:t.description}}function bd(t){const e=V.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:d,toggleAllPrompts:u,onTabChange:m}=t,_=n[r],f=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==u||e[3]!==d||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?d(r):u(r)},e[0]=i,e[1]=r,e[2]=u,e[3]=d,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 w;e[16]!==v||e[17]!==x?(w=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let y;e[20]!==m?(y=z=>m(z),e[20]=m,e[21]=y):y=e[21];let k;e[22]!==i||e[23]!==y?(k=o.jsx(ih,{tabs:N,activeTab:i,onTabChange:y}),e[22]=i,e[23]=y,e[24]=k):k=e[24];const j=f?"Deselect all":"Select all";let M;e[25]!==g||e[26]!==j?(M=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:j}),e[25]=g,e[26]=j,e[27]=M):M=e[27];let D;e[28]!==M||e[29]!==k?(D=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[k,M]}),e[28]=M,e[29]=k,e[30]=D):D=e[30];let T;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(T=i==="tools"&&o.jsx(Qt,{fallback:Fi("Tools not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(md,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(z,B)=>a(r,z,B)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=T):T=e[35];let C;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(C=i==="resources"&&o.jsx(Qt,{fallback:Fi("Resources not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(pd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(z,B)=>l(r,z,B)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=C):C=e[40];let R;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(R=i==="prompts"&&o.jsx(Qt,{fallback:Fi("Prompts not supported by this server"),children:o.jsx(A.Suspense,{fallback:o.jsx(ai,{}),children:o.jsx(vd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(z,B)=>h(r,z,B)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=R):R=e[45];let E;e[46]!==T||e[47]!==C||e[48]!==R?(E=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[T,C,R]}),e[46]=T,e[47]=C,e[48]=R,e[49]=E):E=e[49];let L;return e[50]!==D||e[51]!==E||e[52]!==w?(L=o.jsxs(o.Fragment,{children:[w,D,E]}),e[50]=D,e[51]=E,e[52]=w,e[53]=L):L=e[53],L}function Sd(t){const e=V.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=ha(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(vc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=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]=d):d=e[3];let u;e[4]!==s||e[5]!==i?(u=i&&o.jsx(se,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=u):u=e[6];let m;return e[7]!==u?(m=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,d,u]}),e[7]=u,e[8]=m):m=e[8],m}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function yd(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 Pn(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function wd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Cd(t){const e=V.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,d]=A.useReducer(wd,h),u=Qr(r??"");let m;e[1]!==a?(m=a??[],e[1]=a,e[2]=m):m=e[2];let _;e[3]!==m?(_=yd(m),e[3]=m,e[4]=_):_=e[4];const f=_;let p;e[5]!==n||e[6]!==f?(p=(I,F,U,K)=>{const G=f[I]?.[F];let P;G===null?P=K.filter(Y=>Y!==U):G?.includes(U)?P=G.filter(Y=>Y!==U):(P=[...G??[],U],P.length===K.length&&(P=null));const Z={...f};Z[I]?Z[I]={...Z[I]}:Z[I]={tools:null,resources:null,prompts:null},Z[I][F]=P,n.setValue("connections",Pn(Z),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=f,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==f?(v=(I,F)=>{const K=f[I]?.[F]===null?[]:null,G={...f};G[I]?G[I]={...G[I]}:G[I]={tools:null,resources:null,prompts:null},G[I][F]=K,n.setValue("connections",Pn(G),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=f,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(I,F,U)=>g(I,"tools",F,U),e[11]=g,e[12]=S):S=e[12];const x=S;let w;e[13]!==g?(w=(I,F,U)=>g(I,"resources",F,U),e[13]=g,e[14]=w):w=e[14];const N=w;let y;e[15]!==g?(y=(I,F,U)=>g(I,"prompts",F,U),e[15]=g,e[16]=y):y=e[16];const k=y;let j;e[17]!==b?(j=I=>b(I,"tools"),e[17]=b,e[18]=j):j=e[18];const M=j;let D;e[19]!==b?(D=I=>b(I,"resources"),e[19]=b,e[20]=D):D=e[20];const T=D;let C;e[21]!==b?(C=I=>b(I,"prompts"),e[21]=b,e[22]=C):C=e[22];const R=C;if(!r||!u)return null;let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(ai,{}),e[23]=E):E=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=I=>d({type:"SET_ACTIVE_TAB",payload:I}),e[24]=L):L=e[24];let z;e[25]!==u||e[26]!==c.activeTab||e[27]!==f||e[28]!==r||e[29]!==R||e[30]!==T||e[31]!==M||e[32]!==k||e[33]!==N||e[34]!==x?(z=o.jsx(bd,{currentConnection:u,activeTab:c.activeTab,selectedId:r,formData:f,toggleTool:x,toggleResource:N,togglePrompt:k,toggleAllTools:M,toggleAllResources:T,toggleAllPrompts:R,onTabChange:L},r),e[25]=u,e[26]=c.activeTab,e[27]=f,e[28]=r,e[29]=R,e[30]=T,e[31]=M,e[32]=k,e[33]=N,e[34]=x,e[35]=z):z=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==z?(B=o.jsx(A.Suspense,{fallback:E,children:o.jsx(Sd,{connectionId:r,onAuthenticate:l,children:z})}),e[36]=l,e[37]=r,e[38]=z,e[39]=B):B=e[39];let O;e[40]!==i?(O=o.jsx(Qc,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(se,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let $;e[42]!==B||e[43]!==O?($=o.jsxs(en,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,O]}),e[42]=B,e[43]=O,e[44]=$):$=e[44];let W;return e[45]!==i||e[46]!==s||e[47]!==$?(W=o.jsx(tn,{open:s,onOpenChange:i,children:$}),e[45]=i,e[46]=s,e[47]=$,e[48]=W):W=e[48],W}const Hi={tools:null,resources:null,prompts:null},kd=Dl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Nd(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function jd(t){const e=V.c(11),{url:s,agentId:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{Se("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),me.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(Ei,{size:20,className:"text-green-600"}):o.jsx(Ci,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let d;e[5]!==c?(d=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=d):d=e[6];let u;return e[7]!==l||e[8]!==h||e[9]!==d?(u=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,d]}),e[7]=l,e[8]=h,e[9]=d,e[10]=u):u=e[10],u}function Ed(t){const e=V.c(9),{url:s,serverName:i,agentId:r,organizationId:n}=t;let a;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(a=()=>{Se("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=da(i),_=Nd(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor","x-org-id":n}},null,2)),f=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(_)}`;window.open(f,"_blank"),me.success("Opening Cursor...")},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=a):a=e[4];const l=a;let h,c;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=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%)"}}),c=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[5]=h,e[6]=c):(h=e[5],c=e[6]);let d;return e[7]!==l?(d=o.jsxs(se,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,c]}),e[7]=l,e[8]=d):d=e[8],d}function Td(t){const e=V.c(13),{url:s,serverName:i,agentId:r,organizationId:n}=t,[a,l]=A.useState(!1);let h;e[0]!==r||e[1]!==n||e[2]!==i||e[3]!==s?(h=async()=>{Se("agent_connect_action",{agent_id:r,action:"install_claude_code"});const f=da(i),g=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code","x-org-id":n}},null,2),v=`claude mcp add-json "${f}" '${g.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(v),l(!0),me.success("Claude Code command copied to clipboard"),setTimeout(()=>l(!1),2e3)},e[0]=r,e[1]=n,e[2]=i,e[3]=s,e[4]=h):h=e[4];const c=h;let d;e[5]!==a?(d=a?o.jsx(Ei,{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[5]=a,e[6]=d):d=e[6];const u=a?"Copied!":"Install on Claude Code";let m;e[7]!==u?(m=o.jsx("span",{className:"text-xs font-medium",children:u}),e[7]=u,e[8]=m):m=e[8];let _;return e[9]!==c||e[10]!==d||e[11]!==m?(_=o.jsxs(se,{type:"button",variant:"outline",onClick:c,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[d,m]}),e[9]=c,e[10]=d,e[11]=m,e[12]=_):_=e[12],_}function Rd({virtualMcp:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),[i,r]=A.useState(null),[n,a]=A.useState(!1),[l,h]=A.useState(!1),c=t.id,d=t.title||`agent-${c.slice(0,8)}`,u=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,m=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${d}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),Se("agent_typegen_key_generated",{agent_id:c})}catch{Se("agent_typegen_key_failed",{agent_id:c}),me.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{Se("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(u),h(!0),me.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(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:m,disabled:n,children:[n?o.jsx(Me,{size:14,className:"animate-spin"}):o.jsx(sh,{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:u}),o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(Dd,{apiKey:i,agentId:c})]})}function Dd(t){const e=V.c(21),{apiKey:s,agentId:i}=t,[r,n]=A.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
3
3
  ${h}`;let d;e[0]!==i||e[1]!==s||e[2]!==c?(d=async()=>{Se("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]=d):d=e[3];const u=d,m=!s;let _;e[4]!==m?(_=te({"opacity-50":m}),e[4]=m,e[5]=_):_=e[5];let f;e[6]!==l||e[7]!==_?(f=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=f):f=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]!==f?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[f,p,g]}),e[11]=f,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Ei,{size:12,className:"text-green-600"}):o.jsx(Ci,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==u||e[16]!==b?(S=o.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:u,children:b}),e[15]=u,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 Md(t){const e=V.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(A.Suspense,{fallback:i,children:o.jsx(Rd,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Id(t){const e=V.c(38),{open:s,onOpenChange:i,virtualMcp:r}=t,n=`/mcp/virtual-mcp/${r.id}`;let a;e[0]!==n?(a=new URL(n,window.location.origin),e[0]=n,e[1]=a):a=e[1];const l=a;let h;e[2]!==r.id||e[3]!==r.title?(h=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=h):h=e[4];const c=h,d=aa();let u;e[5]!==r.id||e[6]!==l.href?(u=o.jsx(jd,{url:l.href,agentId:r.id}),e[5]=r.id,e[6]=l.href,e[7]=u):u=e[7];let m,_;e[8]!==c||e[9]!==r.id||e[10]!==r.organization_id||e[11]!==l.href?(m=o.jsx(Ed,{url:l.href,serverName:c,agentId:r.id,organizationId:r.organization_id}),_=o.jsx(Td,{url:l.href,serverName:c,agentId:r.id,organizationId:r.organization_id}),e[8]=c,e[9]=r.id,e[10]=r.organization_id,e[11]=l.href,e[12]=m,e[13]=_):(m=e[12],_=e[13]);let f;e[14]!==u||e[15]!==m||e[16]!==_?(f=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[u,m,_]})}),e[14]=u,e[15]=m,e[16]=_,e[17]=f):f=e[17];let p;e[18]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("div",{className:"border-t border-border"}),e[18]=p):p=e[18];let g;e[19]!==r?(g=o.jsx(Md,{virtualMcp:r}),e[19]=r,e[20]=g):g=e[20];let v;e[21]!==f||e[22]!==g?(v=o.jsxs("div",{className:"flex flex-col gap-6",children:[f,p,g]}),e[21]=f,e[22]=g,e[23]=v):v=e[23];const b=v;if(d){let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(lh,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[24]=N):N=e[24];let y;e[25]!==b?(y=o.jsx(ch,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[N,b]})}),e[25]=b,e[26]=y):y=e[26];let k;return e[27]!==i||e[28]!==s||e[29]!==y?(k=o.jsx(hh,{open:s,onOpenChange:i,children:y}),e[27]=i,e[28]=s,e[29]=y,e[30]=k):k=e[30],k}let S;e[31]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(ba,{children:o.jsx(Sa,{children:"Connect"})}),e[31]=S):S=e[31];let x;e[32]!==b?(x=o.jsxs(en,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[S,b]}),e[32]=b,e[33]=x):x=e[33];let w;return e[34]!==i||e[35]!==s||e[36]!==x?(w=o.jsx(tn,{open:s,onOpenChange:i,children:x}),e[34]=i,e[35]=s,e[36]=x,e[37]=w):w=e[37],w}function Bd(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 Ad(t){const e=V.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=Qr(s),{org:d}=ye();if(!c)return null;let u;e[0]!==c?(u=Zc(c),e[0]=c,e[1]=u):u=e[1];const m=u;let _;e[2]!==s?(_=o.jsx(zd,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let f;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]!==d.slug||e[16]!==m||e[17]!==i?(f=o.jsx(Od,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:m,orgSlug:d.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]=d.slug,e[16]=m,e[17]=i,e[18]=f):f=e[18];let p;return e[19]!==_||e[20]!==f?(p=o.jsx(A.Suspense,{fallback:_,children:f}),e[19]=_,e[20]=f,e[21]=p):p=e[21],p}const Ln="__new_instance__";async function Pd(t,e){const s=t?.idToken??null;if(s){const r=On(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 On(e)}function On(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 Ld(t){const e=V.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=ji(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===Ln?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(ts,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(ss,{})}),e[6]=d):d=e[6];let u;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(Dt,{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],u=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=u}else u=e[10];let m;e[14]!==a?(m=a&&o.jsx(Dt,{value:Ln,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=m):m=e[15];let _;e[16]!==u||e[17]!==m?(_=o.jsxs(is,{children:[u,m]}),e[16]=u,e[17]=m,e[18]=_):_=e[18];let f;return e[19]!==i||e[20]!==c||e[21]!==_?(f=o.jsxs(es,{value:i,onValueChange:c,children:[d,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=f):f=e[22],f}function Od(t){const e=V.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:d,onOpenSettings:u,onRemove:m,onAuthenticate:_,onSwitchInstance:f,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=ha(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let w;e[2]!==x?(w=te("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=w):w=e[3];let N;e[4]!==h||e[5]!==l?(N={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=N):N=e[6];let y;e[7]!==n||e[8]!==i?(y=o.jsx(ds,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=y):y=e[9];let k;e[10]!==i?(k=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=k):k=e[11];let j;e[12]!==r||e[13]!==S?(j=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]=j):j=e[14];let M;e[15]!==k||e[16]!==j?(M=o.jsxs("div",{className:"flex-1 min-w-0",children:[k,j]}),e[15]=k,e[16]=j,e[17]=M):M=e[17];let D;e[18]!==s||e[19]!==S||e[20]!==_?(D=S?o.jsx(se,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:K=>{K.preventDefault(),K.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ve,{delayDuration:0,children:[o.jsx(Ke,{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(th,{size:16})})}),o.jsx(qe,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=D):D=e[21];let T;e[22]!==N||e[23]!==y||e[24]!==M||e[25]!==D?(T=o.jsxs(Bl,{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:[y,M,D]}),e[22]=N,e[23]=y,e[24]=M,e[25]=D,e[26]=T):T=e[26];let C;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==f||e[31]!==d?(C=c&&o.jsx(Ld,{appName:c,connectionId:s,usedConnectionIds:d,onSwitchInstance:f,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=f,e[31]=d,e[32]=C):C=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=o.jsx(bc,{size:13}),e[33]=R):R=e[33];let E;e[34]!==u?(E=o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:u,"aria-label":"Configure resources",children:R})}),e[34]=u,e[35]=E):E=e[35];let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=o.jsx(qe,{side:"bottom",children:"Configure resources"}),e[36]=L):L=e[36];let z;e[37]!==E?(z=o.jsxs(Ve,{delayDuration:0,children:[E,L]}),e[37]=E,e[38]=z):z=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=o.jsx(ls,{size:13}),e[39]=B):B=e[39];let O;e[40]!==m?(O=o.jsx(Ke,{asChild:!0,children:o.jsx(se,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:m,"aria-label":"Remove connection",children:B})}),e[40]=m,e[41]=O):O=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx(qe,{side:"bottom",children:"Remove"}),e[42]=$):$=e[42];let W;e[43]!==O?(W=o.jsxs(Ve,{delayDuration:0,children:[O,$]}),e[43]=O,e[44]=W):W=e[44];let I;e[45]!==z||e[46]!==W?(I=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[z,W]}),e[45]=z,e[46]=W,e[47]=I):I=e[47];let F;e[48]!==C||e[49]!==I?(F=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[C,I]}),e[48]=C,e[49]=I,e[50]=F):F=e[50];let U;return e[51]!==T||e[52]!==F||e[53]!==w?(U=o.jsxs("div",{className:w,children:[T,F]}),e[51]=T,e[52]=F,e[53]=w,e[54]=U):U=e[54],U}function zd(t){const e=V.c(17),{connection_id:s}=t,i=Qr(s);if(!i){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(Ra,{}),e[0]=u):u=e[0],u}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 d;return e[15]!==h?(d=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=d):d=e[16],d}function Ra(){const t=V.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 $d({virtualMcpId:t}){const{org:e}=ye(),s=Fe({connectionId:It,orgId:e.id}),i=Ht(),r=gt(t),n=(r?.connections??[]).map(O=>O.connection_id).sort(),{data:a}=Wo({queryKey:As.projectConnectionDetails(t,n),enabled:n.length>0,queryFn:async()=>await Promise.all(n.map(async $=>{try{const W=await s.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:$}}),{item:I}=Li(W),F=(I?.tools??[]).filter(U=>!!Xc(U._meta)).map(U=>({name:U.name,description:U.description}));return{fetchOk:!0,id:$,title:I?.title??$,icon:I?.icon??null,uiTools:F}}catch{return{fetchOk:!1,id:$,title:$,icon:null,uiTools:[]}}}))}),l=(a??[]).filter(O=>O.uiTools.length>0),h=new Set(ic),c=r?.metadata?.ui,d=c?.pinnedViews??[],u=c?.layout?.defaultMainView??null,m=c?.layout?.chatDefaultOpen??!1,_=!u||u.type==="chat"?"chat":u.type==="instructions"||u.type==="connections"||u.type==="layout"?"settings":h.has(u.type)?u.type:`${u.type}:${u.id??""}:${u.toolName??""}`,[f,p]=A.useState(d),[g,v]=A.useState(_),[b,S]=A.useState(m),[x,w]=A.useState(!1),N=O=>{const[$,W,I]=O.split(":");return $?$==="chat"?{type:$}:h.has($)?{type:$}:$==="ext-apps"&&W?{type:"ext-apps",id:W,toolName:I||void 0}:null:null},y=A.useRef(!1);if(a&&a.length>0&&!y.current){y.current=!0;const O=new Set((a??[]).filter(I=>I.fetchOk).map(I=>I.id)),$=new Set(l.flatMap(I=>I.uiTools.map(F=>`${I.id}:${F.name}`))),W=d.filter(I=>!O.has(I.connectionId)||$.has(`${I.connectionId}:${I.toolName}`));if(W.length!==d.length){p(W);let I=g;u?.type==="ext-apps"&&!W.some(F=>F.connectionId===u.id&&F.toolName===u.toolName)&&(I="chat",v(I)),s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:W,layout:{defaultMainView:N(I),chatDefaultOpen:b}}}).then(F=>{Li(F),i.invalidateQueries({predicate:U=>Array.isArray(U.queryKey)&&U.queryKey.includes("collection")&&U.queryKey.includes("VIRTUAL_MCP")})}).catch(()=>{p(d),v(_)})}}const k=(O,$,W)=>{w(!0),(async()=>{try{const F=await s.callTool({name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",arguments:{virtualMcpId:t,pinnedViews:O,layout:{defaultMainView:N($),chatDefaultOpen:W??b}}});Li(F),i.invalidateQueries({predicate:U=>Array.isArray(U.queryKey)&&U.queryKey.includes("collection")&&U.queryKey.includes("VIRTUAL_MCP")}),me.success("Layout updated")}catch(F){me.error("Failed to update layout: "+(F instanceof Error?F.message:"Unknown error"))}finally{w(!1)}})()},j=(O,$)=>{const W=f.some(U=>U.connectionId===O&&U.toolName===$);let I,F=g;if(W){I=f.filter(K=>!(K.connectionId===O&&K.toolName===$));const U=`ext-apps:${O}:${$}`;g===U&&(F="chat",v(F))}else I=[...f,{connectionId:O,toolName:$,label:yn($),icon:null}];p(I),k(I,F)},M=(O,$,W)=>{p(I=>I.map(F=>F.connectionId===O&&F.toolName===$?{...F,label:W}:F))},D=()=>{k(f,g)},T=(O,$,W)=>{p(F=>F.map(U=>U.connectionId===O&&U.toolName===$?{...U,icon:W}:U));const I=f.map(F=>F.connectionId===O&&F.toolName===$?{...F,icon:W}:F);k(I,g)},C=O=>{v(O),k(f,O)},R=n.length===0,E=a&&l.length===0,L=!!Bt(r),z=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];L&&(z.push({value:"env",label:"Terminal"}),z.push({value:"preview",label:"Preview"}));for(const O of f)z.push({value:`ext-apps:${O.connectionId}:${O.toolName}`,label:O.label||O.toolName});const B=l.length>0||R||E;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(eh,{className:"p-6 gap-5",children:[o.jsxs(Tn,{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(Ms,{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:g,onValueChange:C,children:[o.jsx(ts,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(ss,{})}),o.jsx(is,{children:z.map(O=>o.jsx(Dt,{value:O.value,className:"capitalize",children:O.label},O.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(Ms,{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(Ve,{delayDuration:0,children:[o.jsx(Ke,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(cr,{checked:g==="chat"?!0:b,disabled:g==="chat"||x,onCheckedChange:O=>{S(O),k(f,g,O)}})})}),g==="chat"&&o.jsx(qe,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),B&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Tn,{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(Ms,{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."})]})}),R&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),E&&!R&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),l.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:l.map((O,$)=>o.jsxs("div",{children:[$>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:O.icon,name:O.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:O.title})]}),o.jsx("div",{className:"space-y-1.5",children:O.uiTools.map(W=>{const I=f.some(U=>U.connectionId===O.id&&U.toolName===W.name),F=f.find(U=>U.connectionId===O.id&&U.toolName===W.name);return o.jsxs("div",{className:te("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",I?"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(hd,{value:F?.icon??null,onChange:U=>T(O.id,W.name,U),disabled:!I||x}),o.jsx(fs,{value:I&&F?F.label:yn(W.name),onChange:U=>M(O.id,W.name,U.target.value),onBlur:D,className:"h-7 text-sm w-40",disabled:!I||x,readOnly:!I})]}),o.jsx(cr,{checked:I,onCheckedChange:()=>j(O.id,W.name),disabled:x})]},W.name)})})]},O.id))})]})]})]})]})}function Fd({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ye(),i=Ul(),r=qc(),n=Ht(),a=Fe({connectionId:It,orgId:s.id}),l=Vo({resolver:Ml(kd),defaultValues:t}),h=l.watch("connections"),c=!!Bt(t),[d,u]=A.useReducer(Bd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[m,_]=A.useState(!1),{createTaskWithMessage:f}=lt(),{setChatMode:p}=yi(),{createNewTask:g}=Zr(),v=()=>{const P=l.getValues("metadata.instructions");P?.trim()&&(M(),Se("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:P.length}),p("plan"),f({virtualMcpId:Xo(s.id),message:{parts:[{type:"text",text:`/writing-prompts ${t.id}
4
4
 
5
5
  <instructions>
@@ -186,4 +186,4 @@ ${X}
186
186
 
187
187
  <message>
188
188
  ${ve}
189
- </message>`}]}}))},B=e.models?.credentialId||_||"",O=e.models?.thinking?.id||f?.modelId||"",$=Vo({defaultValues:{name:e.name,active:e.active,credential_id:B,model_id:O}}),W=$.watch("active"),I=$.watch("credential_id"),F=$.watch("model_id"),{models:U,isLoading:K}=jc(I||void 0),G=U.find(ne=>ne.modelId===F)??null,P=A.useRef(null),Z=A.useRef(new Set),Y=A.useRef(0),ee=A.useRef(null),ce=3e4,ie=()=>{ee.current&&(clearTimeout(ee.current),ee.current=null),P.current!==null&&(Se("automation_updated",{automation_id:t,agent_id:n,fields:Array.from(Z.current),save_count:Y.current,edit_duration_ms:Date.now()-P.current}),P.current=null,Z.current=new Set,Y.current=0)},Q=async()=>{if(!(Object.keys($.formState.dirtyFields).length>0)&&!E.current)return!0;const ve=Object.keys($.formState.dirtyFields),tt=E.current;E.current=!1;const _e=$.getValues(),Vt=L.current;try{const gs=_e.credential_id&&_e.model_id?_e.credential_id:"",X=_e.credential_id&&_e.model_id?_e.model_id:"",oe={id:t,name:_e.name,active:_e.active,agent:{id:n},models:{credentialId:gs,thinking:{id:X}},messages:Kl(Vt),temperature:0};await l.mutateAsync(oe),P.current===null&&(P.current=Date.now());for(const Be of ve)Z.current.add(Be);return tt&&Z.current.add("messages"),Y.current+=1,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(ie,ce),$.reset({..._e,credential_id:gs,model_id:X},{keepDirtyValues:!0}),!0}catch{return E.current=!0,!1}},he=A.useRef(Q);he.current=Q;const de=()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=null,he.current()},1e3)},ue=async()=>(R.current&&(clearTimeout(R.current),R.current=null),he.current()),we=ne=>{if(L.current=ne,x(ne),!C.current){C.current=!0;return}E.current=!0,de()},Xe=A.useRef(!1);Xe.current||(Xe.current=!0,$.watch(()=>{de()})),A.useEffect(()=>()=>{R.current&&(clearTimeout(R.current),R.current=null,he.current())},[]);const He=async()=>{Se("automation_test_clicked",{automation_id:t,agent_id:n});const ne=await ue();if(ie(),!ne)return;if(!S){me.error("No instructions configured for this automation");return}G&&I&&m({...G,keyId:I}),v({...g,toolApprovalLevel:"auto"});const ve=xn(S);u({message:{tiptapDoc:S,parts:ve},virtualMcpId:n||void 0})};return o.jsxs(o.Fragment,{children:[i&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(se,{variant:"ghost",size:"sm",onClick:i,children:[o.jsx(ka,{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(fs,{...$.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),r&&o.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:o.jsx(hr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Xt,{control:$.control,name:"active",render:({field:ne})=>o.jsx(cr,{checked:ne.value,onCheckedChange:ve=>{ne.onChange(ve),setTimeout(()=>ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ca,{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(Np,{automationId:t,open:w,onOpenChange:N,onCustomSelect:()=>{k(!0),T(!1),M("")},onEventSelect:()=>{T(!0),k(!1)}})]}),e.triggers.length===0&&!y?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:()=>N(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ne=>o.jsx(jp,{trigger:ne,automationId:t,connectionName:ne.connection_id?d.get(ne.connection_id):void 0},ne.id))}),y&&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(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:j,onChange:ne=>M(ne.target.value),onBlur:async()=>{const ne=j.trim();if(!(!ne||!Bs(ne)))try{await h.mutateAsync({automation_id:t,type:"cron",cron_expression:ne}),Se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),k(!1),M("")}catch{me.error("Failed to add starter")}},onKeyDown:async ne=>{const ve=j.trim();ne.key==="Enter"&&ve&&Bs(ve)&&ne.target.blur(),ne.key==="Escape"&&(k(!1),M(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Bs(j)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),h.isPending&&o.jsx(Me,{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:()=>{k(!1),M("")},children:o.jsx(ls,{size:13})})]}),D&&o.jsx(A.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(Me,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Tp,{automationId:t,onDone:()=>T(!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(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!S,onClick:z,children:[o.jsx(ya,{size:13}),"Improve"]})]}),o.jsx(Hl,{tiptapDoc:S,setTiptapDoc:we,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(Wl,{virtualMcpId:n||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(gh,{model:G,isLoading:K,credentialId:I||null,onCredentialChange:ne=>{$.setValue("credential_id",ne??"",{shouldDirty:!0}),$.setValue("model_id","",{shouldDirty:!0})},onModelChange:ne=>$.setValue("model_id",ne.modelId,{shouldDirty:!0}),placeholder:"Model"}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:He,disabled:!n,children:[o.jsx(Ql,{size:16}),"Test"]})}),o.jsx(qe,{children:"Test Automation"})]})]})]})})]})]})]})}function Bp(t){const e=V.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=Zo(s),e[0]=s,e[1]=r):r=e[1];const n=r;if(!n)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==n.id||e[4]!==i?(l=o.jsx(at,{children:o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsx(A.Suspense,{fallback:a,children:o.jsx(Ap,{id:n.id,virtualMcpId:i})})})})}),e[3]=n.id,e[4]=i,e[5]=l):l=e[5],l}function Ap(t){const e=V.c(9),{id:s,virtualMcpId:i}=t,r=Mt(),{data:n,isLoading:a}=xh(s);let l;e[0]!==r?(l=()=>r({to:".",search:Pp,replace:!0}),e[0]=r,e[1]=l):l=e[1];const h=l;if(a){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=d):d=e[2],d}if(!n){let d;return e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=d):d=e[3],d}let c;return e[4]!==n||e[5]!==s||e[6]!==h||e[7]!==i?(c=o.jsx(Ip,{automationId:s,automation:n,virtualMcpId:i,onBack:h}),e[4]=n,e[5]=s,e[6]=h,e[7]=i,e[8]=c):c=e[8],c}function Pp(t){return{...t,main:"automations"}}function Lp(t){const e=V.c(20),{virtualMcpId:s}=t,i=Mt(),{data:r}=bh(s),n=r===void 0?[]:r,{create:a}=Vs(),[l,h]=A.useState(""),c=l.toLowerCase(),d=n.filter(M=>M.name.toLowerCase().includes(c));let u;e[0]!==i?(u=M=>i({to:".",search:D=>({...D,main:"automation:"+M}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const m=u,_=async()=>{if(a.isPending)return;Se("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const M=await a.mutateAsync(yh(s));m(M.id)},f=at,p=at,g=at;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(at.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(wh,{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(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(se,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let w;e[7]!==b||e[8]!==x?(w=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]=w):w=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{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(se,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):d.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{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:d.map(M=>o.jsx(Sh,{automation:M,onClick:()=>m(M.id)},M.id))});let y;e[10]!==N||e[11]!==g.Body||e[12]!==w?(y=o.jsxs(g.Body,{children:[w,N]}),e[10]=N,e[11]=g.Body,e[12]=w,e[13]=y):y=e[13];let k;e[14]!==y||e[15]!==p.Content?(k=o.jsx(p.Content,{children:y}),e[14]=y,e[15]=p.Content,e[16]=k):k=e[16];let j;return e[17]!==f||e[18]!==k?(j=o.jsx(f,{children:k}),e[17]=f,e[18]=k,e[19]=j):j=e[19],j}function Op(t){const e=V.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(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(A.Suspense,{fallback:i,children:o.jsx(Lp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Lo=A.lazy(()=>Pl(()=>import("./project-app-view-DufFnF1s.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])).then(t=>({default:t.AppViewContent})));function zp(t){const e=V.c(44),{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}=Ta(r);if(nc(n)){let f;return e[3]!==i?(f=o.jsx(zn,{virtualMcpId:i}),e[3]=i,e[4]=f):f=e[4],f}if(n==="git"){let f;return e[5]!==i?(f=o.jsx(bu,{virtualMcpId:i}),e[5]=i,e[6]=f):f=e[6],f}if(n==="automations"){let f;return e[7]!==i?(f=o.jsx(Op,{virtualMcpId:i}),e[7]=i,e[8]=f):f=e[8],f}if(n==="env"){let f;return e[9]!==i?(f=o.jsx(bp,{virtualMcpId:i}),e[9]=i,e[10]=f):f=e[10],f}if(n==="preview"){let f;return e[11]!==i?(f=o.jsx(tf,{virtualMcpId:i}),e[11]=i,e[12]=f):f=e[12],f}if(h){let f;return e[13]!==n||e[14]!==i?(f=o.jsx(Bp,{tabId:n,virtualMcpId:i}),e[13]=n,e[14]=i,e[15]=f):f=e[15],f}let c;e[16]!==n?(c=oc(n),e[16]=n,e[17]=c):c=e[17];const d=c;if(d){let f;if(e[18]!==l||e[19]!==d.connectionId||e[20]!==d.toolName){let S;e[22]!==d.connectionId||e[23]!==d.toolName?(S=x=>x.appId===d.connectionId&&x.toolName===d.toolName,e[22]=d.connectionId,e[23]=d.toolName,e[24]=S):S=e[24],f=l.find(S),e[18]=l,e[19]=d.connectionId,e[20]=d.toolName,e[21]=f}else f=e[21];const p=f;let g;e[25]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[25]=g):g=e[25];const v=p?.args;let b;return e[26]!==n||e[27]!==d.connectionId||e[28]!==d.toolName||e[29]!==v?(b=o.jsx(A.Suspense,{fallback:g,children:o.jsx(Lo,{connectionId:d.connectionId,toolName:d.toolName,args:v},n)}),e[26]=n,e[27]=d.connectionId,e[28]=d.toolName,e[29]=v,e[30]=b):b=e[30],b}let u;if(e[31]!==n||e[32]!==a){let f;e[34]!==n?(f=p=>p.id===n,e[34]=n,e[35]=f):f=e[35],u=a.find(f),e[31]=n,e[32]=a,e[33]=u}else u=e[33];const m=u;if(m){let f;e[36]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[36]=f):f=e[36];let p;return e[37]!==n||e[38]!==m.id||e[39]!==m.view.appId||e[40]!==m.view.args?(p=o.jsx(A.Suspense,{fallback:f,children:o.jsx(Lo,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},n)}),e[37]=n,e[38]=m.id,e[39]=m.view.appId,e[40]=m.view.args,e[41]=p):p=e[41],p}let _;return e[42]!==i?(_=o.jsx(zn,{virtualMcpId:i}),e[42]=i,e[43]=_):_=e[43],_}function $p(t){const e=V.c(7),{children:s,defaultSize:i}=t,[,r]=A.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Go.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=qo(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=m=>r(()=>{m>0&&m<100&&l(m)}),e[1]=l,e[2]=c):c=e[2];const d=c;let u;return e[3]!==s||e[4]!==h||e[5]!==d?(u=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:d,order:1,children:s}),e[3]=s,e[4]=h,e[5]=d,e[6]=u):u=e[6],u}function Fp(t){const e=V.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=En(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=Go.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=qo(c,45),u=A.useRef(null);let m,_;e[4]!==r||e[5]!==n||e[6]!==d?(m=()=>{const M=u.current;if(!M)return;const D=En(r,n),T=D.chat>0&&D.chat<100?d:D.chat,C=D.chat>0&&D.chat<100?100-d:D.main;M.setLayout([T,C])},_=[r,n,d],e[4]=r,e[5]=n,e[6]=d,e[7]=m,e[8]=_):(m=e[7],_=e[8]),A.useEffect(m,_);const f=`${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(Na,{}),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($p,{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(Vc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=te("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 y;e[20]!==i||e[21]!==s?(y=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(zp,{taskId:i,virtualMcpId:s})})})}),e[20]=i,e[21]=s,e[22]=y):y=e[22];let k;e[23]!==h.main||e[24]!==y?(k=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:y}),e[23]=h.main,e[24]=y,e[25]=k):k=e[25];let j;return e[26]!==k||e[27]!==f||e[28]!==b?(j=o.jsxs(Kc,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,k]},f),e[26]=k,e[27]=f,e[28]=b,e[29]=j):j=e[29],j}const nr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Oo="bg-sidebar-accent text-sidebar-foreground",or="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Hp(t){const e=V.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Ec(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Se("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?Oo:or;let d;e[3]!==c?(d=te(nr,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(wc,{size:16}),e[5]=u):u=e[5];let m;e[6]!==h||e[7]!==d||e[8]!==n?(m=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=n,e[9]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(qe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let f;e[11]!==m?(f=o.jsxs(Ve,{delayDuration:300,children:[m,_]}),e[11]=m,e[12]=f):f=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Se("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?Oo:or;let v;e[16]!==g?(v=te(nr,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Cc,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ke,{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(qe,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(Ve,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let y;e[26]!==N?(y=te("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=y):y=e[27];const k=!l,j=l?0:-1,M=!l,D=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==D?(T=te(nr,or,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",D),e[28]=D,e[29]=T):T=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(ta,{size:16}),e[30]=C):C=e[30];let R;e[31]!==r||e[32]!==k||e[33]!==j||e[34]!==M||e[35]!==T?(R=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:k,tabIndex:j,"aria-hidden":M,className:T,children:C})}),e[31]=r,e[32]=k,e[33]=j,e[34]=M,e[35]=T,e[36]=R):R=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(qe,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let L;e[38]!==R?(L=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ve,{delayDuration:300,children:[R,E]})}),e[38]=R,e[39]=L):L=e[39];let z;e[40]!==y||e[41]!==L?(z=o.jsx("div",{className:y,children:L}),e[40]=y,e[41]=L,e[42]=z):z=e[42];let B;return e[43]!==w||e[44]!==z||e[45]!==f?(B=o.jsxs(o.Fragment,{children:[f,w,z]}),e[43]=w,e[44]=z,e[45]=f,e[46]=B):B=e[46],B}function Wp(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(u=>u.id===e))return{visible:i,overflow:r};const a=r.findIndex(u=>u.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],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function Up(t){const e=V.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=te("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(Vp,{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 d;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=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]=d):d=e[12],d}function Vp(t){const e=V.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 Kp(t){const e=V.c(13),{overflow:s,onSelect:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i?(a=m=>{n(!1),i(m)},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(Hs,{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(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let m;e[6]!==l?(m=_=>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(qp,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=m):m=e[7],c=s.map(m),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=o.jsx(Ws,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=o.jsxs(Us,{open:r,onOpenChange:n,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function qp(t){const e=V.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 Gp=6;function Yp(t){const e=V.c(20),{virtualMcpId:s,taskId:i}=t,r=Mt();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}=Ta(n);let d,u,m,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=ac({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:w}=Wp(a,S,Gp);u=w,d=N=>{const y=a.find(j=>j.id===N),k=S===N&&h;if(Se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:y?.kind??null,was_active:k}),N==="automations"){const j=lc({activeTab:l,mainOpen:h});r({to:".",search:M=>({...M,main:j}),replace:!0});return}c(N)},m="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(Up,{title:N.title,icon:N.icon,active:v(N),onClick:()=>d(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=m,e[12]=_}else d=e[9],u=e[10],m=e[11],_=e[12];let f;e[13]!==d||e[14]!==u?(f=u.length>0&&o.jsx(Kp,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=f):f=e[15];let p;return e[16]!==m||e[17]!==_||e[18]!==f?(p=o.jsxs("div",{className:m,children:[_,f]}),e[16]=m,e[17]=_,e[18]=f,e[19]=p):p=e[19],p}function Xp(t){const e=V.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=te("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(Ll,{"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 Jp(t){const e=V.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(cu({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(lu({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(se,{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 d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(dr,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=o.jsx(ns,{asChild:!0,children:o.jsx(se,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:d})}),e[10]=i,e[11]=u):u=e[11];let m;e[12]!==h?(m=o.jsx(os,{align:"end",children:o.jsx(yt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=m):m=e[13];let _;e[14]!==u||e[15]!==m?(_=o.jsxs(rs,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=_):_=e[16];let f;return e[17]!==c||e[18]!==_?(f=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=f):f=e[19],f}const Zp=new Set(["failure","timed_out","cancelled","action_required"]);function Qp(t){return t.status==="completed"&&Zp.has(t.conclusion)}function eg(t){return t.status==="queued"||t.status==="in_progress"}function tg(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"};if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.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(e.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 ${e.branch} → ${e.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 h=i.filter(Qp).map(u=>u.name);if(h.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${h.join(", ")}`,meta:{failingChecks:h}};const c=i.filter(eg);if(c.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${c.length} check${c.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 ${e.base}`}}function sg(){return ms().branchStatus}const ig=6e4,rg=3e4;function ng(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:ig,refetchIntervalInBackground:!1,staleTime:rg,select:og},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function og(t){const e=Ks(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 ag(t){const e=V.c(39),{virtualMcpId:s}=t,{org:i}=ye(),r=gt(s),{currentBranch:n}=lt(),a=wi(),l=r?.metadata?.githubRepo??null,h=sg(),c=l?.connectionId??"",d=l?.owner??"",u=l?.name??"",m=n??null;let _;e[0]!==i.id||e[1]!==c||e[2]!==d||e[3]!==u||e[4]!==m?(_={orgId:i.id,connectionId:c,owner:d,repo:u,branch:m},e[0]=i.id,e[1]=c,e[2]=d,e[3]=u,e[4]=m,e[5]=_):_=e[5];const f=Da(_),p=f.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[6]!==i.id||e[7]!==g||e[8]!==v||e[9]!==b||e[10]!==S?(x={orgId:i.id,connectionId:g,owner:v,repo:b,prNumber:S},e[6]=i.id,e[7]=g,e[8]=v,e[9]=b,e[10]=S,e[11]=x):x=e[11];const w=Ia(x),N=l?.connectionId??"",y=l?.owner??"",k=l?.name??"",j=p&&p.state==="open"?p.number:null;let M;e[12]!==i.id||e[13]!==N||e[14]!==y||e[15]!==k||e[16]!==j?(M={orgId:i.id,connectionId:N,owner:y,repo:k,prNumber:j},e[12]=i.id,e[13]=N,e[14]=y,e[15]=k,e[16]=j,e[17]=M):M=e[17];const D=ng(M);if(!l?.connectionId||!n)return null;let T;e[18]!==h||e[19]!==w.data||e[20]!==p||e[21]!==f.isPending||e[22]!==D.data?(T=tg({branchStatus:h,pr:p,checks:w.data??[],reviews:D.data??null,loading:f.isPending}),e[18]=h,e[19]=w.data,e[20]=p,e[21]=f.isPending,e[22]=D.data,e[23]=T):T=e[23];const C=T;let R;e[24]!==a?(R=I=>a.sendMessage({parts:[{type:"text",text:I}]}),e[24]=a,e[25]=R):R=e[25];const E=R,L=a.isStreaming;let z;e[26]!==n||e[27]!==C||e[28]!==L||e[29]!==p||e[30]!==E?(z=I=>{if(!L)switch(I){case"commit-and-push":{E(eu({branch:n}));return}case"create-pr":{E(tu({branch:n}));return}case"reopen":{p&&E(su({prNumber:p.number}));return}case"rebase":{E(iu({branch:n}));return}case"fix-checks":{p&&E(nu({prNumber:p.number,failingChecks:C.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(ou({prNumber:p.number}));return}case"resolve-comments":{p&&E(au({prNumber:p.number}));return}case"merge-split":return}},e[26]=n,e[27]=C,e[28]=L,e[29]=p,e[30]=E,e[31]=z):z=e[31];const B=z;let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(Xp,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[32]=O):O=e[32];const $=p?.number;let W;return e[33]!==C||e[34]!==L||e[35]!==B||e[36]!==E||e[37]!==$?(W=o.jsxs(o.Fragment,{children:[O,o.jsx(lg,{button:C,isStreaming:L,onActivate:B,prNumber:$,send:E})]}),e[33]=C,e[34]=L,e[35]=B,e[36]=E,e[37]=$,e[38]=W):W=e[38],W}function lg(t){const e=V.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 d;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(d=o.jsx(Jp,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=d):d=e[3];let u;return e[4]!==d||e[5]!==n?(u=o.jsx(zo,{label:n,children:d}),e[4]=d,e[5]=n,e[6]=u):u=e[6],u}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(dh,{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(se,{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(zo,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function zo(t){const e=V.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(Ke,{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(qe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(zc,{children:o.jsxs(Ve,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function cg(t){const e=V.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(lr.Right,{children:o.jsx(ag,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Jt=A.createContext(null);function pn(){return A.use(Jt)}function $o(t){const e=V.c(7),{children:s}=t,{taskId:i}=lt();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(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Na,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Qt,{fallback:r,children:o.jsx(A.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Fo(t){const e=V.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],A.useLayoutEffect(r),null}function hg(t){const e=V.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Gl,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Ho(t){const e=V.c(15),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ye(),{currentBranch:l}=lt(),{data:h}=Si.useSession(),c=h?.user?.id;let d;e[0]!==a.id?(d={connectionId:It,orgId:a.id},e[0]=a.id,e[1]=d):d=e[1];const u=Fe(d),{mutate:m}=sn(u);let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[2]=_):_=e[2];const f=A.useRef(_);let p,g;e[3]!==l||e[4]!==i||e[5]!==m||e[6]!==c||e[7]!==s||e[8]!==r?(p=()=>{i&&c&&l&&(r?.[c]?.[l]||f.current.has(l)||(f.current.add(l),m({virtualMcpId:s,branch:l},{onError:dg})))},g=[i,c,l,r,s,m],e[3]=l,e[4]=i,e[5]=m,e[6]=c,e[7]=s,e[8]=r,e[9]=p,e[10]=g):(p=e[9],g=e[10]),A.useEffect(p,g);const v=l??null;let b;return e[11]!==n||e[12]!==v||e[13]!==s?(b=o.jsx(Au,{virtualMcpId:s,branch:v,children:n}),e[11]=n,e[12]=v,e[13]=s,e[14]=b):b=e[14],b}function dg(t){console.error("[auto-start-vm] failed:",t)}function ug(){const t=V.c(96),e=aa(),s=Mt(),{org:i}=ye(),r=Tc()?.tasksOpen??!1;$c(i.id);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Ol(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=Yr(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??Yo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,m=Nh(a.taskId??"",u),_=gt(u),f=_?.metadata?.ui?.layout??null;let p;t[5]!==f?(p=f?{defaultMainView:f.defaultMainView??null,chatDefaultOpen:f.chatDefaultOpen??null}:null,t[5]=f,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Bt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==u?(S={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=S):S=t[11];const x=Rc(g,S),{setOpenMobile:w,openMobile:N}=Ac(),y=w,k=A.useRef(null);let j,M;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const K=G=>{Ic(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),k.current?.())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},M=[],t[12]=j,t[13]=M):(j=t[12],M=t[13]),A.useEffect(j,M);const D=u;let T;t[14]!==_||t[15]!==u?(T={virtualMcpId:u,entity:_},t[14]=_,t[15]=u,t[16]=T):T=t[16];const C=T;if(m.status==="creating"||m.status==="loading"){let K;t[17]===Symbol.for("react.memo_cache_sentinel")?(K=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(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=K):K=t[17];let G;return t[18]!==C?(G=o.jsx(Jt,{value:C,children:K}),t[18]=C,t[19]=G):G=t[19],G}if(m.status==="error"){let K;t[20]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=K):K=t[20];let G;t[21]!==m.error.message?(G=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:[K,o.jsx("div",{className:"text-muted-foreground",children:m.error.message})]})}),t[21]=m.error.message,t[22]=G):G=t[22];let P;return t[23]!==C||t[24]!==G?(P=o.jsx(Jt,{value:C,children:G}),t[23]=C,t[24]=G,t[25]=P):P=t[25],P}if(!_){let K;t[26]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(as,{size:48,className:"text-muted-foreground"}),t[26]=K):K=t[26];const G=`The agent "${u}" does not exist in this organization.`;let P;t[27]!==s||t[28]!==l?(P=o.jsx(se,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=P):P=t[29];let Z;t[30]!==G||t[31]!==P?(Z=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(Ps,{image:K,title:"Agent not found",description:G,actions:P})})}),t[30]=G,t[31]=P,t[32]=Z):Z=t[32];let Y;return t[33]!==C||t[34]!==Z?(Y=o.jsx(Jt,{value:C,children:Z}),t[33]=C,t[34]=Z,t[35]=Y):Y=t[35],Y}if(e){let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(Pc,{className:"sr-only",children:"Navigation"}),t[36]=K):K=t[36];let G;t[37]!==y?(G=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(Dc,{onClose:()=>y(!1)})}),t[37]=y,t[38]=G):G=t[38];let P;t[39]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Mc,{})}),t[39]=P):P=t[39];let Z;t[40]!==G?(Z=o.jsxs(Lc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[K,o.jsxs("div",{className:"flex h-full",children:[G,P]})]}),t[40]=G,t[41]=Z):Z=t[41];let Y;t[42]!==N||t[43]!==y||t[44]!==Z?(Y=o.jsx(Oc,{open:N,onOpenChange:y,children:Z}),t[42]=N,t[43]=y,t[44]=Z,t[45]=Y):Y=t[45];const ee=Y,ce=_?.metadata?.vmMap;let ie;t[46]!==x.createNewTask?(ie=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ie):ie=t[47];let Q;t[48]!==y?(Q=o.jsx(hg,{onOpenSidebar:()=>y(!0)}),t[48]=y,t[49]=Q):Q=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx($o,{})}),t[50]=he):he=t[50];let de;t[51]!==b||t[52]!==ee||t[53]!==ce||t[54]!==ie||t[55]!==Q||t[56]!==u?(de=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:ce,children:[ie,Q,he,ee]}),t[51]=b,t[52]=ee,t[53]=ce,t[54]=ie,t[55]=Q,t[56]=u,t[57]=de):de=t[57];let ue;t[58]!==D||t[59]!==de?(ue=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:D,children:de},D)}),t[58]=D,t[59]=de,t[60]=ue):ue=t[60];let we;return t[61]!==C||t[62]!==ue?(we=o.jsx(Jt,{value:C,children:ue}),t[61]=C,t[62]=ue,t[63]=we):we=t[63],we}const R=r?void 0:x.createNewTask;let E;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==R?(E=o.jsx(lr.Toggles,{children:o.jsx(Hp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:R})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=R,t[67]=E):E=t[67];let L;t[68]!==x.taskId||t[69]!==u?(L=o.jsx(lr.Tabs,{children:o.jsx(Yp,{virtualMcpId:u,taskId:x.taskId})}),t[68]=x.taskId,t[69]=u,t[70]=L):L=t[70];const z=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(cg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let $;t[75]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx($o,{}),t[75]=$):$=t[75];let W;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==u?(W=o.jsx(Fp,{virtualMcpId:u,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:$}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=u,t[80]=W):W=t[80];let I;t[81]!==b||t[82]!==z||t[83]!==B||t[84]!==O||t[85]!==W||t[86]!==u?(I=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:z,children:[B,O,W]}),t[81]=b,t[82]=z,t[83]=B,t[84]=O,t[85]=W,t[86]=u,t[87]=I):I=t[87];let F;t[88]!==D||t[89]!==L||t[90]!==I?(F=o.jsxs(je.Provider,{virtualMcpId:D,children:[L,I]},D),t[88]=D,t[89]=L,t[90]=I,t[91]=F):F=t[91];let U;return t[92]!==C||t[93]!==E||t[94]!==F?(U=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Jt,{value:C,children:[E,F]})}),t[92]=C,t[93]=E,t[94]=F,t[95]=U):U=t[95],U}function v1(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(A.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(ug,{})}),t[0]=e):e=t[0],e}export{v1 as default,pn as useInsetContext};
189
+ </message>`}]}}))},B=e.models?.credentialId||_||"",O=e.models?.thinking?.id||f?.modelId||"",$=Vo({defaultValues:{name:e.name,active:e.active,credential_id:B,model_id:O}}),W=$.watch("active"),I=$.watch("credential_id"),F=$.watch("model_id"),{models:U,isLoading:K}=jc(I||void 0),G=U.find(ne=>ne.modelId===F)??null,P=A.useRef(null),Z=A.useRef(new Set),Y=A.useRef(0),ee=A.useRef(null),ce=3e4,ie=()=>{ee.current&&(clearTimeout(ee.current),ee.current=null),P.current!==null&&(Se("automation_updated",{automation_id:t,agent_id:n,fields:Array.from(Z.current),save_count:Y.current,edit_duration_ms:Date.now()-P.current}),P.current=null,Z.current=new Set,Y.current=0)},Q=async()=>{if(!(Object.keys($.formState.dirtyFields).length>0)&&!E.current)return!0;const ve=Object.keys($.formState.dirtyFields),tt=E.current;E.current=!1;const _e=$.getValues(),Vt=L.current;try{const gs=_e.credential_id&&_e.model_id?_e.credential_id:"",X=_e.credential_id&&_e.model_id?_e.model_id:"",oe={id:t,name:_e.name,active:_e.active,agent:{id:n},models:{credentialId:gs,thinking:{id:X}},messages:Kl(Vt),temperature:0};await l.mutateAsync(oe),P.current===null&&(P.current=Date.now());for(const Be of ve)Z.current.add(Be);return tt&&Z.current.add("messages"),Y.current+=1,ee.current&&clearTimeout(ee.current),ee.current=setTimeout(ie,ce),$.reset({..._e,credential_id:gs,model_id:X},{keepDirtyValues:!0}),!0}catch{return E.current=!0,!1}},he=A.useRef(Q);he.current=Q;const de=()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=null,he.current()},1e3)},ue=async()=>(R.current&&(clearTimeout(R.current),R.current=null),he.current()),we=ne=>{if(L.current=ne,x(ne),!C.current){C.current=!0;return}E.current=!0,de()},Xe=A.useRef(!1);Xe.current||(Xe.current=!0,$.watch(()=>{de()})),A.useEffect(()=>()=>{R.current&&(clearTimeout(R.current),R.current=null,he.current())},[]);const He=async()=>{Se("automation_test_clicked",{automation_id:t,agent_id:n});const ne=await ue();if(ie(),!ne)return;if(!S){me.error("No instructions configured for this automation");return}G&&I&&m({...G,keyId:I}),v({...g,toolApprovalLevel:"auto"});const ve=xn(S);u({message:{tiptapDoc:S,parts:ve},virtualMcpId:n||void 0})};return o.jsxs(o.Fragment,{children:[i&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(se,{variant:"ghost",size:"sm",onClick:i,children:[o.jsx(ka,{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(fs,{...$.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),r&&o.jsx(se,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:r,children:o.jsx(hr,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Xt,{control:$.control,name:"active",render:({field:ne})=>o.jsx(cr,{checked:ne.value,onCheckedChange:ve=>{ne.onChange(ve),setTimeout(()=>ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:W?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ca,{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(Np,{automationId:t,open:w,onOpenChange:N,onCustomSelect:()=>{k(!0),T(!1),M("")},onEventSelect:()=>{T(!0),k(!1)}})]}),e.triggers.length===0&&!y?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:()=>N(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ne=>o.jsx(jp,{trigger:ne,automationId:t,connectionName:ne.connection_id?d.get(ne.connection_id):void 0},ne.id))}),y&&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(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:j,onChange:ne=>M(ne.target.value),onBlur:async()=>{const ne=j.trim();if(!(!ne||!Bs(ne)))try{await h.mutateAsync({automation_id:t,type:"cron",cron_expression:ne}),Se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),me.success("Starter added"),k(!1),M("")}catch{me.error("Failed to add starter")}},onKeyDown:async ne=>{const ve=j.trim();ne.key==="Enter"&&ve&&Bs(ve)&&ne.target.blur(),ne.key==="Escape"&&(k(!1),M(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),j&&!Bs(j)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),h.isPending&&o.jsx(Me,{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:()=>{k(!1),M("")},children:o.jsx(ls,{size:13})})]}),D&&o.jsx(A.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(Me,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Tp,{automationId:t,onDone:()=>T(!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(se,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!S,onClick:z,children:[o.jsx(ya,{size:13}),"Improve"]})]}),o.jsx(Hl,{tiptapDoc:S,setTiptapDoc:we,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(Wl,{virtualMcpId:n||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(gh,{model:G,isLoading:K,credentialId:I||null,onCredentialChange:ne=>{$.setValue("credential_id",ne??"",{shouldDirty:!0}),$.setValue("model_id","",{shouldDirty:!0})},onModelChange:ne=>$.setValue("model_id",ne.modelId,{shouldDirty:!0}),placeholder:"Model"}),o.jsxs(Ve,{children:[o.jsx(Ke,{asChild:!0,children:o.jsxs(se,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:He,disabled:!n,children:[o.jsx(Ql,{size:16}),"Test"]})}),o.jsx(qe,{children:"Test Automation"})]})]})]})})]})]})]})}function Bp(t){const e=V.c(6),{tabId:s,virtualMcpId:i}=t;let r;e[0]!==s?(r=Zo(s),e[0]=s,e[1]=r):r=e[1];const n=r;if(!n)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==n.id||e[4]!==i?(l=o.jsx(at,{children:o.jsx(at.Content,{children:o.jsx(at.Body,{children:o.jsx(A.Suspense,{fallback:a,children:o.jsx(Ap,{id:n.id,virtualMcpId:i})})})})}),e[3]=n.id,e[4]=i,e[5]=l):l=e[5],l}function Ap(t){const e=V.c(9),{id:s,virtualMcpId:i}=t,r=Mt(),{data:n,isLoading:a}=xh(s);let l;e[0]!==r?(l=()=>r({to:".",search:Pp,replace:!0}),e[0]=r,e[1]=l):l=e[1];const h=l;if(a){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=d):d=e[2],d}if(!n){let d;return e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=d):d=e[3],d}let c;return e[4]!==n||e[5]!==s||e[6]!==h||e[7]!==i?(c=o.jsx(Ip,{automationId:s,automation:n,virtualMcpId:i,onBack:h}),e[4]=n,e[5]=s,e[6]=h,e[7]=i,e[8]=c):c=e[8],c}function Pp(t){return{...t,main:"automations"}}function Lp(t){const e=V.c(20),{virtualMcpId:s}=t,i=Mt(),{data:r}=bh(s),n=r===void 0?[]:r,{create:a}=Vs(),[l,h]=A.useState(""),c=l.toLowerCase(),d=n.filter(M=>M.name.toLowerCase().includes(c));let u;e[0]!==i?(u=M=>i({to:".",search:D=>({...D,main:"automation:"+M}),replace:!0}),e[0]=i,e[1]=u):u=e[1];const m=u,_=async()=>{if(a.isPending)return;Se("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const M=await a.mutateAsync(yh(s));m(M.id)},f=at,p=at,g=at;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(at.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(wh,{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(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(se,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let w;e[7]!==b||e[8]!==x?(w=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]=w):w=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{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(se,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):d.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ps,{image:o.jsx(Ls,{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:d.map(M=>o.jsx(Sh,{automation:M,onClick:()=>m(M.id)},M.id))});let y;e[10]!==N||e[11]!==g.Body||e[12]!==w?(y=o.jsxs(g.Body,{children:[w,N]}),e[10]=N,e[11]=g.Body,e[12]=w,e[13]=y):y=e[13];let k;e[14]!==y||e[15]!==p.Content?(k=o.jsx(p.Content,{children:y}),e[14]=y,e[15]=p.Content,e[16]=k):k=e[16];let j;return e[17]!==f||e[18]!==k?(j=o.jsx(f,{children:k}),e[17]=f,e[18]=k,e[19]=j):j=e[19],j}function Op(t){const e=V.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(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(A.Suspense,{fallback:i,children:o.jsx(Lp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Lo=A.lazy(()=>Pl(()=>import("./project-app-view-BWTIFTZt.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])).then(t=>({default:t.AppViewContent})));function zp(t){const e=V.c(44),{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}=Ta(r);if(nc(n)){let f;return e[3]!==i?(f=o.jsx(zn,{virtualMcpId:i}),e[3]=i,e[4]=f):f=e[4],f}if(n==="git"){let f;return e[5]!==i?(f=o.jsx(bu,{virtualMcpId:i}),e[5]=i,e[6]=f):f=e[6],f}if(n==="automations"){let f;return e[7]!==i?(f=o.jsx(Op,{virtualMcpId:i}),e[7]=i,e[8]=f):f=e[8],f}if(n==="env"){let f;return e[9]!==i?(f=o.jsx(bp,{virtualMcpId:i}),e[9]=i,e[10]=f):f=e[10],f}if(n==="preview"){let f;return e[11]!==i?(f=o.jsx(tf,{virtualMcpId:i}),e[11]=i,e[12]=f):f=e[12],f}if(h){let f;return e[13]!==n||e[14]!==i?(f=o.jsx(Bp,{tabId:n,virtualMcpId:i}),e[13]=n,e[14]=i,e[15]=f):f=e[15],f}let c;e[16]!==n?(c=oc(n),e[16]=n,e[17]=c):c=e[17];const d=c;if(d){let f;if(e[18]!==l||e[19]!==d.connectionId||e[20]!==d.toolName){let S;e[22]!==d.connectionId||e[23]!==d.toolName?(S=x=>x.appId===d.connectionId&&x.toolName===d.toolName,e[22]=d.connectionId,e[23]=d.toolName,e[24]=S):S=e[24],f=l.find(S),e[18]=l,e[19]=d.connectionId,e[20]=d.toolName,e[21]=f}else f=e[21];const p=f;let g;e[25]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[25]=g):g=e[25];const v=p?.args;let b;return e[26]!==n||e[27]!==d.connectionId||e[28]!==d.toolName||e[29]!==v?(b=o.jsx(A.Suspense,{fallback:g,children:o.jsx(Lo,{connectionId:d.connectionId,toolName:d.toolName,args:v},n)}),e[26]=n,e[27]=d.connectionId,e[28]=d.toolName,e[29]=v,e[30]=b):b=e[30],b}let u;if(e[31]!==n||e[32]!==a){let f;e[34]!==n?(f=p=>p.id===n,e[34]=n,e[35]=f):f=e[35],u=a.find(f),e[31]=n,e[32]=a,e[33]=u}else u=e[33];const m=u;if(m){let f;e[36]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),e[36]=f):f=e[36];let p;return e[37]!==n||e[38]!==m.id||e[39]!==m.view.appId||e[40]!==m.view.args?(p=o.jsx(A.Suspense,{fallback:f,children:o.jsx(Lo,{connectionId:m.view.appId,toolName:m.id,args:m.view.args},n)}),e[37]=n,e[38]=m.id,e[39]=m.view.appId,e[40]=m.view.args,e[41]=p):p=e[41],p}let _;return e[42]!==i?(_=o.jsx(zn,{virtualMcpId:i}),e[42]=i,e[43]=_):_=e[43],_}function $p(t){const e=V.c(7),{children:s,defaultSize:i}=t,[,r]=A.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Go.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=qo(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=m=>r(()=>{m>0&&m<100&&l(m)}),e[1]=l,e[2]=c):c=e[2];const d=c;let u;return e[3]!==s||e[4]!==h||e[5]!==d?(u=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:d,order:1,children:s}),e[3]=s,e[4]=h,e[5]=d,e[6]=u):u=e[6],u}function Fp(t){const e=V.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=En(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=Go.decoChatPanelWidth(),e[3]=c):c=e[3];const[d]=qo(c,45),u=A.useRef(null);let m,_;e[4]!==r||e[5]!==n||e[6]!==d?(m=()=>{const M=u.current;if(!M)return;const D=En(r,n),T=D.chat>0&&D.chat<100?d:D.chat,C=D.chat>0&&D.chat<100?100-d:D.main;M.setLayout([T,C])},_=[r,n,d],e[4]=r,e[5]=n,e[6]=d,e[7]=m,e[8]=_):(m=e[7],_=e[8]),A.useEffect(m,_);const f=`${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(Na,{}),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($p,{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(Vc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w={overflow:"visible"},e[18]=w):w=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=te("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 y;e[20]!==i||e[21]!==s?(y=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(zp,{taskId:i,virtualMcpId:s})})})}),e[20]=i,e[21]=s,e[22]=y):y=e[22];let k;e[23]!==h.main||e[24]!==y?(k=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:w,collapsible:!0,collapsedSize:0,minSize:20,children:y}),e[23]=h.main,e[24]=y,e[25]=k):k=e[25];let j;return e[26]!==k||e[27]!==f||e[28]!==b?(j=o.jsxs(Kc,{ref:u,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,k]},f),e[26]=k,e[27]=f,e[28]=b,e[29]=j):j=e[29],j}const nr="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",Oo="bg-sidebar-accent text-sidebar-foreground",or="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Hp(t){const e=V.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Ec(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{Se("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?Oo:or;let d;e[3]!==c?(d=te(nr,c),e[3]=c,e[4]=d):d=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(wc,{size:16}),e[5]=u):u=e[5];let m;e[6]!==h||e[7]!==d||e[8]!==n?(m=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:d,children:u})}),e[6]=h,e[7]=d,e[8]=n,e[9]=m):m=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(qe,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let f;e[11]!==m?(f=o.jsxs(Ve,{delayDuration:300,children:[m,_]}),e[11]=m,e[12]=f):f=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{Se("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?Oo:or;let v;e[16]!==g?(v=te(nr,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Cc,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(Ke,{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(qe,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let w;e[24]!==S?(w=o.jsxs(Ve,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=w):w=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let y;e[26]!==N?(y=te("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=y):y=e[27];const k=!l,j=l?0:-1,M=!l,D=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let T;e[28]!==D?(T=te(nr,or,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",D),e[28]=D,e[29]=T):T=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(ta,{size:16}),e[30]=C):C=e[30];let R;e[31]!==r||e[32]!==k||e[33]!==j||e[34]!==M||e[35]!==T?(R=o.jsx(Ke,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:k,tabIndex:j,"aria-hidden":M,className:T,children:C})}),e[31]=r,e[32]=k,e[33]=j,e[34]=M,e[35]=T,e[36]=R):R=e[36];let E;e[37]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(qe,{side:"bottom",children:"New task"}),e[37]=E):E=e[37];let L;e[38]!==R?(L=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ve,{delayDuration:300,children:[R,E]})}),e[38]=R,e[39]=L):L=e[39];let z;e[40]!==y||e[41]!==L?(z=o.jsx("div",{className:y,children:L}),e[40]=y,e[41]=L,e[42]=z):z=e[42];let B;return e[43]!==w||e[44]!==z||e[45]!==f?(B=o.jsxs(o.Fragment,{children:[f,w,z]}),e[43]=w,e[44]=z,e[45]=f,e[46]=B):B=e[46],B}function Wp(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(u=>u.id===e))return{visible:i,overflow:r};const a=r.findIndex(u=>u.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],d=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:d}}function Up(t){const e=V.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=te("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(Vp,{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 d;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(d=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]=d):d=e[12],d}function Vp(t){const e=V.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 Kp(t){const e=V.c(13),{overflow:s,onSelect:i}=t,[r,n]=A.useState(!1);let a;e[0]!==i?(a=m=>{n(!1),i(m)},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(Hs,{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(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let m;e[6]!==l?(m=_=>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(qp,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=m):m=e[7],c=s.map(m),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let d;e[8]!==c?(d=o.jsx(Ws,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=d):d=e[9];let u;return e[10]!==r||e[11]!==d?(u=o.jsxs(Us,{open:r,onOpenChange:n,children:[h,d]}),e[10]=r,e[11]=d,e[12]=u):u=e[12],u}function qp(t){const e=V.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 Gp=6;function Yp(t){const e=V.c(20),{virtualMcpId:s,taskId:i}=t,r=Mt();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}=Ta(n);let d,u,m,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=ac({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:w}=Wp(a,S,Gp);u=w,d=N=>{const y=a.find(j=>j.id===N),k=S===N&&h;if(Se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:y?.kind??null,was_active:k}),N==="automations"){const j=lc({activeTab:l,mainOpen:h});r({to:".",search:M=>({...M,main:j}),replace:!0});return}c(N)},m="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(Up,{title:N.title,icon:N.icon,active:v(N),onClick:()=>d(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=d,e[10]=u,e[11]=m,e[12]=_}else d=e[9],u=e[10],m=e[11],_=e[12];let f;e[13]!==d||e[14]!==u?(f=u.length>0&&o.jsx(Kp,{overflow:u,onSelect:d}),e[13]=d,e[14]=u,e[15]=f):f=e[15];let p;return e[16]!==m||e[17]!==_||e[18]!==f?(p=o.jsxs("div",{className:m,children:[_,f]}),e[16]=m,e[17]=_,e[18]=f,e[19]=p):p=e[19],p}function Xp(t){const e=V.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=te("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(Ll,{"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 Jp(t){const e=V.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(cu({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(lu({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(se,{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 d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(dr,{className:"h-3.5 w-3.5"}),e[9]=d):d=e[9];let u;e[10]!==i?(u=o.jsx(ns,{asChild:!0,children:o.jsx(se,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:d})}),e[10]=i,e[11]=u):u=e[11];let m;e[12]!==h?(m=o.jsx(os,{align:"end",children:o.jsx(yt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=m):m=e[13];let _;e[14]!==u||e[15]!==m?(_=o.jsxs(rs,{children:[u,m]}),e[14]=u,e[15]=m,e[16]=_):_=e[16];let f;return e[17]!==c||e[18]!==_?(f=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=f):f=e[19],f}const Zp=new Set(["failure","timed_out","cancelled","action_required"]);function Qp(t){return t.status==="completed"&&Zp.has(t.conclusion)}function eg(t){return t.status==="queued"||t.status==="in_progress"}function tg(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"};if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.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(e.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 ${e.branch} → ${e.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 h=i.filter(Qp).map(u=>u.name);if(h.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${h.join(", ")}`,meta:{failingChecks:h}};const c=i.filter(eg);if(c.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${c.length} check${c.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 ${e.base}`}}function sg(){return ms().branchStatus}const ig=6e4,rg=3e4;function ng(t){const e=V.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Fe(s),r=t.prNumber??0;let n;e[3]!==t.owner||e[4]!==t.repo||e[5]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[3]=t.owner,e[4]=t.repo,e[5]=r,e[6]=n):n=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==n||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:ig,refetchIntervalInBackground:!1,staleTime:rg,select:og},e[7]=i,e[8]=n,e[9]=a,e[10]=l):l=e[10],us(l)}function og(t){const e=Ks(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 ag(t){const e=V.c(39),{virtualMcpId:s}=t,{org:i}=ye(),r=gt(s),{currentBranch:n}=lt(),a=wi(),l=r?.metadata?.githubRepo??null,h=sg(),c=l?.connectionId??"",d=l?.owner??"",u=l?.name??"",m=n??null;let _;e[0]!==i.id||e[1]!==c||e[2]!==d||e[3]!==u||e[4]!==m?(_={orgId:i.id,connectionId:c,owner:d,repo:u,branch:m},e[0]=i.id,e[1]=c,e[2]=d,e[3]=u,e[4]=m,e[5]=_):_=e[5];const f=Da(_),p=f.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[6]!==i.id||e[7]!==g||e[8]!==v||e[9]!==b||e[10]!==S?(x={orgId:i.id,connectionId:g,owner:v,repo:b,prNumber:S},e[6]=i.id,e[7]=g,e[8]=v,e[9]=b,e[10]=S,e[11]=x):x=e[11];const w=Ia(x),N=l?.connectionId??"",y=l?.owner??"",k=l?.name??"",j=p&&p.state==="open"?p.number:null;let M;e[12]!==i.id||e[13]!==N||e[14]!==y||e[15]!==k||e[16]!==j?(M={orgId:i.id,connectionId:N,owner:y,repo:k,prNumber:j},e[12]=i.id,e[13]=N,e[14]=y,e[15]=k,e[16]=j,e[17]=M):M=e[17];const D=ng(M);if(!l?.connectionId||!n)return null;let T;e[18]!==h||e[19]!==w.data||e[20]!==p||e[21]!==f.isPending||e[22]!==D.data?(T=tg({branchStatus:h,pr:p,checks:w.data??[],reviews:D.data??null,loading:f.isPending}),e[18]=h,e[19]=w.data,e[20]=p,e[21]=f.isPending,e[22]=D.data,e[23]=T):T=e[23];const C=T;let R;e[24]!==a?(R=I=>a.sendMessage({parts:[{type:"text",text:I}]}),e[24]=a,e[25]=R):R=e[25];const E=R,L=a.isStreaming;let z;e[26]!==n||e[27]!==C||e[28]!==L||e[29]!==p||e[30]!==E?(z=I=>{if(!L)switch(I){case"commit-and-push":{E(eu({branch:n}));return}case"create-pr":{E(tu({branch:n}));return}case"reopen":{p&&E(su({prNumber:p.number}));return}case"rebase":{E(iu({branch:n}));return}case"fix-checks":{p&&E(nu({prNumber:p.number,failingChecks:C.meta?.failingChecks??[]}));return}case"mark-ready":{p&&E(ou({prNumber:p.number}));return}case"resolve-comments":{p&&E(au({prNumber:p.number}));return}case"merge-split":return}},e[26]=n,e[27]=C,e[28]=L,e[29]=p,e[30]=E,e[31]=z):z=e[31];const B=z;let O;e[32]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(Xp,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[32]=O):O=e[32];const $=p?.number;let W;return e[33]!==C||e[34]!==L||e[35]!==B||e[36]!==E||e[37]!==$?(W=o.jsxs(o.Fragment,{children:[O,o.jsx(lg,{button:C,isStreaming:L,onActivate:B,prNumber:$,send:E})]}),e[33]=C,e[34]=L,e[35]=B,e[36]=E,e[37]=$,e[38]=W):W=e[38],W}function lg(t){const e=V.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 d;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(d=o.jsx(Jp,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=d):d=e[3];let u;return e[4]!==d||e[5]!==n?(u=o.jsx(zo,{label:n,children:d}),e[4]=d,e[5]=n,e[6]=u):u=e[6],u}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(dh,{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(se,{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(zo,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function zo(t){const e=V.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(Ke,{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(qe,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(zc,{children:o.jsxs(Ve,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function cg(t){const e=V.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(lr.Right,{children:o.jsx(ag,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Jt=A.createContext(null);function pn(){return A.use(Jt)}function $o(t){const e=V.c(7),{children:s}=t,{taskId:i}=lt();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(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Na,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Qt,{fallback:r,children:o.jsx(A.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Fo(t){const e=V.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],A.useLayoutEffect(r),null}function hg(t){const e=V.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Gl,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Ho(t){const e=V.c(15),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ye(),{currentBranch:l}=lt(),{data:h}=Si.useSession(),c=h?.user?.id;let d;e[0]!==a.id?(d={connectionId:It,orgId:a.id},e[0]=a.id,e[1]=d):d=e[1];const u=Fe(d),{mutate:m}=sn(u);let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[2]=_):_=e[2];const f=A.useRef(_);let p,g;e[3]!==l||e[4]!==i||e[5]!==m||e[6]!==c||e[7]!==s||e[8]!==r?(p=()=>{i&&c&&l&&(r?.[c]?.[l]||f.current.has(l)||(f.current.add(l),m({virtualMcpId:s,branch:l},{onError:dg})))},g=[i,c,l,r,s,m],e[3]=l,e[4]=i,e[5]=m,e[6]=c,e[7]=s,e[8]=r,e[9]=p,e[10]=g):(p=e[9],g=e[10]),A.useEffect(p,g);const v=l??null;let b;return e[11]!==n||e[12]!==v||e[13]!==s?(b=o.jsx(Au,{virtualMcpId:s,branch:v,children:n}),e[11]=n,e[12]=v,e[13]=s,e[14]=b):b=e[14],b}function dg(t){console.error("[auto-start-vm] failed:",t)}function ug(){const t=V.c(96),e=aa(),s=Mt(),{org:i}=ye(),r=Tc()?.tasksOpen??!1;$c(i.id);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Ol(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=Yr(h);let d;t[2]!==i.id||t[3]!==c.virtualmcpid?(d=c.virtualmcpid??Yo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=d):d=t[4];const u=d,m=Nh(a.taskId??"",u),_=gt(u),f=_?.metadata?.ui?.layout??null;let p;t[5]!==f?(p=f?{defaultMainView:f.defaultMainView??null,chatDefaultOpen:f.chatDefaultOpen??null}:null,t[5]=f,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Bt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==u?(S={virtualMcpId:u,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=u,t[11]=S):S=t[11];const x=Rc(g,S),{setOpenMobile:w,openMobile:N}=Ac(),y=w,k=A.useRef(null);let j,M;t[12]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const K=G=>{Ic(G)&&G.shiftKey&&G.code==="KeyS"&&!G.repeat&&(G.preventDefault(),k.current?.())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},M=[],t[12]=j,t[13]=M):(j=t[12],M=t[13]),A.useEffect(j,M);const D=u;let T;t[14]!==_||t[15]!==u?(T={virtualMcpId:u,entity:_},t[14]=_,t[15]=u,t[16]=T):T=t[16];const C=T;if(m.status==="creating"||m.status==="loading"){let K;t[17]===Symbol.for("react.memo_cache_sentinel")?(K=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(Me,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=K):K=t[17];let G;return t[18]!==C?(G=o.jsx(Jt,{value:C,children:K}),t[18]=C,t[19]=G):G=t[19],G}if(m.status==="error"){let K;t[20]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=K):K=t[20];let G;t[21]!==m.error.message?(G=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:[K,o.jsx("div",{className:"text-muted-foreground",children:m.error.message})]})}),t[21]=m.error.message,t[22]=G):G=t[22];let P;return t[23]!==C||t[24]!==G?(P=o.jsx(Jt,{value:C,children:G}),t[23]=C,t[24]=G,t[25]=P):P=t[25],P}if(!_){let K;t[26]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(as,{size:48,className:"text-muted-foreground"}),t[26]=K):K=t[26];const G=`The agent "${u}" does not exist in this organization.`;let P;t[27]!==s||t[28]!==l?(P=o.jsx(se,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=P):P=t[29];let Z;t[30]!==G||t[31]!==P?(Z=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(Ps,{image:K,title:"Agent not found",description:G,actions:P})})}),t[30]=G,t[31]=P,t[32]=Z):Z=t[32];let Y;return t[33]!==C||t[34]!==Z?(Y=o.jsx(Jt,{value:C,children:Z}),t[33]=C,t[34]=Z,t[35]=Y):Y=t[35],Y}if(e){let K;t[36]===Symbol.for("react.memo_cache_sentinel")?(K=o.jsx(Pc,{className:"sr-only",children:"Navigation"}),t[36]=K):K=t[36];let G;t[37]!==y?(G=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(Dc,{onClose:()=>y(!1)})}),t[37]=y,t[38]=G):G=t[38];let P;t[39]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Mc,{})}),t[39]=P):P=t[39];let Z;t[40]!==G?(Z=o.jsxs(Lc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[K,o.jsxs("div",{className:"flex h-full",children:[G,P]})]}),t[40]=G,t[41]=Z):Z=t[41];let Y;t[42]!==N||t[43]!==y||t[44]!==Z?(Y=o.jsx(Oc,{open:N,onOpenChange:y,children:Z}),t[42]=N,t[43]=y,t[44]=Z,t[45]=Y):Y=t[45];const ee=Y,ce=_?.metadata?.vmMap;let ie;t[46]!==x.createNewTask?(ie=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=ie):ie=t[47];let Q;t[48]!==y?(Q=o.jsx(hg,{onOpenSidebar:()=>y(!0)}),t[48]=y,t[49]=Q):Q=t[49];let he;t[50]===Symbol.for("react.memo_cache_sentinel")?(he=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx($o,{})}),t[50]=he):he=t[50];let de;t[51]!==b||t[52]!==ee||t[53]!==ce||t[54]!==ie||t[55]!==Q||t[56]!==u?(de=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:ce,children:[ie,Q,he,ee]}),t[51]=b,t[52]=ee,t[53]=ce,t[54]=ie,t[55]=Q,t[56]=u,t[57]=de):de=t[57];let ue;t[58]!==D||t[59]!==de?(ue=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:D,children:de},D)}),t[58]=D,t[59]=de,t[60]=ue):ue=t[60];let we;return t[61]!==C||t[62]!==ue?(we=o.jsx(Jt,{value:C,children:ue}),t[61]=C,t[62]=ue,t[63]=we):we=t[63],we}const R=r?void 0:x.createNewTask;let E;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==R?(E=o.jsx(lr.Toggles,{children:o.jsx(Hp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:R})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=R,t[67]=E):E=t[67];let L;t[68]!==x.taskId||t[69]!==u?(L=o.jsx(lr.Tabs,{children:o.jsx(Yp,{virtualMcpId:u,taskId:x.taskId})}),t[68]=x.taskId,t[69]=u,t[70]=L):L=t[70];const z=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(cg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Fo,{onNewTaskRef:k,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let $;t[75]===Symbol.for("react.memo_cache_sentinel")?($=o.jsx($o,{}),t[75]=$):$=t[75];let W;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==u?(W=o.jsx(Fp,{virtualMcpId:u,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:$}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=u,t[80]=W):W=t[80];let I;t[81]!==b||t[82]!==z||t[83]!==B||t[84]!==O||t[85]!==W||t[86]!==u?(I=o.jsxs(Ho,{virtualMcpId:u,hasActiveGithubRepo:b,vmMap:z,children:[B,O,W]}),t[81]=b,t[82]=z,t[83]=B,t[84]=O,t[85]=W,t[86]=u,t[87]=I):I=t[87];let F;t[88]!==D||t[89]!==L||t[90]!==I?(F=o.jsxs(je.Provider,{virtualMcpId:D,children:[L,I]},D),t[88]=D,t[89]=L,t[90]=I,t[91]=F):F=t[91];let U;return t[92]!==C||t[93]!==E||t[94]!==F?(U=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Jt,{value:C,children:[E,F]})}),t[92]=C,t[93]=E,t[94]=F,t[95]=U):U=t[95],U}function v1(){const t=V.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(A.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Me,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(ug,{})}),t[0]=e):e=t[0],e}export{v1 as default,pn as useInsetContext};