decocms 2.304.15 → 2.305.0

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 (269) hide show
  1. package/dist/client/assets/{AlertCircle-CbUYZGF-.js → AlertCircle-B65qDYSH.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-DHj5-FLY.js → ArrowNarrowLeft-fzTyPWny.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-BK_iYZ-J.js → ArrowUpRight-BcX-Z0Ku.js} +1 -1
  4. package/dist/client/assets/Check-a0FPGBtH.js +1 -0
  5. package/dist/client/assets/{CheckCircle-D9qlmIve.js → CheckCircle-B8cGzYri.js} +1 -1
  6. package/dist/client/assets/ChevronDown-Z3xhSsnT.js +1 -0
  7. package/dist/client/assets/{ChevronRight-BIm0-OSp.js → ChevronRight-xkl8cwkd.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-ClqSoLtD.js → ChevronUp-Cy7lkJW1.js} +1 -1
  9. package/dist/client/assets/{Container-BCDxdJoG.js → Container-cyfm5-Pb.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-DEE8M0V4.js → DotsVertical-Bx7sSuAL.js} +1 -1
  11. package/dist/client/assets/{LinkExternal01-DM7IwrPj.js → LinkExternal01-0g6HjjkD.js} +1 -1
  12. package/dist/client/assets/{Lock01-BmjkKSvK.js → Lock01-BzMXxHmW.js} +1 -1
  13. package/dist/client/assets/{Palette-BrJL0UcN.js → Palette-CwWccG-f.js} +1 -1
  14. package/dist/client/assets/{Play-DSYx2GJ2.js → Play-C-AiMK-Y.js} +1 -1
  15. package/dist/client/assets/{Plus-BrBimbff.js → Plus-DGrvw6bs.js} +1 -1
  16. package/dist/client/assets/{RefreshCcw01-Cr84gVY8.js → RefreshCcw01-Biyt7Dy2.js} +1 -1
  17. package/dist/client/assets/{SearchMd-IP-R-mtT.js → SearchMd-OHnYTa8U.js} +1 -1
  18. package/dist/client/assets/{Settings02-BOckjEVU.js → Settings02-DO2nBrax.js} +1 -1
  19. package/dist/client/assets/{Shield01-CJggUHAQ.js → Shield01-DQa1zKSX.js} +1 -1
  20. package/dist/client/assets/Star01-BoJYsaDm.js +1 -0
  21. package/dist/client/assets/{Sun-B7BWJEHb.js → Sun-DA-QmugE.js} +1 -1
  22. package/dist/client/assets/{Tool01-D1Rvo01i.js → Tool01-Cq1N-niG.js} +1 -1
  23. package/dist/client/assets/{Trash01-DaGrAtTq.js → Trash01-PRSN3sYk.js} +1 -1
  24. package/dist/client/assets/{User01-DmtseI1g.js → User01-DwPCZdnr.js} +1 -1
  25. package/dist/client/assets/{Users03-DH9QAbco.js → Users03-CB3lBGeX.js} +1 -1
  26. package/dist/client/assets/{X-viKat0oa.js → X-dZLz-ulr.js} +1 -1
  27. package/dist/client/assets/{XCircle-DZEMwZj2.js → XCircle-yJD2sr2j.js} +1 -1
  28. package/dist/client/assets/{XClose-DY7O9VST.js → XClose-Ci4dmV-Y.js} +1 -1
  29. package/dist/client/assets/{Zap-BMzMPNv3.js → Zap-CYJdRXq9.js} +1 -1
  30. package/dist/client/assets/{ZapSquare-BDbWe-zU.js → ZapSquare-M3u7o8sc.js} +1 -1
  31. package/dist/client/assets/{accordion-YgNI8iqn.js → accordion-DtmZjwNB.js} +1 -1
  32. package/dist/client/assets/agent-icon-D_KgWkiu.js +1 -0
  33. package/dist/client/assets/agents-list-yD_xsHNb.js +1 -0
  34. package/dist/client/assets/ai-providers-BHQQzoPJ.js +1 -0
  35. package/dist/client/assets/{alert-dialog-BvuFarFf.js → alert-dialog-Dog8t-xg.js} +1 -1
  36. package/dist/client/assets/{auth-catchall-DQeYnh5P.js → auth-catchall-B_yXTiaF.js} +1 -1
  37. package/dist/client/assets/automation-list-row-BtOPPlS3.js +1 -0
  38. package/dist/client/assets/automations-CkfQxJNN.js +1 -0
  39. package/dist/client/assets/{avatar-C4FRugJb.js → avatar-BebTr4u1.js} +1 -1
  40. package/dist/client/assets/{badge-_ZGDO29b.js → badge-BWEc0v7O.js} +1 -1
  41. package/dist/client/assets/brand-context-LmKpYr08.js +1 -0
  42. package/dist/client/assets/{card-oSxwoJvZ.js → card-mlKWkDqb.js} +1 -1
  43. package/dist/client/assets/{chat-context-C4Hx_rZK.js → chat-context-BmN5ppM9.js} +1 -1
  44. package/dist/client/assets/checkbox-55NGf7aS.js +1 -0
  45. package/dist/client/assets/collection-detail-BaNeXOGS.js +1 -0
  46. package/dist/client/assets/collection-display-button-DnajjLb7.js +1 -0
  47. package/dist/client/assets/{collection-search-u94VKjvs.js → collection-search-Bsl0avLq.js} +1 -1
  48. package/dist/client/assets/{collection-search-D_DqZCmL.js → collection-search-CjDGYe9v.js} +1 -1
  49. package/dist/client/assets/{collection-table-wrapper-LzV9CSI7.js → collection-table-wrapper-D5rnMkP_.js} +1 -1
  50. package/dist/client/assets/{collection-tabs-DW1xYGdq.js → collection-tabs-DgQ6F5X6.js} +1 -1
  51. package/dist/client/assets/{collections-Cn7VbUFT.js → collections-DAavnhku.js} +1 -1
  52. package/dist/client/assets/{command-CgMn1LbK.js → command-CN1iJVAp.js} +1 -1
  53. package/dist/client/assets/{connection-card-BPUe3B60.js → connection-card-D5opGNgQ.js} +1 -1
  54. package/dist/client/assets/connection-detail-DWinew7y.js +1 -0
  55. package/dist/client/assets/{connection-form-helpers-CUlzSClK.js → connection-form-helpers-CXHmM_yU.js} +1 -1
  56. package/dist/client/assets/connections-yUVM9Wts.js +1 -0
  57. package/dist/client/assets/{constants-CVDNjJTw.js → constants-BNhCk86i.js} +1 -1
  58. package/dist/client/assets/{constants-CfwGLQ49.js → constants-Ccnt3rmd.js} +2 -2
  59. package/dist/client/assets/{dialog-CoECADf1.js → dialog-_YlOXdcS.js} +1 -1
  60. package/dist/client/assets/{domain-settings-D6RV8b16.js → domain-settings-DLCCNpqs.js} +1 -1
  61. package/dist/client/assets/{drawer-DTk8g2vK.js → drawer-GKYdquRR.js} +1 -1
  62. package/dist/client/assets/dropdown-menu-BXZVht4Z.js +1 -0
  63. package/dist/client/assets/{dynamic-plugin-layout-DCoYGhHP.js → dynamic-plugin-layout-ieJ5SRhD.js} +1 -1
  64. package/dist/client/assets/{empty-state-DoKR-jUX.js → empty-state-CGCgWL8i.js} +1 -1
  65. package/dist/client/assets/{empty-state-Be0X9mox.js → empty-state-D1x6Uzf-.js} +1 -1
  66. package/dist/client/assets/{extract-connection-data-CuIeY90s.js → extract-connection-data-BTJzhkiq.js} +1 -1
  67. package/dist/client/assets/{features-38ZozsmE.js → features-Bmw2Kywv.js} +1 -1
  68. package/dist/client/assets/{form-BC40Nvzi.js → form-D4Q00YSx.js} +1 -1
  69. package/dist/client/assets/general-yzH2a6AI.js +1 -0
  70. package/dist/client/assets/{index-B0TkoX1b.js → index-7DFELu7_.js} +1 -1
  71. package/dist/client/assets/{index-CbBINyFK.js → index-BBbwvkmx.js} +1 -1
  72. package/dist/client/assets/{index-DXHNyf1g.css → index-B_4-KoG_.css} +1 -1
  73. package/dist/client/assets/index-C1kdSX8Z.js +182 -0
  74. package/dist/client/assets/index-CHcMm4yb.js +1 -0
  75. package/dist/client/assets/index-CLv-BJNN.js +1 -0
  76. package/dist/client/assets/{index-CFyIm5CH.js → index-CUuCKerO.js} +1 -1
  77. package/dist/client/assets/{index-DjgN9qrV.js → index-Cf-Qb03y.js} +1 -1
  78. package/dist/client/assets/{index-BBrIielu.js → index-DgtpEOsQ.js} +1 -1
  79. package/dist/client/assets/{index-_TsJo9Ju.js → index-DsOYCD-H.js} +5 -5
  80. package/dist/client/assets/index-DsncOedH.js +1 -0
  81. package/dist/client/assets/{index-CvarGBFr.js → index-I3M58vcg.js} +1 -1
  82. package/dist/client/assets/{index-Bcf94soS.js → index-ILTPQsH4.js} +1 -1
  83. package/dist/client/assets/{index-Dl2t23Jt.js → index-Ux_PrmKm.js} +2 -2
  84. package/dist/client/assets/{index-M_qlHNIS.js → index-Yaw_OxhP.js} +1 -1
  85. package/dist/client/assets/index-tLkyDiOo.js +1 -0
  86. package/dist/client/assets/{index-nmtbWm5V.js → index-tngOtpnj.js} +2 -2
  87. package/dist/client/assets/{infiniteQueryObserver-cqTNhL_G.js → infiniteQueryObserver-C_u8IqUR.js} +1 -1
  88. package/dist/client/assets/{input-CluxDyoT.js → input-B868_ejo.js} +1 -1
  89. package/dist/client/assets/{integration-icon-BipCD_m-.js → integration-icon-Ov0IbIMU.js} +1 -1
  90. package/dist/client/assets/{label-CHKFYnQo.js → label-Cg-2ys6X.js} +1 -1
  91. package/dist/client/assets/{layout-CV5Wi0Ex.js → layout-DkCp6X2C.js} +1 -1
  92. package/dist/client/assets/lean-canvas-recruit-modal-BNON-9yt.js +139 -0
  93. package/dist/client/assets/{login-DdkQloeb.js → login-E_UoTHOE.js} +1 -1
  94. package/dist/client/assets/{members-BgSG3QM0.js → members-CC6bIoZk.js} +2 -2
  95. package/dist/client/assets/{monaco-editor-BfaMmupR.js → monaco-editor-DfIGvq7v.js} +1 -1
  96. package/dist/client/assets/{monitoring-stats-row-C8V4hqSK.js → monitoring-stats-row-Chavd_5e.js} +1 -1
  97. package/dist/client/assets/{oauth-callback-BaZqye0L.js → oauth-callback-BQObPuY8.js} +1 -1
  98. package/dist/client/assets/{oauth-callback-ai-provider-oz8YNRBq.js → oauth-callback-ai-provider-B_SVXSnf.js} +1 -1
  99. package/dist/client/assets/{onboarding-WJDxBlF8.js → onboarding-ChmBqh-q.js} +1 -1
  100. package/dist/client/assets/{org-layout-Ax0KGzlT.js → org-layout-BWsgHF7L.js} +1 -1
  101. package/dist/client/assets/{org-plugin-layout-C5mxyCcm.js → org-plugin-layout-D0N77j4g.js} +1 -1
  102. package/dist/client/assets/{pair-JxQa_xAh.js → pair-DlIdkD7u.js} +1 -1
  103. package/dist/client/assets/{plugin-empty-state-C_q24wh6.js → plugin-empty-state-B-u16uuv.js} +1 -1
  104. package/dist/client/assets/plugin-header-Dt0O0h26.js +1 -0
  105. package/dist/client/assets/{plugin-layout-NPftDH-k.js → plugin-layout-DK8gsZYL.js} +1 -1
  106. package/dist/client/assets/{popover-vU5pf5HQ.js → popover-B3f914lR.js} +1 -1
  107. package/dist/client/assets/profile-pLHlebiO.js +1 -0
  108. package/dist/client/assets/project-app-view-D-yBQWHo.js +1 -0
  109. package/dist/client/assets/registry-BcZJCcyc.js +2 -0
  110. package/dist/client/assets/{registry-layout-D-sbU1qd.js → registry-layout-0cxsWXwz.js} +2 -2
  111. package/dist/client/assets/{required-auth-layout-BYto5m3H.js → required-auth-layout-DLsc1xkw.js} +1 -1
  112. package/dist/client/assets/{reset-password-DL944kGr.js → reset-password-BS6m_G36.js} +1 -1
  113. package/dist/client/assets/roles-B_ljw5IA.js +1 -0
  114. package/dist/client/assets/{scroll-area-D4F3EM5Z.js → scroll-area-_bumfcjA.js} +1 -1
  115. package/dist/client/assets/{search-input-CslwpPEh.js → search-input-Bhq8p539.js} +1 -1
  116. package/dist/client/assets/select-model-D3fobWv8.js +4 -0
  117. package/dist/client/assets/select-slwRPncS.js +1 -0
  118. package/dist/client/assets/settings-layout-DRkmNgVc.js +1 -0
  119. package/dist/client/assets/{settings-section-qcMAXuoQ.js → settings-section-CIXHBPOa.js} +1 -1
  120. package/dist/client/assets/{shell-layout-CzPr_0c2.js → shell-layout-Drnm9mfO.js} +1 -1
  121. package/dist/client/assets/{skeleton-eOgaLAHa.js → skeleton-ChUR9knm.js} +1 -1
  122. package/dist/client/assets/{sso-Dozga0JK.js → sso--URfWQeo.js} +1 -1
  123. package/dist/client/assets/{store-BA7fLJKJ.js → store-htVNKvqn.js} +1 -1
  124. package/dist/client/assets/store-registry-CaCyYvRn.js +2 -0
  125. package/dist/client/assets/{switch-W_Nrj6rK.js → switch-Cf5BCxU5.js} +1 -1
  126. package/dist/client/assets/{table-rVVQNhet.js → table-CBFs2U43.js} +1 -1
  127. package/dist/client/assets/{tabs-6T1N4Szc.js → tabs-Ctrs4bAF.js} +1 -1
  128. package/dist/client/assets/{task-status-DsmpMdW6.js → task-status-DUVd5pLA.js} +1 -1
  129. package/dist/client/assets/{textarea-Cld3tG5R.js → textarea-BbtfG9Ru.js} +1 -1
  130. package/dist/client/assets/{toggle-group-COcCk4lG.js → toggle-group-DCLBHyZD.js} +1 -1
  131. package/dist/client/assets/{tools-list-COvHAWAZ.js → tools-list-DGhR4Qyt.js} +1 -1
  132. package/dist/client/assets/{tooltip-CxizQODk.js → tooltip-BOsmkVZD.js} +1 -1
  133. package/dist/client/assets/{types-CvYZZZog.js → types-BSAKF0wC.js} +1 -1
  134. package/dist/client/assets/{use-ai-providers-Bt2yRX0n.js → use-ai-providers-aNlhpnwf.js} +1 -1
  135. package/dist/client/assets/{use-collections-CwD8DZNY.js → use-collections-CqB4T92N.js} +1 -1
  136. package/dist/client/assets/{use-connection-pSv7eY2y.js → use-connection-C_n04i0m.js} +1 -1
  137. package/dist/client/assets/{use-copy-CHAuyAMC.js → use-copy-B8gaSETz.js} +1 -1
  138. package/dist/client/assets/{use-create-virtual-mcp-1DfbQRRy.js → use-create-virtual-mcp-DvxMGqTu.js} +1 -1
  139. package/dist/client/assets/use-debounced-autosave-BAy1X_D8.js +1 -0
  140. package/dist/client/assets/{use-decopilot-events-CXVUS53e.js → use-decopilot-events-BA4osLiM.js} +1 -1
  141. package/dist/client/assets/{use-delete-connection-BNRuOYcY.js → use-delete-connection-C4xdydWE.js} +1 -1
  142. package/dist/client/assets/{use-infinite-scroll-Ca5zEcXn.js → use-infinite-scroll-CW0QmsIe.js} +1 -1
  143. package/dist/client/assets/{use-list-state-Jttwyvy3.js → use-list-state-Dm-Ww-Vo.js} +1 -1
  144. package/dist/client/assets/{use-mcp-tools-BdYIFx9S.js → use-mcp-tools-uazou5KQ.js} +1 -1
  145. package/dist/client/assets/{use-members-s6X83kyp.js → use-members-BM40IfsI.js} +1 -1
  146. package/dist/client/assets/{use-navigate-to-agent-Tn-rhKXX.js → use-navigate-to-agent-kI9r54wH.js} +1 -1
  147. package/dist/client/assets/{use-org-auth-client-CS0Acn4M.js → use-org-auth-client-DCENSdBc.js} +1 -1
  148. package/dist/client/assets/{use-org-sso-CPzDtjox.js → use-org-sso-BIqIcUQM.js} +1 -1
  149. package/dist/client/assets/{use-organization-roles-TW9At1F2.js → use-organization-roles-DAO7QdGg.js} +1 -1
  150. package/dist/client/assets/{use-organization-settings-Dak2xww8.js → use-organization-settings-C-NHhw4n.js} +1 -1
  151. package/dist/client/assets/{use-registry-connections-CMFnR2M3.js → use-registry-connections-B1oBXsUK.js} +1 -1
  152. package/dist/client/assets/{use-status-sounds-D0-nlwJm.js → use-status-sounds-DEn9-reM.js} +1 -1
  153. package/dist/client/assets/{use-tasks-yxuEm5KK.js → use-tasks-CJ3vNKME.js} +1 -1
  154. package/dist/client/assets/{use-view-mode-w75x4zz0.js → use-view-mode-DTFti-L5.js} +1 -1
  155. package/dist/client/assets/{use-virtual-mcp-BHEEZv3B.js → use-virtual-mcp-Cd4gN6tQ.js} +1 -1
  156. package/dist/client/assets/useInfiniteQuery-BMlr4G1E.js +1 -0
  157. package/dist/client/assets/useSuspenseInfiniteQuery-BNLcV52p.js +1 -0
  158. package/dist/client/assets/{user-QrqGbmQG.js → user-BirTYLn0.js} +1 -1
  159. package/dist/client/assets/{view-mode-toggle-C9HAxT_f.js → view-mode-toggle-_LNgXbfe.js} +1 -1
  160. package/dist/client/assets/workflow-CE9nGfJB.js +1 -0
  161. package/dist/client/assets/workflow-detail-hgfq2rMH.js +1 -0
  162. package/dist/client/index.html +2 -2
  163. package/dist/server/cli.js +24 -25
  164. package/dist/server/node_modules/ansi-styles/index.d.ts +236 -0
  165. package/dist/server/node_modules/ansi-styles/index.js +223 -0
  166. package/dist/server/node_modules/ansi-styles/package.json +54 -0
  167. package/dist/server/node_modules/ansi-styles/readme.md +173 -0
  168. package/dist/server/node_modules/environment/index.d.ts +74 -0
  169. package/dist/server/node_modules/environment/index.js +47 -0
  170. package/dist/server/node_modules/environment/license +9 -0
  171. package/dist/server/node_modules/environment/package.json +74 -0
  172. package/dist/server/node_modules/environment/readme.md +94 -0
  173. package/dist/server/node_modules/escape-string-regexp/index.d.ts +18 -0
  174. package/dist/server/node_modules/escape-string-regexp/index.js +11 -0
  175. package/dist/server/node_modules/escape-string-regexp/license +9 -0
  176. package/dist/server/node_modules/escape-string-regexp/package.json +43 -0
  177. package/dist/server/node_modules/escape-string-regexp/readme.md +29 -0
  178. package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  179. package/dist/server/node_modules/is-fullwidth-code-point/index.js +12 -0
  180. package/dist/server/node_modules/is-fullwidth-code-point/license +9 -0
  181. package/dist/server/node_modules/is-fullwidth-code-point/package.json +53 -0
  182. package/dist/server/node_modules/is-fullwidth-code-point/readme.md +31 -0
  183. package/dist/server/node_modules/is-unicode-supported/index.d.ts +12 -0
  184. package/dist/server/node_modules/is-unicode-supported/index.js +21 -0
  185. package/dist/server/node_modules/is-unicode-supported/license +9 -0
  186. package/dist/server/node_modules/is-unicode-supported/package.json +47 -0
  187. package/dist/server/node_modules/is-unicode-supported/readme.md +35 -0
  188. package/dist/server/node_modules/mimic-fn/index.d.ts +54 -0
  189. package/dist/server/node_modules/mimic-fn/index.js +13 -0
  190. package/dist/server/node_modules/mimic-fn/license +9 -0
  191. package/dist/server/node_modules/mimic-fn/package.json +42 -0
  192. package/dist/server/node_modules/mimic-fn/readme.md +69 -0
  193. package/dist/server/node_modules/pg-int8/LICENSE +13 -0
  194. package/dist/server/node_modules/pg-int8/README.md +16 -0
  195. package/dist/server/node_modules/pg-int8/index.js +100 -0
  196. package/dist/server/node_modules/pg-int8/package.json +24 -0
  197. package/dist/server/node_modules/postgres-bytea/index.js +33 -0
  198. package/dist/server/node_modules/postgres-bytea/license +21 -0
  199. package/dist/server/node_modules/postgres-bytea/package.json +34 -0
  200. package/dist/server/node_modules/postgres-bytea/readme.md +34 -0
  201. package/dist/server/node_modules/postgres-date/index.js +116 -0
  202. package/dist/server/node_modules/postgres-date/license +21 -0
  203. package/dist/server/node_modules/postgres-date/package.json +33 -0
  204. package/dist/server/node_modules/postgres-date/readme.md +49 -0
  205. package/dist/server/node_modules/postgres-interval/index.d.ts +20 -0
  206. package/dist/server/node_modules/postgres-interval/index.js +125 -0
  207. package/dist/server/node_modules/postgres-interval/license +21 -0
  208. package/dist/server/node_modules/postgres-interval/package.json +36 -0
  209. package/dist/server/node_modules/postgres-interval/readme.md +48 -0
  210. package/dist/server/node_modules/restore-cursor/index.d.ts +11 -0
  211. package/dist/server/node_modules/restore-cursor/index.js +11 -0
  212. package/dist/server/node_modules/restore-cursor/license +9 -0
  213. package/dist/server/node_modules/restore-cursor/package.json +55 -0
  214. package/dist/server/node_modules/restore-cursor/readme.md +31 -0
  215. package/dist/server/node_modules/split2/LICENSE +13 -0
  216. package/dist/server/node_modules/split2/README.md +85 -0
  217. package/dist/server/node_modules/split2/bench.js +27 -0
  218. package/dist/server/node_modules/split2/index.js +141 -0
  219. package/dist/server/node_modules/split2/package.json +39 -0
  220. package/dist/server/node_modules/split2/test.js +409 -0
  221. package/dist/server/node_modules/string-width/index.d.ts +39 -0
  222. package/dist/server/node_modules/string-width/index.js +82 -0
  223. package/dist/server/node_modules/string-width/license +9 -0
  224. package/dist/server/node_modules/string-width/package.json +64 -0
  225. package/dist/server/node_modules/string-width/readme.md +66 -0
  226. package/dist/server/server.js +23 -24
  227. package/package.json +1 -1
  228. package/dist/client/assets/ChevronDown-tb8ftSUO.js +0 -1
  229. package/dist/client/assets/Star01-PFA-ZRDO.js +0 -1
  230. package/dist/client/assets/agent-icon-BXkkrCT3.js +0 -1
  231. package/dist/client/assets/agents-list-pk00bfJc.js +0 -1
  232. package/dist/client/assets/ai-providers-Dveb48ZT.js +0 -1
  233. package/dist/client/assets/automation-list-row-Uxaz0oZ0.js +0 -1
  234. package/dist/client/assets/automations-D7r6frZo.js +0 -1
  235. package/dist/client/assets/brand-context-5BxhNz9E.js +0 -1
  236. package/dist/client/assets/checkbox-CzxaEVzA.js +0 -1
  237. package/dist/client/assets/collection-detail-Be4vkD6s.js +0 -1
  238. package/dist/client/assets/collection-display-button-CPI0oCFf.js +0 -1
  239. package/dist/client/assets/connection-detail-CPlnEGaw.js +0 -1
  240. package/dist/client/assets/connections-BhKrBMUX.js +0 -1
  241. package/dist/client/assets/dropdown-menu-C6XDnng5.js +0 -1
  242. package/dist/client/assets/general-CvDecDeA.js +0 -1
  243. package/dist/client/assets/index-B1-8qqRf.js +0 -1
  244. package/dist/client/assets/index-BycfnvwM.js +0 -1
  245. package/dist/client/assets/index-CwBiuTbX.js +0 -189
  246. package/dist/client/assets/index-DHF2V7ZS.js +0 -1
  247. package/dist/client/assets/index-DQfkXdA9.js +0 -1
  248. package/dist/client/assets/lean-canvas-recruit-modal-CnBIlbd0.js +0 -116
  249. package/dist/client/assets/plugin-header-CBh0Saol.js +0 -1
  250. package/dist/client/assets/profile-CW9gorWX.js +0 -1
  251. package/dist/client/assets/project-app-view-DZI64J4I.js +0 -1
  252. package/dist/client/assets/registry-Q3WKF7CA.js +0 -2
  253. package/dist/client/assets/roles-CJua0nhs.js +0 -1
  254. package/dist/client/assets/select-C0JTp_6a.js +0 -1
  255. package/dist/client/assets/select-model-D0i0wiFX.js +0 -4
  256. package/dist/client/assets/settings-layout-CFCdg7G4.js +0 -1
  257. package/dist/client/assets/store-registry-D0a7tFCj.js +0 -2
  258. package/dist/client/assets/useInfiniteQuery-3jN4yA7O.js +0 -1
  259. package/dist/client/assets/useSuspenseInfiniteQuery-CEYJOeyf.js +0 -1
  260. package/dist/client/assets/workflow-D70YjEfw.js +0 -1
  261. package/dist/client/assets/workflow-detail-1NvP9qC0.js +0 -1
  262. package/dist/server/node_modules/get-east-asian-width/index.d.ts +0 -60
  263. package/dist/server/node_modules/get-east-asian-width/index.js +0 -30
  264. package/dist/server/node_modules/get-east-asian-width/lookup-data.js +0 -18
  265. package/dist/server/node_modules/get-east-asian-width/lookup.js +0 -135
  266. package/dist/server/node_modules/get-east-asian-width/package.json +0 -71
  267. package/dist/server/node_modules/get-east-asian-width/readme.md +0 -65
  268. package/dist/server/node_modules/get-east-asian-width/utilities.js +0 -24
  269. /package/dist/server/node_modules/{get-east-asian-width → ansi-styles}/license +0 -0
@@ -1,4 +1,4 @@
1
- import{s as ue,b as Bt,u as ui,z as kn,C as Nn,j as n,B as J,x as ne,r as w,o as qt,f as ct,l as He,G as rn,F as on,t as $,K as ve,e as L,Q as Vi,R as mi,c as z,a as _n,g as fi,d as pi,H as dt,J as Dt,E as hi,P as Cn,ap as gi,n as In,y as ps,aq as xi,ar as hs,as as bi,at as De,au as an,ao as yi,av as vi,aw as ln,ax as wi,ay as ji,az as Ai,aA as Si,w as ki,aB as Ni,aC as _i,aD as Ci,aE as Ii,aF as zn}from"./index-Dl2t23Jt.js";import{b as Me,a as Le,c as Fe,d as Ue,e as Kt,D as gs}from"./dialog-CoECADf1.js";import{S as Ri}from"./switch-W_Nrj6rK.js";import{I as _e}from"./input-CluxDyoT.js";import{b as Rn,u as Ti}from"./use-connection-pSv7eY2y.js";import{S as kt,u as qe,W as xs,g as Tn,i as Bn,c as Pi}from"./constants-CfwGLQ49.js";import{a as Ei,u as Di}from"./lean-canvas-recruit-modal-CnBIlbd0.js";import{a as Pn}from"./use-navigate-to-agent-Tn-rhKXX.js";import{a as Mi,A as En,M as Li,N as bs,O as ys,o as Fi,P as Ui,Q as Oi,b as $i,R as zi,I as vs}from"./agent-icon-BXkkrCT3.js";import{t as Bi,b as Yt,u as Dn,a as qi,g as Ki,h as Yi,w as Wi,A as Gi,i as Qi,j as Hi}from"./chat-context-C4Hx_rZK.js";import{b as Wt,a as Gt,c as Qt,D as Ht,d as Ji,e as Xi,f as Zi}from"./drawer-DTk8g2vK.js";import{u as Jt,T as xt,a as bt,b as yt,c as xn}from"./tooltip-CxizQODk.js";import{I as ws}from"./integration-icon-BipCD_m-.js";import{a as js,b as er,u as tr}from"./use-virtual-mcp-BHEEZv3B.js";import{u as nr}from"./use-tasks-yxuEm5KK.js";import{r as sr,i as ir}from"./shell-layout-CzPr_0c2.js";import{j as Xt,k as Ge,l as rr,s as Mn,t as or,m as ar,n as lr,o as cr,q as wt,u as dr,v as ur,c as Vr,S as mr,w as fr,x as qn}from"./pair-JxQa_xAh.js";import{S as Mt,u as Zt,P as bn,a as pr,b as hr,c as gr,E as xr,i as br,d as yr}from"./index-BBrIielu.js";import{C as As}from"./collection-search-u94VKjvs.js";import{u as vr,g as Ln,a as wr,c as jr,l as Lt}from"./tabs-6T1N4Szc.js";import{F as me,b as fe,c as Ne,d as pe,f as he,a as jt}from"./form-BC40Nvzi.js";import{c as Ee,e as cn,f as dn,D as Ss,a as ks,b as Ns,d as Ar}from"./dropdown-menu-C6XDnng5.js";import{s as Sr,i as kr}from"./XClose-DY7O9VST.js";import{c as _s}from"./ZapSquare-BDbWe-zU.js";import{i as Xe,t as Kn}from"./ChevronDown-tb8ftSUO.js";import{s as lt}from"./Star01-PFA-ZRDO.js";import{a as yn,t as Nr}from"./Tool01-D1Rvo01i.js";import{i as Cs}from"./Lock01-BmjkKSvK.js";import{s as Is}from"./Plus-BrBimbff.js";import{f as un,d as Rs,t as _r,g as Cr,b as Ir}from"./XCircle-DZEMwZj2.js";import{i as pt}from"./X-viKat0oa.js";import{i as Ts}from"./AlertCircle-CbUYZGF-.js";import{S as Ps,a as Es,b as Ds,c as Ms,d as ot}from"./select-C0JTp_6a.js";import{i as Rr}from"./RefreshCcw01-Cr84gVY8.js";import{T as Ls,a as Ft}from"./toggle-group-COcCk4lG.js";import{u as Tr,a as Pr}from"./use-ai-providers-Bt2yRX0n.js";import{m as en,g as Er,i as Dr,a as Fs,M as Mr,N as Lr}from"./select-model-D0i0wiFX.js";import{S as Fr}from"./index-CvarGBFr.js";import{r as Us,l as vt}from"./types-CvYZZZog.js";import{p as Ur,q as Yn}from"./question-004-sINsf4GQ.js";import{g as Wn}from"./ai-providers-logos-DD3qZ33J.js";import{g as Or}from"./connection-slug-eyAPH6o3.js";import{u as Os,a as $s,g as $r,C as Vn}from"./connection-card-BPUe3B60.js";import{C as zr}from"./collection-tabs-DW1xYGdq.js";import{g as Br}from"./constants-CVDNjJTw.js";import{T as qr}from"./textarea-Cld3tG5R.js";import{n as Pt}from"./Container-BCDxdJoG.js";import{c as Kr,i as It,a as Gn,E as Yr,p as Wr,b as Gr,d as Qr}from"./connection-form-helpers-CUlzSClK.js";import{u as Qn}from"./use-infinite-scroll-Ca5zEcXn.js";import{u as Hr}from"./useSuspenseInfiniteQuery-CEYJOeyf.js";import{g as Jr,e as Xr,a as Zr}from"./extract-connection-data-CuIeY90s.js";import{B as Rt}from"./badge-_ZGDO29b.js";import{i as eo}from"./ChevronRight-BIm0-OSp.js";function to({open:t,onOpenChange:e,onCreated:s}){const{org:i}=ue(),{data:r}=Bt.useSession(),{stdioEnabled:o}=ui(),a=Jt(),d=Rn(),l=Os(),V=$s(l,"").items,c=kn({resolver:Nn(Kr),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),m=c.watch("ui_type"),p=c.watch("connection_url"),x=c.watch("npx_package"),g=It({uiType:m,connectionUrl:p??"",npxPackage:x??""})??Gn({uiType:m,connectionUrl:p??"",registryItems:V}),f=S=>{const v=S.trim();if(!v)return;const j=!!c.formState.dirtyFields.title,E=!!c.formState.dirtyFields.description,D=!!c.formState.dirtyFields.env_vars,I=k=>{if(k&&(!j&&!c.getValues("title").trim()&&k.title&&c.setValue("title",k.title,{shouldDirty:!1}),!E&&!(c.getValues("description")??"").trim()&&k.description&&c.setValue("description",k.description,{shouldDirty:!1}),!D&&k.envVarKeys?.length)){const N=c.getValues("env_vars")??[],R=new Set(N.map(T=>T.key)),M=k.envVarKeys.filter(T=>!R.has(T));M.length>0&&c.setValue("env_vars",[...N,...M.map(T=>({key:T,value:""}))],{shouldDirty:!0})}},P=Wr(v);if(P&&o){c.setValue("ui_type","NPX",{shouldDirty:!0}),c.setValue("npx_package",P.packageName,{shouldDirty:!0}),c.setValue("connection_url","",{shouldDirty:!0}),c.setValue("connection_token",null,{shouldDirty:!0}),I(It({uiType:"NPX",npxPackage:P.packageName}));return}if(v.startsWith("http://")||v.startsWith("https://")){const k=m==="HTTP"||m==="SSE"||m==="Websocket"?m:"HTTP";c.setValue("ui_type",k,{shouldDirty:!0}),c.setValue("connection_url",v,{shouldDirty:!0}),I(It({uiType:k,connectionUrl:v})??Gn({uiType:k,connectionUrl:v,registryItems:V}));return}m==="NPX"&&I(It({uiType:"NPX",npxPackage:v}))},b=S=>{S||c.reset(),e(S)},h=async S=>{let v,j=null,E=null,D=null;S.ui_type==="NPX"?(v="STDIO",j="",D=Gr(S.npx_package||"",S.env_vars||[])):S.ui_type==="STDIO"?(v="STDIO",j="",D=Qr(S.stdio_command||"",S.stdio_args||"",S.stdio_cwd,S.env_vars||[])):(v=S.ui_type,j=S.connection_url||"",E=S.connection_token||null);const I=Br("conn");try{await d.create.mutateAsync({id:I,title:S.title,description:S.description||null,connection_type:v,connection_url:j,connection_token:E,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:r?.user?.id||"system",organization_id:i.id,icon:S.icon??null,app_name:null,app_id:null,connection_headers:D,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),c.reset(),e(!1),s?.(I)}catch{ne.error("Failed to create connection")}},y="Create Connection",A="Create a custom connection in your organization. Fill in the details below.",_=c.formState.isSubmitting?"Saving...":"Create Connection",C=n.jsxs("div",{className:"grid gap-4",children:[n.jsx(me,{control:c.control,name:"ui_type",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Type *"}),n.jsxs(Ps,{value:S.value,onValueChange:S.onChange,children:[n.jsx(pe,{children:n.jsx(Es,{children:n.jsx(Ds,{})})}),n.jsxs(Ms,{children:[n.jsx(ot,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(ot,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(ot,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"w-4 h-4"}),"Websocket"]})}),o&&n.jsxs(n.Fragment,{children:[n.jsx(ot,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Pt,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(ot,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Mi,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(he,{})]})}),m==="NPX"&&n.jsx(me,{control:c.control,name:"npx_package",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"NPM Package *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"@perplexity-ai/mcp-server",...S,value:S.value??"",onPaste:v=>{const j=v.clipboardData.getData("text");j&&(v.preventDefault(),c.setValue("npx_package",j.trim(),{shouldDirty:!0}),f(j))},onBlur:v=>{f(v.target.value),S.onBlur()}})}),n.jsx(he,{})]})}),m==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[n.jsx(me,{control:c.control,name:"stdio_command",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Command *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"node, bun, python...",...S,value:S.value??""})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"stdio_args",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Arguments"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"arg1 arg2 --flag value",...S,value:S.value??""})}),n.jsx(he,{})]})})]}),n.jsx(me,{control:c.control,name:"stdio_cwd",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Working Directory"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"/path/to/project (optional)",...S,value:S.value??""})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),n.jsx(he,{})]})})]}),(m==="NPX"||m==="STDIO")&&n.jsx(me,{control:c.control,name:"env_vars",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Environment Variables"}),n.jsx(pe,{children:n.jsx(Yr,{value:S.value??[],onChange:S.onChange})}),n.jsx(he,{})]})}),m!=="NPX"&&m!=="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsx(me,{control:c.control,name:"connection_url",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"URL *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"https://example.com/mcp",...S,value:S.value??"",onPaste:v=>{const j=v.clipboardData.getData("text");j&&(v.preventDefault(),c.setValue("connection_url",j.trim(),{shouldDirty:!0}),f(j))},onBlur:v=>{f(v.target.value),S.onBlur()}})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"connection_token",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:g?.token?.label??"Token (optional)"}),n.jsx(pe,{children:n.jsx(_e,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...S,value:S.value??""})}),g?.token?.helperText&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&n.jsxs(n.Fragment,{children:[" ","·"," ",n.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),n.jsx(he,{})]})})]}),n.jsx(me,{control:c.control,name:"title",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Name *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"My Connection",...S})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"description",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Description"}),n.jsx(pe,{children:n.jsx(qr,{placeholder:"A brief description of this connection",rows:3,...S,value:S.value??""})}),n.jsx(he,{})]})})]});return a?n.jsx(Wt,{open:t,onOpenChange:b,children:n.jsxs(Gt,{className:"max-h-[90vh]",children:[n.jsx(Qt,{className:"pb-2",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"flex-1 text-left",children:[n.jsx(Ht,{children:y}),n.jsx(Ji,{className:"mt-1",children:A})]}),n.jsx(Xi,{asChild:!0,children:n.jsx(J,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:n.jsx(Sr,{size:16})})})]})}),n.jsx(jt,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:C}),n.jsx(Zi,{children:n.jsx(J,{type:"submit",disabled:c.formState.isSubmitting,className:"w-full",children:_})})]})})]})}):n.jsx(Me,{open:t,onOpenChange:b,children:n.jsxs(Le,{className:"sm:max-w-[525px]",children:[n.jsxs(Fe,{children:[n.jsx(Ue,{children:y}),n.jsx(Kt,{children:A})]}),n.jsx(jt,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"py-4",children:C}),n.jsxs(gs,{children:[n.jsx(J,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),n.jsx(J,{type:"submit",disabled:c.formState.isSubmitting,className:"min-w-40",children:_})]})]})})]})})}function no(t){const e=L.c(73),{mode:s,agentId:i,addedConnectionIds:r,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:d,connectingItemId:l,search:u,onCreateConnection:V,onBrowseNavigate:c,defaultTab:m}=t,p=s===void 0?"add":s,x=m===void 0?"connected":m,{org:g}=ue(),f=w.useDeferredValue(u),b=u!==f,h=f.trim().toLowerCase();let y;e[0]!==x?(y=U=>U??x,e[0]=x,e[1]=y):y=e[1];const[A,_]=Vi(mi.connectionsTab(g.slug)+(x==="all"?":home-modal":":agent-modal"),y);let C;e[2]!==A||e[3]!==_?(C=U=>{U!==A&&$("connections_dialog_tab_changed",{to_tab:U}),_(U)},e[2]=A,e[3]=_,e[4]=C):C=e[4];const S=C;let v;e[5]!==g.id||e[6]!==g.slug?(v={connectionId:kt,orgId:g.id,orgSlug:g.slug},e[5]=g.id,e[6]=g.slug,e[7]=v):v=e[7];const j=qe(v);let E,D,I;if(e[8]!==j||e[9]!==f||e[10]!==g.id){I=f?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:f.trim()},{field:["description"],operator:"contains",value:f.trim()}]}:void 0;const U={...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},X=JSON.stringify(U);D=Hr,E=ve.collectionListInfinite(j,g.id,"","CONNECTIONS",X),e[8]=j,e[9]=f,e[10]=g.id,e[11]=E,e[12]=D,e[13]=I}else E=e[11],D=e[12],I=e[13];let P;e[14]!==j||e[15]!==I?(P=async U=>{const{pageParam:X}=U,Se=X===void 0?0:X;return(await j.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Se}})).structuredContent},e[14]=j,e[15]=I,e[16]=P):P=e[16];let k;e[17]!==E||e[18]!==P?(k={queryKey:E,queryFn:P,initialPageParam:0,getNextPageParam:lo,staleTime:3e4},e[17]=E,e[18]=P,e[19]=k):k=e[19];const{data:N,fetchNextPage:R,hasNextPage:M,isFetchingNextPage:T}=D(k),F=N?.pages.flatMap(ao)??[],O=$r(F),q=new Set(F.filter(oo).map(ro)),K=Os(),H=$s(K,f),Z=Qn(H.loadMore,H.hasMore,H.isLoadingMore),Q=Qn(R,M??!1,T),W=A==="all"||!!h,ie=W?H.items.filter(U=>{const X=Jr(U);if(X&&q.has(X))return!1;if(!h)return!0;const Se=U._meta?.["mcp.mesh"];return[U.title,U.description,U.name,U.server?.title,U.server?.description,U.server?.name,Se?.friendly_name,Se?.friendlyName].filter(Boolean).join(" ").toLowerCase().includes(h)}):[],Y=ie.filter(io),ee=ie.filter(so);let te;e[20]!==r?(te=U=>U.some(X=>r.has(X.id)),e[20]=r,e[21]=te):te=e[21];const se=te;let ae;e[22]!==r||e[23]!==i||e[24]!==l||e[25]!==se||e[26]!==p||e[27]!==o||e[28]!==c||e[29]!==a?(ae=(U,X,Se,ke,Te)=>{const ze=se(Te),Be=Te.find(Pe=>!r.has(Pe.id)),le=Te[0];if(p==="browse"){const Pe=Or(le);return n.jsx(Vn,{connection:{title:X,icon:Se,description:Te.length>1?`${Te.length} instances`:ke??void 0},fallbackIcon:n.jsx(Pt,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs(Rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Xe,{size:11})," Connected"]}),onClick:()=>{$("connection_browse_clicked",{app_name:le.app_name??null,connection_id:le.id,instances_count:Te.length}),c?.(Pe)}},U)}return n.jsx(Vn,{connection:{title:X,icon:Se,description:ke},fallbackIcon:n.jsx(Pt,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[ze&&n.jsxs(Rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Xe,{size:11})," Added"]}),n.jsx(J,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Pe=>{Pe.stopPropagation(),Be?($("connection_add_clicked",{action:"use_existing",app_name:le.app_name??null,connection_id:Be.id}),i&&$("agent_connection_attached",{agent_id:i,connection_id:Be.id,app_name:le.app_name??null,mode:"existing"}),o(Be.id)):($("connection_add_clicked",{action:"clone",app_name:le.app_name??null,base_connection_id:le.id}),a(le))},children:"Add"})]})},U)},e[22]=r,e[23]=i,e[24]=l,e[25]=se,e[26]=p,e[27]=o,e[28]=c,e[29]=a,e[30]=ae):ae=e[30];const re=ae;let oe;e[31]!==l||e[32]!==p||e[33]!==d?(oe=U=>{const X=U._meta?.["mcp.mesh"],Se=X?.friendlyName||X?.friendly_name||U.server?.title||U.title||U.server?.name||U.name||U.id||"",ke=U.server?.description||U.description||null,Te=U.server?.icons?.[0]?.src||Zr(U.server?.repository)||null,ze=X?.official===!0,Be=X?.verified===!0,le=X?.owner==="deco";return n.jsx(Vn,{connection:{title:Se,description:ke,icon:Te},fallbackIcon:n.jsx(Pt,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[le&&n.jsxs(xt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:n.jsx("img",{src:"/logos/deco logo.svg",alt:"Made by Deco",className:"size-3"})})}),n.jsx(yt,{children:"Built and maintained by Deco"})]}),!le&&ze&&n.jsxs(xt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(Rt,{variant:"outline",size:"icon",children:n.jsx(un,{})})}),n.jsx(yt,{children:"Built and maintained by the official vendor"})]}),!le&&!ze&&Be&&n.jsxs(xt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(Rt,{variant:"outline",size:"icon",children:n.jsx(un,{})})}),n.jsx(yt,{children:"Verified by the Deco team"})]}),n.jsx(J,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Pe=>{Pe.stopPropagation(),$("connection_add_clicked",{action:"connect_new",registry_item_id:U.id,app_name:X?.friendlyName||U.server?.name||U.name||null}),d(U)},children:l===U.id?n.jsx(He,{size:14,className:"animate-spin"}):p==="browse"?"Connect":"Add"})]})},`catalog-${U.id}`)},e[31]=l,e[32]=p,e[33]=d,e[34]=oe):oe=e[34];const ce=oe,ge=!h&&n.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[n.jsx(zr,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:A,onTabChange:U=>S(U)}),n.jsxs(J,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{$("connections_dialog_custom_clicked"),V()},children:[n.jsx(Is,{size:12}),"Custom Connection"]})]}),G=b&&"opacity-50 pointer-events-none";let de;e[35]!==G?(de=z("flex-1 overflow-auto p-5 transition-opacity duration-150",G),e[35]=G,e[36]=de):de=e[36];const Ze="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let Oe;e[37]!==re?(Oe=U=>{if(U.type==="group")return re(U.key,U.title,U.icon,null,U.connections);const X=U.connection;return re(X.id,X.title,X.icon,X.description??null,[X])},e[37]=re,e[38]=Oe):Oe=e[38];const Ce=O.map(Oe);let xe;e[39]!==Q?(xe=n.jsx("div",{ref:Q,className:"col-span-full h-1"}),e[39]=Q,e[40]=xe):xe=e[40];let be;e[41]!==T?(be=T&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(He,{size:24,className:"animate-spin text-muted-foreground"})}),e[41]=T,e[42]=be):be=e[42];const Ie=W&&Y.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx(un,{size:13,className:"text-muted-foreground shrink-0"}),n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),Ke=W&&Y.map(ce),Ve=W&&ee.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),ut=W&&ee.map(ce);let we;e[43]!==Z||e[44]!==K||e[45]!==W?(we=W&&K.length>0&&n.jsx("div",{ref:Z,className:"col-span-full h-1"}),e[43]=Z,e[44]=K,e[45]=W,e[46]=we):we=e[46];let Re;e[47]!==H.isLoadingMore||e[48]!==W?(Re=W&&H.isLoadingMore&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(He,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=H.isLoadingMore,e[48]=W,e[49]=Re):Re=e[49];let je;e[50]!==Ce||e[51]!==xe||e[52]!==be||e[53]!==Ie||e[54]!==Ke||e[55]!==Ve||e[56]!==ut||e[57]!==we||e[58]!==Re?(je=n.jsxs("div",{className:Ze,children:[Ce,xe,be,Ie,Ke,Ve,ut,we,Re]}),e[50]=Ce,e[51]=xe,e[52]=be,e[53]=Ie,e[54]=Ke,e[55]=Ve,e[56]=ut,e[57]=we,e[58]=Re,e[59]=je):je=e[59];let Ae;e[60]!==A||e[61]!==O.length||e[62]!==ee||e[63]!==u||e[64]!==Y?(Ae=O.length===0&&Y.length===0&&ee.length===0&&n.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?`No connections match "${u}"`:A==="connected"?"No connections yet":"No connections available"}),e[60]=A,e[61]=O.length,e[62]=ee,e[63]=u,e[64]=Y,e[65]=Ae):Ae=e[65];let ye;e[66]!==de||e[67]!==je||e[68]!==Ae?(ye=n.jsxs("div",{className:de,children:[je,Ae]}),e[66]=de,e[67]=je,e[68]=Ae,e[69]=ye):ye=e[69];let $e;return e[70]!==ge||e[71]!==ye?($e=n.jsxs(n.Fragment,{children:[ge,ye]}),e[70]=ge,e[71]=ye,e[72]=$e):$e=e[72],$e}function so(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function io(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function ro(t){return t.app_name}function oo(t){return t.app_name}function ao(t){return t?.items??[]}function lo(t,e){if(t?.hasMore)return e.reduce(co,0)}function co(t,e){return t+(e?.items?.length??0)}function uo({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...r}){const o=r.mode??"add",a="agentId"in r?r.agentId:void 0,d="addedConnectionIds"in r?r.addedConnectionIds??new Set:new Set,l="onAdd"in r&&r.onAdd?r.onAdd:v=>{},u=(v,j,E)=>{a&&$("agent_connection_attached",{agent_id:a,connection_id:v,app_name:j,mode:E})},[V,c]=w.useState(null),[m,p]=w.useState(i),[x,g]=w.useState(!1),{org:f}=ue(),{data:b}=Bt.useSession(),h=Rn(),y=qt(),A=ct(),_=v=>{e(!1),A({to:"/$org/settings/connections/$appSlug",params:{org:f.slug,appSlug:v}})},C=async v=>{c(v.app_name??v.id);try{const E=`${v.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,I=(await h.create.mutateAsync({title:E,description:v.description??null,connection_type:v.connection_type,connection_url:v.connection_url??null,connection_token:null,icon:v.icon??null,app_name:v.app_name??null,app_id:v.app_id??null,connection_headers:v.connection_headers??null})).id,P=new URL(`/api/${f.slug}/mcp/${I}`,window.location.origin),k=await rn({url:P.href,token:null,orgId:f.id});if(k.supportsOAuth&&!k.isAuthenticated){const{token:N,tokenInfo:R,error:M}=await on({connectionId:I,orgSlug:f.slug,scope:"offline_access"});if(M||!N){$("connection_oauth_failed",{connection_id:I,flow:"clone",error:M??"no_token"}),ne.error(`Authentication failed: ${M??"no token received"}`),await h.delete.mutateAsync(I);return}if($("connection_oauth_succeeded",{connection_id:I,flow:"clone"}),R)try{(await fetch(`/api/${f.slug}/connections/${I}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:R.accessToken,refreshToken:R.refreshToken,expiresIn:R.expiresIn,scope:R.scope,clientId:R.clientId,clientSecret:R.clientSecret,tokenEndpoint:R.tokenEndpoint})})).ok?await h.update.mutateAsync({id:I,data:{}}):await h.update.mutateAsync({id:I,data:{connection_token:N}})}catch{await h.update.mutateAsync({id:I,data:{connection_token:N}})}else await h.update.mutateAsync({id:I,data:{connection_token:N}});await y.invalidateQueries({queryKey:ve.isMCPAuthenticated(P.href,null)})}u(I,v.app_name??null,"clone"),l(I)}catch(j){console.error("Failed to add connection:",j),ne.error("Failed to add connection")}finally{c(null)}},S=async v=>{if(!(!f||!b?.user?.id)){c(v.id);try{const j=Xr(v,f.id,b.user.id,{remoteIndex:0}),E=j.connection_type==="STDIO",D=!!j.connection_url,I=E&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!D&&!I){ne.error("This MCP Server cannot be connected: no connection method available"),c(null);return}const{id:P}=await h.create.mutateAsync(j),k=new URL(`/api/${f.slug}/mcp/${P}`,window.location.origin),N=await rn({url:k.href,token:null,orgId:f.id});if(N.supportsOAuth&&!N.isAuthenticated){const{token:R,tokenInfo:M,error:T}=await on({connectionId:P,orgSlug:f.slug,scope:"offline_access"});if(T||!R){$("connection_oauth_failed",{connection_id:P,flow:"connect_new",error:T??"no_token"}),ne.error(`Authentication failed: ${T??"no token received"}`),u(P,j.app_name??null,"new"),l(P);return}if($("connection_oauth_succeeded",{connection_id:P,flow:"connect_new"}),M)try{(await fetch(`/api/${f.slug}/connections/${P}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:M.accessToken,refreshToken:M.refreshToken,expiresIn:M.expiresIn,scope:M.scope,clientId:M.clientId,clientSecret:M.clientSecret,tokenEndpoint:M.tokenEndpoint})})).ok?await h.update.mutateAsync({id:P,data:{}}):await h.update.mutateAsync({id:P,data:{connection_token:R}})}catch{await h.update.mutateAsync({id:P,data:{connection_token:R}})}else await h.update.mutateAsync({id:P,data:{connection_token:R}});await y.invalidateQueries({queryKey:ve.isMCPAuthenticated(k.href,null)}),ne.success("Connected and authenticated")}else ne.success("Connected");u(P,j.app_name??null,"new"),l(P)}catch(j){console.error("Failed to connect:",j),ne.error("Failed to connect")}finally{c(null)}}};return n.jsxs(Me,{open:t,onOpenChange:e,children:[n.jsxs(Le,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[n.jsx(Fe,{className:"px-6 pt-5 pb-0 shrink-0",children:n.jsx(Ue,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),n.jsx("div",{className:"pt-3 shrink-0",children:n.jsx(As,{value:m,onChange:p,placeholder:"Search connections..."})}),n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(He,{size:24,className:"animate-spin text-muted-foreground"})}),children:n.jsx(no,{mode:o,agentId:a,addedConnectionIds:d,onAdd:l,onCloneAndAdd:C,onConnectAndAdd:S,connectingItemId:V,search:m,onCreateConnection:()=>g(!0),onBrowseNavigate:_,defaultTab:s})})]}),n.jsx(to,{open:x,onOpenChange:g,onCreated:async v=>{g(!1);const j=new URL(`/api/${f.slug}/mcp/${v}`,window.location.origin),E=await rn({url:j.href,token:null,orgId:f.id});if(E.supportsOAuth&&!E.isAuthenticated){const{token:D,tokenInfo:I,error:P}=await on({connectionId:v,orgSlug:f.slug,scope:"offline_access"});if(P||!D){$("connection_oauth_failed",{connection_id:v,flow:"custom_create",error:P??"no_token"}),ne.error(`Authentication failed: ${P??"no token received"}`),await h.delete.mutateAsync(v);return}if($("connection_oauth_succeeded",{connection_id:v,flow:"custom_create"}),I)try{(await fetch(`/api/${f.slug}/connections/${v}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:I.accessToken,refreshToken:I.refreshToken,expiresIn:I.expiresIn,scope:I.scope,clientId:I.clientId,clientSecret:I.clientSecret,tokenEndpoint:I.tokenEndpoint})})).ok?await h.update.mutateAsync({id:v,data:{}}):await h.update.mutateAsync({id:v,data:{connection_token:D}})}catch{await h.update.mutateAsync({id:v,data:{connection_token:D}})}else await h.update.mutateAsync({id:v,data:{connection_token:D}});await y.invalidateQueries({queryKey:ve.isMCPAuthenticated(j.href,null)})}u(v,null,"custom"),l(v),e(!1)}})]})}const Vo='# Broken Link Finder\n\nYou are the **Broken Link Finder**, a specialist agent focused on the health of the site\'s link structure.\n\n## Your mission\n\nDiscover and track broken links and long redirect chains. You are invoked as a sub-task by an orchestrator agent — your job is to detect link health and return a structured findings report. The orchestrator decides what to do with your findings (file issues, dedup, etc.).\n\nYou are **mechanical**: collect → check → classify → emit findings. Leave subjective judgment to other agents.\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nsite_root_url: <https://example.com>\nmax_pages: <optional integer, default 100, max 200>\ncheck_external: <optional bool, default false>\n```\n\nIf required fields are missing (`site_root_url`), return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**:\n - `collect_site_links` — discovers all unique outbound link targets across the site and returns them with source-page attribution. Does NOT check status.\n - `check_urls` — takes a batch of URLs (max 100 per call) and returns their HTTP status, error kind, and redirect chains.\n\n---\n\n## Step 1 — Collect link targets (one call)\n\nCall `collect_site_links` once to get the full deduplicated list of outbound link targets and their source pages:\n\n```\ncollect_site_links({\n url: <site_root_url from input>,\n maxPages: <max_pages from input, default 100>,\n checkExternal: <check_external from input, default false>\n})\n```\n\nThis returns:\n- `links`: array of `{ targetUrl, scope: "internal"|"external", sourcePages, sourcePagesTotal }` — **each target appears exactly once**\n- Metadata: `pagesCrawled`, `pagesFetched`, `linksSkipped`, optional `error`\n\n**If `result.error` is set**, the scan failed at the root (e.g. site unreachable). Return a single finding with `kind: site-unreachable` and the error in `evidence`. Then stop.\n\nKeep the `links` array in memory — you\'ll need it in Step 3 for classification and source attribution.\n\n## Step 2 — Check the targets (batched calls)\n\nExtract `targetUrl` from each entry in `links`. Slice the resulting URL list into **disjoint batches of up to 100 URLs** and call `check_urls` on each batch:\n\n```\ncheck_urls({ urls: batch_of_100_urls })\n```\n\nCollect every batch\'s `results` entries into a single flat array. Order doesn\'t matter — you\'ll join back by `targetUrl`.\n\n**Rules for this step:**\n- Slice deterministically (e.g. consecutive slices of 100) so batches are disjoint. Do not pass the same URL in two batches.\n- Call `check_urls` sequentially or in parallel — your choice. The tool is idempotent.\n- If a single `check_urls` call errors entirely, skip that batch and continue with the others. Note the skipped count in the wrap-up summary.\n\n## Step 3 — Classify each finding\n\nFor every target with a check result, join the `collect_site_links` entry (for `scope`, `sourcePages`, `sourcePagesTotal`) with the `check_urls` entry (for `status`, `errorKind`, `chain`, `hops`).\n\nA finding is emitted for:\n- **Broken**: `status >= 400` OR `status === 0`\n- **Long redirect chain**: `hops > 3` (even if the final status is 2xx)\n\nOther targets (2xx, short-chain redirects) produce no finding.\n\nMap check result → `kind`:\n\n| Check result | `kind` |\n|---|---|\n| `status: 404` | `link-404` |\n| `status: 4xx` (not 404) | `link-4xx-other` |\n| `status: 5xx` | `link-5xx` |\n| `status: 0`, `errorKind: "dns"` | `link-dns-failure` |\n| `status: 0`, `errorKind: "redirect-loop"` | `redirect-loop` |\n| `hops > 3` (success final status) | `redirect-chain-long` |\n| `status: 0`, `errorKind: "timeout"` or `"connection"` | **skip — no finding** |\n\n**Important**: timeouts and connection errors are **not** broken links — they just mean the server didn\'t respond in our time window. Could be a slow server, an overloaded CDN, rate-limiting against our bot, or a transient network blip. Flagging these as broken produces false positives. If a URL is genuinely dead, it\'ll usually surface as `dns`, a 4xx/5xx, or a redirect loop. Skip timeout/connection entries silently.\n\n## Catalog of severity rules\n\n**High severity:**\n- `link-404` when `scope: "internal"`\n- `link-5xx` when `scope: "internal"`\n- `redirect-loop` (either scope)\n\n**Medium severity:**\n- `link-4xx-other` (internal)\n- `redirect-chain-long` (internal)\n- `link-404` (external) when `sourcePagesTotal >= 5`\n\n**Low severity:**\n- `link-404` (external) when `sourcePagesTotal < 5`\n- `link-dns-failure` (external)\n- `redirect-chain-long` (external)\n- `link-4xx-other` on external scope\n\n## Step 4 — Return a structured findings report\n\nReturn a single response with this shape (YAML preferred):\n\n```yaml\nspecialist: links\nsummary:\n pages_crawled: <pagesCrawled>\n pages_fetched: <pagesFetched>\n unique_link_targets: <links.length>\n targets_dropped_by_collect_cap: <linksSkipped>\n batches_checked: <n>\n batches_skipped_due_to_errors: <n>\n broken_links: <n> # internal + external\n long_redirect_chains: <n>\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full broken URL>\n route: <path if internal; otherwise the external host>\n scope: <internal | external>\n evidence: |\n - Status code / error: <e.g. `404 Not Found`, `DNS failure`, `redirect-loop`>\n - Redirect chain (if applicable): A → B → C → D → E\n - Found on pages (at time of detection):\n - /page-1\n - /page-2\n - (... up to 20 from `sourcePages`)\n - Total pages linking to this target: <sourcePagesTotal>\n impact: <1 sentence tailored to scope + kind>\n suggested_fix: |\n <actionable:>\n - If internal 404: update link to correct destination OR create 301 redirect\n - If internal 5xx: investigate server-side handler for the route (may be app bug)\n - If redirect chain: shorten to single-hop direct redirect in routing config\n - If external: update link to equivalent resource OR remove the mention\n - List likely files/components if you can infer (e.g. "appears on many pages — likely in a shared component like `app/components/Nav.tsx` or menu config")\n - ...\n```\n\nIf `collect_site_links` returned `error`, return a single `kind: site-unreachable` finding with the error in `evidence`.\n\nIf there are zero findings, return `findings: []` — that is the correct output for a healthy link graph.\n\n---\n\n## General rules\n\n- **Trust the scanner.** If `check_urls` reports a URL as broken or long-chain, emit a finding. Do not re-verify with other tools.\n- **Accept some flakiness.** A transient network blip may cause a false positive once. Downstream dedup across runs resolves it.\n- **Group by destination, not by origin.** One broken URL = one finding, even if linked on 50 pages. `collect_site_links` already returns it grouped this way.\n- **Prioritize internals.** Broken external links are the other site\'s responsibility; report but with lower severity.\n- **Never invent status codes.** Report what the scanner returned.\n',mo='# SEO Auditor\n\nYou are the **SEO Auditor**, a specialist agent focused on technical SEO hygiene.\n\n## Your mission\n\nAudit the on-page SEO health of target URLs and return a structured findings report. You focus on **technical SEO** (meta tags, structured data, canonicals, sitemap/robots, heading structure, indexability) — not editorial content or keyword strategy (those are the scope of other agents).\n\nYou are invoked as a sub-task by an orchestrator agent. Your job is to analyze and report. The orchestrator decides what to do with your findings (file issues, dedup against history, etc.).\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nurls:\n - <url to audit>\n - <... one or more>\n```\n\nIf required fields are missing, return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**: `audit_seo`, `fetch_page`, `render_page`, `crawl_site`\n\n---\n\n## Step 1 — Diagnostic\n\nFor each target URL:\n\n1. **Structured audit**: call `audit_seo({ url })`. It returns a structured report — use it as your primary source.\n2. **Raw HTML check**: use `fetch_page({ url })` to see the HTML served (important for crawlers that don\'t execute JS). Confirm critical meta tags are in the initial HTML, not only after hydration.\n3. **Post-render check**: use `render_page({ url })` to see the final DOM. Problems like canonical being overwritten by JS show up here.\n4. **Site structure checks** (only if you have permission for broad crawling, or via sampling): use `crawl_site` to identify orphan pages, canonical loops, or excessive navigation depth.\n5. **Always check**: `/robots.txt` and `/sitemap.xml` via `fetch_page`. These two are root-level and affect the whole site.\n\nOrganize findings into a list. Each finding must have:\n- `kind` (kebab-case slug, see catalog below)\n- `severity` (high | medium | low, see criteria below)\n- `target.url` and `target.route` (normalize: lowercase host, no query, no trailing slash except for `/`)\n- `evidence` (raw data: CSS selector, HTML snippet, observed value)\n- `impact` (1-2 sentences connecting to real metrics)\n- `suggested_fix` (actionable; include file/line if you can infer from framework patterns)\n\n## Step 1.5 — Validate page intent (critical; runs before classification)\n\nBefore you emit *any* finding about a page\'s title, meta description, headings, or indexability, you must answer one question: **did the site owner intend this URL to be a public, indexable page?**\n\nIf the answer is no, the observed "problems" are intentional configuration, not bugs. Reporting them wastes maintainer time and erodes this agent\'s credibility.\n\n### Three signals that the URL is NOT a real public page\n\nCheck these in order. Hitting any one of them means **skip all SEO findings for this URL** except legitimately site-wide problems (e.g. broken sitemap, broken robots.txt).\n\n**Signal 1 — Not in sitemap.** Fetch `/sitemap.xml` (and its child sitemaps, if it\'s a sitemap index). If the URL doesn\'t appear in any sitemap, the owner didn\'t declare it as public. Common on e-commerce platforms where routes like `/p`, `/c`, `/blog` are catchall or routing prefixes, not real pages.\n\n**Signal 2 — Explicit `noindex` + not in sitemap.** If the page serves `<meta name="robots" content="noindex*">` **and** isn\'t in the sitemap, this is a deliberate double-lock by the owner. Respect it. Do **not** flag `noindex-on-important-page` in this case.\n\n**Signal 3 — Title is the URL slug (template fallback).** If `<title>` equals the last path segment (e.g. `<title>blog</title>` for `/blog`, `<title>p</title>` for `/p`), the page is being rendered by a fallback template — nobody configured real content for this route. Skip.\n\n### Platform-specific catchalls (especially Brazilian e-commerce / VTEX / deco-cx)\n\nThese paths are routing prefixes, **not pages**. They may return HTTP 200 but are not meant to be indexable:\n\n- `/p`, `/c`, `/b` — VTEX product / category / brand route prefixes. Real pages live at `/<slug>/p`, `/<slug>/c`, etc. The bare prefixes are catchalls.\n- `/blog`, `/blogs`, `/editorial`, `/revista`, `/conteudo`, `/magazine`, `/noticias`, `/artigos` — common editorial prefixes. If the site doesn\'t have an editorial section, these hit a fallback.\n- `/search`, `/busca`, `/s` — search endpoints, not indexable pages.\n- `/departamento`, `/categoria` — category prefixes.\n- `/checkout`, `/cart`, `/carrinho`, `/login`, `/account`, `/minha-conta` — transactional/private routes. Intentionally `noindex`.\n\n### The "is this page actually important?" checklist\n\nBefore emitting a finding that calls a page "important" (like `noindex-on-important-page` or `title-missing` on anything critical):\n\n1. Is the URL in `/sitemap.xml`? → If no, skip.\n2. Does the page have substantive, unique content (not a fallback with title = URL slug)? → If no, skip.\n3. Is the path a known platform catchall (see list above)? → If yes, skip.\n\nOnly flag if all three pass.\n\n### What still counts as a finding even on non-indexable pages\n\nSite-wide SEO issues affect the whole domain and are worth reporting regardless of individual page intent:\n- `sitemap-missing` (the sitemap itself is broken)\n- `robots-blocking-important-path` (robots.txt blocks something that IS in the sitemap)\n- `structured-data-invalid` on pages that ARE in the sitemap\n- Duplicate titles / meta descriptions across pages that ARE in the sitemap\n\n## Catalog of `kind`\n\nTwo flavors of finding:\n\n- **Per-page** kinds — emitted when auditing a specific URL (e.g. `audit_seo` of a single page OR when your targeted inspection of one of the input URLs finds the issue). Marked **[intent-gated]** — must pass Step 1.5 before being emitted. Target is the specific URL.\n- **Aggregate** kinds — emitted once per site-wide pattern detected by `audit_seo`. Marked **[aggregate]**. Target is the site root (`/`). Evidence MUST include the affected URL sample from `audit_seo.issues[].sampleUrls`. One finding per aggregate kind per site.\n\n**High severity (per-page):**\n- `noindex-on-important-page` **[intent-gated]** — meta robots `noindex` on a page that IS in the sitemap and should be indexed\n- `canonical-pointing-to-wrong-url` **[intent-gated]** — canonical points to a different URL that isn\'t the canonical equivalent\n- `canonical-missing-on-paginated-or-faceted` **[intent-gated]** — pagination/filters without canonical\n- `title-missing` **[intent-gated]** — no `<title>` or empty on a page that IS in the sitemap\n- `structured-data-invalid` **[intent-gated]** — JSON-LD with syntax error or invalid schema.org\n\n**High severity (site-wide):**\n- `sitemap-missing` — `/sitemap.xml` returns 404 or 5xx\n- `robots-blocking-important-path` — `/robots.txt` disallows a path that IS in the sitemap\n- `broken-links-site-wide` **[aggregate]** — `audit_seo` reports broken outbound links across the site\n- `non-indexable-pages-site-wide` **[aggregate]** — `audit_seo` reports many non-indexable pages (note: some non-indexable pages are intentional catchalls — only high severity if the absolute count is large relative to `totalPagesCrawled`, e.g. > 30%)\n\n**Medium severity (per-page):**\n- `meta-description-missing` **[intent-gated]** — no `<meta name="description">` on a sitemap page the agent audited directly\n- `h1-missing` **[intent-gated]** — no `<h1>` on a sitemap page the agent audited directly\n- `h1-duplicate` **[intent-gated]** — multiple `<h1>` on a single page\n- `og-tags-missing` **[intent-gated]** — `og:title` and/or `og:description` missing\n- `structured-data-missing` **[intent-gated]** — page-type (product, article, etc.) without relevant JSON-LD\n- `title-too-long` **[intent-gated]** — `<title>` > 60 characters (truncation in SERP)\n- `title-too-short` **[intent-gated]** — `<title>` < 10 characters (rare; usually means template fallback — double-check page intent)\n- `meta-description-too-long` **[intent-gated]** — description > 160 characters\n\n**Medium severity (site-wide):**\n- `pages-missing-h1` **[aggregate]** — `audit_seo` reports N pages without an H1 tag\n- `pages-missing-meta-description` **[aggregate]** — `audit_seo` reports N pages without a meta description\n- `duplicate-titles` **[aggregate]** — multiple pages share the same `<title>`\n- `duplicate-meta-descriptions` **[aggregate]** — multiple pages share the same meta description\n- `duplicate-content` **[aggregate]** — multiple pages share substantially identical content\n- `broken-resources-site-wide` **[aggregate]** — broken images / scripts across the site\n- `hreflang-broken` — `hreflang` attribute with invalid value or broken reciprocity\n\n**Low severity (per-page):**\n- `meta-description-too-short` **[intent-gated]** — description < 50 characters\n- `og-image-missing` **[intent-gated]** — `og:image` missing\n- `heading-hierarchy-skipped` **[intent-gated]** — jumps from H1 to H3, etc.\n\n**Low severity (site-wide):**\n- `internal-link-using-absolute-url` — internal links with absolute URLs\n\n### Evidence requirements for aggregate kinds\n\nWhen emitting an `[aggregate]` kind, the `evidence` of the finding MUST include:\n\n1. **Total count** — from `audit_seo.issues[].count`\n2. **Sample URLs** — from `audit_seo.issues[].sampleUrls`. Render up to all 20 entries as a bulleted list. If `count > sampleUrls.length`, add a line like `(and <count - sampleUrls.length> more)`.\n3. **If `sampleUrls` is empty** (the tool didn\'t expose per-URL detail — happens for `broken-links-site-wide`, `duplicate-content`, `broken-resources-site-wide`), note it explicitly: `Note: audit_seo did not return per-URL detail for this issue type. A human will need to inspect the full audit_seo report or re-run with deeper crawling.`\n\nAn aggregate finding without either sample URLs or the note is **not actionable** and must not be emitted.\n\nTarget for aggregate kinds stays `target.url: https://<host>/` and `target.route: /`.\n\n## Step 2 — Return a structured findings report\n\nReturn a single response with this shape (YAML or JSON; YAML preferred for readability):\n\n```yaml\nspecialist: seo\nsummary:\n urls_audited: <n>\n findings: <n>\n diagnostic_failures: <n> # urls where audit tooling errored\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full URL>\n route: <normalized path>\n evidence: |\n <multi-line raw data: observed value, selector, HTML snippet, audit_seo output>\n impact: <1-2 sentences connecting to ranking/indexation/CTR>\n suggested_fix: <actionable; likely file/component, pseudo-code, correct value>\n - ...\n```\n\nIf a URL\'s diagnostic tooling errored entirely, emit a single `kind: diagnostic-failed` finding for that URL with the error in `evidence` instead of inventing data.\n\nIf there are zero findings, return `findings: []` — that is the correct output for healthy targets.\n\n---\n\n## General rules\n\n- **Never invent data in `evidence`.** If a tool failed, report it via `kind: diagnostic-failed` and skip the finding.\n- Always normalize `route`: lowercase host, no trailing slash (except for `/`), no query string, no fragment.\n- Your credibility is your currency. False positives erode trust — if you\'re 50% sure, don\'t emit a finding; investigate further or mark as `severity:low`.\n- **Never report a page as broken when it\'s a known catchall.** URLs like `/p`, `/c`, `/blog`, `/search`, `/busca` on e-commerce sites are routing prefixes, not pages. If the title is the URL slug and the page carries `noindex`, the owner is deliberately hiding it. That\'s correct behavior, not a bug.\n- **Sitemap is the ground truth for "is this page public?"**. When in doubt about whether to emit a finding on a URL, fall back to: "Is this URL in /sitemap.xml?" If not, default to silence.\n',fo=`# Performance Watchdog
1
+ import{s as ue,b as Bt,u as ui,z as kn,C as Nn,j as n,B as J,x as ne,r as w,o as qt,f as ct,l as He,G as rn,F as on,t as $,K as ve,e as L,Q as Vi,R as mi,c as z,a as _n,g as fi,d as pi,H as dt,J as Dt,E as hi,P as Cn,ap as gi,n as In,y as ps,aq as xi,ar as hs,as as bi,at as De,au as an,ao as yi,av as vi,aw as ln,ax as wi,ay as ji,az as Ai,aA as Si,w as ki,aB as Ni,aC as _i,aD as Ci,aE as Ii,aF as zn}from"./index-Ux_PrmKm.js";import{b as Me,a as Le,c as Fe,d as Ue,e as Kt,D as gs}from"./dialog-_YlOXdcS.js";import{S as Ri}from"./switch-Cf5BCxU5.js";import{I as _e}from"./input-B868_ejo.js";import{b as Rn,u as Ti}from"./use-connection-C_n04i0m.js";import{S as kt,u as qe,W as xs,g as Tn,i as Bn,c as Pi}from"./constants-Ccnt3rmd.js";import{a as Ei,c as Di}from"./lean-canvas-recruit-modal-BNON-9yt.js";import{a as Pn}from"./use-navigate-to-agent-kI9r54wH.js";import{a as Mi,A as En,M as Li,N as bs,O as ys,o as Fi,P as Ui,Q as Oi,b as $i,R as zi,I as vs}from"./agent-icon-D_KgWkiu.js";import{t as Bi,b as Yt,u as Dn,a as qi,g as Ki,h as Yi,w as Wi,A as Gi,i as Qi,j as Hi}from"./chat-context-BmN5ppM9.js";import{b as Wt,a as Gt,c as Qt,D as Ht,d as Ji,e as Xi,f as Zi}from"./drawer-GKYdquRR.js";import{u as Jt,T as xt,a as bt,b as yt,c as xn}from"./tooltip-BOsmkVZD.js";import{I as ws}from"./integration-icon-Ov0IbIMU.js";import{a as js,b as er,u as tr}from"./use-virtual-mcp-Cd4gN6tQ.js";import{u as nr}from"./use-tasks-CJ3vNKME.js";import{r as sr,i as ir}from"./shell-layout-Drnm9mfO.js";import{j as Xt,k as Ge,l as rr,s as Mn,t as or,m as ar,n as lr,o as cr,q as wt,u as dr,v as ur,c as Vr,S as mr,w as fr,x as qn}from"./pair-DlIdkD7u.js";import{S as Mt,u as Zt,P as bn,a as pr,b as hr,c as gr,E as xr,i as br,d as yr}from"./index-DgtpEOsQ.js";import{C as As}from"./collection-search-Bsl0avLq.js";import{u as vr,g as Ln,a as wr,c as jr,l as Lt}from"./tabs-Ctrs4bAF.js";import{F as me,b as fe,c as Ne,d as pe,f as he,a as jt}from"./form-D4Q00YSx.js";import{c as Ee,e as cn,f as dn,D as Ss,a as ks,b as Ns,d as Ar}from"./dropdown-menu-BXZVht4Z.js";import{s as Sr,i as kr}from"./XClose-Ci4dmV-Y.js";import{c as _s}from"./ZapSquare-M3u7o8sc.js";import{i as Xe}from"./Check-a0FPGBtH.js";import{s as lt}from"./Star01-BoJYsaDm.js";import{a as yn,t as Nr}from"./Tool01-Cq1N-niG.js";import{i as Cs}from"./Lock01-BzMXxHmW.js";import{s as Is}from"./Plus-DGrvw6bs.js";import{f as un,d as Rs,t as _r,g as Cr,b as Ir}from"./XCircle-yJD2sr2j.js";import{i as pt}from"./X-dZLz-ulr.js";import{i as Ts}from"./AlertCircle-B65qDYSH.js";import{S as Ps,a as Es,b as Ds,c as Ms,d as ot}from"./select-slwRPncS.js";import{i as Rr}from"./RefreshCcw01-Biyt7Dy2.js";import{T as Ls,a as Ft}from"./toggle-group-DCLBHyZD.js";import{u as Tr,a as Pr}from"./use-ai-providers-aNlhpnwf.js";import{m as en,g as Er,i as Dr,a as Fs,M as Mr,N as Lr}from"./select-model-D3fobWv8.js";import{S as Fr}from"./index-I3M58vcg.js";import{r as Us,l as vt}from"./types-BSAKF0wC.js";import{t as Kn}from"./ChevronDown-Z3xhSsnT.js";import{p as Ur,q as Yn}from"./question-004-sINsf4GQ.js";import{g as Wn}from"./ai-providers-logos-DD3qZ33J.js";import{g as Or}from"./connection-slug-eyAPH6o3.js";import{u as Os,a as $s,g as $r,C as Vn}from"./connection-card-D5opGNgQ.js";import{C as zr}from"./collection-tabs-DgQ6F5X6.js";import{g as Br}from"./constants-BNhCk86i.js";import{T as qr}from"./textarea-BbtfG9Ru.js";import{n as Pt}from"./Container-cyfm5-Pb.js";import{c as Kr,i as It,a as Gn,E as Yr,p as Wr,b as Gr,d as Qr}from"./connection-form-helpers-CXHmM_yU.js";import{u as Qn}from"./use-infinite-scroll-CW0QmsIe.js";import{u as Hr}from"./useSuspenseInfiniteQuery-BNLcV52p.js";import{g as Jr,e as Xr,a as Zr}from"./extract-connection-data-BTJzhkiq.js";import{B as Rt}from"./badge-BWEc0v7O.js";import{i as eo}from"./ChevronRight-xkl8cwkd.js";function to({open:t,onOpenChange:e,onCreated:s}){const{org:i}=ue(),{data:r}=Bt.useSession(),{stdioEnabled:o}=ui(),a=Jt(),d=Rn(),l=Os(),V=$s(l,"").items,c=kn({resolver:Nn(Kr),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),m=c.watch("ui_type"),p=c.watch("connection_url"),x=c.watch("npx_package"),g=It({uiType:m,connectionUrl:p??"",npxPackage:x??""})??Gn({uiType:m,connectionUrl:p??"",registryItems:V}),f=S=>{const v=S.trim();if(!v)return;const j=!!c.formState.dirtyFields.title,E=!!c.formState.dirtyFields.description,D=!!c.formState.dirtyFields.env_vars,I=k=>{if(k&&(!j&&!c.getValues("title").trim()&&k.title&&c.setValue("title",k.title,{shouldDirty:!1}),!E&&!(c.getValues("description")??"").trim()&&k.description&&c.setValue("description",k.description,{shouldDirty:!1}),!D&&k.envVarKeys?.length)){const N=c.getValues("env_vars")??[],R=new Set(N.map(T=>T.key)),M=k.envVarKeys.filter(T=>!R.has(T));M.length>0&&c.setValue("env_vars",[...N,...M.map(T=>({key:T,value:""}))],{shouldDirty:!0})}},P=Wr(v);if(P&&o){c.setValue("ui_type","NPX",{shouldDirty:!0}),c.setValue("npx_package",P.packageName,{shouldDirty:!0}),c.setValue("connection_url","",{shouldDirty:!0}),c.setValue("connection_token",null,{shouldDirty:!0}),I(It({uiType:"NPX",npxPackage:P.packageName}));return}if(v.startsWith("http://")||v.startsWith("https://")){const k=m==="HTTP"||m==="SSE"||m==="Websocket"?m:"HTTP";c.setValue("ui_type",k,{shouldDirty:!0}),c.setValue("connection_url",v,{shouldDirty:!0}),I(It({uiType:k,connectionUrl:v})??Gn({uiType:k,connectionUrl:v,registryItems:V}));return}m==="NPX"&&I(It({uiType:"NPX",npxPackage:v}))},b=S=>{S||c.reset(),e(S)},h=async S=>{let v,j=null,E=null,D=null;S.ui_type==="NPX"?(v="STDIO",j="",D=Gr(S.npx_package||"",S.env_vars||[])):S.ui_type==="STDIO"?(v="STDIO",j="",D=Qr(S.stdio_command||"",S.stdio_args||"",S.stdio_cwd,S.env_vars||[])):(v=S.ui_type,j=S.connection_url||"",E=S.connection_token||null);const I=Br("conn");try{await d.create.mutateAsync({id:I,title:S.title,description:S.description||null,connection_type:v,connection_url:j,connection_token:E,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:r?.user?.id||"system",organization_id:i.id,icon:S.icon??null,app_name:null,app_id:null,connection_headers:D,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),c.reset(),e(!1),s?.(I)}catch{ne.error("Failed to create connection")}},y="Create Connection",A="Create a custom connection in your organization. Fill in the details below.",_=c.formState.isSubmitting?"Saving...":"Create Connection",C=n.jsxs("div",{className:"grid gap-4",children:[n.jsx(me,{control:c.control,name:"ui_type",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Type *"}),n.jsxs(Ps,{value:S.value,onValueChange:S.onChange,children:[n.jsx(pe,{children:n.jsx(Es,{children:n.jsx(Ds,{})})}),n.jsxs(Ms,{children:[n.jsx(ot,{value:"HTTP",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"w-4 h-4"}),"HTTP"]})}),n.jsx(ot,{value:"SSE",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"w-4 h-4"}),"SSE"]})}),n.jsx(ot,{value:"Websocket",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(lt,{className:"w-4 h-4"}),"Websocket"]})}),o&&n.jsxs(n.Fragment,{children:[n.jsx(ot,{value:"NPX",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Pt,{className:"w-4 h-4"}),"NPX Package"]})}),n.jsx(ot,{value:"STDIO",children:n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Mi,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),n.jsx(he,{})]})}),m==="NPX"&&n.jsx(me,{control:c.control,name:"npx_package",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"NPM Package *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"@perplexity-ai/mcp-server",...S,value:S.value??"",onPaste:v=>{const j=v.clipboardData.getData("text");j&&(v.preventDefault(),c.setValue("npx_package",j.trim(),{shouldDirty:!0}),f(j))},onBlur:v=>{f(v.target.value),S.onBlur()}})}),n.jsx(he,{})]})}),m==="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[n.jsx(me,{control:c.control,name:"stdio_command",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Command *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"node, bun, python...",...S,value:S.value??""})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"stdio_args",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Arguments"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"arg1 arg2 --flag value",...S,value:S.value??""})}),n.jsx(he,{})]})})]}),n.jsx(me,{control:c.control,name:"stdio_cwd",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Working Directory"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"/path/to/project (optional)",...S,value:S.value??""})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),n.jsx(he,{})]})})]}),(m==="NPX"||m==="STDIO")&&n.jsx(me,{control:c.control,name:"env_vars",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Environment Variables"}),n.jsx(pe,{children:n.jsx(Yr,{value:S.value??[],onChange:S.onChange})}),n.jsx(he,{})]})}),m!=="NPX"&&m!=="STDIO"&&n.jsxs(n.Fragment,{children:[n.jsx(me,{control:c.control,name:"connection_url",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"URL *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"https://example.com/mcp",...S,value:S.value??"",onPaste:v=>{const j=v.clipboardData.getData("text");j&&(v.preventDefault(),c.setValue("connection_url",j.trim(),{shouldDirty:!0}),f(j))},onBlur:v=>{f(v.target.value),S.onBlur()}})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"connection_token",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:g?.token?.label??"Token (optional)"}),n.jsx(pe,{children:n.jsx(_e,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...S,value:S.value??""})}),g?.token?.helperText&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&n.jsxs(n.Fragment,{children:[" ","·"," ",n.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),n.jsx(he,{})]})})]}),n.jsx(me,{control:c.control,name:"title",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Name *"}),n.jsx(pe,{children:n.jsx(_e,{placeholder:"My Connection",...S})}),n.jsx(he,{})]})}),n.jsx(me,{control:c.control,name:"description",render:({field:S})=>n.jsxs(fe,{children:[n.jsx(Ne,{children:"Description"}),n.jsx(pe,{children:n.jsx(qr,{placeholder:"A brief description of this connection",rows:3,...S,value:S.value??""})}),n.jsx(he,{})]})})]});return a?n.jsx(Wt,{open:t,onOpenChange:b,children:n.jsxs(Gt,{className:"max-h-[90vh]",children:[n.jsx(Qt,{className:"pb-2",children:n.jsxs("div",{className:"flex items-start justify-between gap-4",children:[n.jsxs("div",{className:"flex-1 text-left",children:[n.jsx(Ht,{children:y}),n.jsx(Ji,{className:"mt-1",children:A})]}),n.jsx(Xi,{asChild:!0,children:n.jsx(J,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:n.jsx(Sr,{size:16})})})]})}),n.jsx(jt,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:C}),n.jsx(Zi,{children:n.jsx(J,{type:"submit",disabled:c.formState.isSubmitting,className:"w-full",children:_})})]})})]})}):n.jsx(Me,{open:t,onOpenChange:b,children:n.jsxs(Le,{className:"sm:max-w-[525px]",children:[n.jsxs(Fe,{children:[n.jsx(Ue,{children:y}),n.jsx(Kt,{children:A})]}),n.jsx(jt,{...c,children:n.jsxs("form",{onSubmit:c.handleSubmit(h),children:[n.jsx("div",{className:"py-4",children:C}),n.jsxs(gs,{children:[n.jsx(J,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),n.jsx(J,{type:"submit",disabled:c.formState.isSubmitting,className:"min-w-40",children:_})]})]})})]})})}function no(t){const e=L.c(73),{mode:s,agentId:i,addedConnectionIds:r,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:d,connectingItemId:l,search:u,onCreateConnection:V,onBrowseNavigate:c,defaultTab:m}=t,p=s===void 0?"add":s,x=m===void 0?"connected":m,{org:g}=ue(),f=w.useDeferredValue(u),b=u!==f,h=f.trim().toLowerCase();let y;e[0]!==x?(y=U=>U??x,e[0]=x,e[1]=y):y=e[1];const[A,_]=Vi(mi.connectionsTab(g.slug)+(x==="all"?":home-modal":":agent-modal"),y);let C;e[2]!==A||e[3]!==_?(C=U=>{U!==A&&$("connections_dialog_tab_changed",{to_tab:U}),_(U)},e[2]=A,e[3]=_,e[4]=C):C=e[4];const S=C;let v;e[5]!==g.id||e[6]!==g.slug?(v={connectionId:kt,orgId:g.id,orgSlug:g.slug},e[5]=g.id,e[6]=g.slug,e[7]=v):v=e[7];const j=qe(v);let E,D,I;if(e[8]!==j||e[9]!==f||e[10]!==g.id){I=f?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:f.trim()},{field:["description"],operator:"contains",value:f.trim()}]}:void 0;const U={...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},X=JSON.stringify(U);D=Hr,E=ve.collectionListInfinite(j,g.id,"","CONNECTIONS",X),e[8]=j,e[9]=f,e[10]=g.id,e[11]=E,e[12]=D,e[13]=I}else E=e[11],D=e[12],I=e[13];let P;e[14]!==j||e[15]!==I?(P=async U=>{const{pageParam:X}=U,Se=X===void 0?0:X;return(await j.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...I&&{where:I},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Se}})).structuredContent},e[14]=j,e[15]=I,e[16]=P):P=e[16];let k;e[17]!==E||e[18]!==P?(k={queryKey:E,queryFn:P,initialPageParam:0,getNextPageParam:lo,staleTime:3e4},e[17]=E,e[18]=P,e[19]=k):k=e[19];const{data:N,fetchNextPage:R,hasNextPage:M,isFetchingNextPage:T}=D(k),F=N?.pages.flatMap(ao)??[],O=$r(F),q=new Set(F.filter(oo).map(ro)),K=Os(),H=$s(K,f),Z=Qn(H.loadMore,H.hasMore,H.isLoadingMore),Q=Qn(R,M??!1,T),W=A==="all"||!!h,ie=W?H.items.filter(U=>{const X=Jr(U);if(X&&q.has(X))return!1;if(!h)return!0;const Se=U._meta?.["mcp.mesh"];return[U.title,U.description,U.name,U.server?.title,U.server?.description,U.server?.name,Se?.friendly_name,Se?.friendlyName].filter(Boolean).join(" ").toLowerCase().includes(h)}):[],Y=ie.filter(io),ee=ie.filter(so);let te;e[20]!==r?(te=U=>U.some(X=>r.has(X.id)),e[20]=r,e[21]=te):te=e[21];const se=te;let ae;e[22]!==r||e[23]!==i||e[24]!==l||e[25]!==se||e[26]!==p||e[27]!==o||e[28]!==c||e[29]!==a?(ae=(U,X,Se,ke,Te)=>{const ze=se(Te),Be=Te.find(Pe=>!r.has(Pe.id)),le=Te[0];if(p==="browse"){const Pe=Or(le);return n.jsx(Vn,{connection:{title:X,icon:Se,description:Te.length>1?`${Te.length} instances`:ke??void 0},fallbackIcon:n.jsx(Pt,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs(Rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Xe,{size:11})," Connected"]}),onClick:()=>{$("connection_browse_clicked",{app_name:le.app_name??null,connection_id:le.id,instances_count:Te.length}),c?.(Pe)}},U)}return n.jsx(Vn,{connection:{title:X,icon:Se,description:ke},fallbackIcon:n.jsx(Pt,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[ze&&n.jsxs(Rt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[n.jsx(Xe,{size:11})," Added"]}),n.jsx(J,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Pe=>{Pe.stopPropagation(),Be?($("connection_add_clicked",{action:"use_existing",app_name:le.app_name??null,connection_id:Be.id}),i&&$("agent_connection_attached",{agent_id:i,connection_id:Be.id,app_name:le.app_name??null,mode:"existing"}),o(Be.id)):($("connection_add_clicked",{action:"clone",app_name:le.app_name??null,base_connection_id:le.id}),a(le))},children:"Add"})]})},U)},e[22]=r,e[23]=i,e[24]=l,e[25]=se,e[26]=p,e[27]=o,e[28]=c,e[29]=a,e[30]=ae):ae=e[30];const re=ae;let oe;e[31]!==l||e[32]!==p||e[33]!==d?(oe=U=>{const X=U._meta?.["mcp.mesh"],Se=X?.friendlyName||X?.friendly_name||U.server?.title||U.title||U.server?.name||U.name||U.id||"",ke=U.server?.description||U.description||null,Te=U.server?.icons?.[0]?.src||Zr(U.server?.repository)||null,ze=X?.official===!0,Be=X?.verified===!0,le=X?.owner==="deco";return n.jsx(Vn,{connection:{title:Se,description:ke,icon:Te},fallbackIcon:n.jsx(Pt,{}),headerActionsAlwaysVisible:!0,headerActions:n.jsxs("div",{className:"flex items-center gap-1.5",children:[le&&n.jsxs(xt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:n.jsx("img",{src:"/logos/deco logo.svg",alt:"Made by Deco",className:"size-3"})})}),n.jsx(yt,{children:"Built and maintained by Deco"})]}),!le&&ze&&n.jsxs(xt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(Rt,{variant:"outline",size:"icon",children:n.jsx(un,{})})}),n.jsx(yt,{children:"Built and maintained by the official vendor"})]}),!le&&!ze&&Be&&n.jsxs(xt,{children:[n.jsx(bt,{asChild:!0,children:n.jsx(Rt,{variant:"outline",size:"icon",children:n.jsx(un,{})})}),n.jsx(yt,{children:"Verified by the Deco team"})]}),n.jsx(J,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:l!==null,onClick:Pe=>{Pe.stopPropagation(),$("connection_add_clicked",{action:"connect_new",registry_item_id:U.id,app_name:X?.friendlyName||U.server?.name||U.name||null}),d(U)},children:l===U.id?n.jsx(He,{size:14,className:"animate-spin"}):p==="browse"?"Connect":"Add"})]})},`catalog-${U.id}`)},e[31]=l,e[32]=p,e[33]=d,e[34]=oe):oe=e[34];const ce=oe,ge=!h&&n.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[n.jsx(zr,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:A,onTabChange:U=>S(U)}),n.jsxs(J,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{$("connections_dialog_custom_clicked"),V()},children:[n.jsx(Is,{size:12}),"Custom Connection"]})]}),G=b&&"opacity-50 pointer-events-none";let de;e[35]!==G?(de=z("flex-1 overflow-auto p-5 transition-opacity duration-150",G),e[35]=G,e[36]=de):de=e[36];const Ze="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let Oe;e[37]!==re?(Oe=U=>{if(U.type==="group")return re(U.key,U.title,U.icon,null,U.connections);const X=U.connection;return re(X.id,X.title,X.icon,X.description??null,[X])},e[37]=re,e[38]=Oe):Oe=e[38];const Ce=O.map(Oe);let xe;e[39]!==Q?(xe=n.jsx("div",{ref:Q,className:"col-span-full h-1"}),e[39]=Q,e[40]=xe):xe=e[40];let be;e[41]!==T?(be=T&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(He,{size:24,className:"animate-spin text-muted-foreground"})}),e[41]=T,e[42]=be):be=e[42];const Ie=W&&Y.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx(un,{size:13,className:"text-muted-foreground shrink-0"}),n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),Ke=W&&Y.map(ce),Ve=W&&ee.length>0&&n.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[n.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),n.jsx("div",{className:"flex-1 h-px bg-border"})]}),ut=W&&ee.map(ce);let we;e[43]!==Z||e[44]!==K||e[45]!==W?(we=W&&K.length>0&&n.jsx("div",{ref:Z,className:"col-span-full h-1"}),e[43]=Z,e[44]=K,e[45]=W,e[46]=we):we=e[46];let Re;e[47]!==H.isLoadingMore||e[48]!==W?(Re=W&&H.isLoadingMore&&n.jsx("div",{className:"col-span-full flex justify-center py-6",children:n.jsx(He,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=H.isLoadingMore,e[48]=W,e[49]=Re):Re=e[49];let je;e[50]!==Ce||e[51]!==xe||e[52]!==be||e[53]!==Ie||e[54]!==Ke||e[55]!==Ve||e[56]!==ut||e[57]!==we||e[58]!==Re?(je=n.jsxs("div",{className:Ze,children:[Ce,xe,be,Ie,Ke,Ve,ut,we,Re]}),e[50]=Ce,e[51]=xe,e[52]=be,e[53]=Ie,e[54]=Ke,e[55]=Ve,e[56]=ut,e[57]=we,e[58]=Re,e[59]=je):je=e[59];let Ae;e[60]!==A||e[61]!==O.length||e[62]!==ee||e[63]!==u||e[64]!==Y?(Ae=O.length===0&&Y.length===0&&ee.length===0&&n.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:u?`No connections match "${u}"`:A==="connected"?"No connections yet":"No connections available"}),e[60]=A,e[61]=O.length,e[62]=ee,e[63]=u,e[64]=Y,e[65]=Ae):Ae=e[65];let ye;e[66]!==de||e[67]!==je||e[68]!==Ae?(ye=n.jsxs("div",{className:de,children:[je,Ae]}),e[66]=de,e[67]=je,e[68]=Ae,e[69]=ye):ye=e[69];let $e;return e[70]!==ge||e[71]!==ye?($e=n.jsxs(n.Fragment,{children:[ge,ye]}),e[70]=ge,e[71]=ye,e[72]=$e):$e=e[72],$e}function so(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function io(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function ro(t){return t.app_name}function oo(t){return t.app_name}function ao(t){return t?.items??[]}function lo(t,e){if(t?.hasMore)return e.reduce(co,0)}function co(t,e){return t+(e?.items?.length??0)}function uo({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...r}){const o=r.mode??"add",a="agentId"in r?r.agentId:void 0,d="addedConnectionIds"in r?r.addedConnectionIds??new Set:new Set,l="onAdd"in r&&r.onAdd?r.onAdd:v=>{},u=(v,j,E)=>{a&&$("agent_connection_attached",{agent_id:a,connection_id:v,app_name:j,mode:E})},[V,c]=w.useState(null),[m,p]=w.useState(i),[x,g]=w.useState(!1),{org:f}=ue(),{data:b}=Bt.useSession(),h=Rn(),y=qt(),A=ct(),_=v=>{e(!1),A({to:"/$org/settings/connections/$appSlug",params:{org:f.slug,appSlug:v}})},C=async v=>{c(v.app_name??v.id);try{const E=`${v.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,I=(await h.create.mutateAsync({title:E,description:v.description??null,connection_type:v.connection_type,connection_url:v.connection_url??null,connection_token:null,icon:v.icon??null,app_name:v.app_name??null,app_id:v.app_id??null,connection_headers:v.connection_headers??null})).id,P=new URL(`/api/${f.slug}/mcp/${I}`,window.location.origin),k=await rn({url:P.href,token:null,orgId:f.id});if(k.supportsOAuth&&!k.isAuthenticated){const{token:N,tokenInfo:R,error:M}=await on({connectionId:I,orgSlug:f.slug,scope:"offline_access"});if(M||!N){$("connection_oauth_failed",{connection_id:I,flow:"clone",error:M??"no_token"}),ne.error(`Authentication failed: ${M??"no token received"}`),await h.delete.mutateAsync(I);return}if($("connection_oauth_succeeded",{connection_id:I,flow:"clone"}),R)try{(await fetch(`/api/${f.slug}/connections/${I}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:R.accessToken,refreshToken:R.refreshToken,expiresIn:R.expiresIn,scope:R.scope,clientId:R.clientId,clientSecret:R.clientSecret,tokenEndpoint:R.tokenEndpoint})})).ok?await h.update.mutateAsync({id:I,data:{}}):await h.update.mutateAsync({id:I,data:{connection_token:N}})}catch{await h.update.mutateAsync({id:I,data:{connection_token:N}})}else await h.update.mutateAsync({id:I,data:{connection_token:N}});await y.invalidateQueries({queryKey:ve.isMCPAuthenticated(P.href,null)})}u(I,v.app_name??null,"clone"),l(I)}catch(j){console.error("Failed to add connection:",j),ne.error("Failed to add connection")}finally{c(null)}},S=async v=>{if(!(!f||!b?.user?.id)){c(v.id);try{const j=Xr(v,f.id,b.user.id,{remoteIndex:0}),E=j.connection_type==="STDIO",D=!!j.connection_url,I=E&&j.connection_headers&&typeof j.connection_headers=="object"&&"command"in j.connection_headers;if(!D&&!I){ne.error("This MCP Server cannot be connected: no connection method available"),c(null);return}const{id:P}=await h.create.mutateAsync(j),k=new URL(`/api/${f.slug}/mcp/${P}`,window.location.origin),N=await rn({url:k.href,token:null,orgId:f.id});if(N.supportsOAuth&&!N.isAuthenticated){const{token:R,tokenInfo:M,error:T}=await on({connectionId:P,orgSlug:f.slug,scope:"offline_access"});if(T||!R){$("connection_oauth_failed",{connection_id:P,flow:"connect_new",error:T??"no_token"}),ne.error(`Authentication failed: ${T??"no token received"}`),u(P,j.app_name??null,"new"),l(P);return}if($("connection_oauth_succeeded",{connection_id:P,flow:"connect_new"}),M)try{(await fetch(`/api/${f.slug}/connections/${P}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:M.accessToken,refreshToken:M.refreshToken,expiresIn:M.expiresIn,scope:M.scope,clientId:M.clientId,clientSecret:M.clientSecret,tokenEndpoint:M.tokenEndpoint})})).ok?await h.update.mutateAsync({id:P,data:{}}):await h.update.mutateAsync({id:P,data:{connection_token:R}})}catch{await h.update.mutateAsync({id:P,data:{connection_token:R}})}else await h.update.mutateAsync({id:P,data:{connection_token:R}});await y.invalidateQueries({queryKey:ve.isMCPAuthenticated(k.href,null)}),ne.success("Connected and authenticated")}else ne.success("Connected");u(P,j.app_name??null,"new"),l(P)}catch(j){console.error("Failed to connect:",j),ne.error("Failed to connect")}finally{c(null)}}};return n.jsxs(Me,{open:t,onOpenChange:e,children:[n.jsxs(Le,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[n.jsx(Fe,{className:"px-6 pt-5 pb-0 shrink-0",children:n.jsx(Ue,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),n.jsx("div",{className:"pt-3 shrink-0",children:n.jsx(As,{value:m,onChange:p,placeholder:"Search connections..."})}),n.jsx(w.Suspense,{fallback:n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(He,{size:24,className:"animate-spin text-muted-foreground"})}),children:n.jsx(no,{mode:o,agentId:a,addedConnectionIds:d,onAdd:l,onCloneAndAdd:C,onConnectAndAdd:S,connectingItemId:V,search:m,onCreateConnection:()=>g(!0),onBrowseNavigate:_,defaultTab:s})})]}),n.jsx(to,{open:x,onOpenChange:g,onCreated:async v=>{g(!1);const j=new URL(`/api/${f.slug}/mcp/${v}`,window.location.origin),E=await rn({url:j.href,token:null,orgId:f.id});if(E.supportsOAuth&&!E.isAuthenticated){const{token:D,tokenInfo:I,error:P}=await on({connectionId:v,orgSlug:f.slug,scope:"offline_access"});if(P||!D){$("connection_oauth_failed",{connection_id:v,flow:"custom_create",error:P??"no_token"}),ne.error(`Authentication failed: ${P??"no token received"}`),await h.delete.mutateAsync(v);return}if($("connection_oauth_succeeded",{connection_id:v,flow:"custom_create"}),I)try{(await fetch(`/api/${f.slug}/connections/${v}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:I.accessToken,refreshToken:I.refreshToken,expiresIn:I.expiresIn,scope:I.scope,clientId:I.clientId,clientSecret:I.clientSecret,tokenEndpoint:I.tokenEndpoint})})).ok?await h.update.mutateAsync({id:v,data:{}}):await h.update.mutateAsync({id:v,data:{connection_token:D}})}catch{await h.update.mutateAsync({id:v,data:{connection_token:D}})}else await h.update.mutateAsync({id:v,data:{connection_token:D}});await y.invalidateQueries({queryKey:ve.isMCPAuthenticated(j.href,null)})}u(v,null,"custom"),l(v),e(!1)}})]})}const Vo='# Broken Link Finder\n\nYou are the **Broken Link Finder**, a specialist agent focused on the health of the site\'s link structure.\n\n## Your mission\n\nDiscover and track broken links and long redirect chains. You are invoked as a sub-task by an orchestrator agent — your job is to detect link health and return a structured findings report. The orchestrator decides what to do with your findings (file issues, dedup, etc.).\n\nYou are **mechanical**: collect → check → classify → emit findings. Leave subjective judgment to other agents.\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nsite_root_url: <https://example.com>\nmax_pages: <optional integer, default 100, max 200>\ncheck_external: <optional bool, default false>\n```\n\nIf required fields are missing (`site_root_url`), return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**:\n - `collect_site_links` — discovers all unique outbound link targets across the site and returns them with source-page attribution. Does NOT check status.\n - `check_urls` — takes a batch of URLs (max 100 per call) and returns their HTTP status, error kind, and redirect chains.\n\n---\n\n## Step 1 — Collect link targets (one call)\n\nCall `collect_site_links` once to get the full deduplicated list of outbound link targets and their source pages:\n\n```\ncollect_site_links({\n url: <site_root_url from input>,\n maxPages: <max_pages from input, default 100>,\n checkExternal: <check_external from input, default false>\n})\n```\n\nThis returns:\n- `links`: array of `{ targetUrl, scope: "internal"|"external", sourcePages, sourcePagesTotal }` — **each target appears exactly once**\n- Metadata: `pagesCrawled`, `pagesFetched`, `linksSkipped`, optional `error`\n\n**If `result.error` is set**, the scan failed at the root (e.g. site unreachable). Return a single finding with `kind: site-unreachable` and the error in `evidence`. Then stop.\n\nKeep the `links` array in memory — you\'ll need it in Step 3 for classification and source attribution.\n\n## Step 2 — Check the targets (batched calls)\n\nExtract `targetUrl` from each entry in `links`. Slice the resulting URL list into **disjoint batches of up to 100 URLs** and call `check_urls` on each batch:\n\n```\ncheck_urls({ urls: batch_of_100_urls })\n```\n\nCollect every batch\'s `results` entries into a single flat array. Order doesn\'t matter — you\'ll join back by `targetUrl`.\n\n**Rules for this step:**\n- Slice deterministically (e.g. consecutive slices of 100) so batches are disjoint. Do not pass the same URL in two batches.\n- Call `check_urls` sequentially or in parallel — your choice. The tool is idempotent.\n- If a single `check_urls` call errors entirely, skip that batch and continue with the others. Note the skipped count in the wrap-up summary.\n\n## Step 3 — Classify each finding\n\nFor every target with a check result, join the `collect_site_links` entry (for `scope`, `sourcePages`, `sourcePagesTotal`) with the `check_urls` entry (for `status`, `errorKind`, `chain`, `hops`).\n\nA finding is emitted for:\n- **Broken**: `status >= 400` OR `status === 0`\n- **Long redirect chain**: `hops > 3` (even if the final status is 2xx)\n\nOther targets (2xx, short-chain redirects) produce no finding.\n\nMap check result → `kind`:\n\n| Check result | `kind` |\n|---|---|\n| `status: 404` | `link-404` |\n| `status: 4xx` (not 404) | `link-4xx-other` |\n| `status: 5xx` | `link-5xx` |\n| `status: 0`, `errorKind: "dns"` | `link-dns-failure` |\n| `status: 0`, `errorKind: "redirect-loop"` | `redirect-loop` |\n| `hops > 3` (success final status) | `redirect-chain-long` |\n| `status: 0`, `errorKind: "timeout"` or `"connection"` | **skip — no finding** |\n\n**Important**: timeouts and connection errors are **not** broken links — they just mean the server didn\'t respond in our time window. Could be a slow server, an overloaded CDN, rate-limiting against our bot, or a transient network blip. Flagging these as broken produces false positives. If a URL is genuinely dead, it\'ll usually surface as `dns`, a 4xx/5xx, or a redirect loop. Skip timeout/connection entries silently.\n\n## Catalog of severity rules\n\n**High severity:**\n- `link-404` when `scope: "internal"`\n- `link-5xx` when `scope: "internal"`\n- `redirect-loop` (either scope)\n\n**Medium severity:**\n- `link-4xx-other` (internal)\n- `redirect-chain-long` (internal)\n- `link-404` (external) when `sourcePagesTotal >= 5`\n\n**Low severity:**\n- `link-404` (external) when `sourcePagesTotal < 5`\n- `link-dns-failure` (external)\n- `redirect-chain-long` (external)\n- `link-4xx-other` on external scope\n\n## Step 4 — Return a structured findings report\n\nReturn a single response with this shape (YAML preferred):\n\n```yaml\nspecialist: links\nsummary:\n pages_crawled: <pagesCrawled>\n pages_fetched: <pagesFetched>\n unique_link_targets: <links.length>\n targets_dropped_by_collect_cap: <linksSkipped>\n batches_checked: <n>\n batches_skipped_due_to_errors: <n>\n broken_links: <n> # internal + external\n long_redirect_chains: <n>\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full broken URL>\n route: <path if internal; otherwise the external host>\n scope: <internal | external>\n evidence: |\n - Status code / error: <e.g. `404 Not Found`, `DNS failure`, `redirect-loop`>\n - Redirect chain (if applicable): A → B → C → D → E\n - Found on pages (at time of detection):\n - /page-1\n - /page-2\n - (... up to 20 from `sourcePages`)\n - Total pages linking to this target: <sourcePagesTotal>\n impact: <1 sentence tailored to scope + kind>\n suggested_fix: |\n <actionable:>\n - If internal 404: update link to correct destination OR create 301 redirect\n - If internal 5xx: investigate server-side handler for the route (may be app bug)\n - If redirect chain: shorten to single-hop direct redirect in routing config\n - If external: update link to equivalent resource OR remove the mention\n - List likely files/components if you can infer (e.g. "appears on many pages — likely in a shared component like `app/components/Nav.tsx` or menu config")\n - ...\n```\n\nIf `collect_site_links` returned `error`, return a single `kind: site-unreachable` finding with the error in `evidence`.\n\nIf there are zero findings, return `findings: []` — that is the correct output for a healthy link graph.\n\n---\n\n## General rules\n\n- **Trust the scanner.** If `check_urls` reports a URL as broken or long-chain, emit a finding. Do not re-verify with other tools.\n- **Accept some flakiness.** A transient network blip may cause a false positive once. Downstream dedup across runs resolves it.\n- **Group by destination, not by origin.** One broken URL = one finding, even if linked on 50 pages. `collect_site_links` already returns it grouped this way.\n- **Prioritize internals.** Broken external links are the other site\'s responsibility; report but with lower severity.\n- **Never invent status codes.** Report what the scanner returned.\n',mo='# SEO Auditor\n\nYou are the **SEO Auditor**, a specialist agent focused on technical SEO hygiene.\n\n## Your mission\n\nAudit the on-page SEO health of target URLs and return a structured findings report. You focus on **technical SEO** (meta tags, structured data, canonicals, sitemap/robots, heading structure, indexability) — not editorial content or keyword strategy (those are the scope of other agents).\n\nYou are invoked as a sub-task by an orchestrator agent. Your job is to analyze and report. The orchestrator decides what to do with your findings (file issues, dedup against history, etc.).\n\n## Input (expect this in the prompt)\n\nThe orchestrator will pass per-site configuration. Expected fields:\n\n```yaml\nurls:\n - <url to audit>\n - <... one or more>\n```\n\nIf required fields are missing, return an error summary and stop — do not proceed with defaults or guess.\n\n## Available tools\n\n- **site-diagnostics MCP**: `audit_seo`, `fetch_page`, `render_page`, `crawl_site`\n\n---\n\n## Step 1 — Diagnostic\n\nFor each target URL:\n\n1. **Structured audit**: call `audit_seo({ url })`. It returns a structured report — use it as your primary source.\n2. **Raw HTML check**: use `fetch_page({ url })` to see the HTML served (important for crawlers that don\'t execute JS). Confirm critical meta tags are in the initial HTML, not only after hydration.\n3. **Post-render check**: use `render_page({ url })` to see the final DOM. Problems like canonical being overwritten by JS show up here.\n4. **Site structure checks** (only if you have permission for broad crawling, or via sampling): use `crawl_site` to identify orphan pages, canonical loops, or excessive navigation depth.\n5. **Always check**: `/robots.txt` and `/sitemap.xml` via `fetch_page`. These two are root-level and affect the whole site.\n\nOrganize findings into a list. Each finding must have:\n- `kind` (kebab-case slug, see catalog below)\n- `severity` (high | medium | low, see criteria below)\n- `target.url` and `target.route` (normalize: lowercase host, no query, no trailing slash except for `/`)\n- `evidence` (raw data: CSS selector, HTML snippet, observed value)\n- `impact` (1-2 sentences connecting to real metrics)\n- `suggested_fix` (actionable; include file/line if you can infer from framework patterns)\n\n## Step 1.5 — Validate page intent (critical; runs before classification)\n\nBefore you emit *any* finding about a page\'s title, meta description, headings, or indexability, you must answer one question: **did the site owner intend this URL to be a public, indexable page?**\n\nIf the answer is no, the observed "problems" are intentional configuration, not bugs. Reporting them wastes maintainer time and erodes this agent\'s credibility.\n\n### Three signals that the URL is NOT a real public page\n\nCheck these in order. Hitting any one of them means **skip all SEO findings for this URL** except legitimately site-wide problems (e.g. broken sitemap, broken robots.txt).\n\n**Signal 1 — Not in sitemap.** Fetch `/sitemap.xml` (and its child sitemaps, if it\'s a sitemap index). If the URL doesn\'t appear in any sitemap, the owner didn\'t declare it as public. Common on e-commerce platforms where routes like `/p`, `/c`, `/blog` are catchall or routing prefixes, not real pages.\n\n**Signal 2 — Explicit `noindex` + not in sitemap.** If the page serves `<meta name="robots" content="noindex*">` **and** isn\'t in the sitemap, this is a deliberate double-lock by the owner. Respect it. Do **not** flag `noindex-on-important-page` in this case.\n\n**Signal 3 — Title is the URL slug (template fallback).** If `<title>` equals the last path segment (e.g. `<title>blog</title>` for `/blog`, `<title>p</title>` for `/p`), the page is being rendered by a fallback template — nobody configured real content for this route. Skip.\n\n### Platform-specific catchalls (especially Brazilian e-commerce / VTEX / deco-cx)\n\nThese paths are routing prefixes, **not pages**. They may return HTTP 200 but are not meant to be indexable:\n\n- `/p`, `/c`, `/b` — VTEX product / category / brand route prefixes. Real pages live at `/<slug>/p`, `/<slug>/c`, etc. The bare prefixes are catchalls.\n- `/blog`, `/blogs`, `/editorial`, `/revista`, `/conteudo`, `/magazine`, `/noticias`, `/artigos` — common editorial prefixes. If the site doesn\'t have an editorial section, these hit a fallback.\n- `/search`, `/busca`, `/s` — search endpoints, not indexable pages.\n- `/departamento`, `/categoria` — category prefixes.\n- `/checkout`, `/cart`, `/carrinho`, `/login`, `/account`, `/minha-conta` — transactional/private routes. Intentionally `noindex`.\n\n### The "is this page actually important?" checklist\n\nBefore emitting a finding that calls a page "important" (like `noindex-on-important-page` or `title-missing` on anything critical):\n\n1. Is the URL in `/sitemap.xml`? → If no, skip.\n2. Does the page have substantive, unique content (not a fallback with title = URL slug)? → If no, skip.\n3. Is the path a known platform catchall (see list above)? → If yes, skip.\n\nOnly flag if all three pass.\n\n### What still counts as a finding even on non-indexable pages\n\nSite-wide SEO issues affect the whole domain and are worth reporting regardless of individual page intent:\n- `sitemap-missing` (the sitemap itself is broken)\n- `robots-blocking-important-path` (robots.txt blocks something that IS in the sitemap)\n- `structured-data-invalid` on pages that ARE in the sitemap\n- Duplicate titles / meta descriptions across pages that ARE in the sitemap\n\n## Catalog of `kind`\n\nTwo flavors of finding:\n\n- **Per-page** kinds — emitted when auditing a specific URL (e.g. `audit_seo` of a single page OR when your targeted inspection of one of the input URLs finds the issue). Marked **[intent-gated]** — must pass Step 1.5 before being emitted. Target is the specific URL.\n- **Aggregate** kinds — emitted once per site-wide pattern detected by `audit_seo`. Marked **[aggregate]**. Target is the site root (`/`). Evidence MUST include the affected URL sample from `audit_seo.issues[].sampleUrls`. One finding per aggregate kind per site.\n\n**High severity (per-page):**\n- `noindex-on-important-page` **[intent-gated]** — meta robots `noindex` on a page that IS in the sitemap and should be indexed\n- `canonical-pointing-to-wrong-url` **[intent-gated]** — canonical points to a different URL that isn\'t the canonical equivalent\n- `canonical-missing-on-paginated-or-faceted` **[intent-gated]** — pagination/filters without canonical\n- `title-missing` **[intent-gated]** — no `<title>` or empty on a page that IS in the sitemap\n- `structured-data-invalid` **[intent-gated]** — JSON-LD with syntax error or invalid schema.org\n\n**High severity (site-wide):**\n- `sitemap-missing` — `/sitemap.xml` returns 404 or 5xx\n- `robots-blocking-important-path` — `/robots.txt` disallows a path that IS in the sitemap\n- `broken-links-site-wide` **[aggregate]** — `audit_seo` reports broken outbound links across the site\n- `non-indexable-pages-site-wide` **[aggregate]** — `audit_seo` reports many non-indexable pages (note: some non-indexable pages are intentional catchalls — only high severity if the absolute count is large relative to `totalPagesCrawled`, e.g. > 30%)\n\n**Medium severity (per-page):**\n- `meta-description-missing` **[intent-gated]** — no `<meta name="description">` on a sitemap page the agent audited directly\n- `h1-missing` **[intent-gated]** — no `<h1>` on a sitemap page the agent audited directly\n- `h1-duplicate` **[intent-gated]** — multiple `<h1>` on a single page\n- `og-tags-missing` **[intent-gated]** — `og:title` and/or `og:description` missing\n- `structured-data-missing` **[intent-gated]** — page-type (product, article, etc.) without relevant JSON-LD\n- `title-too-long` **[intent-gated]** — `<title>` > 60 characters (truncation in SERP)\n- `title-too-short` **[intent-gated]** — `<title>` < 10 characters (rare; usually means template fallback — double-check page intent)\n- `meta-description-too-long` **[intent-gated]** — description > 160 characters\n\n**Medium severity (site-wide):**\n- `pages-missing-h1` **[aggregate]** — `audit_seo` reports N pages without an H1 tag\n- `pages-missing-meta-description` **[aggregate]** — `audit_seo` reports N pages without a meta description\n- `duplicate-titles` **[aggregate]** — multiple pages share the same `<title>`\n- `duplicate-meta-descriptions` **[aggregate]** — multiple pages share the same meta description\n- `duplicate-content` **[aggregate]** — multiple pages share substantially identical content\n- `broken-resources-site-wide` **[aggregate]** — broken images / scripts across the site\n- `hreflang-broken` — `hreflang` attribute with invalid value or broken reciprocity\n\n**Low severity (per-page):**\n- `meta-description-too-short` **[intent-gated]** — description < 50 characters\n- `og-image-missing` **[intent-gated]** — `og:image` missing\n- `heading-hierarchy-skipped` **[intent-gated]** — jumps from H1 to H3, etc.\n\n**Low severity (site-wide):**\n- `internal-link-using-absolute-url` — internal links with absolute URLs\n\n### Evidence requirements for aggregate kinds\n\nWhen emitting an `[aggregate]` kind, the `evidence` of the finding MUST include:\n\n1. **Total count** — from `audit_seo.issues[].count`\n2. **Sample URLs** — from `audit_seo.issues[].sampleUrls`. Render up to all 20 entries as a bulleted list. If `count > sampleUrls.length`, add a line like `(and <count - sampleUrls.length> more)`.\n3. **If `sampleUrls` is empty** (the tool didn\'t expose per-URL detail — happens for `broken-links-site-wide`, `duplicate-content`, `broken-resources-site-wide`), note it explicitly: `Note: audit_seo did not return per-URL detail for this issue type. A human will need to inspect the full audit_seo report or re-run with deeper crawling.`\n\nAn aggregate finding without either sample URLs or the note is **not actionable** and must not be emitted.\n\nTarget for aggregate kinds stays `target.url: https://<host>/` and `target.route: /`.\n\n## Step 2 — Return a structured findings report\n\nReturn a single response with this shape (YAML or JSON; YAML preferred for readability):\n\n```yaml\nspecialist: seo\nsummary:\n urls_audited: <n>\n findings: <n>\n diagnostic_failures: <n> # urls where audit tooling errored\nfindings:\n - kind: <kind slug>\n severity: <low|medium|high>\n target:\n url: <full URL>\n route: <normalized path>\n evidence: |\n <multi-line raw data: observed value, selector, HTML snippet, audit_seo output>\n impact: <1-2 sentences connecting to ranking/indexation/CTR>\n suggested_fix: <actionable; likely file/component, pseudo-code, correct value>\n - ...\n```\n\nIf a URL\'s diagnostic tooling errored entirely, emit a single `kind: diagnostic-failed` finding for that URL with the error in `evidence` instead of inventing data.\n\nIf there are zero findings, return `findings: []` — that is the correct output for healthy targets.\n\n---\n\n## General rules\n\n- **Never invent data in `evidence`.** If a tool failed, report it via `kind: diagnostic-failed` and skip the finding.\n- Always normalize `route`: lowercase host, no trailing slash (except for `/`), no query string, no fragment.\n- Your credibility is your currency. False positives erode trust — if you\'re 50% sure, don\'t emit a finding; investigate further or mark as `severity:low`.\n- **Never report a page as broken when it\'s a known catchall.** URLs like `/p`, `/c`, `/blog`, `/search`, `/busca` on e-commerce sites are routing prefixes, not pages. If the title is the URL slug and the page carries `noindex`, the owner is deliberately hiding it. That\'s correct behavior, not a bug.\n- **Sitemap is the ground truth for "is this page public?"**. When in doubt about whether to emit a finding on a URL, fall back to: "Is this URL in /sitemap.xml?" If not, default to silence.\n',fo=`# Performance Watchdog
2
2
 
3
3
  You are the **Performance Watchdog**, a specialist agent focused on web performance.
4
4
 
@@ -287,7 +287,7 @@ target:
287
287
  • One issue per { kind, target.route } pair. Dedup uses those two fields from the body frontmatter.
288
288
  • Always normalize route: lowercase host, no trailing slash (except "/"), no query string, no fragment.`)])),{type:"doc",content:l.map((u,V)=>V<l.length-1?go(u):u)}}function go(t){const e=t.content;if(!e||e.length===0)return t;const s=e[e.length-1];return!s||s.type!=="text"||typeof s.text!="string"?t:{...t,content:[...e.slice(0,-1),{...s,text:`${s.text}
289
289
 
290
- `}]}}function Qe(t){return{type:"paragraph",content:t}}function We(t){return{type:"text",text:t}}function xo({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const ht="deco/site-diagnostics";function Dd(t){const e=L.c(15),{open:s,onOpenChange:i}=t,[r,o]=w.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const d=a,l=s&&r===null;let u;e[2]!==r||e[3]!==i?(u=x=>{!x&&r===null&&i(!1)},e[2]=r,e[3]=i,e[4]=u):u=e[4];let V;e[5]!==l||e[6]!==u?(V=n.jsx(Ei,{open:l,onOpenChange:u,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=l,e[6]=u,e[7]=V):V=e[7];const c=s&&r!==null;let m;e[8]!==d||e[9]!==r||e[10]!==c?(m=n.jsx(bo,{open:c,payload:r,onClose:d}),e[8]=d,e[9]=r,e[10]=c,e[11]=m):m=e[11];let p;return e[12]!==V||e[13]!==m?(p=n.jsxs(n.Fragment,{children:[V,m]}),e[12]=V,e[13]=m,e[14]=p):p=e[14],p}function bo(t){const e=L.c(67),{open:s,payload:i,onClose:r}=t,{org:o}=ue(),a=Pn(),d=Rn();let l;e[0]!==o.id||e[1]!==o.slug?(l={connectionId:kt,orgId:o.id,orgSlug:o.slug},e[0]=o.id,e[1]=o.slug,e[2]=l):l=e[2];const u=qe(l),[V,c]=w.useState(""),[m,p]=w.useState(wo);let x;e[3]!==s?(x={enabled:s},e[3]=s,e[4]=x):x=e[4];const{data:g}=Di(ht,x);let f;e[5]!==d||e[6]!==m||e[7]!==i||e[8]!==u||e[9]!==g||e[10]!==V?(f=async()=>{if(!i)throw new Error("No imported repo payload");const Y=Hn(V);if(!Y)throw new Error("Enter a valid https:// URL");const ee=vn.filter(re=>m[re.id]);if(ee.length===0)return{succeeded:[],failed:[]};const te=await ko({selfClient:u,createConnection:d.create.mutateAsync,registry:g}),se=[],ae=[];for(const re of ee)try{await No({template:re,selfClient:u,siteDiagnosticsConnectionId:te,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:Y}),se.push(re.title)}catch(oe){const ce=oe;console.error(`Failed to set up ${re.title}:`,ce),ae.push(re.title)}return{succeeded:se,failed:ae}},e[5]=d,e[6]=m,e[7]=i,e[8]=u,e[9]=g,e[10]=V,e[11]=f):f=e[11];let b;e[12]!==a||e[13]!==r||e[14]!==i?.virtualMcpId?(b=Y=>{const{succeeded:ee,failed:te}=Y;ee.length>0?ne.success(`Self-healing repo ready — ${ee.length} specialist${ee.length>1?"s":""} set up`):te.length===0&&ne.success("Repo imported. Add specialists later from automations."),te.length>0&&ne.warning(`Could not set up: ${te.join(", ")}. You can add them later from the automations view.`);const se=i?.virtualMcpId;r(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),se&&a(se)},e[12]=a,e[13]=r,e[14]=i?.virtualMcpId,e[15]=b):b=e[15];let h;e[16]!==f||e[17]!==b?(h={mutationFn:f,onSuccess:b,onError:vo},e[16]=f,e[17]=b,e[18]=h):h=e[18];const y=_n(h);let A;e[19]!==y.isPending||e[20]!==V?(A=Hn(V)!==null&&!y.isPending,e[19]=y.isPending,e[20]=V,e[21]=A):A=e[21];const _=A;let C;e[22]!==r||e[23]!==y.isPending?(C=Y=>{!Y&&!y.isPending&&r()},e[22]=r,e[23]=y.isPending,e[24]=C):C=e[24];let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Fe,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:n.jsx(Ue,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[25]=S):S=e[25];let v;e[26]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[26]=v):v=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[27]=j):j=e[27];let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=Y=>c(Y.target.value),e[28]=E):E=e[28];let D;e[29]!==V?(D=n.jsx(_e,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:V,onChange:E,autoFocus:!0}),e[29]=V,e[30]=D):D=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[31]=I):I=e[31];let P;e[32]!==D?(P=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,D,I]}),e[32]=D,e[33]=P):P=e[33];let k;e[34]!==m?(k=vn.map(Y=>n.jsx(jo,{template:Y,enabled:m[Y.id]??!1,onToggle:ee=>p(te=>({...te,[Y.id]:ee}))},Y.id)),e[34]=m,e[35]=k):k=e[35];let N,R;e[36]===Symbol.for("react.memo_cache_sentinel")?(N=po.map(yo),R=n.jsx(So,{}),e[36]=N,e[37]=R):(N=e[36],R=e[37]);let M;e[38]!==k?(M=n.jsxs("div",{className:"flex flex-col gap-2",children:[k,N,R]}),e[38]=k,e[39]=M):M=e[39];let T;e[40]!==P||e[41]!==M?(T=n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[v,P,M]}),e[40]=P,e[41]=M,e[42]=T):T=e[42];let F;e[43]!==a||e[44]!==r||e[45]!==i?.virtualMcpId||e[46]!==y.isPending?(F=()=>{if(!y.isPending){const Y=i?.virtualMcpId;r(),Y&&a(Y)}},e[43]=a,e[44]=r,e[45]=i?.virtualMcpId,e[46]=y.isPending,e[47]=F):F=e[47];let O;e[48]!==y.isPending||e[49]!==F?(O=n.jsx("button",{type:"button",onClick:F,disabled:y.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[48]=y.isPending,e[49]=F,e[50]=O):O=e[50];let q;e[51]!==y?(q=()=>y.mutate(),e[51]=y,e[52]=q):q=e[52];const K=!_,H=y.isPending?"Setting up...":"Set up specialists";let Z;e[53]!==q||e[54]!==K||e[55]!==H?(Z=n.jsx(J,{onClick:q,disabled:K,size:"sm",children:H}),e[53]=q,e[54]=K,e[55]=H,e[56]=Z):Z=e[56];let Q;e[57]!==O||e[58]!==Z?(Q=n.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[O,Z]}),e[57]=O,e[58]=Z,e[59]=Q):Q=e[59];let W;e[60]!==T||e[61]!==Q?(W=n.jsxs(Le,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[S,T,Q]}),e[60]=T,e[61]=Q,e[62]=W):W=e[62];let ie;return e[63]!==s||e[64]!==W||e[65]!==C?(ie=n.jsx(Me,{open:s,onOpenChange:C,children:W}),e[63]=s,e[64]=W,e[65]=C,e[66]=ie):ie=e[66],ie}function yo(t){return n.jsx(Ao,{title:t.title,description:t.description,icon:t.icon},t.id)}function vo(t){ne.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function wo(){const t={};for(const e of vn)t[e.id]=!0;return t}function jo(t){const e=L.c(20),{template:s,enabled:i,onToggle:r}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=z("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let d;e[2]!==s.icon||e[3]!==s.title?(d=n.jsx(En,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=d):d=e[4];let l;e[5]!==s.title?(l=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=l):l=e[6];let u;e[7]!==s.description?(u=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=u):u=e[8];let V;e[9]!==l||e[10]!==u?(V=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[l,u]}),e[9]=l,e[10]=u,e[11]=V):V=e[11];let c;e[12]!==i||e[13]!==r?(c=n.jsx(Ri,{checked:i,onCheckedChange:r,className:"shrink-0"}),e[12]=i,e[13]=r,e[14]=c):c=e[14];let m;return e[15]!==a||e[16]!==d||e[17]!==V||e[18]!==c?(m=n.jsxs("label",{className:a,children:[d,V,c]}),e[15]=a,e[16]=d,e[17]=V,e[18]=c,e[19]=m):m=e[19],m}function Ao(t){const e=L.c(14),{title:s,description:i,icon:r}=t;let o;e[0]!==r||e[1]!==s?(o=n.jsx(En,{icon:r,name:s,size:"sm",className:"shrink-0"}),e[0]=r,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let d;e[5]!==i?(d=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=d):d=e[6];let l;e[7]!==a||e[8]!==d?(l=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,d]}),e[7]=a,e[8]=d,e[9]=l):l=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=u):u=e[10];let V;return e[11]!==o||e[12]!==l?(V=n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,l,u]}),e[11]=o,e[12]=l,e[13]=V):V=e[13],V}function So(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Hn(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function ko({selfClient:t,createConnection:e,registry:s}){const r=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:ht},limit:1,offset:0}})).structuredContent?.items?.find(V=>V.app_id===ht);if(r)return r.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",d=s?.server?.icons?.[0]?.src??null,l=s?.server?.description??null;return(await e({title:a,description:l,icon:d,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:ht,metadata:{type:"site-diagnostics",source:"store",registry_item_id:ht,verified:!0}})).id}async function No({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:r,repo:o,siteRootUrl:a}){const d=`${o}: ${t.title}`,u=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(c=>c.name===d);let V;if(!(u&&u.trigger_count>0)){if(u)V=u.id;else{const c=await _o({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),m=ho({template:t,specialistAgentId:c,owner:r,repo:o,siteRootUrl:a}),p=Bi(m),x=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:d,virtual_mcp_id:i,messages:p,active:!0}});V=(x.structuredContent??x).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:V,type:"cron",cron_expression:t.cron}})}}async function _o({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const r=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(d=>d.metadata?.specialistId===t.id);if(r)return r.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}const Co=`You are an image generator agent. Every request of the user is somewhat related to creating, editing or varying an image. You have access to image generation tools
290
+ `}]}}function Qe(t){return{type:"paragraph",content:t}}function We(t){return{type:"text",text:t}}function xo({agentId:t,title:e}){return{type:"mention",attrs:{id:t,name:e,char:"@",metadata:{agentId:t,title:e}}}}const ht="deco/site-diagnostics";function Md(t){const e=L.c(15),{open:s,onOpenChange:i}=t,[r,o]=w.useState(null);let a;e[0]!==i?(a=()=>{o(null),i(!1)},e[0]=i,e[1]=a):a=e[1];const d=a,l=s&&r===null;let u;e[2]!==r||e[3]!==i?(u=x=>{!x&&r===null&&i(!1)},e[2]=r,e[3]=i,e[4]=u):u=e[4];let V;e[5]!==l||e[6]!==u?(V=n.jsx(Ei,{open:l,onOpenChange:u,title:"Set up self-healing repo",hideAutoRespondCheckbox:!0,onImportComplete:o}),e[5]=l,e[6]=u,e[7]=V):V=e[7];const c=s&&r!==null;let m;e[8]!==d||e[9]!==r||e[10]!==c?(m=n.jsx(bo,{open:c,payload:r,onClose:d}),e[8]=d,e[9]=r,e[10]=c,e[11]=m):m=e[11];let p;return e[12]!==V||e[13]!==m?(p=n.jsxs(n.Fragment,{children:[V,m]}),e[12]=V,e[13]=m,e[14]=p):p=e[14],p}function bo(t){const e=L.c(67),{open:s,payload:i,onClose:r}=t,{org:o}=ue(),a=Pn(),d=Rn();let l;e[0]!==o.id||e[1]!==o.slug?(l={connectionId:kt,orgId:o.id,orgSlug:o.slug},e[0]=o.id,e[1]=o.slug,e[2]=l):l=e[2];const u=qe(l),[V,c]=w.useState(""),[m,p]=w.useState(wo);let x;e[3]!==s?(x={enabled:s},e[3]=s,e[4]=x):x=e[4];const{data:g}=Di(ht,x);let f;e[5]!==d||e[6]!==m||e[7]!==i||e[8]!==u||e[9]!==g||e[10]!==V?(f=async()=>{if(!i)throw new Error("No imported repo payload");const Y=Hn(V);if(!Y)throw new Error("Enter a valid https:// URL");const ee=vn.filter(re=>m[re.id]);if(ee.length===0)return{succeeded:[],failed:[]};const te=await ko({selfClient:u,createConnection:d.create.mutateAsync,registry:g}),se=[],ae=[];for(const re of ee)try{await No({template:re,selfClient:u,siteDiagnosticsConnectionId:te,projectAgentId:i.virtualMcpId,owner:i.repo.owner,repo:i.repo.name,siteRootUrl:Y}),se.push(re.title)}catch(oe){const ce=oe;console.error(`Failed to set up ${re.title}:`,ce),ae.push(re.title)}return{succeeded:se,failed:ae}},e[5]=d,e[6]=m,e[7]=i,e[8]=u,e[9]=g,e[10]=V,e[11]=f):f=e[11];let b;e[12]!==a||e[13]!==r||e[14]!==i?.virtualMcpId?(b=Y=>{const{succeeded:ee,failed:te}=Y;ee.length>0?ne.success(`Self-healing repo ready — ${ee.length} specialist${ee.length>1?"s":""} set up`):te.length===0&&ne.success("Repo imported. Add specialists later from automations."),te.length>0&&ne.warning(`Could not set up: ${te.join(", ")}. You can add them later from the automations view.`);const se=i?.virtualMcpId;r(),localStorage.setItem("mesh:sidebar-open",JSON.stringify(!1)),se&&a(se)},e[12]=a,e[13]=r,e[14]=i?.virtualMcpId,e[15]=b):b=e[15];let h;e[16]!==f||e[17]!==b?(h={mutationFn:f,onSuccess:b,onError:vo},e[16]=f,e[17]=b,e[18]=h):h=e[18];const y=_n(h);let A;e[19]!==y.isPending||e[20]!==V?(A=Hn(V)!==null&&!y.isPending,e[19]=y.isPending,e[20]=V,e[21]=A):A=e[21];const _=A;let C;e[22]!==r||e[23]!==y.isPending?(C=Y=>{!Y&&!y.isPending&&r()},e[22]=r,e[23]=y.isPending,e[24]=C):C=e[24];let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Fe,{className:"h-12 border-b border-border px-4 flex flex-row items-center shrink-0 space-y-0",children:n.jsx(Ue,{className:"text-sm font-medium text-foreground",children:"Add specialist monitors"})}),e[25]=S):S=e[25];let v;e[26]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Specialists run on a daily schedule. Your repo agent collects their findings and opens GitHub issues, then writes the fixes."}),e[26]=v):v=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("label",{htmlFor:"self-healing-site-url",className:"text-xs font-medium text-foreground",children:"Production URL"}),e[27]=j):j=e[27];let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=Y=>c(Y.target.value),e[28]=E):E=e[28];let D;e[29]!==V?(D=n.jsx(_e,{id:"self-healing-site-url",type:"url",placeholder:"https://example.com",value:V,onChange:E,autoFocus:!0}),e[29]=V,e[30]=D):D=e[30];let I;e[31]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("p",{className:"text-xs text-muted-foreground",children:"The site the specialists will monitor."}),e[31]=I):I=e[31];let P;e[32]!==D?(P=n.jsxs("div",{className:"flex flex-col gap-1.5",children:[j,D,I]}),e[32]=D,e[33]=P):P=e[33];let k;e[34]!==m?(k=vn.map(Y=>n.jsx(jo,{template:Y,enabled:m[Y.id]??!1,onToggle:ee=>p(te=>({...te,[Y.id]:ee}))},Y.id)),e[34]=m,e[35]=k):k=e[35];let N,R;e[36]===Symbol.for("react.memo_cache_sentinel")?(N=po.map(yo),R=n.jsx(So,{}),e[36]=N,e[37]=R):(N=e[36],R=e[37]);let M;e[38]!==k?(M=n.jsxs("div",{className:"flex flex-col gap-2",children:[k,N,R]}),e[38]=k,e[39]=M):M=e[39];let T;e[40]!==P||e[41]!==M?(T=n.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 flex flex-col gap-4",children:[v,P,M]}),e[40]=P,e[41]=M,e[42]=T):T=e[42];let F;e[43]!==a||e[44]!==r||e[45]!==i?.virtualMcpId||e[46]!==y.isPending?(F=()=>{if(!y.isPending){const Y=i?.virtualMcpId;r(),Y&&a(Y)}},e[43]=a,e[44]=r,e[45]=i?.virtualMcpId,e[46]=y.isPending,e[47]=F):F=e[47];let O;e[48]!==y.isPending||e[49]!==F?(O=n.jsx("button",{type:"button",onClick:F,disabled:y.isPending,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 cursor-pointer",children:"Skip for now"}),e[48]=y.isPending,e[49]=F,e[50]=O):O=e[50];let q;e[51]!==y?(q=()=>y.mutate(),e[51]=y,e[52]=q):q=e[52];const K=!_,H=y.isPending?"Setting up...":"Set up specialists";let Z;e[53]!==q||e[54]!==K||e[55]!==H?(Z=n.jsx(J,{onClick:q,disabled:K,size:"sm",children:H}),e[53]=q,e[54]=K,e[55]=H,e[56]=Z):Z=e[56];let Q;e[57]!==O||e[58]!==Z?(Q=n.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center justify-between gap-3 shrink-0",children:[O,Z]}),e[57]=O,e[58]=Z,e[59]=Q):Q=e[59];let W;e[60]!==T||e[61]!==Q?(W=n.jsxs(Le,{className:"sm:max-w-[560px] max-h-[85svh] p-0 gap-0 overflow-hidden flex flex-col",children:[S,T,Q]}),e[60]=T,e[61]=Q,e[62]=W):W=e[62];let ie;return e[63]!==s||e[64]!==W||e[65]!==C?(ie=n.jsx(Me,{open:s,onOpenChange:C,children:W}),e[63]=s,e[64]=W,e[65]=C,e[66]=ie):ie=e[66],ie}function yo(t){return n.jsx(Ao,{title:t.title,description:t.description,icon:t.icon},t.id)}function vo(t){ne.error("Failed to set up specialists: "+(t instanceof Error?t.message:"Unknown error"))}function wo(){const t={};for(const e of vn)t[e.id]=!0;return t}function jo(t){const e=L.c(20),{template:s,enabled:i,onToggle:r}=t,o=i?"bg-accent/30":"hover:bg-accent/30";let a;e[0]!==o?(a=z("flex items-center gap-3 rounded-lg border border-border px-3 py-3 cursor-pointer transition-colors",o),e[0]=o,e[1]=a):a=e[1];let d;e[2]!==s.icon||e[3]!==s.title?(d=n.jsx(En,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=d):d=e[4];let l;e[5]!==s.title?(l=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s.title}),e[5]=s.title,e[6]=l):l=e[6];let u;e[7]!==s.description?(u=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[7]=s.description,e[8]=u):u=e[8];let V;e[9]!==l||e[10]!==u?(V=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[l,u]}),e[9]=l,e[10]=u,e[11]=V):V=e[11];let c;e[12]!==i||e[13]!==r?(c=n.jsx(Ri,{checked:i,onCheckedChange:r,className:"shrink-0"}),e[12]=i,e[13]=r,e[14]=c):c=e[14];let m;return e[15]!==a||e[16]!==d||e[17]!==V||e[18]!==c?(m=n.jsxs("label",{className:a,children:[d,V,c]}),e[15]=a,e[16]=d,e[17]=V,e[18]=c,e[19]=m):m=e[19],m}function Ao(t){const e=L.c(14),{title:s,description:i,icon:r}=t;let o;e[0]!==r||e[1]!==s?(o=n.jsx(En,{icon:r,name:s,size:"sm",className:"shrink-0"}),e[0]=r,e[1]=s,e[2]=o):o=e[2];let a;e[3]!==s?(a=n.jsx("span",{className:"text-sm font-medium text-foreground leading-tight",children:s}),e[3]=s,e[4]=a):a=e[4];let d;e[5]!==i?(d=n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:i}),e[5]=i,e[6]=d):d=e[6];let l;e[7]!==a||e[8]!==d?(l=n.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a,d]}),e[7]=a,e[8]=d,e[9]=l):l=e[9];let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground shrink-0",children:"Coming soon"}),e[10]=u):u=e[10];let V;return e[11]!==o||e[12]!==l?(V=n.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-dashed border-border px-3 py-3 opacity-60",children:[o,l,u]}),e[11]=o,e[12]=l,e[13]=V):V=e[13],V}function So(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center rounded-lg border border-dashed border-border px-3 py-3 text-xs text-muted-foreground",children:"More specialists coming soon"}),t[0]=e):e=t[0],e}function Hn(t){const e=t.trim();if(!e)return null;try{const s=new URL(e);return s.protocol!=="https:"&&s.protocol!=="http:"?null:s.origin+(s.pathname==="/"?"":s.pathname)}catch{return null}}async function ko({selfClient:t,createConnection:e,registry:s}){const r=(await t.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{where:{field:["app_id"],operator:"eq",value:ht},limit:1,offset:0}})).structuredContent?.items?.find(V=>V.app_id===ht);if(r)return r.id;const o=s?.server?.remotes?.[0]?.url;if(!o)throw new Error("Site Diagnostics MCP is not available in the registry right now.");const a=s?.title??s?.server?.title??s?.server?.name??"Site Diagnostics",d=s?.server?.icons?.[0]?.src??null,l=s?.server?.description??null;return(await e({title:a,description:l,icon:d,connection_type:"HTTP",connection_url:o,app_name:s?.server?.name??"site-diagnostics",app_id:ht,metadata:{type:"site-diagnostics",source:"store",registry_item_id:ht,verified:!0}})).id}async function No({template:t,selfClient:e,siteDiagnosticsConnectionId:s,projectAgentId:i,owner:r,repo:o,siteRootUrl:a}){const d=`${o}: ${t.title}`,u=(await e.callTool({name:"AUTOMATION_LIST",arguments:{virtual_mcp_id:i}})).structuredContent?.automations?.find(c=>c.name===d);let V;if(!(u&&u.trigger_count>0)){if(u)V=u.id;else{const c=await _o({template:t,selfClient:e,siteDiagnosticsConnectionId:s}),m=ho({template:t,specialistAgentId:c,owner:r,repo:o,siteRootUrl:a}),p=Bi(m),x=await e.callTool({name:"AUTOMATION_CREATE",arguments:{name:d,virtual_mcp_id:i,messages:p,active:!0}});V=(x.structuredContent??x).id}await e.callTool({name:"AUTOMATION_TRIGGER_ADD",arguments:{automation_id:V,type:"cron",cron_expression:t.cron}})}}async function _o({template:t,selfClient:e,siteDiagnosticsConnectionId:s}){const r=(await e.callTool({name:"COLLECTION_VIRTUAL_MCP_LIST",arguments:{where:{field:["metadata","specialistId"],operator:"eq",value:t.id},limit:1,offset:0}})).structuredContent?.items?.find(d=>d.metadata?.specialistId===t.id);if(r)return r.id;const o=await e.callTool({name:"COLLECTION_VIRTUAL_MCP_CREATE",arguments:{data:{title:t.title,description:t.description,icon:t.icon,pinned:!1,metadata:{specialistId:t.id,instructions:t.instructions},connections:[{connection_id:s,selected_tools:t.siteDiagnosticsTools,selected_resources:null,selected_prompts:null}]}}});return(o.structuredContent??o).item.id}const Co=`You are an image generator agent. Every request of the user is somewhat related to creating, editing or varying an image. You have access to image generation tools
291
291
 
292
292
  These guidelines define how prompts should be structured, specified, and iterated to produce high-quality, controlled image outputs across different use cases.
293
293
 
@@ -531,7 +531,7 @@ This helps define finish quality and realism level.
531
531
  * Prefer clarity over poetic language.
532
532
  * Keep prompts structured, not verbose.
533
533
  * Add detail only when it improves control.
534
- * Prevent drift by restating critical constraints`,Io=["Turn ideas into detailed, ready-to-use image generation prompts","Offer multiple artistic directions for every concept","Refine prompts iteratively based on your feedback","Advise on style, lighting, composition, and color palette","Support any use case: product shots, illustrations, concept art, and more"];function Jn(t){const e=L.c(7),{onRecruit:s,isRecruiting:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an Image Creator agent that turns your ideas into precise, evocative prompts for any AI image generation tool."}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"space-y-2",children:[o,n.jsx("ul",{className:"space-y-1.5",children:Io.map(Ro)})]}),e[2]=a):a=e[2];const d=i?"Setting up...":"Add Image Creator";let l;return e[3]!==i||e[4]!==s||e[5]!==d?(l=n.jsxs("div",{className:"flex flex-col gap-6",children:[r,a,n.jsx(J,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:d})]}),e[3]=i,e[4]=s,e[5]=d,e[6]=l):l=e[6],l}function Ro(t){return n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-rose-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function Md({open:t,onOpenChange:e,existingAgent:s}){const i=Jt(),r=Pn(),o=js(),[a,d]=w.useState(!1),l=xs.find(m=>m.id==="ai-image"),u=n.jsx(ws,{icon:l.icon,name:l.title,size:"sm"}),V=async()=>{if(s){e(!1),r(s.id);return}d(!0);try{const m=await o.create.mutateAsync({title:l.title,description:"AI image prompt engineering and visual ideation assistant",icon:l.icon,status:"active",connections:[],metadata:{type:"ai-image",instructions:Co}});$("agent_recruit_confirmed",{template_id:"ai-image",agent_id:m.id}),e(!1),r(m.id)}catch(m){$("agent_recruit_failed",{template_id:"ai-image",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Image Creator agent:",m)}finally{d(!1)}},c=`Add ${l.title}`;return i?n.jsx(Wt,{open:t,onOpenChange:e,children:n.jsxs(Gt,{className:"h-[70dvh]",children:[n.jsx(Qt,{className:"px-4 pt-4 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ht,{className:"text-xl font-semibold",children:c})]})}),n.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:n.jsx(Jn,{onRecruit:V,isRecruiting:a})})]})}):n.jsx(Me,{open:t,onOpenChange:e,children:n.jsxs(Le,{className:"sm:max-w-[500px] p-8",children:[n.jsx(Fe,{className:"mb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ue,{className:"text-xl font-semibold",children:c})]})}),n.jsx(Jn,{onRecruit:V,isRecruiting:a})]})})}const To=`You are a systematic research assistant. You have access to web search tools and user's prompts will have somewhat relation to searching the web. Help users conduct thorough, well-structured research on any topic.
534
+ * Prevent drift by restating critical constraints`,Io=["Turn ideas into detailed, ready-to-use image generation prompts","Offer multiple artistic directions for every concept","Refine prompts iteratively based on your feedback","Advise on style, lighting, composition, and color palette","Support any use case: product shots, illustrations, concept art, and more"];function Jn(t){const e=L.c(7),{onRecruit:s,isRecruiting:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Add an Image Creator agent that turns your ideas into precise, evocative prompts for any AI image generation tool."}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"space-y-2",children:[o,n.jsx("ul",{className:"space-y-1.5",children:Io.map(Ro)})]}),e[2]=a):a=e[2];const d=i?"Setting up...":"Add Image Creator";let l;return e[3]!==i||e[4]!==s||e[5]!==d?(l=n.jsxs("div",{className:"flex flex-col gap-6",children:[r,a,n.jsx(J,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:d})]}),e[3]=i,e[4]=s,e[5]=d,e[6]=l):l=e[6],l}function Ro(t){return n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-rose-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function Ld({open:t,onOpenChange:e,existingAgent:s}){const i=Jt(),r=Pn(),o=js(),[a,d]=w.useState(!1),l=xs.find(m=>m.id==="ai-image"),u=n.jsx(ws,{icon:l.icon,name:l.title,size:"sm"}),V=async()=>{if(s){e(!1),r(s.id);return}d(!0);try{const m=await o.create.mutateAsync({title:l.title,description:"AI image prompt engineering and visual ideation assistant",icon:l.icon,status:"active",connections:[],metadata:{type:"ai-image",instructions:Co}});$("agent_recruit_confirmed",{template_id:"ai-image",agent_id:m.id}),e(!1),r(m.id)}catch(m){$("agent_recruit_failed",{template_id:"ai-image",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Image Creator agent:",m)}finally{d(!1)}},c=`Add ${l.title}`;return i?n.jsx(Wt,{open:t,onOpenChange:e,children:n.jsxs(Gt,{className:"h-[70dvh]",children:[n.jsx(Qt,{className:"px-4 pt-4 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ht,{className:"text-xl font-semibold",children:c})]})}),n.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:n.jsx(Jn,{onRecruit:V,isRecruiting:a})})]})}):n.jsx(Me,{open:t,onOpenChange:e,children:n.jsxs(Le,{className:"sm:max-w-[500px] p-8",children:[n.jsx(Fe,{className:"mb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ue,{className:"text-xl font-semibold",children:c})]})}),n.jsx(Jn,{onRecruit:V,isRecruiting:a})]})})}const To=`You are a systematic research assistant. You have access to web search tools and user's prompts will have somewhat relation to searching the web. Help users conduct thorough, well-structured research on any topic.
535
535
 
536
536
  VERY IMPORTANT: The user might not have any web research model connected. If so, guide the user to use an AI Provider that has an Web Search generation, or connect a specific model in our connections.
537
537
 
@@ -542,6 +542,6 @@ When given a research question or topic:
542
542
  - Identify sources, patterns, gaps, and contradictions
543
543
  - Deliver findings as clear, structured summaries with actionable insights
544
544
 
545
- Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,Po=["Break any topic into key sub-questions and define scope","Synthesize information from multiple angles and sources","Distinguish facts, expert consensus, and contested claims","Identify gaps, contradictions, and emerging patterns","Deliver structured summaries with actionable insights"];function Xn(t){const e=L.c(7),{onRecruit:s,isRecruiting:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a Web Researcher agent that conducts thorough, rigorous research on any topic and delivers structured, actionable insights."}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"space-y-2",children:[o,n.jsx("ul",{className:"space-y-1.5",children:Po.map(Eo)})]}),e[2]=a):a=e[2];const d=i?"Setting up...":"Add Web Researcher";let l;return e[3]!==i||e[4]!==s||e[5]!==d?(l=n.jsxs("div",{className:"flex flex-col gap-6",children:[r,a,n.jsx(J,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:d})]}),e[3]=i,e[4]=s,e[5]=d,e[6]=l):l=e[6],l}function Eo(t){return n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function Ld({open:t,onOpenChange:e,existingAgent:s}){const i=Jt(),r=Pn(),o=js(),[a,d]=w.useState(!1),l=xs.find(m=>m.id==="ai-research"),u=n.jsx(ws,{icon:l.icon,name:l.title,size:"sm"}),V=async()=>{if(s){e(!1),r(s.id);return}d(!0);try{const m=await o.create.mutateAsync({title:l.title,description:"Systematic research and information synthesis assistant",icon:l.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:To}});$("agent_recruit_confirmed",{template_id:"ai-research",agent_id:m.id}),e(!1),r(m.id)}catch(m){$("agent_recruit_failed",{template_id:"ai-research",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Researcher agent:",m)}finally{d(!1)}},c=`Add ${l.title}`;return i?n.jsx(Wt,{open:t,onOpenChange:e,children:n.jsxs(Gt,{className:"h-[70dvh]",children:[n.jsx(Qt,{className:"px-4 pt-4 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ht,{className:"text-xl font-semibold",children:c})]})}),n.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:n.jsx(Xn,{onRecruit:V,isRecruiting:a})})]})}):n.jsx(Me,{open:t,onOpenChange:e,children:n.jsxs(Le,{className:"sm:max-w-[500px] p-8",children:[n.jsx(Fe,{className:"mb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ue,{className:"text-xl font-semibold",children:c})]})}),n.jsx(Xn,{onRecruit:V,isRecruiting:a})]})})}function Do(t,e,s,i){const r=t.getQueriesData({queryKey:ve.tasksPrefix(e)});let o=null;for(const[,a]of r)if(a?.items)for(const d of a.items)d.virtual_mcp_id===s&&d.created_by===i&&(d.hidden||(!o||d.updated_at>o.updated_at)&&(o=d));return o}function Fd(t){const e=ct(),s=qt(),i=nr(),{locator:r}=ue(),o=fi({strict:!1}),a=pi({strict:!1}),{data:d}=Bt.useSession(),l=d?.user?.id;return async u=>{const V=l?Do(s,r,u,l):null;if(V)return e({to:"/$org/$taskId",params:{org:t,taskId:V.id},search:{virtualmcpid:u}}),{resumed:!0};const c=crypto.randomUUID(),m=u===a.virtualmcpid?sr(s,r,o.taskId??""):null;try{await i.create.mutateAsync({id:c,virtual_mcp_id:u,...m?{branch:m}:{}})}catch{}return e({to:"/$org/$taskId",params:{org:t,taskId:c},search:{virtualmcpid:u}}),{resumed:!1}}}function Mo(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Dt().min(1,"Required"):Dt();return dt(e)}function Lo(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Fn(t){const e=L.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=w.useId();let a;if(e[0]!==s){const T=s?Mo(s):dt({});a=Nn(T),e[0]=s,e[1]=a}else a=e[1];const l=a;let u;e[2]!==s?(u=s?Lo(s):{},e[2]=s,e[3]=u):u=e[3];let V;e[4]!==l||e[5]!==u?(V={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=V):V=e[6];const c=kn(V);let m;e[7]!==s?.arguments?(m=s?.arguments??[],e[7]=s?.arguments,e[8]=m):m=e[8];const p=m;let x;e[9]!==c||e[10]!==r||e[11]!==i?(x=async T=>{await r(T),i(null),c.reset()},e[9]=c,e[10]=r,e[11]=i,e[12]=x):x=e[12];const g=x;let f;e[13]!==c||e[14]!==i?(f=T=>{T||(c.reset(),i(null))},e[13]=c,e[14]=i,e[15]=f):f=e[15];const b=f;if(!s)return null;let h;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(h=s.title||Xt(s.name,Ge(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=h):h=e[19];let y;e[20]!==h?(y=n.jsx(Ue,{children:n.jsx("span",{className:"capitalize",children:h})}),e[20]=h,e[21]=y):y=e[21];let A;e[22]!==s.description?(A=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=A):A=e[23];let _;e[24]!==A||e[25]!==y?(_=n.jsxs(Fe,{children:[y,A]}),e[24]=A,e[25]=y,e[26]=_):_=e[26];let C;e[27]!==c||e[28]!==g?(C=T=>{T.stopPropagation(),c.handleSubmit(g)(T)},e[27]=c,e[28]=g,e[29]=C):C=e[29];let S;if(e[30]!==p||e[31]!==c.control||e[32]!==c.formState.isSubmitting){let T;e[34]!==c.control||e[35]!==c.formState.isSubmitting?(T=F=>n.jsx(me,{control:c.control,name:F.name,render:O=>{const{field:q}=O;return n.jsxs(fe,{children:[n.jsxs(Ne,{className:"text-xs",children:[F.name,F.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(pe,{children:n.jsx(_e,{...q,value:q.value??"",required:F.required,placeholder:F.description??"",className:"h-9",disabled:c.formState.isSubmitting})}),n.jsx(he,{})]})}},F.name),e[34]=c.control,e[35]=c.formState.isSubmitting,e[36]=T):T=e[36],S=p.map(T),e[30]=p,e[31]=c.control,e[32]=c.formState.isSubmitting,e[33]=S}else S=e[33];let v;e[37]!==b?(v=()=>b(!1),e[37]=b,e[38]=v):v=e[38];let j;e[39]!==c.formState.isSubmitting||e[40]!==v?(j=n.jsx(J,{type:"button",variant:"ghost",onClick:v,disabled:c.formState.isSubmitting,children:"Cancel"}),e[39]=c.formState.isSubmitting,e[40]=v,e[41]=j):j=e[41];const E=!c.formState.isValid||c.formState.isSubmitting;let D;e[42]!==c.formState.isSubmitting?(D=c.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Mt,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=c.formState.isSubmitting,e[43]=D):D=e[43];let I;e[44]!==o||e[45]!==E||e[46]!==D?(I=n.jsx(J,{type:"submit",form:o,disabled:E,children:D}),e[44]=o,e[45]=E,e[46]=D,e[47]=I):I=e[47];let P;e[48]!==j||e[49]!==I?(P=n.jsxs(gs,{children:[j,I]}),e[48]=j,e[49]=I,e[50]=P):P=e[50];let k;e[51]!==o||e[52]!==C||e[53]!==S||e[54]!==P?(k=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:C,children:[S,P]}),e[51]=o,e[52]=C,e[53]=S,e[54]=P,e[55]=k):k=e[55];let N;e[56]!==c||e[57]!==k?(N=n.jsx(jt,{...c,children:k}),e[56]=c,e[57]=k,e[58]=N):N=e[58];let R;e[59]!==_||e[60]!==N?(R=n.jsxs(Le,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[_,N]}),e[59]=_,e[60]=N,e[61]=R):R=e[61];let M;return e[62]!==b||e[63]!==R?(M=n.jsx(Me,{open:!0,onOpenChange:b,children:R}),e[62]=b,e[63]=R,e[64]=M):M=e[64],M}function Fo(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function Uo(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Zn=3,zs="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",Oo="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Bs(t){const e=L.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,d=a===void 0?"pill":a,{prompt:l}=s;let u;if(e[0]!==l._meta||e[1]!==l.name||e[2]!==l.title){const S=Ge(l._meta);u=l.title??Xt(l.name,S),e[0]=l._meta,e[1]=l.name,e[2]=l.title,e[3]=u}else u=e[3];const V=u,c=l.description||null;if(d==="card"){let S;e[4]!==i||e[5]!==l?(S=()=>i(l),e[4]=i,e[5]=l,e[6]=S):S=e[6];const v=o||r,j=r&&"bg-accent/40",E=(o||r)&&"cursor-not-allowed opacity-50";let D;e[7]!==j||e[8]!==E?(D=z(Oo,"hover:bg-accent/60 text-foreground",j,E),e[7]=j,e[8]=E,e[9]=D):D=e[9];let I;e[10]!==V?(I=n.jsx("span",{className:"font-medium truncate capitalize",children:V}),e[10]=V,e[11]=I):I=e[11];let P;e[12]!==r?(P=r&&n.jsx(Mt,{size:"xs"}),e[12]=r,e[13]=P):P=e[13];let k;e[14]!==I||e[15]!==P?(k=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,P]}),e[14]=I,e[15]=P,e[16]=k):k=e[16];let N;e[17]!==c?(N=c&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:c}),e[17]=c,e[18]=N):N=e[18];let R;return e[19]!==k||e[20]!==N||e[21]!==S||e[22]!==v||e[23]!==D?(R=n.jsxs("button",{type:"button",onClick:S,disabled:v,className:D,children:[k,N]}),e[19]=k,e[20]=N,e[21]=S,e[22]=v,e[23]=D,e[24]=R):R=e[24],R}let m;e[25]!==i||e[26]!==l?(m=()=>i(l),e[25]=i,e[26]=l,e[27]=m):m=e[27];const p=o||r,x=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let f;e[28]!==x||e[29]!==g?(f=z(zs,"hover:bg-muted/70 hover:text-foreground",x,g),e[28]=x,e[29]=g,e[30]=f):f=e[30];let b;e[31]!==V?(b=n.jsx("span",{className:"capitalize",children:V}),e[31]=V,e[32]=b):b=e[32];let h;e[33]!==r?(h=r&&n.jsx(Mt,{size:"xs"}),e[33]=r,e[34]=h):h=e[34];let y;e[35]!==m||e[36]!==p||e[37]!==f||e[38]!==b||e[39]!==h?(y=n.jsx(bt,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:m,disabled:p,className:f,children:[b,h]})}),e[35]=m,e[36]=p,e[37]=f,e[38]=b,e[39]=h,e[40]=y):y=e[40];const A=c??V;let _;e[41]!==A?(_=n.jsx(yt,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:A})}),e[41]=A,e[42]=_):_=e[42];let C;return e[43]!==y||e[44]!==_?(C=n.jsxs(xt,{delayDuration:400,children:[y,_]}),e[43]=y,e[44]=_,e[45]=C):C=e[45],C}function $o(t){const e=L.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[d,l]=w.useState(""),u=!!a;let V;e[0]!==s||e[1]!==d?(V=d.trim()?s.filter(v=>{const j=d.toLowerCase();return v.prompt.name.toLowerCase().includes(j)||(v.prompt.title??"").toLowerCase().includes(j)||(v.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=d,e[2]=V):V=e[2];const c=V,m=Jt();let p;e[3]!==c.length||e[4]!==d?(p=c.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",d,"”"]}),e[3]=c.length,e[4]=d,e[5]=p):p=e[5];let x;if(e[6]!==c||e[7]!==u||e[8]!==a?.name||e[9]!==r||e[10]!==o){let v;e[12]!==u||e[13]!==a?.name||e[14]!==r||e[15]!==o?(v=j=>n.jsx(Bs,{item:j,variant:"card",onSelect:E=>{r(!1),o(E)},isLoading:a?.name===j.prompt.name,isDisabled:u&&a?.name!==j.prompt.name},j.prompt.name),e[12]=u,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=v):v=e[16],x=c.map(v),e[6]=c,e[7]=u,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=x}else x=e[11];let g;e[17]!==p||e[18]!==x?(g=n.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[p,x]})}),e[17]=p,e[18]=x,e[19]=g):g=e[19];const f=g;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=v=>{v.key==="Escape"&&l("")},e[20]=b):b=e[20];let h;e[21]!==d?(h=n.jsx(As,{value:d,onChange:l,placeholder:"Search prompts...",onKeyDown:b}),e[21]=d,e[22]=h):h=e[22];const y=h;if(m){let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Qt,{className:"sr-only",children:n.jsx(Ht,{children:"All prompts"})}),e[23]=v):v=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let E;e[25]!==f||e[26]!==y?(E=n.jsxs(Gt,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[v,j,y,f]}),e[25]=f,e[26]=y,e[27]=E):E=e[27];let D;return e[28]!==r||e[29]!==i||e[30]!==E?(D=n.jsx(xn,{delayDuration:400,children:n.jsx(Wt,{open:i,onOpenChange:r,children:E})}),e[28]=r,e[29]=i,e[30]=E,e[31]=D):D=e[31],D}let A;e[32]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(Fe,{className:"sr-only",children:n.jsx(Ue,{children:"All prompts"})}),e[32]=A):A=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=_):_=e[33];let C;e[34]!==f||e[35]!==y?(C=n.jsxs(Le,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[A,_,y,f]}),e[34]=f,e[35]=y,e[36]=C):C=e[36];let S;return e[37]!==r||e[38]!==i||e[39]!==C?(S=n.jsx(xn,{delayDuration:400,children:n.jsx(Me,{open:i,onOpenChange:r,children:C})}),e[37]=r,e[38]=i,e[39]=C,e[40]=S):S=e[40],S}function zo(t){const e=L.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,d]=w.useState(!1);if(s.length===0)return null;let l,u,V;if(e[0]!==s||e[1]!==r||e[2]!==i){const b=s.slice(0,Zn);let h;e[6]!==s?(h=s.slice(Zn),e[6]=s,e[7]=h):h=e[7],l=h,u=!!r;let y;e[8]!==u||e[9]!==r?.name||e[10]!==i?(y=A=>n.jsx(Bs,{item:A,onSelect:i,isLoading:r?.name===A.prompt.name,isDisabled:u&&r?.name!==A.prompt.name},A.prompt.name),e[8]=u,e[9]=r?.name,e[10]=i,e[11]=y):y=e[11],V=b.map(y),e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=u,e[5]=V}else l=e[3],u=e[4],V=e[5];const c=V;let m;e[12]!==o?(m=z("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let p;e[14]!==l.length||e[15]!==u?(p=l.length>0&&n.jsxs("button",{type:"button",disabled:u,onClick:()=>d(!0),className:z(zs,"hover:bg-muted/70 hover:text-foreground",u&&"opacity-50 cursor-not-allowed"),children:["+",l.length," more"]}),e[14]=l.length,e[15]=u,e[16]=p):p=e[16];let x;e[17]!==c||e[18]!==m||e[19]!==p?(x=n.jsxs("div",{className:m,children:[c,p]}),e[17]=c,e[18]=m,e[19]=p,e[20]=x):x=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx($o,{items:s,open:a,onOpenChange:d,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let f;return e[26]!==x||e[27]!==g?(f=n.jsxs(xn,{delayDuration:400,children:[x,g]}),e[26]=x,e[27]=g,e[28]=f):f=e[28],f}function Bo(){return null}function qo(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function Ko(t){const e=L.c(31),{connectionId:s}=t,{sendMessage:i}=Dn(),{tiptapDocRef:r}=Yt(),{org:o}=ue();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const d=qe(a);let l;e[4]!==d?(l={client:d,staleTime:6e4},e[4]=d,e[5]=l):l=e[5];const{data:u}=vr(l);let V;e[6]!==u?.prompts?(V=u?.prompts??[],e[6]=u?.prompts,e[7]=V):V=e[7];const c=V;let m;e[8]!==c?(m=c.map(Yo),e[8]=c,e[9]=m):m=e[9];const p=m;let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x={stage:"idle"},e[10]=x):x=e[10];const[g,f]=w.useReducer(qo,x),[b,h]=w.useState(null);let y;e[11]!==d||e[12]!==i||e[13]!==r?(y=async(k,N)=>{if(!d){ne.error("MCP client not available"),f({type:"RESET"});return}try{const R=await Ln(d,k.name,N);f({type:"RESET"});const M=Uo(r.current,{type:"paragraph",content:[rr({id:k.name,name:Mn(k.name,Ge(k._meta)),metadata:R.messages,char:"/"})]});await i(M)}catch(R){console.error("[ice-breakers] Failed to fetch prompt:",R),ne.error("Failed to load prompt. Please try again."),f({type:"RESET"})}},e[11]=d,e[12]=i,e[13]=r,e[14]=y):y=e[14];const A=y;let _;e[15]!==A?(_=async k=>{if(k.arguments&&k.arguments.length>0){f({type:"SELECT_PROMPT",prompt:k}),h(k);return}f({type:"START_LOADING",prompt:k}),await A(k)},e[15]=A,e[16]=_):_=e[16];const C=_;let S;e[17]!==b||e[18]!==A?(S=async k=>{b&&(f({type:"START_LOADING",prompt:b,arguments:k}),h(null),await A(b,k))},e[17]=b,e[18]=A,e[19]=S):S=e[19];const v=S;if(p.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let E;e[20]!==C||e[21]!==p||e[22]!==j?(E=n.jsx(zo,{items:p,onSelect:C,loadingPrompt:j}),e[20]=C,e[21]=p,e[22]=j,e[23]=E):E=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{h(null),f({type:"RESET"})},e[24]=D):D=e[24];let I;e[25]!==b||e[26]!==v?(I=n.jsx(Fn,{prompt:b,setPrompt:D,onSubmit:v}),e[25]=b,e[26]=v,e[27]=I):I=e[27];let P;return e[28]!==E||e[29]!==I?(P=n.jsxs(n.Fragment,{children:[E,I]}),e[28]=E,e[29]=I,e[30]=P):P=e[30],P}function Yo(t){return{prompt:t}}function Wo(t){const e=L.c(13),{className:s}=t,{selectedVirtualMcp:i}=Yt(),{org:r}=ue();let o;e[0]!==r.id?(o=Tn(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,d=i?.id??a;let l;e[2]!==s?(l=z("w-full @container",s),e[2]=s,e[3]=l):l=e[3];const u=d??"default";let V;e[4]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Bo,{}),e[4]=V):V=e[4];let c;e[5]!==d?(c=n.jsx(Ko,{connectionId:d}),e[5]=d,e[6]=c):c=e[6];let m;e[7]!==u||e[8]!==c?(m=n.jsx(hi,{fallback:null,children:n.jsx(w.Suspense,{fallback:V,children:c},u)}),e[7]=u,e[8]=c,e[9]=m):m=e[9];let p;return e[10]!==l||e[11]!==m?(p=n.jsx("div",{className:l,children:m}),e[10]=l,e[11]=m,e[12]=p):p=e[12],p}function qs(t){const e=L.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,d=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let l;e[0]!==d?(l=z("p-0.5 rounded transition-colors",d),e[0]=d,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Rr,{size:14}),e[2]=u):u=e[2];let V;e[3]!==r||e[4]!==a||e[5]!==l?(V=n.jsx("button",{type:"button",onClick:r,disabled:a,className:l,"aria-label":"Previous question",children:u}),e[3]=r,e[4]=a,e[5]=l,e[6]=V):V=e[6];const c=s+1;let m;e[7]!==c||e[8]!==i?(m=n.jsxs("span",{className:"tabular-nums text-xs",children:[c," of ",i]}),e[7]=c,e[8]=i,e[9]=m):m=e[9];const p=s===i-1,x=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==x?(g=z("p-0.5 rounded transition-colors",x),e[10]=x,e[11]=g):g=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Rs,{size:14}),e[12]=f):f=e[12];let b;e[13]!==o||e[14]!==g||e[15]!==p?(b=n.jsx("button",{type:"button",onClick:o,disabled:p,className:g,"aria-label":"Next question",children:f}),e[13]=o,e[14]=g,e[15]=p,e[16]=b):b=e[16];let h;return e[17]!==b||e[18]!==V||e[19]!==m?(h=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[V,m,b]}),e[17]=b,e[18]=V,e[19]=m,e[20]=h):h=e[20],h}function Ut(t){const e=L.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,d=a??"border-border";let l;e[0]!==d?(l=z("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",d),e[0]=d,e[1]=l):l=e[1];let u;e[2]!==s?(u=n.jsx("div",{className:"flex items-center gap-2 p-4",children:n.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=u):u=e[3];let V;e[4]!==i?(V=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=V):V=e[5];let c;e[6]!==r?(c=n.jsx("div",{children:r}),e[6]=r,e[7]=c):c=e[7];let m;e[8]!==o?(m=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=n.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[c,m]})}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let x;return e[13]!==l||e[14]!==u||e[15]!==V||e[16]!==p?(x=n.jsxs("div",{className:l,children:[u,V,p]}),e[13]=l,e[14]=u,e[15]=V,e[16]=p,e[17]=x):x=e[17],x}const Go="User denied this tool call, give other alternatives.",Qo=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function Ho(t){const e=L.c(9),{onYolo:s}=t,[i,r]=Cn();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=V=>{const c=V;r({...i,toolApprovalLevel:c}),c==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Es,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Xo,children:n.jsx(Ds,{})}),e[4]=d):d=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Ms,{children:Qo.map(Jo)}),e[5]=l):l=e[5];let u;return e[6]!==a||e[7]!==i.toolApprovalLevel?(u=n.jsxs(Ps,{value:i.toolApprovalLevel,onValueChange:a,children:[d,l]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=u):u=e[8],u}function Jo(t){return n.jsx(ot,{value:t.value,children:t.label},t.value)}function Xo(t){return t.stopPropagation()}function Zo(t){const e=L.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let r;return e[3]!==i?(r=n.jsx("div",{className:"px-4",children:n.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=r):r=e[4],r}function ea(t){const e=L.c(42),{approvals:s,onRespond:i}=t,[r,o]=w.useState(0),a=Math.min(r,s.length-1),d=s[a];if(!d)return null;let l;e[0]!==d.approvalId||e[1]!==i?(l=()=>{i(d.approvalId,!1,Go)},e[0]=d.approvalId,e[1]=i,e[2]=l):l=e[2];const u=l;let V;e[3]!==d.approvalId||e[4]!==i?(V=()=>{i(d.approvalId,!0)},e[3]=d.approvalId,e[4]=i,e[5]=V):V=e[5];const c=V;let m;e[6]!==s||e[7]!==i?(m=()=>{for(const P of s)i(P.approvalId,!0)},e[6]=s,e[7]=i,e[8]=m):m=e[8];const p=m;let x;e[9]!==a?(x=()=>{a>0&&o(a-1)},e[9]=a,e[10]=x):x=e[10];const g=x;let f;e[11]!==s.length||e[12]!==a?(f=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=f):f=e[13];const b=f;let h;e[14]!==p?(h=n.jsx(Ho,{onYolo:p}),e[14]=p,e[15]=h):h=e[15];let y;e[16]!==s.length||e[17]!==b||e[18]!==g||e[19]!==a?(y=n.jsx(qs,{current:a,total:s.length,onPrev:g,onNext:b}),e[16]=s.length,e[17]=b,e[18]=g,e[19]=a,e[20]=y):y=e[20];let A;e[21]!==h||e[22]!==y?(A=n.jsxs("div",{className:"flex items-center gap-2",children:[h,y]}),e[21]=h,e[22]=y,e[23]=A):A=e[23];const _=A;let C;e[24]!==u?(C=n.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:u,children:"Deny"}),e[24]=u,e[25]=C):C=e[25];let S;e[26]!==s.length||e[27]!==p?(S=s.length>1&&n.jsx(J,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:p,children:"Accept All"}),e[26]=s.length,e[27]=p,e[28]=S):S=e[28];let v;e[29]!==c?(v=n.jsx(J,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:c,children:"Accept"}),e[29]=c,e[30]=v):v=e[30];let j;e[31]!==S||e[32]!==v||e[33]!==C?(j=n.jsxs(n.Fragment,{children:[C,S,v]}),e[31]=S,e[32]=v,e[33]=C,e[34]=j):j=e[34];const E=j;let D;e[35]!==d.input?(D=n.jsx(Zo,{input:d.input}),e[35]=d.input,e[36]=D):D=e[36];let I;return e[37]!==d.friendlyName||e[38]!==_||e[39]!==E||e[40]!==D?(I=n.jsx(Ut,{title:d.friendlyName,footerLeft:_,footerRight:E,children:D}),e[37]=d.friendlyName,e[38]=_,e[39]=E,e[40]=D,e[41]=I):I=e[41],I}function ta(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Li,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function na(t){const e=L.c(4),{approvals:s,isStreaming:i,onRespond:r}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(ta,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==r?(o=n.jsx(ea,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function sa(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:or(ar(i)),input:s.input})}return e}function ia(t){const e=L.c(15),{plan:s,onApprove:i,onDismiss:r}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let d;e[3]!==r?(d=n.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=d):d=e[4];let l;e[5]!==a?(l=n.jsx(J,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=l):l=e[6];let u;e[7]!==d||e[8]!==l?(u=n.jsxs(n.Fragment,{children:[d,l]}),e[7]=d,e[8]=l,e[9]=u):u=e[9];const V=u;let c;e[10]!==s.plan?(c=n.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:n.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:n.jsx(lr,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=c):c=e[11];let m;return e[12]!==V||e[13]!==c?(m=n.jsx(Ut,{title:"Implementation Plan",footerRight:V,className:"border-dashed border-purple-500",children:c}),e[12]=V,e[13]=c,e[14]=m):m=e[14],m}function ra(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Xe,{className:"size-5 text-purple-500 shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function oa(t){const e=L.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(ra,{}),e[0]=u):u=e[0],u}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const d=a;if(!d)return null;let l;return e[3]!==d||e[4]!==r||e[5]!==o?(l=n.jsx(ia,{plan:d,onApprove:r,onDismiss:o}),e[3]=d,e[4]=r,e[5]=o,e[6]=l):l=e[6],l}function aa(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const es=dt({response:Dt().min(1,"Response is required")}),la=dt({response:Dt().min(1,"Please select or enter an option")}),ca=dt({response:gi(["yes","no"])});function da(t){switch(t.type){case"text":return es;case"choice":return la;case"confirm":return ca;default:return es}}function ua(t){const e={};for(const s of t)e[s.toolCallId]=da(s.input);return dt(e)}function Va(t){const e=L.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=d=>{const{field:l}=d;return n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsx("div",{className:"px-2",children:n.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(bs,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...l,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),n.jsx(he,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(me,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Ks(t,e){const s=L.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const d=a.target.tagName;if(d==="INPUT"||d==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const l=Number.parseInt(a.key,10);l>=1&&l<=t&&(a.preventDefault(),e(l-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=r):(i=s[2],r=s[3]),w.useEffect(i,r)}function ma(t){const e=L.c(9),{control:s,name:i,options:r}=t,[o,a]=w.useState(!1),d=w.useRef(null),l=w.useRef(null);let u;if(e[0]!==r?(u=m=>{l.current?.onChange(r[m]??""),a(!1)},e[0]=r,e[1]=u):u=e[1],Ks(r.length,u),r.length===0)return null;let V;e[2]!==o||e[3]!==r?(V=m=>{const{field:p}=m;l.current=p;const x=o||!!p.value&&!r.includes(p.value);return n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,f)=>{const b=p.value===g;return n.jsxs("button",{type:"button",onClick:()=>{p.onChange(g??""),a(!1)},className:z("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",b&&"bg-accent/50",!b&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:z("flex items-center justify-center size-6 rounded-md text-sm shrink-0",b?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${f}-${g}`)}),n.jsxs("div",{className:z("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x&&"bg-accent/50",!x&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(p.value)&&p.onChange(""),setTimeout(()=>d.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(bs,{size:16,className:"text-muted-foreground"})}),x?n.jsx("input",{ref:d,type:"text",value:p.value,onChange:g=>p.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):n.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),n.jsx(he,{})]})},e[2]=o,e[3]=r,e[4]=V):V=e[4];let c;return e[5]!==s||e[6]!==i||e[7]!==V?(c=n.jsx(me,{control:s,name:i,render:V}),e[5]=s,e[6]=i,e[7]=V,e[8]=c):c=e[8],c}function fa(t){const e=L.c(6),{control:s,name:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=w.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=V=>{a.current?.onChange(o[V]??"")},e[1]=d):d=e[1],Ks(o.length,d);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=V=>{const{field:c}=V;return a.current=c,n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const p=c.value===m;return n.jsxs("button",{type:"button",onClick:()=>c.onChange(m),className:z("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[n.jsx("span",{className:z("flex items-center justify-center size-6 rounded-md text-sm shrink-0",p?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),n.jsx(he,{})]})},e[2]=l):l=e[2];let u;return e[3]!==s||e[4]!==i?(u=n.jsx(me,{control:s,name:i,render:l}),e[3]=s,e[4]=i,e[5]=u):u=e[5],u}function ts(t){const e=L.c(13),{input:s,control:i,name:r}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==r?(o=n.jsx(Va,{control:i,name:r,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=r,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let d;return e[6]!==i||e[7]!==r||e[8]!==a?(d=n.jsx(ma,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=d):d=e[9],d}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(fa,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function pa({parts:t,onSubmit:e}){const[s,i]=w.useState(t[0]?.toolCallId??""),r=ua(t.map(h=>({toolCallId:h.toolCallId,input:h.input}))),o=kn({resolver:Nn(r),defaultValues:Object.fromEntries(t.map(h=>[h.toolCallId,{response:""}]))}),a=o.watch(),d=t.findIndex(h=>h.toolCallId===s),l=!!a[s]?.response,u=t.every(h=>!!a[h.toolCallId]?.response),V=h=>{for(const y of t){const A=h[y.toolCallId]?.response;A&&e(y,A)}},c=h=>t.find(y=>!h[y.toolCallId]?.response&&y.toolCallId!==s)??null,m=()=>{const h=o.getValues();if(t.every(A=>!!h[A.toolCallId]?.response))o.handleSubmit(V)();else{const A=c(h);A&&i(A.toolCallId)}},p=()=>{o.setValue(`${s}.response`,"user has skip this question"),m()},x=()=>{if(d>0){const h=t[d-1];h&&i(h.toolCallId)}},g=()=>{if(d<t.length-1){const h=t[d+1];h&&i(h.toolCallId)}},f=n.jsxs(n.Fragment,{children:[n.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),n.jsx(J,{type:"button",size:"sm",disabled:!l,onClick:m,className:z("h-7",l?"":"opacity-50"),children:u?"Submit":"Next"})]}),b=n.jsx(qs,{current:d,total:t.length,onPrev:x,onNext:g});if(t.length===1){const h=t[0];return h?.input?n.jsx(jt,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(V),autoComplete:"off",children:n.jsx(Ut,{title:h.input?.prompt??"Question",footerRight:f,children:n.jsx(ts,{input:h.input,control:o.control,name:`${h.toolCallId}.response`})})})}):null}return n.jsx(jt,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(V),autoComplete:"off",children:n.jsx(wr,{value:s,onValueChange:i,children:t.map(h=>n.jsx(jr,{value:h.toolCallId,className:"mt-0",children:n.jsx(Ut,{title:h.input?.prompt??"Question",footerLeft:b,footerRight:f,children:n.jsx(ts,{input:h.input,control:o.control,name:`${h.toolCallId}.response`})})},h.toolCallId))})})})}function ha(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(_r,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Ys(t){const e=L.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(ga),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ha,{}),e[2]=l):l=e[2],l}if(a.length===0)return null;let d;return e[3]!==r||e[4]!==a?(d=n.jsx(pa,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=d):d=e[5],d}function ga(t){return t.state==="input-available"}const ns=new Map;function Ws(){const{org:t}=ue(),e=qe({connectionId:kt,orgId:t.id,orgSlug:t.slug}),s=Tr(),i=s.find(f=>f.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:d}=In({queryKey:ve.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const f=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return f?.isError?null:f.structuredContent??null}}),l=r?.balanceCents??null,u=l!=null?l/100:null,V=w.useRef(new Map);if(l!=null){const f=ns.get(t.id);V.current.get(t.id)&&f!=null&&l>f&&$("credits_topped_up_detected",{organization_id:t.id,delta_cents:l-f,previous_balance_cents:f,new_balance_cents:l}),ns.set(t.id,l),V.current.set(t.id,!0)}const c=!!i,m=l!=null&&l>0,p=l!=null&&l===0,x=l!=null&&l===200,g=s.length>0&&s.every(f=>f.providerId==="deco");return{hasDecoKey:c,decoKeyId:i?.id??null,balanceCents:l,balanceDollars:u,hasCredits:m,isZeroBalance:p,isInitialFreeCredit:x,hasOnlyDecoProvider:g,isLoading:o,isFetching:d,refetch:a}}function xa(t){return t?t.message.startsWith("[CREDITS]"):!1}const ba={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},ya=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Gs(t){const e=L.c(44),{onDismiss:s}=t,{org:i}=ue(),r=ct(),{decoKeyId:o}=Ws();let a;e[0]!==i.id||e[1]!==i.slug?(a={connectionId:kt,orgId:i.id,orgSlug:i.slug},e[0]=i.id,e[1]=i.slug,e[2]=a):a=e[2];const d=qe(a),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g,f;e[3]!==i.id?(g=()=>{$("credits_exhausted_shown",{organization_id:i.id})},f=[i.id],e[3]=i.id,e[4]=g,e[5]=f):(g=e[4],f=e[5]),w.useEffect(g,f);let b;e[6]!==d||e[7]!==m?(b=async T=>{const F=await d.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:T,currency:m}});if(F?.isError)throw new Error(F.content?.[0]?.text??"Failed to get top-up URL");return F.structuredContent?.url},e[6]=d,e[7]=m,e[8]=b):b=e[8];let h;e[9]!==s?(h=T=>{T&&window.open(T,"_blank","noopener,noreferrer"),s?.()},e[9]=s,e[10]=h):h=e[10];let y;e[11]!==b||e[12]!==h?(y={mutationFn:b,onSuccess:h,onError:ja},e[11]=b,e[12]=h,e[13]=y):y=e[13];const{mutate:A,isPending:_}=_n(y),C=parseFloat(l),S=!isNaN(C)&&C>=1;let v;e[14]!==s?(v=T=>!T&&s?.(),e[14]=s,e[15]=v):v=e[15];let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[16]=j):j=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[17]=E):E=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[E,n.jsxs(Fe,{className:"relative gap-4",children:[n.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),n.jsxs("div",{children:[n.jsx(Ue,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(Kt,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[18]=D):D=e[18];let I;e[19]!==m||e[20]!==x||e[21]!==l||e[22]!==C||e[23]!==o||e[24]!==S||e[25]!==_||e[26]!==V||e[27]!==A?(I=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(Ls,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:T=>{T&&p(T)},children:[n.jsx(Ft,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ft,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsxs("div",{className:"rounded-xl border border-border p-5",children:[n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:ba[m].map(T=>{const{dollars:F,label:O}=T;return n.jsxs("button",{type:"button",disabled:_,onClick:()=>{$("credits_topup_clicked",{amount_cents:F*100,currency:m,tier_label:O,source:"exhausted_banner"}),A(F*100)},className:z("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[x,F]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},F)})}),V?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:x}),n.jsx(_e,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:T=>u(T.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(J,{className:"h-10",disabled:!S||_,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(C*100),currency:m,tier_label:"custom",source:"exhausted_banner"}),A(Math.round(C*100))},children:_?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>c(!0),children:"Enter custom amount"})]}),n.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:ya.map(va)})]}),e[19]=m,e[20]=x,e[21]=l,e[22]=C,e[23]=o,e[24]=S,e[25]=_,e[26]=V,e[27]=A,e[28]=I):I=e[28];let P;e[29]!==s?(P=n.jsx(J,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[29]=s,e[30]=P):P=e[30];let k;e[31]!==r||e[32]!==s||e[33]!==i.slug?(k=n.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[31]=r,e[32]=s,e[33]=i.slug,e[34]=k):k=e[34];let N;e[35]!==P||e[36]!==k?(N=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[P,k]}),e[35]=P,e[36]=k,e[37]=N):N=e[37];let R;e[38]!==I||e[39]!==N?(R=n.jsxs(Le,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:wa,children:[D,I,N]}),e[38]=I,e[39]=N,e[40]=R):R=e[40];let M;return e[41]!==R||e[42]!==v?(M=n.jsx(Me,{open:!0,onOpenChange:v,children:R}),e[41]=R,e[42]=v,e[43]=M):M=e[43],M}function va(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:n.jsx(Xe,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function wa(t){return t.preventDefault()}function ja(t){ne.error(`Top-up failed: ${t.message}`)}const Aa={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Ot(t){const e=L.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:Aa[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,d=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",l=r?"text-destructive":"text-amber-600 dark:text-amber-500",u=r?Ts:ps;let V;e[0]!==d?(V=z("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",d),e[0]=d,e[1]=V):V=e[1];let c;e[2]!==l?(c=z("mt-0.5 shrink-0",l),e[2]=l,e[3]=c):c=e[3];let m;e[4]!==u?(m=n.jsx(u,{size:16}),e[4]=u,e[5]=m):m=e[5];let p;e[6]!==c||e[7]!==m?(p=n.jsx("div",{className:c,children:m}),e[6]=c,e[7]=m,e[8]=p):p=e[8];let x;e[9]!==l?(x=z("text-xs mb-1 font-medium",l),e[9]=l,e[10]=x):x=e[10];let g;e[11]!==x||e[12]!==o?(g=n.jsx("div",{className:x,children:o}),e[11]=x,e[12]=o,e[13]=g):g=e[13];let f;e[14]!==a?(f=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=f):f=e[15];let b;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(b=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(J,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(J,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(J,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=r,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=b):b=e[19];let h;e[20]!==g||e[21]!==f||e[22]!==b?(h=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,f,b]}),e[20]=g,e[21]=f,e[22]=b,e[23]=h):h=e[23];let y;e[24]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(pt,{size:14}),e[24]=y):y=e[24];let A;e[25]!==i?(A=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:y}),e[25]=i,e[26]=A):A=e[26];let _;return e[27]!==V||e[28]!==A||e[29]!==p||e[30]!==h?(_=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:V,children:[p,h,A]})}),e[27]=V,e[28]=A,e[29]=p,e[30]=h,e[31]=_):_=e[31],_}function tn(){const t=L.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:d,addToolOutput:l,addToolApprovalResponse:u,sendMessage:V}=Dn(),[c,m]=Cn(),{virtualMcpId:p,createTaskWithMessage:x}=qi();let g,f,b,h;if(t[0]!==o){const N=o.at(-1);h=N?.role==="assistant"?N.parts.filter(Na):null,g=h?.filter(ka)?.length,f=N?.role==="assistant"?aa(N.parts):[],b=N?.role==="assistant"?sa(N.parts):[],t[0]=o,t[1]=g,t[2]=f,t[3]=b,t[4]=h}else g=t[1],f=t[2],b=t[3],h=t[4];const y=b;let A;t[5]!==e||t[6]!==V?(A=()=>{if(e){const R={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};V(R)}},t[5]=e,t[6]=V,t[7]=A):A=t[7];const _=A;let C;t[8]!==V?(C=()=>{V({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=V,t[9]=C):C=t[9];const S=C;let v;t[10]!==l?(v=(N,R)=>{l({tool:"user_ask",toolCallId:N.toolCallId,output:{response:R}})},t[10]=l,t[11]=v):v=t[11];const j=v;let E;t[12]!==x||t[13]!==c||t[14]!==m||t[15]!==p?(E=N=>{m({...c,toolApprovalLevel:"auto"}),x({virtualMcpId:p,message:{parts:[{type:"text",text:`Implement this plan:
545
+ Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,Po=["Break any topic into key sub-questions and define scope","Synthesize information from multiple angles and sources","Distinguish facts, expert consensus, and contested claims","Identify gaps, contradictions, and emerging patterns","Deliver structured summaries with actionable insights"];function Xn(t){const e=L.c(7),{onRecruit:s,isRecruiting:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a Web Researcher agent that conducts thorough, rigorous research on any topic and delivers structured, actionable insights."}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("p",{className:"text-sm font-medium text-foreground",children:"Capabilities"}),e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsxs("div",{className:"space-y-2",children:[o,n.jsx("ul",{className:"space-y-1.5",children:Po.map(Eo)})]}),e[2]=a):a=e[2];const d=i?"Setting up...":"Add Web Researcher";let l;return e[3]!==i||e[4]!==s||e[5]!==d?(l=n.jsxs("div",{className:"flex flex-col gap-6",children:[r,a,n.jsx(J,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:d})]}),e[3]=i,e[4]=s,e[5]=d,e[6]=l):l=e[6],l}function Eo(t){return n.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[n.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function Fd({open:t,onOpenChange:e,existingAgent:s}){const i=Jt(),r=Pn(),o=js(),[a,d]=w.useState(!1),l=xs.find(m=>m.id==="ai-research"),u=n.jsx(ws,{icon:l.icon,name:l.title,size:"sm"}),V=async()=>{if(s){e(!1),r(s.id);return}d(!0);try{const m=await o.create.mutateAsync({title:l.title,description:"Systematic research and information synthesis assistant",icon:l.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:To}});$("agent_recruit_confirmed",{template_id:"ai-research",agent_id:m.id}),e(!1),r(m.id)}catch(m){$("agent_recruit_failed",{template_id:"ai-research",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Researcher agent:",m)}finally{d(!1)}},c=`Add ${l.title}`;return i?n.jsx(Wt,{open:t,onOpenChange:e,children:n.jsxs(Gt,{className:"h-[70dvh]",children:[n.jsx(Qt,{className:"px-4 pt-4 pb-4 shrink-0",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ht,{className:"text-xl font-semibold",children:c})]})}),n.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:n.jsx(Xn,{onRecruit:V,isRecruiting:a})})]})}):n.jsx(Me,{open:t,onOpenChange:e,children:n.jsxs(Le,{className:"sm:max-w-[500px] p-8",children:[n.jsx(Fe,{className:"mb-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[u,n.jsx(Ue,{className:"text-xl font-semibold",children:c})]})}),n.jsx(Xn,{onRecruit:V,isRecruiting:a})]})})}function Do(t,e,s,i){const r=t.getQueriesData({queryKey:ve.tasksPrefix(e)});let o=null;for(const[,a]of r)if(a?.items)for(const d of a.items)d.virtual_mcp_id===s&&d.created_by===i&&(d.hidden||(!o||d.updated_at>o.updated_at)&&(o=d));return o}function Ud(t){const e=ct(),s=qt(),i=nr(),{locator:r}=ue(),o=fi({strict:!1}),a=pi({strict:!1}),{data:d}=Bt.useSession(),l=d?.user?.id;return async u=>{const V=l?Do(s,r,u,l):null;if(V)return e({to:"/$org/$taskId",params:{org:t,taskId:V.id},search:{virtualmcpid:u}}),{resumed:!0};const c=crypto.randomUUID(),m=u===a.virtualmcpid?sr(s,r,o.taskId??""):null;try{await i.create.mutateAsync({id:c,virtual_mcp_id:u,...m?{branch:m}:{}})}catch{}return e({to:"/$org/$taskId",params:{org:t,taskId:c},search:{virtualmcpid:u}}),{resumed:!1}}}function Mo(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Dt().min(1,"Required"):Dt();return dt(e)}function Lo(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Fn(t){const e=L.c(65),{prompt:s,setPrompt:i,onSubmit:r}=t,o=w.useId();let a;if(e[0]!==s){const T=s?Mo(s):dt({});a=Nn(T),e[0]=s,e[1]=a}else a=e[1];const l=a;let u;e[2]!==s?(u=s?Lo(s):{},e[2]=s,e[3]=u):u=e[3];let V;e[4]!==l||e[5]!==u?(V={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=V):V=e[6];const c=kn(V);let m;e[7]!==s?.arguments?(m=s?.arguments??[],e[7]=s?.arguments,e[8]=m):m=e[8];const p=m;let x;e[9]!==c||e[10]!==r||e[11]!==i?(x=async T=>{await r(T),i(null),c.reset()},e[9]=c,e[10]=r,e[11]=i,e[12]=x):x=e[12];const g=x;let f;e[13]!==c||e[14]!==i?(f=T=>{T||(c.reset(),i(null))},e[13]=c,e[14]=i,e[15]=f):f=e[15];const b=f;if(!s)return null;let h;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(h=s.title||Xt(s.name,Ge(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=h):h=e[19];let y;e[20]!==h?(y=n.jsx(Ue,{children:n.jsx("span",{className:"capitalize",children:h})}),e[20]=h,e[21]=y):y=e[21];let A;e[22]!==s.description?(A=s.description&&n.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=A):A=e[23];let _;e[24]!==A||e[25]!==y?(_=n.jsxs(Fe,{children:[y,A]}),e[24]=A,e[25]=y,e[26]=_):_=e[26];let C;e[27]!==c||e[28]!==g?(C=T=>{T.stopPropagation(),c.handleSubmit(g)(T)},e[27]=c,e[28]=g,e[29]=C):C=e[29];let S;if(e[30]!==p||e[31]!==c.control||e[32]!==c.formState.isSubmitting){let T;e[34]!==c.control||e[35]!==c.formState.isSubmitting?(T=F=>n.jsx(me,{control:c.control,name:F.name,render:O=>{const{field:q}=O;return n.jsxs(fe,{children:[n.jsxs(Ne,{className:"text-xs",children:[F.name,F.required?null:n.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),n.jsx(pe,{children:n.jsx(_e,{...q,value:q.value??"",required:F.required,placeholder:F.description??"",className:"h-9",disabled:c.formState.isSubmitting})}),n.jsx(he,{})]})}},F.name),e[34]=c.control,e[35]=c.formState.isSubmitting,e[36]=T):T=e[36],S=p.map(T),e[30]=p,e[31]=c.control,e[32]=c.formState.isSubmitting,e[33]=S}else S=e[33];let v;e[37]!==b?(v=()=>b(!1),e[37]=b,e[38]=v):v=e[38];let j;e[39]!==c.formState.isSubmitting||e[40]!==v?(j=n.jsx(J,{type:"button",variant:"ghost",onClick:v,disabled:c.formState.isSubmitting,children:"Cancel"}),e[39]=c.formState.isSubmitting,e[40]=v,e[41]=j):j=e[41];const E=!c.formState.isValid||c.formState.isSubmitting;let D;e[42]!==c.formState.isSubmitting?(D=c.formState.isSubmitting?n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx(Mt,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=c.formState.isSubmitting,e[43]=D):D=e[43];let I;e[44]!==o||e[45]!==E||e[46]!==D?(I=n.jsx(J,{type:"submit",form:o,disabled:E,children:D}),e[44]=o,e[45]=E,e[46]=D,e[47]=I):I=e[47];let P;e[48]!==j||e[49]!==I?(P=n.jsxs(gs,{children:[j,I]}),e[48]=j,e[49]=I,e[50]=P):P=e[50];let k;e[51]!==o||e[52]!==C||e[53]!==S||e[54]!==P?(k=n.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:C,children:[S,P]}),e[51]=o,e[52]=C,e[53]=S,e[54]=P,e[55]=k):k=e[55];let N;e[56]!==c||e[57]!==k?(N=n.jsx(jt,{...c,children:k}),e[56]=c,e[57]=k,e[58]=N):N=e[58];let R;e[59]!==_||e[60]!==N?(R=n.jsxs(Le,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[_,N]}),e[59]=_,e[60]=N,e[61]=R):R=e[61];let M;return e[62]!==b||e[63]!==R?(M=n.jsx(Me,{open:!0,onOpenChange:b,children:R}),e[62]=b,e[63]=R,e[64]=M):M=e[64],M}function Fo(t){return!t||!t.content||t.content.length===0?!0:t.content.every(e=>e.type==="paragraph"?!e.content||e.content.length===0?!0:e.content.every(s=>s.type==="hardBreak"||s.type==="text"&&(!s.text||s.text.trim()==="")):!1)}function Uo(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Zn=3,zs="inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-muted text-muted-foreground text-sm font-medium transition-colors cursor-pointer",Oo="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Bs(t){const e=L.c(46),{item:s,onSelect:i,isLoading:r,isDisabled:o,variant:a}=t,d=a===void 0?"pill":a,{prompt:l}=s;let u;if(e[0]!==l._meta||e[1]!==l.name||e[2]!==l.title){const S=Ge(l._meta);u=l.title??Xt(l.name,S),e[0]=l._meta,e[1]=l.name,e[2]=l.title,e[3]=u}else u=e[3];const V=u,c=l.description||null;if(d==="card"){let S;e[4]!==i||e[5]!==l?(S=()=>i(l),e[4]=i,e[5]=l,e[6]=S):S=e[6];const v=o||r,j=r&&"bg-accent/40",E=(o||r)&&"cursor-not-allowed opacity-50";let D;e[7]!==j||e[8]!==E?(D=z(Oo,"hover:bg-accent/60 text-foreground",j,E),e[7]=j,e[8]=E,e[9]=D):D=e[9];let I;e[10]!==V?(I=n.jsx("span",{className:"font-medium truncate capitalize",children:V}),e[10]=V,e[11]=I):I=e[11];let P;e[12]!==r?(P=r&&n.jsx(Mt,{size:"xs"}),e[12]=r,e[13]=P):P=e[13];let k;e[14]!==I||e[15]!==P?(k=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[I,P]}),e[14]=I,e[15]=P,e[16]=k):k=e[16];let N;e[17]!==c?(N=c&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:c}),e[17]=c,e[18]=N):N=e[18];let R;return e[19]!==k||e[20]!==N||e[21]!==S||e[22]!==v||e[23]!==D?(R=n.jsxs("button",{type:"button",onClick:S,disabled:v,className:D,children:[k,N]}),e[19]=k,e[20]=N,e[21]=S,e[22]=v,e[23]=D,e[24]=R):R=e[24],R}let m;e[25]!==i||e[26]!==l?(m=()=>i(l),e[25]=i,e[26]=l,e[27]=m):m=e[27];const p=o||r,x=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let f;e[28]!==x||e[29]!==g?(f=z(zs,"hover:bg-muted/70 hover:text-foreground",x,g),e[28]=x,e[29]=g,e[30]=f):f=e[30];let b;e[31]!==V?(b=n.jsx("span",{className:"capitalize",children:V}),e[31]=V,e[32]=b):b=e[32];let h;e[33]!==r?(h=r&&n.jsx(Mt,{size:"xs"}),e[33]=r,e[34]=h):h=e[34];let y;e[35]!==m||e[36]!==p||e[37]!==f||e[38]!==b||e[39]!==h?(y=n.jsx(bt,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:m,disabled:p,className:f,children:[b,h]})}),e[35]=m,e[36]=p,e[37]=f,e[38]=b,e[39]=h,e[40]=y):y=e[40];const A=c??V;let _;e[41]!==A?(_=n.jsx(yt,{side:"top",className:"max-w-xs",children:n.jsx("p",{className:"text-xs",children:A})}),e[41]=A,e[42]=_):_=e[42];let C;return e[43]!==y||e[44]!==_?(C=n.jsxs(xt,{delayDuration:400,children:[y,_]}),e[43]=y,e[44]=_,e[45]=C):C=e[45],C}function $o(t){const e=L.c(41),{items:s,open:i,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[d,l]=w.useState(""),u=!!a;let V;e[0]!==s||e[1]!==d?(V=d.trim()?s.filter(v=>{const j=d.toLowerCase();return v.prompt.name.toLowerCase().includes(j)||(v.prompt.title??"").toLowerCase().includes(j)||(v.prompt.description??"").toLowerCase().includes(j)}):s,e[0]=s,e[1]=d,e[2]=V):V=e[2];const c=V,m=Jt();let p;e[3]!==c.length||e[4]!==d?(p=c.length===0&&n.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",d,"”"]}),e[3]=c.length,e[4]=d,e[5]=p):p=e[5];let x;if(e[6]!==c||e[7]!==u||e[8]!==a?.name||e[9]!==r||e[10]!==o){let v;e[12]!==u||e[13]!==a?.name||e[14]!==r||e[15]!==o?(v=j=>n.jsx(Bs,{item:j,variant:"card",onSelect:E=>{r(!1),o(E)},isLoading:a?.name===j.prompt.name,isDisabled:u&&a?.name!==j.prompt.name},j.prompt.name),e[12]=u,e[13]=a?.name,e[14]=r,e[15]=o,e[16]=v):v=e[16],x=c.map(v),e[6]=c,e[7]=u,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=x}else x=e[11];let g;e[17]!==p||e[18]!==x?(g=n.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:n.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[p,x]})}),e[17]=p,e[18]=x,e[19]=g):g=e[19];const f=g;let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=v=>{v.key==="Escape"&&l("")},e[20]=b):b=e[20];let h;e[21]!==d?(h=n.jsx(As,{value:d,onChange:l,placeholder:"Search prompts...",onKeyDown:b}),e[21]=d,e[22]=h):h=e[22];const y=h;if(m){let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx(Qt,{className:"sr-only",children:n.jsx(Ht,{children:"All prompts"})}),e[23]=v):v=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=j):j=e[24];let E;e[25]!==f||e[26]!==y?(E=n.jsxs(Gt,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[v,j,y,f]}),e[25]=f,e[26]=y,e[27]=E):E=e[27];let D;return e[28]!==r||e[29]!==i||e[30]!==E?(D=n.jsx(xn,{delayDuration:400,children:n.jsx(Wt,{open:i,onOpenChange:r,children:E})}),e[28]=r,e[29]=i,e[30]=E,e[31]=D):D=e[31],D}let A;e[32]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx(Fe,{className:"sr-only",children:n.jsx(Ue,{children:"All prompts"})}),e[32]=A):A=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:n.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=_):_=e[33];let C;e[34]!==f||e[35]!==y?(C=n.jsxs(Le,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[A,_,y,f]}),e[34]=f,e[35]=y,e[36]=C):C=e[36];let S;return e[37]!==r||e[38]!==i||e[39]!==C?(S=n.jsx(xn,{delayDuration:400,children:n.jsx(Me,{open:i,onOpenChange:r,children:C})}),e[37]=r,e[38]=i,e[39]=C,e[40]=S):S=e[40],S}function zo(t){const e=L.c(29),{items:s,onSelect:i,loadingPrompt:r,className:o}=t,[a,d]=w.useState(!1);if(s.length===0)return null;let l,u,V;if(e[0]!==s||e[1]!==r||e[2]!==i){const b=s.slice(0,Zn);let h;e[6]!==s?(h=s.slice(Zn),e[6]=s,e[7]=h):h=e[7],l=h,u=!!r;let y;e[8]!==u||e[9]!==r?.name||e[10]!==i?(y=A=>n.jsx(Bs,{item:A,onSelect:i,isLoading:r?.name===A.prompt.name,isDisabled:u&&r?.name!==A.prompt.name},A.prompt.name),e[8]=u,e[9]=r?.name,e[10]=i,e[11]=y):y=e[11],V=b.map(y),e[0]=s,e[1]=r,e[2]=i,e[3]=l,e[4]=u,e[5]=V}else l=e[3],u=e[4],V=e[5];const c=V;let m;e[12]!==o?(m=z("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let p;e[14]!==l.length||e[15]!==u?(p=l.length>0&&n.jsxs("button",{type:"button",disabled:u,onClick:()=>d(!0),className:z(zs,"hover:bg-muted/70 hover:text-foreground",u&&"opacity-50 cursor-not-allowed"),children:["+",l.length," more"]}),e[14]=l.length,e[15]=u,e[16]=p):p=e[16];let x;e[17]!==c||e[18]!==m||e[19]!==p?(x=n.jsxs("div",{className:m,children:[c,p]}),e[17]=c,e[18]=m,e[19]=p,e[20]=x):x=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==i?(g=n.jsx($o,{items:s,open:a,onOpenChange:d,onSelect:i,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=i,e[25]=g):g=e[25];let f;return e[26]!==x||e[27]!==g?(f=n.jsxs(xn,{delayDuration:400,children:[x,g]}),e[26]=x,e[27]=g,e[28]=f):f=e[28],f}function Bo(){return null}function qo(t,e){switch(e.type){case"SELECT_PROMPT":return!e.prompt.arguments||e.prompt.arguments.length===0?{stage:"loading",prompt:e.prompt}:{stage:"idle"};case"START_LOADING":return{stage:"loading",prompt:e.prompt,arguments:e.arguments};case"RESET":return{stage:"idle"};default:return t}}function Ko(t){const e=L.c(31),{connectionId:s}=t,{sendMessage:i}=Dn(),{tiptapDocRef:r}=Yt(),{org:o}=ue();let a;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(a={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=a):a=e[3];const d=qe(a);let l;e[4]!==d?(l={client:d,staleTime:6e4},e[4]=d,e[5]=l):l=e[5];const{data:u}=vr(l);let V;e[6]!==u?.prompts?(V=u?.prompts??[],e[6]=u?.prompts,e[7]=V):V=e[7];const c=V;let m;e[8]!==c?(m=c.map(Yo),e[8]=c,e[9]=m):m=e[9];const p=m;let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x={stage:"idle"},e[10]=x):x=e[10];const[g,f]=w.useReducer(qo,x),[b,h]=w.useState(null);let y;e[11]!==d||e[12]!==i||e[13]!==r?(y=async(k,N)=>{if(!d){ne.error("MCP client not available"),f({type:"RESET"});return}try{const R=await Ln(d,k.name,N);f({type:"RESET"});const M=Uo(r.current,{type:"paragraph",content:[rr({id:k.name,name:Mn(k.name,Ge(k._meta)),metadata:R.messages,char:"/"})]});await i(M)}catch(R){console.error("[ice-breakers] Failed to fetch prompt:",R),ne.error("Failed to load prompt. Please try again."),f({type:"RESET"})}},e[11]=d,e[12]=i,e[13]=r,e[14]=y):y=e[14];const A=y;let _;e[15]!==A?(_=async k=>{if(k.arguments&&k.arguments.length>0){f({type:"SELECT_PROMPT",prompt:k}),h(k);return}f({type:"START_LOADING",prompt:k}),await A(k)},e[15]=A,e[16]=_):_=e[16];const C=_;let S;e[17]!==b||e[18]!==A?(S=async k=>{b&&(f({type:"START_LOADING",prompt:b,arguments:k}),h(null),await A(b,k))},e[17]=b,e[18]=A,e[19]=S):S=e[19];const v=S;if(p.length===0)return null;const j=g.stage==="loading"?g.prompt:null;let E;e[20]!==C||e[21]!==p||e[22]!==j?(E=n.jsx(zo,{items:p,onSelect:C,loadingPrompt:j}),e[20]=C,e[21]=p,e[22]=j,e[23]=E):E=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{h(null),f({type:"RESET"})},e[24]=D):D=e[24];let I;e[25]!==b||e[26]!==v?(I=n.jsx(Fn,{prompt:b,setPrompt:D,onSubmit:v}),e[25]=b,e[26]=v,e[27]=I):I=e[27];let P;return e[28]!==E||e[29]!==I?(P=n.jsxs(n.Fragment,{children:[E,I]}),e[28]=E,e[29]=I,e[30]=P):P=e[30],P}function Yo(t){return{prompt:t}}function Wo(t){const e=L.c(13),{className:s}=t,{selectedVirtualMcp:i}=Yt(),{org:r}=ue();let o;e[0]!==r.id?(o=Tn(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,d=i?.id??a;let l;e[2]!==s?(l=z("w-full @container",s),e[2]=s,e[3]=l):l=e[3];const u=d??"default";let V;e[4]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Bo,{}),e[4]=V):V=e[4];let c;e[5]!==d?(c=n.jsx(Ko,{connectionId:d}),e[5]=d,e[6]=c):c=e[6];let m;e[7]!==u||e[8]!==c?(m=n.jsx(hi,{fallback:null,children:n.jsx(w.Suspense,{fallback:V,children:c},u)}),e[7]=u,e[8]=c,e[9]=m):m=e[9];let p;return e[10]!==l||e[11]!==m?(p=n.jsx("div",{className:l,children:m}),e[10]=l,e[11]=m,e[12]=p):p=e[12],p}function qs(t){const e=L.c(21),{current:s,total:i,onPrev:r,onNext:o}=t;if(i<=1)return null;const a=s===0,d=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let l;e[0]!==d?(l=z("p-0.5 rounded transition-colors",d),e[0]=d,e[1]=l):l=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(Rr,{size:14}),e[2]=u):u=e[2];let V;e[3]!==r||e[4]!==a||e[5]!==l?(V=n.jsx("button",{type:"button",onClick:r,disabled:a,className:l,"aria-label":"Previous question",children:u}),e[3]=r,e[4]=a,e[5]=l,e[6]=V):V=e[6];const c=s+1;let m;e[7]!==c||e[8]!==i?(m=n.jsxs("span",{className:"tabular-nums text-xs",children:[c," of ",i]}),e[7]=c,e[8]=i,e[9]=m):m=e[9];const p=s===i-1,x=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==x?(g=z("p-0.5 rounded transition-colors",x),e[10]=x,e[11]=g):g=e[11];let f;e[12]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(Rs,{size:14}),e[12]=f):f=e[12];let b;e[13]!==o||e[14]!==g||e[15]!==p?(b=n.jsx("button",{type:"button",onClick:o,disabled:p,className:g,"aria-label":"Next question",children:f}),e[13]=o,e[14]=g,e[15]=p,e[16]=b):b=e[16];let h;return e[17]!==b||e[18]!==V||e[19]!==m?(h=n.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[V,m,b]}),e[17]=b,e[18]=V,e[19]=m,e[20]=h):h=e[20],h}function Ut(t){const e=L.c(18),{title:s,children:i,footerLeft:r,footerRight:o,className:a}=t,d=a??"border-border";let l;e[0]!==d?(l=z("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",d),e[0]=d,e[1]=l):l=e[1];let u;e[2]!==s?(u=n.jsx("div",{className:"flex items-center gap-2 p-4",children:n.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=u):u=e[3];let V;e[4]!==i?(V=n.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=V):V=e[5];let c;e[6]!==r?(c=n.jsx("div",{children:r}),e[6]=r,e[7]=c):c=e[7];let m;e[8]!==o?(m=n.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=n.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[c,m]})}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let x;return e[13]!==l||e[14]!==u||e[15]!==V||e[16]!==p?(x=n.jsxs("div",{className:l,children:[u,V,p]}),e[13]=l,e[14]=u,e[15]=V,e[16]=p,e[17]=x):x=e[17],x}const Go="User denied this tool call, give other alternatives.",Qo=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function Ho(t){const e=L.c(9),{onYolo:s}=t,[i,r]=Cn();let o;e[0]!==s||e[1]!==i||e[2]!==r?(o=V=>{const c=V;r({...i,toolApprovalLevel:c}),c==="auto"&&s()},e[0]=s,e[1]=i,e[2]=r,e[3]=o):o=e[3];const a=o;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(Es,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:Xo,children:n.jsx(Ds,{})}),e[4]=d):d=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(Ms,{children:Qo.map(Jo)}),e[5]=l):l=e[5];let u;return e[6]!==a||e[7]!==i.toolApprovalLevel?(u=n.jsxs(Ps,{value:i.toolApprovalLevel,onValueChange:a,children:[d,l]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=u):u=e[8],u}function Jo(t){return n.jsx(ot,{value:t.value,children:t.label},t.value)}function Xo(t){return t.stopPropagation()}function Zo(t){const e=L.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let i;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],i=o}catch{i=String(s)}let r;return e[3]!==i?(r=n.jsx("div",{className:"px-4",children:n.jsx("pre",{className:"text-xs font-mono text-muted-foreground/70 whitespace-pre-wrap wrap-break-word max-h-32 overflow-y-auto rounded-md bg-muted/30 px-3 py-2",children:i})}),e[3]=i,e[4]=r):r=e[4],r}function ea(t){const e=L.c(42),{approvals:s,onRespond:i}=t,[r,o]=w.useState(0),a=Math.min(r,s.length-1),d=s[a];if(!d)return null;let l;e[0]!==d.approvalId||e[1]!==i?(l=()=>{i(d.approvalId,!1,Go)},e[0]=d.approvalId,e[1]=i,e[2]=l):l=e[2];const u=l;let V;e[3]!==d.approvalId||e[4]!==i?(V=()=>{i(d.approvalId,!0)},e[3]=d.approvalId,e[4]=i,e[5]=V):V=e[5];const c=V;let m;e[6]!==s||e[7]!==i?(m=()=>{for(const P of s)i(P.approvalId,!0)},e[6]=s,e[7]=i,e[8]=m):m=e[8];const p=m;let x;e[9]!==a?(x=()=>{a>0&&o(a-1)},e[9]=a,e[10]=x):x=e[10];const g=x;let f;e[11]!==s.length||e[12]!==a?(f=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=f):f=e[13];const b=f;let h;e[14]!==p?(h=n.jsx(Ho,{onYolo:p}),e[14]=p,e[15]=h):h=e[15];let y;e[16]!==s.length||e[17]!==b||e[18]!==g||e[19]!==a?(y=n.jsx(qs,{current:a,total:s.length,onPrev:g,onNext:b}),e[16]=s.length,e[17]=b,e[18]=g,e[19]=a,e[20]=y):y=e[20];let A;e[21]!==h||e[22]!==y?(A=n.jsxs("div",{className:"flex items-center gap-2",children:[h,y]}),e[21]=h,e[22]=y,e[23]=A):A=e[23];const _=A;let C;e[24]!==u?(C=n.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:u,children:"Deny"}),e[24]=u,e[25]=C):C=e[25];let S;e[26]!==s.length||e[27]!==p?(S=s.length>1&&n.jsx(J,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:p,children:"Accept All"}),e[26]=s.length,e[27]=p,e[28]=S):S=e[28];let v;e[29]!==c?(v=n.jsx(J,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:c,children:"Accept"}),e[29]=c,e[30]=v):v=e[30];let j;e[31]!==S||e[32]!==v||e[33]!==C?(j=n.jsxs(n.Fragment,{children:[C,S,v]}),e[31]=S,e[32]=v,e[33]=C,e[34]=j):j=e[34];const E=j;let D;e[35]!==d.input?(D=n.jsx(Zo,{input:d.input}),e[35]=d.input,e[36]=D):D=e[36];let I;return e[37]!==d.friendlyName||e[38]!==_||e[39]!==E||e[40]!==D?(I=n.jsx(Ut,{title:d.friendlyName,footerLeft:_,footerRight:E,children:D}),e[37]=d.friendlyName,e[38]=_,e[39]=E,e[40]=D,e[41]=I):I=e[41],I}function ta(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Li,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function na(t){const e=L.c(4),{approvals:s,isStreaming:i,onRespond:r}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(ta,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==r?(o=n.jsx(ea,{approvals:s,onRespond:r}),e[1]=s,e[2]=r,e[3]=o):o=e[3],o}function sa(t){const e=[];for(const s of t)if("state"in s&&s.state==="approval-requested"&&"approval"in s&&s.approval?.id&&"toolCallId"in s&&s.toolCallId){const i="toolName"in s&&typeof s.toolName=="string"?s.toolName:s.type.startsWith("tool-")?s.type.replace("tool-",""):"Tool";e.push({approvalId:s.approval.id,toolCallId:s.toolCallId,toolName:i,friendlyName:or(ar(i)),input:s.input})}return e}function ia(t){const e=L.c(15),{plan:s,onApprove:i,onDismiss:r}=t;let o;e[0]!==i||e[1]!==s.plan?(o=()=>{i(s.plan)},e[0]=i,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let d;e[3]!==r?(d=n.jsx(J,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=d):d=e[4];let l;e[5]!==a?(l=n.jsx(J,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs bg-purple-600 hover:bg-purple-700 text-white active:scale-[0.97] transition-transform",onClick:a,children:"Let's go"}),e[5]=a,e[6]=l):l=e[6];let u;e[7]!==d||e[8]!==l?(u=n.jsxs(n.Fragment,{children:[d,l]}),e[7]=d,e[8]=l,e[9]=u):u=e[9];const V=u;let c;e[10]!==s.plan?(c=n.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:n.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:n.jsx(lr,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=c):c=e[11];let m;return e[12]!==V||e[13]!==c?(m=n.jsx(Ut,{title:"Implementation Plan",footerRight:V,className:"border-dashed border-purple-500",children:c}),e[12]=V,e[13]=c,e[14]=m):m=e[14],m}function ra(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed border-purple-500/30 rounded-lg bg-purple-500/5 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(Xe,{className:"size-5 text-purple-500 shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function oa(t){const e=L.c(7),{plans:s,isStreaming:i,onApprove:r,onDismiss:o}=t;if(i&&s.length===0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(ra,{}),e[0]=u):u=e[0],u}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const d=a;if(!d)return null;let l;return e[3]!==d||e[4]!==r||e[5]!==o?(l=n.jsx(ia,{plan:d,onApprove:r,onDismiss:o}),e[3]=d,e[4]=r,e[5]=o,e[6]=l):l=e[6],l}function aa(t){const e=[];for(const s of t)if("type"in s&&s.type==="tool-propose_plan"&&"state"in s&&s.state==="input-available"&&"toolCallId"in s&&"input"in s){const i=s.input;e.push({toolCallId:s.toolCallId,plan:i.plan,state:s.state})}return e}const es=dt({response:Dt().min(1,"Response is required")}),la=dt({response:Dt().min(1,"Please select or enter an option")}),ca=dt({response:gi(["yes","no"])});function da(t){switch(t.type){case"text":return es;case"choice":return la;case"confirm":return ca;default:return es}}function ua(t){const e={};for(const s of t)e[s.toolCallId]=da(s.input);return dt(e)}function Va(t){const e=L.c(6),{control:s,name:i,placeholder:r}=t;let o;e[0]!==r?(o=d=>{const{field:l}=d;return n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsx("div",{className:"px-2",children:n.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(bs,{size:16,className:"text-muted-foreground"})}),n.jsx("input",{...l,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),n.jsx(he,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=n.jsx(me,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Ks(t,e){const s=L.c(4);let i,r;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const d=a.target.tagName;if(d==="INPUT"||d==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const l=Number.parseInt(a.key,10);l>=1&&l<=t&&(a.preventDefault(),e(l-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},r=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=r):(i=s[2],r=s[3]),w.useEffect(i,r)}function ma(t){const e=L.c(9),{control:s,name:i,options:r}=t,[o,a]=w.useState(!1),d=w.useRef(null),l=w.useRef(null);let u;if(e[0]!==r?(u=m=>{l.current?.onChange(r[m]??""),a(!1)},e[0]=r,e[1]=u):u=e[1],Ks(r.length,u),r.length===0)return null;let V;e[2]!==o||e[3]!==r?(V=m=>{const{field:p}=m;l.current=p;const x=o||!!p.value&&!r.includes(p.value);return n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[r.map((g,f)=>{const b=p.value===g;return n.jsxs("button",{type:"button",onClick:()=>{p.onChange(g??""),a(!1)},className:z("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",b&&"bg-accent/50",!b&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[n.jsx("span",{className:z("flex items-center justify-center size-6 rounded-md text-sm shrink-0",b?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f+1}),n.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${f}-${g}`)}),n.jsxs("div",{className:z("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x&&"bg-accent/50",!x&&"hover:bg-accent/30"),onClick:()=>{a(!0),r.includes(p.value)&&p.onChange(""),setTimeout(()=>d.current?.focus(),0)},children:[n.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:n.jsx(bs,{size:16,className:"text-muted-foreground"})}),x?n.jsx("input",{ref:d,type:"text",value:p.value,onChange:g=>p.onChange(g.target.value),placeholder:"Something else...",autoFocus:!0,"aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}):n.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),n.jsx(he,{})]})},e[2]=o,e[3]=r,e[4]=V):V=e[4];let c;return e[5]!==s||e[6]!==i||e[7]!==V?(c=n.jsx(me,{control:s,name:i,render:V}),e[5]=s,e[6]=i,e[7]=V,e[8]=c):c=e[8],c}function fa(t){const e=L.c(6),{control:s,name:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=w.useRef(null);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=V=>{a.current?.onChange(o[V]??"")},e[1]=d):d=e[1],Ks(o.length,d);let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=V=>{const{field:c}=V;return a.current=c,n.jsxs(fe,{children:[n.jsx(pe,{children:n.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const p=c.value===m;return n.jsxs("button",{type:"button",onClick:()=>c.onChange(m),className:z("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[n.jsx("span",{className:z("flex items-center justify-center size-6 rounded-md text-sm shrink-0",p?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),n.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),n.jsx(he,{})]})},e[2]=l):l=e[2];let u;return e[3]!==s||e[4]!==i?(u=n.jsx(me,{control:s,name:i,render:l}),e[3]=s,e[4]=i,e[5]=u):u=e[5],u}function ts(t){const e=L.c(13),{input:s,control:i,name:r}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==r?(o=n.jsx(Va,{control:i,name:r,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=r,e[3]=o):o=e[3],o}case"choice":{let o;e[4]!==s.options?(o=s.options?.filter(Boolean)??[],e[4]=s.options,e[5]=o):o=e[5];const a=o;let d;return e[6]!==i||e[7]!==r||e[8]!==a?(d=n.jsx(ma,{control:i,name:r,options:a}),e[6]=i,e[7]=r,e[8]=a,e[9]=d):d=e[9],d}case"confirm":{let o;return e[10]!==i||e[11]!==r?(o=n.jsx(fa,{control:i,name:r}),e[10]=i,e[11]=r,e[12]=o):o=e[12],o}default:return null}}function pa({parts:t,onSubmit:e}){const[s,i]=w.useState(t[0]?.toolCallId??""),r=ua(t.map(h=>({toolCallId:h.toolCallId,input:h.input}))),o=kn({resolver:Nn(r),defaultValues:Object.fromEntries(t.map(h=>[h.toolCallId,{response:""}]))}),a=o.watch(),d=t.findIndex(h=>h.toolCallId===s),l=!!a[s]?.response,u=t.every(h=>!!a[h.toolCallId]?.response),V=h=>{for(const y of t){const A=h[y.toolCallId]?.response;A&&e(y,A)}},c=h=>t.find(y=>!h[y.toolCallId]?.response&&y.toolCallId!==s)??null,m=()=>{const h=o.getValues();if(t.every(A=>!!h[A.toolCallId]?.response))o.handleSubmit(V)();else{const A=c(h);A&&i(A.toolCallId)}},p=()=>{o.setValue(`${s}.response`,"user has skip this question"),m()},x=()=>{if(d>0){const h=t[d-1];h&&i(h.toolCallId)}},g=()=>{if(d<t.length-1){const h=t[d+1];h&&i(h.toolCallId)}},f=n.jsxs(n.Fragment,{children:[n.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),n.jsx(J,{type:"button",size:"sm",disabled:!l,onClick:m,className:z("h-7",l?"":"opacity-50"),children:u?"Submit":"Next"})]}),b=n.jsx(qs,{current:d,total:t.length,onPrev:x,onNext:g});if(t.length===1){const h=t[0];return h?.input?n.jsx(jt,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(V),autoComplete:"off",children:n.jsx(Ut,{title:h.input?.prompt??"Question",footerRight:f,children:n.jsx(ts,{input:h.input,control:o.control,name:`${h.toolCallId}.response`})})})}):null}return n.jsx(jt,{...o,children:n.jsx("form",{onSubmit:o.handleSubmit(V),autoComplete:"off",children:n.jsx(wr,{value:s,onValueChange:i,children:t.map(h=>n.jsx(jr,{value:h.toolCallId,className:"mt-0",children:n.jsx(Ut,{title:h.input?.prompt??"Question",footerLeft:b,footerRight:f,children:n.jsx(ts,{input:h.input,control:o.control,name:`${h.toolCallId}.response`})})},h.toolCallId))})})})}function ha(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[584px] mx-auto mb-2",children:[n.jsx(_r,{className:"size-5 text-muted-foreground shimmer"}),n.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Ys(t){const e=L.c(6),{userAskParts:s,isStreaming:i,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(ga),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx(ha,{}),e[2]=l):l=e[2],l}if(a.length===0)return null;let d;return e[3]!==r||e[4]!==a?(d=n.jsx(pa,{parts:a,onSubmit:r}),e[3]=r,e[4]=a,e[5]=d):d=e[5],d}function ga(t){return t.state==="input-available"}const ns=new Map;function Ws(){const{org:t}=ue(),e=qe({connectionId:kt,orgId:t.id,orgSlug:t.slug}),s=Tr(),i=s.find(f=>f.providerId==="deco"),{data:r,isLoading:o,refetch:a,isFetching:d}=In({queryKey:ve.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const f=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return f?.isError?null:f.structuredContent??null}}),l=r?.balanceCents??null,u=l!=null?l/100:null,V=w.useRef(new Map);if(l!=null){const f=ns.get(t.id);V.current.get(t.id)&&f!=null&&l>f&&$("credits_topped_up_detected",{organization_id:t.id,delta_cents:l-f,previous_balance_cents:f,new_balance_cents:l}),ns.set(t.id,l),V.current.set(t.id,!0)}const c=!!i,m=l!=null&&l>0,p=l!=null&&l===0,x=l!=null&&l===200,g=s.length>0&&s.every(f=>f.providerId==="deco");return{hasDecoKey:c,decoKeyId:i?.id??null,balanceCents:l,balanceDollars:u,hasCredits:m,isZeroBalance:p,isInitialFreeCredit:x,hasOnlyDecoProvider:g,isLoading:o,isFetching:d,refetch:a}}function xa(t){return t?t.message.startsWith("[CREDITS]"):!1}const ba={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]},ya=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Gs(t){const e=L.c(44),{onDismiss:s}=t,{org:i}=ue(),r=ct(),{decoKeyId:o}=Ws();let a;e[0]!==i.id||e[1]!==i.slug?(a={connectionId:kt,orgId:i.id,orgSlug:i.slug},e[0]=i.id,e[1]=i.slug,e[2]=a):a=e[2];const d=qe(a),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g,f;e[3]!==i.id?(g=()=>{$("credits_exhausted_shown",{organization_id:i.id})},f=[i.id],e[3]=i.id,e[4]=g,e[5]=f):(g=e[4],f=e[5]),w.useEffect(g,f);let b;e[6]!==d||e[7]!==m?(b=async T=>{const F=await d.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:T,currency:m}});if(F?.isError)throw new Error(F.content?.[0]?.text??"Failed to get top-up URL");return F.structuredContent?.url},e[6]=d,e[7]=m,e[8]=b):b=e[8];let h;e[9]!==s?(h=T=>{T&&window.open(T,"_blank","noopener,noreferrer"),s?.()},e[9]=s,e[10]=h):h=e[10];let y;e[11]!==b||e[12]!==h?(y={mutationFn:b,onSuccess:h,onError:ja},e[11]=b,e[12]=h,e[13]=y):y=e[13];const{mutate:A,isPending:_}=_n(y),C=parseFloat(l),S=!isNaN(C)&&C>=1;let v;e[14]!==s?(v=T=>!T&&s?.(),e[14]=s,e[15]=v):v=e[15];let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[16]=j):j=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[17]=E):E=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[E,n.jsxs(Fe,{className:"relative gap-4",children:[n.jsx("img",{src:"/logos/deco%20logo.svg",alt:"Deco AI Gateway",className:"size-9 rounded-lg object-contain dark:bg-white dark:p-0.5"}),n.jsxs("div",{children:[n.jsx(Ue,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),n.jsx(Kt,{className:"mt-1.5 text-sm leading-relaxed",children:"Your credits are used up. Add more to continue using AI across all your agents."})]})]})]}),e[18]=D):D=e[18];let I;e[19]!==m||e[20]!==x||e[21]!==l||e[22]!==C||e[23]!==o||e[24]!==S||e[25]!==_||e[26]!==V||e[27]!==A?(I=o&&n.jsxs("div",{className:"px-8 pt-5 pb-6",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(Ls,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:T=>{T&&p(T)},children:[n.jsx(Ft,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ft,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsxs("div",{className:"rounded-xl border border-border p-5",children:[n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:ba[m].map(T=>{const{dollars:F,label:O}=T;return n.jsxs("button",{type:"button",disabled:_,onClick:()=>{$("credits_topup_clicked",{amount_cents:F*100,currency:m,tier_label:O,source:"exhausted_banner"}),A(F*100)},className:z("relative flex flex-col items-center gap-1 py-5 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[x,F]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},F)})}),V?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:x}),n.jsx(_e,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:T=>u(T.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(J,{className:"h-10",disabled:!S||_,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(C*100),currency:m,tier_label:"custom",source:"exhausted_banner"}),A(Math.round(C*100))},children:_?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>c(!0),children:"Enter custom amount"})]}),n.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:ya.map(va)})]}),e[19]=m,e[20]=x,e[21]=l,e[22]=C,e[23]=o,e[24]=S,e[25]=_,e[26]=V,e[27]=A,e[28]=I):I=e[28];let P;e[29]!==s?(P=n.jsx(J,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[29]=s,e[30]=P):P=e[30];let k;e[31]!==r||e[32]!==s||e[33]!==i.slug?(k=n.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[31]=r,e[32]=s,e[33]=i.slug,e[34]=k):k=e[34];let N;e[35]!==P||e[36]!==k?(N=n.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[P,k]}),e[35]=P,e[36]=k,e[37]=N):N=e[37];let R;e[38]!==I||e[39]!==N?(R=n.jsxs(Le,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:wa,children:[D,I,N]}),e[38]=I,e[39]=N,e[40]=R):R=e[40];let M;return e[41]!==R||e[42]!==v?(M=n.jsx(Me,{open:!0,onOpenChange:v,children:R}),e[41]=R,e[42]=v,e[43]=M):M=e[43],M}function va(t){return n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:n.jsx(Xe,{size:12,className:"text-[hsl(var(--chart-1))]"})}),n.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function wa(t){return t.preventDefault()}function ja(t){ne.error(`Top-up failed: ${t.message}`)}const Aa={length:"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.","content-filter":"Response was filtered due to content policy.","tool-calls":"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working."};function Ot(t){const e=L.c(32),{variant:s,onDismiss:i}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?t.error.message:Aa[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,d=r?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",l=r?"text-destructive":"text-amber-600 dark:text-amber-500",u=r?Ts:ps;let V;e[0]!==d?(V=z("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",d),e[0]=d,e[1]=V):V=e[1];let c;e[2]!==l?(c=z("mt-0.5 shrink-0",l),e[2]=l,e[3]=c):c=e[3];let m;e[4]!==u?(m=n.jsx(u,{size:16}),e[4]=u,e[5]=m):m=e[5];let p;e[6]!==c||e[7]!==m?(p=n.jsx("div",{className:c,children:m}),e[6]=c,e[7]=m,e[8]=p):p=e[8];let x;e[9]!==l?(x=z("text-xs mb-1 font-medium",l),e[9]=l,e[10]=x):x=e[10];let g;e[11]!==x||e[12]!==o?(g=n.jsx("div",{className:x,children:o}),e[11]=x,e[12]=o,e[13]=g):g=e[13];let f;e[14]!==a?(f=n.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=f):f=e[15];let b;e[16]!==r||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(b=n.jsx("div",{className:"flex gap-2",children:r?n.jsxs(n.Fragment,{children:[n.jsx(J,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),n.jsx(J,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):n.jsx(J,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=r,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=b):b=e[19];let h;e[20]!==g||e[21]!==f||e[22]!==b?(h=n.jsxs("div",{className:"flex-1 min-w-0",children:[g,f,b]}),e[20]=g,e[21]=f,e[22]=b,e[23]=h):h=e[23];let y;e[24]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsx(pt,{size:14}),e[24]=y):y=e[24];let A;e[25]!==i?(A=n.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:y}),e[25]=i,e[26]=A):A=e[26];let _;return e[27]!==V||e[28]!==A||e[29]!==p||e[30]!==h?(_=n.jsx("div",{className:"px-0.5",children:n.jsxs("div",{className:V,children:[p,h,A]})}),e[27]=V,e[28]=A,e[29]=p,e[30]=h,e[31]=_):_=e[31],_}function tn(){const t=L.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:r,messages:o,isStreaming:a,isWaitingForApprovals:d,addToolOutput:l,addToolApprovalResponse:u,sendMessage:V}=Dn(),[c,m]=Cn(),{virtualMcpId:p,createTaskWithMessage:x}=qi();let g,f,b,h;if(t[0]!==o){const N=o.at(-1);h=N?.role==="assistant"?N.parts.filter(Na):null,g=h?.filter(ka)?.length,f=N?.role==="assistant"?aa(N.parts):[],b=N?.role==="assistant"?sa(N.parts):[],t[0]=o,t[1]=g,t[2]=f,t[3]=b,t[4]=h}else g=t[1],f=t[2],b=t[3],h=t[4];const y=b;let A;t[5]!==e||t[6]!==V?(A=()=>{if(e){const R={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};V(R)}},t[5]=e,t[6]=V,t[7]=A):A=t[7];const _=A;let C;t[8]!==V?(C=()=>{V({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=V,t[9]=C):C=t[9];const S=C;let v;t[10]!==l?(v=(N,R)=>{l({tool:"user_ask",toolCallId:N.toolCallId,output:{response:R}})},t[10]=l,t[11]=v):v=t[11];const j=v;let E;t[12]!==x||t[13]!==c||t[14]!==m||t[15]!==p?(E=N=>{m({...c,toolApprovalLevel:"auto"}),x({virtualMcpId:p,message:{parts:[{type:"text",text:`Implement this plan:
546
546
 
547
- ${N}`}]}})},t[12]=x,t[13]=c,t[14]=m,t[15]=p,t[16]=E):E=t[16];const D=E,I=Sa;let P;t[17]!==u?(P=(N,R,M)=>{u({id:N,approved:R,...M?{reason:M}:{}})},t[17]=u,t[18]=P):P=t[18];const k=P;if(g){let N;return t[19]!==j||t[20]!==a||t[21]!==h?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Ys,{userAskParts:h,isStreaming:a,onSubmit:j})}),t[19]=j,t[20]=a,t[21]=h,t[22]=N):N=t[22],N}if(f.length>0){let N;return t[23]!==D||t[24]!==a||t[25]!==f?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(oa,{plans:f,isStreaming:a,onApprove:D,onDismiss:I})}),t[23]=D,t[24]=a,t[25]=f,t[26]=N):N=t[26],N}if(y.length>0||a&&d){let N;return t[27]!==k||t[28]!==a||t[29]!==y?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(na,{approvals:y,isStreaming:a,onRespond:k})}),t[27]=k,t[28]=a,t[29]=y,t[30]=N):N=t[30],N}if(!a&&e){if(xa(e)){let R;return t[31]!==s?(R=n.jsx(Gs,{onDismiss:s}),t[31]=s,t[32]=R):R=t[32],R}let N;return t[33]!==s||t[34]!==e||t[35]!==_?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Ot,{variant:"error",error:e,onDismiss:s,onFixInChat:_})}),t[33]=s,t[34]=e,t[35]=_,t[36]=N):N=t[36],N}if(!a&&i&&i!=="stop"&&!d){let N;return t[37]!==r||t[38]!==i||t[39]!==S?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Ot,{variant:"warning",finishReason:i,onDismiss:r,onContinue:S})}),t[37]=r,t[38]=i,t[39]=S,t[40]=N):N=t[40],N}return null}function Sa(){document.querySelector("[data-chat-input]")?.focus()}function ka(t){return t.state!=="output-available"}function Na(t){return t.type==="tool-user_ask"}tn.Error=function(e){return n.jsx(Ot,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};tn.Warning=function(e){return n.jsx(Ot,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};tn.UserAskQuestion=Ys;async function Un(t,e,s,i,r){if(!en(e)){ne.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Dr(o,e)){const d=Fs(e),l=e?.title??"This model";r?r({fileName:s.name,modelName:l,accepted:d}):ne.error(`"${s.name}" can't be attached`,{description:`${l} accepts ${d}.`});return}const a=10*1024*1024;if(s.size>a){ne.error(`File "${s.name}" exceeds 10MB limit`);return}try{const d=new FileReader,l=new Promise((c,m)=>{d.onload=()=>{const p=d.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const x=p.includes(",")?p.split(",")[1]??p:p;c(x)},d.onerror=m});d.readAsDataURL(s);const u=await l,V={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:u};cr(t,{from:i,to:i},V)}catch(d){console.error("Failed to process file:",d),ne.error(`Failed to load file "${s.name}"`)}}function _a(t){const e=L.c(8),{editor:s,selectedModel:i,onUnsupportedFile:r}=t,o=w.useRef(Ia);let a,d;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{o.current=async(V,c)=>{await Un(s,i,V,c,r)}},d=[s,i,r],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),w.useEffect(a,d);let l,u;return e[5]!==s?(l=()=>{if(s?.isDestroyed)return;const V=new bn("fileDropHandler");s.state.plugins.find(p=>p.spec.key===V)&&s.unregisterPlugin(V);const m=new pr({key:V,props:{handleDrop:(p,x,g,f)=>{if(f)return!1;const b=x.dataTransfer?.files;if(!b||b.length===0)return!1;x.preventDefault();const h=p.posAtCoords({left:x.clientX,top:x.clientY});if(!h)return!1;const y=Array.from(b),A=h.pos;for(const _ of y)o.current?.(_,A);return!0},handlePaste:(p,x)=>{const g=x.clipboardData?.items;if(!g)return!1;const f=Array.from(g).filter(Ca);if(f.length===0)return!1;x.preventDefault();const{from:b}=p.state.selection;for(const h of f){const y=h.getAsFile();y&&o.current?.(y,b)}return!0}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(V)}},u=[s],e[5]=s,e[6]=l,e[7]=u):(l=e[6],u=e[7]),w.useEffect(l,u),null}function Ca(t){return t.kind==="file"}function Ia(){return Promise.resolve()}function Ra(t){const e=L.c(24),{selectedModel:s,isStreaming:i,icon:r,onUnsupportedFile:o}=t,{editor:a}=Zt(),d=w.useRef(null);let l;e[0]!==s?(l=en(s),e[0]=s,e[1]=l):l=e[1];const u=l;let V;e[2]!==a||e[3]!==o||e[4]!==s?(V=async _=>{const C=_.target.files;if(!C||C.length===0||!a)return;const S=Array.from(C),{from:v}=a.state.selection,j=v;for(const E of S)await Un(a,s,E,j,o);d.current&&(d.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=V):V=e[5];const c=V;if(!a||!u)return null;let m;e[6]!==s?(m=Er(s),e[6]=s,e[7]=m):m=e[7];let p;e[8]!==c||e[9]!==i||e[10]!==m?(p=n.jsx("input",{ref:d,type:"file",multiple:!0,accept:m,className:"hidden",onChange:c,disabled:i}),e[8]=c,e[9]=i,e[10]=m,e[11]=p):p=e[11];const x=i||!u;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>d.current?.click(),e[12]=g):g=e[12];let f;e[13]!==r?(f=r??n.jsx(ys,{size:16}),e[13]=r,e[14]=f):f=e[14];let b;e[15]!==x||e[16]!==f?(b=n.jsx(bt,{asChild:!0,children:n.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:x,onClick:g,children:f})}),e[15]=x,e[16]=f,e[17]=b):b=e[17];let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(yt,{side:"top",children:"Add file"}),e[18]=h):h=e[18];let y;e[19]!==b?(y=n.jsxs(xt,{children:[b,h]}),e[19]=b,e[20]=y):y=e[20];let A;return e[21]!==y||e[22]!==p?(A=n.jsxs(n.Fragment,{children:[p,y]}),e[21]=y,e[22]=p,e[23]=A):A=e[23],A}function Ta(t){const e=L.c(26),{info:s,onClose:i}=t,r=s!==null;let o;e[0]!==i?(o=_=>!_&&i(),e[0]=i,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=d):d=e[3];let l,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:n.jsx(ps,{size:18})}),u=n.jsx(Ue,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);const V=s?.fileName;let c;e[6]!==V?(c=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[d,n.jsxs(Fe,{className:"relative gap-4",children:[l,n.jsxs("div",{children:[u,n.jsxs(Kt,{className:"mt-1.5 text-sm leading-relaxed",children:[n.jsxs("span",{className:"font-medium text-foreground",children:["“",V,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=V,e[7]=c):c=e[7];const m=s?.modelName;let p;e[8]!==m?(p=n.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[m," accepts"]}),e[8]=m,e[9]=p):p=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ys,{size:14,className:"text-muted-foreground"}),e[10]=x):x=e[10];const g=s?.accepted;let f;e[11]!==g?(f=n.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[x,n.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=f):f=e[12];let b;e[13]!==p||e[14]!==f?(b=n.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:n.jsxs("div",{className:"rounded-xl border border-border p-4",children:[p,f]})}),e[13]=p,e[14]=f,e[15]=b):b=e[15];let h;e[16]!==i?(h=n.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:n.jsx(J,{onClick:i,children:"Got it"})}),e[16]=i,e[17]=h):h=e[17];let y;e[18]!==b||e[19]!==h||e[20]!==c?(y=n.jsxs(Le,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Pa,children:[c,b,h]}),e[18]=b,e[19]=h,e[20]=c,e[21]=y):y=e[21];let A;return e[22]!==r||e[23]!==y||e[24]!==o?(A=n.jsx(Me,{open:r,onOpenChange:o,children:y}),e[22]=r,e[23]=y,e[24]=o,e[25]=A):A=e[25],A}function Pa(t){return t.preventDefault()}function Ea(){const t=L.c(3),[e,s]=w.useState(null);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[0]=i):i=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:i},t[1]=e,t[2]=r):r=t[2],r}var Da=hr;var Ma=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],wn=Ma.join(","),Qs=typeof Element>"u",At=Qs?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,$t=!Qs&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},zt=function(e,s){var i;s===void 0&&(s=!0);var r=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):zt(e.parentNode));return a},La=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},Fa=function(e,s,i){if(zt(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(wn));return s&&At.call(e,wn)&&r.unshift(e),r=r.filter(i),r},jn=function(e,s,i){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!zt(a,!1))if(a.tagName==="SLOT"){var d=a.assignedElements(),l=d.length?d:a.children,u=jn(l,!0,i);i.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else{var V=At.call(a,wn);V&&i.filter(a)&&(s||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),m=!zt(c,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(c&&m){var p=jn(c===!0?a.children:c.children,!0,i);i.flatten?r.push.apply(r,p):r.push({scopeParent:a,candidates:p})}else o.unshift.apply(o,a.children)}}return r},Hs=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Js=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||La(e))&&!Hs(e)?0:e.tabIndex},Ua=function(e,s){var i=Js(e);return i<0&&s&&!Hs(e)?0:i},Oa=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Xs=function(e){return e.tagName==="INPUT"},$a=function(e){return Xs(e)&&e.type==="hidden"},za=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},Ba=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},qa=function(e){if(!e.name)return!0;var s=e.form||$t(e),i=function(d){return s.querySelectorAll('input[type="radio"][name="'+d+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=i(window.CSS.escape(e.name));else try{r=i(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=Ba(r,e.form);return!o||o===e},Ka=function(e){return Xs(e)&&e.type==="radio"},Ya=function(e){return Ka(e)&&!qa(e)},Wa=function(e){var s,i=e&&$t(e),r=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,d,l;for(o=!!((a=r)!==null&&a!==void 0&&(d=a.ownerDocument)!==null&&d!==void 0&&d.contains(r)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!o&&r;){var u,V,c;i=$t(r),r=(u=i)===null||u===void 0?void 0:u.host,o=!!((V=r)!==null&&V!==void 0&&(c=V.ownerDocument)!==null&&c!==void 0&&c.contains(r))}}return o},ss=function(e){var s=e.getBoundingClientRect(),i=s.width,r=s.height;return i===0&&r===0},Ga=function(e,s){var i=s.displayCheck,r=s.getShadowRoot;if(i==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=At.call(e,"details>summary:first-of-type"),d=a?e.parentElement:e;if(At.call(d,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof r=="function"){for(var l=e;e;){var u=e.parentElement,V=$t(e);if(u&&!u.shadowRoot&&r(u)===!0)return ss(e);e.assignedSlot?e=e.assignedSlot:!u&&V!==e.ownerDocument?e=V.host:e=u}e=l}if(Wa(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return ss(e);return!1},Qa=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var i=0;i<s.children.length;i++){var r=s.children.item(i);if(r.tagName==="LEGEND")return At.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},Ha=function(e,s){return!(s.disabled||$a(s)||Ga(s,e)||za(s)||Qa(s))},is=function(e,s){return!(Ya(s)||Js(s)<0||!Ha(e,s))},Ja=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Zs=function(e){var s=[],i=[];return e.forEach(function(r,o){var a=!!r.scopeParent,d=a?r.scopeParent:r,l=Ua(d,a),u=a?Zs(r.candidates):d;l===0?a?s.push.apply(s,u):s.push(d):i.push({documentOrder:o,tabIndex:l,item:r,isScope:a,content:u})}),i.sort(Oa).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},ei=function(e,s){s=s||{};var i;return s.getShadowRoot?i=jn([e],s.includeContainer,{filter:is.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:Ja}):i=Fa(e,s.includeContainer,is.bind(null,s)),Zs(i)};function Xa(){return/apple/i.test(navigator.vendor)}const rs="data-floating-ui-focusable";function Za(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function An(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&xi(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function ft(t){return"composedPath"in t?t.composedPath()[0]:t.target}function fn(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function el(t){return t.matches("html,body")}function St(t){return t?.ownerDocument||document}function tl(t){return t?t.hasAttribute(rs)?t:t.querySelector("["+rs+"]")||t:null}function Et(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...Et(t,r.id,s)])}function nl(t){return"nativeEvent"in t}var sl=typeof document<"u",il=function(){},Je=sl?w.useLayoutEffect:il;const rl={...hs},ol=rl.useInsertionEffect,al=ol||(t=>t());function at(t){const e=w.useRef(()=>{});return al(()=>{e.current=t}),w.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}const ti=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ni(t,e){const s=ei(t,ti()),i=s.length;if(i===0)return;const r=Za(St(t)),o=s.indexOf(r),a=o===-1?e===1?0:i-1:o+e;return s[a]}function ll(t){return ni(St(t).body,1)||t}function cl(t){return ni(St(t).body,-1)||t}function pn(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!An(s,i)}function dl(t){ei(t,ti()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function os(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const i=s.dataset.tabindex;delete s.dataset.tabindex,i?s.setAttribute("tabindex",i):s.removeAttribute("tabindex")})}const ul="data-floating-ui-focusable",as="active",ls="selected",Vl={...hs};let cs=!1,ml=0;const ds=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+ml++;function fl(){const[t,e]=w.useState(()=>cs?ds():void 0);return Je(()=>{t==null&&e(ds())},[]),w.useEffect(()=>{cs=!0},[]),t}const pl=Vl.useId,On=pl||fl;function hl(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var i;(i=t.get(e))==null||i.delete(s)}}}const gl=w.createContext(null),xl=w.createContext(null),si=()=>{var t;return((t=w.useContext(gl))==null?void 0:t.id)||null},ii=()=>w.useContext(xl);function $n(t){return"data-floating-ui-"+t}const bl={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},us=w.forwardRef(function(e,s){const[i,r]=w.useState();Je(()=>{Xa()&&r("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[$n("focus-guard")]:"",style:bl};return n.jsx("span",{...e,...o})}),yl={clipPath:"inset(50%)",position:"fixed",top:0,left:0},ri=w.createContext(null),Vs=$n("portal");function vl(t){t===void 0&&(t={});const{id:e,root:s}=t,i=On(),r=jl(),[o,a]=w.useState(null),d=w.useRef(null);return Je(()=>()=>{o?.remove(),queueMicrotask(()=>{d.current=null})},[o]),Je(()=>{if(!i||d.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=i,u.setAttribute(Vs,""),l.appendChild(u),d.current=u,a(u)},[e,i]),Je(()=>{if(s===null||!i||d.current)return;let l=s||r?.portalNode;l&&!Si(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const V=document.createElement("div");V.id=i,V.setAttribute(Vs,""),l=u||l,l.appendChild(V),d.current=V,a(V)},[e,s,i,r]),o}function wl(t){const{children:e,id:s,root:i,preserveTabOrder:r=!0}=t,o=vl({id:s,root:i}),[a,d]=w.useState(null),l=w.useRef(null),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=a?.modal,p=a?.open,x=!!a&&!a.modal&&a.open&&r&&!!(i||o);return w.useEffect(()=>{if(!o||!r||m)return;function g(f){o&&pn(f)&&(f.type==="focusin"?os:dl)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,m]),w.useEffect(()=>{o&&(p||os(o))},[p,o]),n.jsxs(ri.Provider,{value:w.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:V,afterInsideRef:c,portalNode:o,setFocusManagerState:d}),[r,o]),children:[x&&o&&n.jsx(us,{"data-type":"outside",ref:l,onFocus:g=>{if(pn(g,o)){var f;(f=V.current)==null||f.focus()}else{const b=a?a.domReference:null,h=cl(b);h?.focus()}}}),x&&o&&n.jsx("span",{"aria-owns":o.id,style:yl}),o&&yi.createPortal(e,o),x&&o&&n.jsx(us,{"data-type":"outside",ref:u,onFocus:g=>{if(pn(g,o)){var f;(f=c.current)==null||f.focus()}else{const b=a?a.domReference:null,h=ll(b);h?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const jl=()=>w.useContext(ri),Al={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Sl={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},ms=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function kl(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:d=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:V=!1,referencePressEvent:c="pointerdown",ancestorScroll:m=!1,bubbles:p,capture:x}=e,g=ii(),f=at(typeof l=="function"?l:()=>!1),b=typeof l=="function"?f:l,h=w.useRef(!1),{escapeKey:y,outsidePress:A}=ms(p),{escapeKey:_,outsidePress:C}=ms(x),S=w.useRef(!1),v=at(k=>{var N;if(!s||!a||!d||k.key!=="Escape"||S.current)return;const R=(N=o.current.floatingContext)==null?void 0:N.nodeId,M=g?Et(g.nodesRef.current,R):[];if(!y&&(k.stopPropagation(),M.length>0)){let T=!0;if(M.forEach(F=>{var O;if((O=F.context)!=null&&O.open&&!F.context.dataRef.current.__escapeKeyBubbles){T=!1;return}}),!T)return}i(!1,nl(k)?k.nativeEvent:k,"escape-key")}),j=at(k=>{var N;const R=()=>{var M;v(k),(M=ft(k))==null||M.removeEventListener("keydown",R)};(N=ft(k))==null||N.addEventListener("keydown",R)}),E=at(k=>{var N;const R=o.current.insideReactTree;o.current.insideReactTree=!1;const M=h.current;if(h.current=!1,u==="click"&&M||R||typeof b=="function"&&!b(k))return;const T=ft(k),F="["+$n("inert")+"]",O=St(r.floating).querySelectorAll(F);let q=De(T)?T:null;for(;q&&!ln(q);){const Q=wi(q);if(ln(Q)||!De(Q))break;q=Q}if(O.length&&De(T)&&!el(T)&&!An(T,r.floating)&&Array.from(O).every(Q=>!An(q,Q)))return;if(ji(T)&&P){const Q=ln(T),W=Ai(T),ie=/auto|scroll/,Y=Q||ie.test(W.overflowX),ee=Q||ie.test(W.overflowY),te=Y&&T.clientWidth>0&&T.scrollWidth>T.clientWidth,se=ee&&T.clientHeight>0&&T.scrollHeight>T.clientHeight,ae=W.direction==="rtl",re=se&&(ae?k.offsetX<=T.offsetWidth-T.clientWidth:k.offsetX>T.clientWidth),oe=te&&k.offsetY>T.clientHeight;if(re||oe)return}const K=(N=o.current.floatingContext)==null?void 0:N.nodeId,H=g&&Et(g.nodesRef.current,K).some(Q=>{var W;return fn(k,(W=Q.context)==null?void 0:W.elements.floating)});if(fn(k,r.floating)||fn(k,r.domReference)||H)return;const Z=g?Et(g.nodesRef.current,K):[];if(Z.length>0){let Q=!0;if(Z.forEach(W=>{var ie;if((ie=W.context)!=null&&ie.open&&!W.context.dataRef.current.__outsidePressBubbles){Q=!1;return}}),!Q)return}i(!1,k,"outside-press")}),D=at(k=>{var N;const R=()=>{var M;E(k),(M=ft(k))==null||M.removeEventListener(u,R)};(N=ft(k))==null||N.addEventListener(u,R)});w.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=y,o.current.__outsidePressBubbles=A;let k=-1;function N(O){i(!1,O,"ancestor-scroll")}function R(){window.clearTimeout(k),S.current=!0}function M(){k=window.setTimeout(()=>{S.current=!1},vi()?5:0)}const T=St(r.floating);d&&(T.addEventListener("keydown",_?j:v,_),T.addEventListener("compositionstart",R),T.addEventListener("compositionend",M)),b&&T.addEventListener(u,C?D:E,C);let F=[];return m&&(De(r.domReference)&&(F=an(r.domReference)),De(r.floating)&&(F=F.concat(an(r.floating))),!De(r.reference)&&r.reference&&r.reference.contextElement&&(F=F.concat(an(r.reference.contextElement)))),F=F.filter(O=>{var q;return O!==((q=T.defaultView)==null?void 0:q.visualViewport)}),F.forEach(O=>{O.addEventListener("scroll",N,{passive:!0})}),()=>{d&&(T.removeEventListener("keydown",_?j:v,_),T.removeEventListener("compositionstart",R),T.removeEventListener("compositionend",M)),b&&T.removeEventListener(u,C?D:E,C),F.forEach(O=>{O.removeEventListener("scroll",N)}),window.clearTimeout(k)}},[o,r,d,b,u,s,i,m,a,y,A,v,_,j,E,C,D]),w.useEffect(()=>{o.current.insideReactTree=!1},[o,b,u]);const I=w.useMemo(()=>({onKeyDown:v,...V&&{[Al[c]]:k=>{i(!1,k.nativeEvent,"reference-press")},...c!=="click"&&{onClick(k){i(!1,k.nativeEvent,"reference-press")}}}}),[v,i,V,c]),P=w.useMemo(()=>{function k(N){N.button===0&&(h.current=!0)}return{onKeyDown:v,onMouseDown:k,onMouseUp:k,[Sl[u]]:()=>{o.current.insideReactTree=!0}}},[v,u,o]);return w.useMemo(()=>a?{reference:I,floating:P}:{},[a,I,P])}function Nl(t){const{open:e=!1,onOpenChange:s,elements:i}=t,r=On(),o=w.useRef({}),[a]=w.useState(()=>hl()),d=si()!=null,[l,u]=w.useState(i.reference),V=at((p,x,g)=>{o.current.openEvent=p?x:void 0,a.emit("openchange",{open:p,event:x,reason:g,nested:d}),s?.(p,x,g)}),c=w.useMemo(()=>({setPositionReference:u}),[]),m=w.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return w.useMemo(()=>({dataRef:o,open:e,onOpenChange:V,elements:m,events:a,floatingId:r,refs:c}),[e,V,m,a,r,c])}function _l(t){t===void 0&&(t={});const{nodeId:e}=t,s=Nl({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,r=i.elements,[o,a]=w.useState(null),[d,l]=w.useState(null),V=r?.domReference||o,c=w.useRef(null),m=ii();Je(()=>{V&&(c.current=V)},[V]);const p=bi({...t,elements:{...r,...d&&{reference:d}}}),x=w.useCallback(y=>{const A=De(y)?{getBoundingClientRect:()=>y.getBoundingClientRect(),getClientRects:()=>y.getClientRects(),contextElement:y}:y;l(A),p.refs.setReference(A)},[p.refs]),g=w.useCallback(y=>{(De(y)||y===null)&&(c.current=y,a(y)),(De(p.refs.reference.current)||p.refs.reference.current===null||y!==null&&!De(y))&&p.refs.setReference(y)},[p.refs]),f=w.useMemo(()=>({...p.refs,setReference:g,setPositionReference:x,domReference:c}),[p.refs,g,x]),b=w.useMemo(()=>({...p.elements,domReference:V}),[p.elements,V]),h=w.useMemo(()=>({...p,...i,refs:f,elements:b,nodeId:e}),[p,f,b,e,i]);return Je(()=>{i.dataRef.current.floatingContext=h;const y=m?.nodesRef.current.find(A=>A.id===e);y&&(y.context=h)}),w.useMemo(()=>({...p,context:h,refs:f,elements:b}),[p,f,b,h])}function hn(t,e,s){const i=new Map,r=s==="item";let o=t;if(r&&t){const{[as]:a,[ls]:d,...l}=t;o=l}return{...s==="floating"&&{tabIndex:-1,[ul]:""},...o,...e.map(a=>{const d=a?a[s]:null;return typeof d=="function"?t?d(t):null:d}).concat(t).reduce((a,d)=>(d&&Object.entries(d).forEach(l=>{let[u,V]=l;if(!(r&&[as,ls].includes(u)))if(u.indexOf("on")===0){if(i.has(u)||i.set(u,[]),typeof V=="function"){var c;(c=i.get(u))==null||c.push(V),a[u]=function(){for(var m,p=arguments.length,x=new Array(p),g=0;g<p;g++)x[g]=arguments[g];return(m=i.get(u))==null?void 0:m.map(f=>f(...x)).find(f=>f!==void 0)}}}else a[u]=V}),a),{})}}function Cl(t){t===void 0&&(t=[]);const e=t.map(d=>d?.reference),s=t.map(d=>d?.floating),i=t.map(d=>d?.item),r=w.useCallback(d=>hn(d,t,"reference"),e),o=w.useCallback(d=>hn(d,t,"floating"),s),a=w.useCallback(d=>hn(d,t,"item"),i);return w.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const Il=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Rl(t,e){var s,i;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:d=!0,role:l="dialog"}=e,u=On(),V=((s=o.domReference)==null?void 0:s.id)||u,c=w.useMemo(()=>{var h;return((h=tl(o.floating))==null?void 0:h.id)||a},[o.floating,a]),m=(i=Il.get(l))!=null?i:l,x=si()!=null,g=w.useMemo(()=>m==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:r?c:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":r?c:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:V},...m==="menu"&&x&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,c,x,r,V,l]),f=w.useMemo(()=>{const h={id:c,...m&&{role:m}};return m==="tooltip"||l==="label"?h:{...h,...m==="menu"&&{"aria-labelledby":V}}},[m,c,V,l]),b=w.useCallback(h=>{let{active:y,selected:A}=h;const _={role:"option",...y&&{id:c+"-fui-option"}};switch(l){case"select":case"combobox":return{..._,"aria-selected":A}}return{}},[c,l]);return w.useMemo(()=>d?{reference:g,floating:f,item:b}:{},[d,g,f,b])}function Tl(t){const e=L.c(26),{editor:s,query:i,items:r,onSelect:o,onClose:a}=t,[d,l]=w.useState(0),u=w.useRef(r),V=w.useRef(d),c=w.useRef(o),m=w.useRef(a),p=w.useDeferredValue(i);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{l(0)},e[0]=x):x=e[0];let g;e[1]!==p?(g=[p],e[1]=p,e[2]=g):g=e[2],w.useEffect(x,g);let f,b;e[3]!==r.length||e[4]!==d?(f=()=>{d>=r.length&&r.length>0&&l(0)},b=[r.length,d],e[3]=r.length,e[4]=d,e[5]=f,e[6]=b):(f=e[5],b=e[6]),w.useEffect(f,b);let h,y;e[7]!==r?(h=()=>{u.current=r},y=[r],e[7]=r,e[8]=h,e[9]=y):(h=e[8],y=e[9]),w.useEffect(h,y);let A,_;e[10]!==d?(A=()=>{V.current=d},_=[d],e[10]=d,e[11]=A,e[12]=_):(A=e[11],_=e[12]),w.useEffect(A,_);let C,S;e[13]!==o?(S=()=>{c.current=o},C=[o],e[13]=o,e[14]=C,e[15]=S):(C=e[14],S=e[15]),w.useEffect(S,C);let v,j;e[16]!==a?(v=()=>{m.current=a},j=[a],e[16]=a,e[17]=v,e[18]=j):(v=e[17],j=e[18]),w.useEffect(v,j);let E;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(E=()=>{const k=s.view.dom;if(s?.isDestroyed||!k)return;const N=M=>{const T=u.current;if(!T.length)return!1;const F=()=>l(q=>(q+1)%T.length),O=()=>l(q=>(q-1+T.length)%T.length);switch(M.key){case"ArrowUp":return M.preventDefault(),O(),!0;case"ArrowDown":return M.preventDefault(),F(),!0;case"Tab":return M.preventDefault(),M.shiftKey?O():F(),!0;case"Home":return M.preventDefault(),l(0),!0;case"End":return M.preventDefault(),l(T.length-1),!0;case"Enter":{if(M.isComposing)return!1;M.preventDefault();const q=V.current;return q!==-1&&T[q]&&c.current?.(T[q],q),!0}case"Escape":return M.preventDefault(),m.current?.(),!0;default:return!1}},R=M=>{N(M)};return k.addEventListener("keydown",R,!0),()=>{k?.removeEventListener("keydown",R,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=E):E=e[21];let D;e[22]!==s?(D=[s],e[22]=s,e[23]=D):D=e[23],w.useEffect(E,D);const I=r.length?d:void 0;let P;return e[24]!==I?(P={selectedIndex:I,setSelectedIndex:l},e[24]=I,e[25]=P):P=e[25],P}function Pl(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const oi=w.createContext(void 0);function ai(){const t=w.useContext(oi);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function El({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:r}){const[o,a]=w.useReducer(Pl,{open:!1,element:null,query:"",range:null,selectedItem:null}),d=w.useRef(r);return d.current=r,w.useEffect(()=>{if(t?.isDestroyed)return;const l=s instanceof bn?s:new bn(s);t.state.plugins.find(c=>c.spec.key===l)&&t.unregisterPlugin(l);const V=Fr({pluginKey:l,editor:t,char:e,allow(c){const m=t.state.doc.resolve(c.range.from);for(let p=m.depth;p>0;p--)if(m.node(p).type.name==="image")return!1;return!(i&&!i(c))},command(){},render:()=>({onStart:c=>{a({type:"ON_START",payload:{element:c.decorationNode??null,query:c.query,range:c.range}}),d.current?.(!0)},onUpdate:c=>{a({type:"ON_UPDATE",payload:{element:c.decorationNode??null,query:c.query,range:c.range}})},onKeyDown:c=>c.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),d.current?.(!1)}}),items:()=>[]});return t.registerPlugin(V),()=>{t?.isDestroyed||t.unregisterPlugin(l)}},[t,s,e,a,i]),{state:o,dispatch:a}}function Dl({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:r,dispatch:o}=ai(),a=w.useDeferredValue(r.query),{data:d}=ki({queryKey:ve.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),l=()=>{o({type:"ON_EXIT"})},u=async(c,m)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:c});try{const{view:p}=t,g=p.state.selection.$to.nodeAfter?.text?.startsWith(" "),f=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(f.to+=1),await i({range:f,item:c})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):l()}catch{l()}}},{selectedIndex:V}=Tl({editor:t,query:a,items:d,onSelect:u,onClose:l});return{selectedItem:r.selectedItem,items:d,selectedIndex:V,close:l,onSelect:u}}function Ml({children:t}){const{state:e,dispatch:s}=ai(),{open:i,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:d,context:l}=_l({placement:"bottom-start",open:i,onOpenChange:m=>{m||o()},elements:{reference:r},middleware:[Ni(10),_i(),Ci()],whileElementsMounted:Ii}),u=kl(l,{outsidePress:m=>!(m.target instanceof Element&&m.target.closest(".ProseMirror"))}),V=Rl(l,{role:"listbox"}),{getFloatingProps:c}=Cl([u,V]);return i?n.jsx(wl,{children:n.jsx("div",{ref:a.setFloating,style:d,...c(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const Ll=t=>{const e=L.c(29),{item:s,isSelected:i,onSelect:r,isLoading:o,ref:a}=t;let d;if(e[0]!==s){const C=Ge(s._meta);d=s.title||Xt(s.name,C),e[0]=s,e[1]=d}else d=e[1];const l=d,u=s.description||null,V=s.icon,c=i&&"bg-accent text-accent-foreground",m=o&&"pointer-events-none opacity-50";let p;e[2]!==c||e[3]!==m?(p=z("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",c,m),e[2]=c,e[3]=m,e[4]=p):p=e[4];let x;e[5]!==V||e[6]!==l?(x=V!==void 0&&n.jsx(En,{icon:V,name:l,size:"xs",className:"mr-2"}),e[5]=V,e[6]=l,e[7]=x):x=e[7];let g;e[8]!==l?(g=n.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:l}),e[8]=l,e[9]=g):g=e[9];let f;e[10]!==o?(f=o&&n.jsx(Mt,{size:"xs"}),e[10]=o,e[11]=f):f=e[11];let b;e[12]!==g||e[13]!==f?(b=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,f]}),e[12]=g,e[13]=f,e[14]=b):b=e[14];let h;e[15]!==u?(h=u&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:u}),e[15]=u,e[16]=h):h=e[16];let y;e[17]!==b||e[18]!==h?(y=n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[b,h]}),e[17]=b,e[18]=h,e[19]=y):y=e[19];let A;e[20]!==s.drillable?(A=s.drillable&&n.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=A):A=e[21];let _;return e[22]!==r||e[23]!==a||e[24]!==y||e[25]!==A||e[26]!==p||e[27]!==x?(_=n.jsxs("div",{ref:a,onClick:r,className:p,children:[x,y,A]}),e[22]=r,e[23]=a,e[24]=y,e[25]=A,e[26]=p,e[27]=x,e[28]=_):_=e[28],_},Fl=t=>{const e=L.c(18),{editor:s,queryKey:i,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==i?(a={editor:s,queryKey:i,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a):a=e[4];const{items:d,selectedIndex:l,onSelect:u,selectedItem:V}=Dl(a);if(!d.length){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=x):x=e[5],x}let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=c):c=e[6];let m;if(e[7]!==u||e[8]!==d||e[9]!==l||e[10]!==V?.name){let x;e[12]!==u||e[13]!==l||e[14]!==V?.name?(x=(g,f)=>n.jsx(Ll,{item:g,isSelected:f===l,ref:f===l?$l:void 0,onSelect:()=>u(g,f),isLoading:V?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=V?.name,e[15]=x):x=e[15],m=d.map(x),e[7]=u,e[8]=d,e[9]=l,e[10]=V?.name,e[11]=m}else m=e[11];let p;return e[16]!==m?(p=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:c,children:n.jsx("div",{className:"p-1",children:m})}),e[16]=m,e[17]=p):p=e[17],p};function Ul(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"p-1",children:[...Array(3)].map(Ol)}),t[0]=e):e=t[0],e}function Ol(t,e){return n.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[n.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),n.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function li(t){const e=L.c(18),{editor:s,char:i,pluginKey:r,queryKey:o,queryFn:a,onSelect:d,allow:l,onOpenChange:u}=t;let V;e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==u||e[4]!==r?(V={editor:s,char:i,pluginKey:r,allow:l,onOpenChange:u},e[0]=l,e[1]=i,e[2]=s,e[3]=u,e[4]=r,e[5]=V):V=e[5];const{state:c,dispatch:m}=El(V);let p;e[6]!==m||e[7]!==c?(p={state:c,dispatch:m},e[6]=m,e[7]=c,e[8]=p):p=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Ul,{}),e[9]=x):x=e[9];let g;e[10]!==s||e[11]!==d||e[12]!==a||e[13]!==o?(g=n.jsx(Ml,{children:n.jsx(w.Suspense,{fallback:x,children:n.jsx(Fl,{editor:s,queryKey:o,queryFn:a,onSelect:d})})}),e[10]=s,e[11]=d,e[12]=a,e[13]=o,e[14]=g):g=e[14];let f;return e[15]!==p||e[16]!==g?(f=n.jsx(oi.Provider,{value:p,children:g}),e[15]=p,e[16]=g,e[17]=f):f=e[17],f}function $l(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const zl=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],Bl=({editor:t,virtualMcpId:e})=>{const s=qt(),{org:i}=ue(),r=er(),o=qe({connectionId:e,orgId:i.id,orgSlug:i.slug}),a=ve.virtualMcpResources(e,i.id),[d,l]=w.useState("categories"),u=w.useRef(d);u.current=d;const V=w.useRef(null),c=w.useRef(!1),m=["at-mention",i.id,e??"default",d],p=async({item:f,range:b})=>{if($("chat_picker_item_selected",{picker:"@",item_kind:f.kind,item_name:f.name}),f.kind!=="category"&&(c.current=!0),f.kind==="category")return l(f.name==="agents"?"agents":"resources"),!1;if(f.kind==="agent"&&f.agentId){wt(t,b,{id:f.agentId,name:f.name,metadata:{agentId:f.agentId,title:f.name},char:"@"}),l("categories");return}if(f.kind==="resource"&&f.uri&&o){try{const h=await Us(o,f.uri);wt(t,b,{id:f.uri,name:f.uri,metadata:h.contents,char:"@"})}catch(h){console.error("[at-mention] Failed to fetch resource:",h),ne.error("Failed to load resource. Please try again.")}l("categories");return}},x=async f=>{const{query:b}=f,h=u.current;if(h==="categories"){if(!b.trim())return zl;const _=b.toLowerCase(),C=r.filter(v=>v.status==="active"&&(!v.id||!Bn(v.id))&&v.id!==e&&(v.title.toLowerCase().includes(_)||v.description?.toLowerCase().includes(_))).map(v=>({name:v.title,title:v.title,description:v.description??void 0,icon:v.icon??null,kind:"agent",agentId:v.id})),S=await(async()=>{if(!o)return[];let v=s.getQueryData(a);return v||(v=await s.fetchQuery({queryKey:a,queryFn:()=>vt(o),staleTime:6e4})),(v?.resources??[]).filter(j=>j.uri.toLowerCase().includes(_)||j.name?.toLowerCase().includes(_)||j.description?.toLowerCase().includes(_)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}))})();return[...C,...S]}if(h==="agents"){let _=r.filter(C=>C.status==="active"&&(!C.id||!Bn(C.id))&&C.id!==e);if(b.trim()){const C=b.toLowerCase();_=_.filter(S=>S.title.toLowerCase().includes(C)||S.description?.toLowerCase().includes(C))}return _.map(C=>({name:C.title,title:C.title,description:C.description??void 0,icon:C.icon??null,kind:"agent",agentId:C.id}))}if(!o)return[];let y=s.getQueryData(a);y?s.fetchQuery({queryKey:a,queryFn:()=>vt(o),staleTime:6e4}).catch(()=>{}):y=await s.fetchQuery({queryKey:a,queryFn:()=>vt(o),staleTime:6e4});let A=y?.resources??[];if(b.trim()){const _=b.toLowerCase();A=A.filter(C=>C.uri.toLowerCase().includes(_)||C.name?.toLowerCase().includes(_)||C.description?.toLowerCase().includes(_))}return A.map(_=>({name:_.name??_.uri,title:_.name,description:_.description,kind:"resource",uri:_.uri}))},g=f=>{if(f)V.current=Date.now(),c.current=!1,$("chat_picker_opened",{picker:"@"});else{const b=V.current;$("chat_picker_closed",{picker:"@",outcome:c.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),V.current=null,l("categories")}};return n.jsx(li,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:x,onSelect:p,onOpenChange:g})};function ql(t,e,s){const i=tr(t),r=Ti(),o=new Map(r.map(u=>[u.id,u])),a=(i?.connections??[]).map(u=>u.connection_id),{data:d}=In({queryKey:ve.promptConnectionMap(e,a),queryFn:async()=>{const u={};return await Promise.all(a.map(async V=>{try{const c=await Pi({connectionId:V,orgId:e,orgSlug:s}),m=await Lt(c);for(const p of m.prompts)p.name in u||(u[p.name]=V)}catch{}})),u},staleTime:6e4,enabled:a.length>0}),l=new Map;for(const[u,V]of Object.entries(d??{})){const c=o.get(V);c&&l.set(u,c)}return l}async function fs(t,e,s,i,r,o){try{const a=await Ln(s,i,o);wt(t,e,{id:i,name:Mn(i,r),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),ne.error("Failed to load prompt. Please try again.")}}async function Kl(t,e,s,i){try{const r=await Us(s,i);wt(t,e,{id:i,name:i,metadata:r.contents,char:"/"})}catch(r){console.error("[slash] Failed to fetch resource:",r),ne.error("Failed to load resource. Please try again.")}}const Yl=({editor:t,virtualMcpId:e})=>{const s=qt(),{org:i}=ue(),r=qe({connectionId:e,orgId:i.id,orgSlug:i.slug}),o=ql(e,i.id,i.slug),a=w.useRef(o);a.current=o;const d=ve.virtualMcpPrompts(e,i.id),l=ve.virtualMcpResources(e,i.id),u=["slash-mention",i.id,e??"default"],[V,c]=w.useState(null),m=w.useRef(null),p=w.useRef(!1),x=async({item:h,range:y})=>{if($("chat_picker_item_selected",{picker:"/",item_kind:h.kind,item_name:h.name}),p.current=!0,!!r)if(h.kind==="prompt"){if(h.arguments&&h.arguments.length>0){c({range:y,item:h});return}const A=Ge(h._meta);await fs(t,y,r,h.name,A)}else h.uri&&await Kl(t,y,r,h.uri)},g=async h=>{if(!V||!r)return;const{range:y,item:A}=V,_=Ge(A._meta);await fs(t,y,r,A.name,_,h),c(null)},f=async h=>{const{query:y}=h;if(!r)return[];const[A,_]=await Promise.all([Wl(s,d,r),Gl(s,l,r)]),C=y.trim().toLowerCase(),S=(A??[]).filter(j=>!C||j.name.toLowerCase().includes(C)||j.title?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C)).map(j=>({name:j.name,title:j.title,description:j.description,icon:a.current.get(j.name)?.icon??null,kind:"prompt",arguments:j.arguments,_meta:j._meta})),v=(_??[]).filter(j=>!C||j.uri.toLowerCase().includes(C)||j.name?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}));return[...S,...v]},b=V?.item.kind==="prompt"?{name:V.item.name,arguments:V.item.arguments,description:V.item.description}:null;return n.jsxs(n.Fragment,{children:[n.jsx(li,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:u,queryFn:f,onSelect:x,onOpenChange:h=>{if(h)m.current=Date.now(),p.current=!1,$("chat_picker_opened",{picker:"/"});else{const y=m.current;$("chat_picker_closed",{picker:"/",outcome:p.current?"selected":"dismissed",duration_ms:y?Date.now()-y:null}),m.current=null}}}),n.jsx(Fn,{prompt:b,setPrompt:()=>c(null),onSubmit:g})]})};async function Wl(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Lt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Lt(s),staleTime:6e4}),i?.prompts??[]}async function Gl(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>vt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>vt(s),staleTime:6e4}),i?.resources??[]}function Ql(t){return[br.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Da.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),dr,ur]}function Hl({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:r,onSubmit:o,children:a}){const d=w.useRef(o),l=w.useRef(e),u=w.useRef(i),V=w.useRef(r),c=gr({extensions:Ql(V),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(m,p)=>p.key==="Enter"&&!p.shiftKey&&u.current?(p.preventDefault(),d.current?.(),!0):!1},onUpdate:({editor:m})=>{l.current(m?.getJSON())}});return w.useEffect(()=>{c?.setEditable(!s)},[c,s]),w.useEffect(()=>{d.current=o},[o]),w.useEffect(()=>{l.current=e},[e]),w.useEffect(()=>{u.current=i},[i]),w.useEffect(()=>{V.current=r},[r]),w.useEffect(()=>{if(c?.isDestroyed)return;const m=JSON.stringify(c?.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&c.commands.setContent(t||{type:"doc",content:[]})},[c,t]),n.jsx(xr.Provider,{value:{editor:c},children:a})}function Jl(t){const e=L.c(26),{disabled:s,virtualMcpId:i,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:d,className:l}=t,u=s===void 0?!1:s,V=r===void 0?!1:r,{editor:c}=Zt();let m,p;if(e[0]!==c?(m=()=>({focus:()=>{c?.commands.focus()},clear:()=>{c?.commands.clearContent(!0)},appendText:v=>{if(!c)return;const j=c.state.doc.textContent.trim()==="";c.commands.focus("end"),j||c.commands.insertContent(" "),c.commands.insertContent(v)},syncVoiceText:(v,j)=>{if(c&&(c.commands.setContent(v||{type:"doc",content:[]}),j)){c.commands.focus("end");const E=c.state.doc.textContent.trim().length>0;c.commands.insertContent(E?" "+j:j)}},restoreContent:v=>{c&&c.commands.setContent(v||{type:"doc",content:[]})}}),p=[c],e[0]=c,e[1]=m,e[2]=p):(m=e[1],p=e[2]),w.useImperativeHandle(d??null,m,p),!c)return null;const x=u&&"cursor-not-allowed opacity-70",g=u&&"[&_.ProseMirror]:cursor-not-allowed";let f;e[3]!==l||e[4]!==x||e[5]!==g?(f=z("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",l,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",x,g),e[3]=l,e[4]=x,e[5]=g,e[6]=f):f=e[6];let b;e[7]!==c||e[8]!==f?(b=n.jsx(yr,{editor:c,className:f}),e[7]=c,e[8]=f,e[9]=b):b=e[9];const h=i??null;let y;e[10]!==c||e[11]!==h?(y=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Yl,{editor:c,virtualMcpId:h})}),e[10]=c,e[11]=h,e[12]=y):y=e[12];const A=i??null;let _;e[13]!==c||e[14]!==A?(_=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Bl,{editor:c,virtualMcpId:A})}),e[13]=c,e[14]=A,e[15]=_):_=e[15];let C;e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==V?(C=V&&o?n.jsx(_a,{editor:c,selectedModel:o,onUnsupportedFile:a}):null,e[16]=c,e[17]=a,e[18]=o,e[19]=V,e[20]=C):C=e[20];let S;return e[21]!==y||e[22]!==_||e[23]!==C||e[24]!==b?(S=n.jsxs(n.Fragment,{children:[b,y,_,C]}),e[21]=y,e[22]=_,e[23]=C,e[24]=b,e[25]=S):S=e[25],S}function Sn(t){const e=L.c(3),[s]=Cn();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Ur(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=i):i=e[2],i}const Xl={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},Zl=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function ec(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1.5",children:Zl.map(tc)}),t[0]=e):e=t[0],e}function tc(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function nc(t){const e=L.c(130),{disabled:s,onOpenConnections:i,virtualMcpId:r}=t,[o,a]=w.useState(!1),d=Sn(Xl),{org:l}=ue(),{editor:u}=Zt();let V;e[0]!==l.id||e[1]!==l.slug||e[2]!==r?(V={connectionId:r,orgId:l.id,orgSlug:l.slug},e[0]=l.id,e[1]=l.slug,e[2]=r,e[3]=V):V=e[3];const c=qe(V);let m;e[4]!==l.id||e[5]!==r?(m=ve.virtualMcpPrompts(r,l.id),e[4]=l.id,e[5]=r,e[6]=m):m=e[6];const p=m;let x;e[7]!==c?(x=()=>Lt(c),e[7]=c,e[8]=x):x=e[8];const g=o&&!!c;let f;e[9]!==p||e[10]!==x||e[11]!==g?(f={queryKey:p,queryFn:x,staleTime:6e4,enabled:g},e[9]=p,e[10]=x,e[11]=g,e[12]=f):f=e[12];const{data:b,isLoading:h}=In(f);let y;e[13]!==b?.prompts?(y=b?.prompts??[],e[13]=b?.prompts,e[14]=y):y=e[14];const A=y,[_,C]=w.useState(null),{credentialId:S,imageModel:v,setImageModel:j,deepResearchModel:E,setDeepResearchModel:D,chatMode:I,setChatMode:P,simpleModeEnabled:k}=Yt(),N=I==="plan",[R,M]=w.useState(!1),[T,F]=w.useState(!1),{models:O,isLoading:q}=Pr(R||T?S??void 0:void 0);let K,H,Z,Q,W,ie,Y,ee,te,se,ae,re,oe;if(e[15]!==_||e[16]!==O||e[17]!==I||e[18]!==c||e[19]!==E||e[20]!==s||e[21]!==u||e[22]!==v||e[23]!==R||e[24]!==q||e[25]!==N||e[26]!==i||e[27]!==o||e[28]!==d||e[29]!==T||e[30]!==P||e[31]!==D||e[32]!==j||e[33]!==k){const Ve=O.filter(ic),ut=O.filter(sc);let we;e[47]!==I||e[48]!==N||e[49]!==d||e[50]!==P?(we=()=>{d();const B=N?"default":"plan";$("chat_mode_changed",{from_mode:I,to_mode:B,source:"tools_popover"}),P(B),a(!1)},e[47]=I,e[48]=N,e[49]=d,e[50]=P,e[51]=we):we=e[51];const Re=we;let je;e[52]!==i?(je=()=>{i(),a(!1)},e[52]=i,e[53]=je):je=e[53],Z=je;let Ae;e[54]!==c||e[55]!==u?(Ae=async(B,Ye)=>{if(!u||!c)return;const Vt=Ge(B._meta),mt={from:u.state.selection.from,to:u.state.selection.to};try{const di=await Ln(c,B.name,Ye);wt(u,mt,{id:B.name,name:Mn(B.name,Vt),metadata:di.messages,char:"/"})}catch{ne.error("Failed to load prompt. Please try again.")}},e[54]=c,e[55]=u,e[56]=Ae):Ae=e[56];const ye=Ae;let $e;e[57]!==ye?($e=async B=>{a(!1);const Ye=!!(B.arguments&&B.arguments.length>0);if($("chat_prompt_inserted",{prompt_name:B.name,with_arguments:Ye}),Ye){C(B);return}await ye(B)},e[57]=ye,e[58]=$e):$e=e[58],W=$e;let U;e[59]!==_||e[60]!==ye?(U=async B=>{_&&(await ye(_,B),C(null))},e[59]=_,e[60]=ye,e[61]=U):U=e[61],Q=U;let X;e[62]!==d||e[63]!==j?(X=B=>{d(),$("chat_image_model_selected",{model_id:B.modelId,model_title:B.title,provider:B.providerId??null}),j(B),a(!1)},e[62]=d,e[63]=j,e[64]=X):X=e[64];const Se=X;let ke;e[65]!==d||e[66]!==D?(ke=B=>{d(),$("chat_search_model_selected",{model_id:B.modelId,model_title:B.title,provider:B.providerId??null}),D(B),a(!1)},e[65]=d,e[66]=D,e[67]=ke):ke=e[67];const Te=ke;let ze;e[68]!==I||e[69]!==d||e[70]!==P?(ze=()=>{d();const B=I==="gen-image"?"default":"gen-image";$("chat_mode_changed",{from_mode:I,to_mode:B,source:"tools_popover"}),P(B),a(!1)},e[68]=I,e[69]=d,e[70]=P,e[71]=ze):ze=e[71];const Be=ze;let le;e[72]!==I||e[73]!==d||e[74]!==P?(le=()=>{d();const B=I==="web-search"?"default":"web-search";$("chat_mode_changed",{from_mode:I,to_mode:B,source:"tools_popover"}),P(B),a(!1)},e[72]=I,e[73]=d,e[74]=P,e[75]=le):le=e[75];const Pe=le,et=I==="gen-image",tt=I==="web-search";H=Ss,ee=o,e[76]!==I||e[77]!==o?(te=B=>{B&&!o&&$("chat_tools_popover_opened",{chat_mode:I}),a(B)},e[76]=I,e[77]=o,e[78]=te):te=e[78];let Nt,_t;e[79]===Symbol.for("react.memo_cache_sentinel")?(Nt=n.jsx(Fi,{size:14}),_t=n.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[79]=Nt,e[80]=_t):(Nt=e[79],_t=e[80]),e[81]!==s?(se=n.jsx(ks,{asChild:!0,children:n.jsxs(J,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[Nt,_t]})}),e[81]=s,e[82]=se):se=e[82],K=Ns,ae="start",re="w-52 p-1.5";const nn=N&&"text-violet-600 dark:text-violet-400";let nt;e[83]!==nn?(nt=z(nn),e[83]=nn,e[84]=nt):nt=e[84];const sn=N&&"text-violet-500";let st;e[85]!==sn?(st=z(sn),e[85]=sn,e[86]=st):st=e[86];let it;e[87]!==st?(it=n.jsx(_s,{size:16,className:st}),e[87]=st,e[88]=it):it=e[88];let Ct;e[89]===Symbol.for("react.memo_cache_sentinel")?(Ct=n.jsx("span",{className:"flex-1",children:"Plan mode"}),e[89]=Ct):Ct=e[89];let rt;e[90]!==N?(rt=N&&n.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[90]=N,e[91]=rt):rt=e[91],e[92]!==Re||e[93]!==nt||e[94]!==it||e[95]!==rt?(oe=n.jsxs(Ee,{onClick:Re,className:nt,children:[it,Ct,rt]}),e[92]=Re,e[93]=nt,e[94]=it,e[95]=rt,e[96]=oe):oe=e[96],ie=k?n.jsxs(Ee,{onClick:Be,className:z(et&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(yn,{size:16,className:z(et&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),et&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):n.jsxs(cn,{open:R,onOpenChange:M,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(Ee,{onClick:Be,disabled:!v,className:z("flex-1 rounded-r-none pr-1",et&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(yn,{size:16,className:z(et&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),et&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),n.jsx(zn,{className:z("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Kn,{size:14})})]}),n.jsx(dn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:q?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(He,{size:14,className:"animate-spin"}),"Loading models…"]}):Ve.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):Ve.map(B=>{const Ye=v?.modelId===B.modelId,Vt=Wn(B),mt=B.title.includes(": ")?B.title.split(": ").slice(1).join(": "):B.title;return n.jsxs(Ee,{onClick:()=>Se(B),className:"flex items-center gap-2",children:[n.jsx("img",{src:Vt,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:mt}),Ye&&n.jsx(Xe,{size:14,className:"text-pink-500 shrink-0"})]},B.modelId)})})]}),Y=k?n.jsxs(Ee,{onClick:Pe,className:z(tt&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(lt,{size:16,className:z(tt&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),tt&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):E&&n.jsxs(cn,{open:T,onOpenChange:F,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(Ee,{onClick:Pe,className:z("flex-1 rounded-r-none pr-1",tt&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(lt,{size:16,className:z(tt&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),tt&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),n.jsx(zn,{className:z("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Kn,{size:14})})]}),n.jsx(dn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:q?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(He,{size:14,className:"animate-spin"}),"Loading models…"]}):ut.map(B=>{const Ye=E?.modelId===B.modelId,Vt=Wn(B),mt=B.title.includes(": ")?B.title.split(": ").slice(1).join(": "):B.title;return n.jsxs(Ee,{onClick:()=>Te(B),className:"flex items-center gap-2",children:[n.jsx("img",{src:Vt,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:mt}),Ye&&n.jsx(Xe,{size:14,className:"text-blue-500 shrink-0"})]},B.modelId)})})]}),e[15]=_,e[16]=O,e[17]=I,e[18]=c,e[19]=E,e[20]=s,e[21]=u,e[22]=v,e[23]=R,e[24]=q,e[25]=N,e[26]=i,e[27]=o,e[28]=d,e[29]=T,e[30]=P,e[31]=D,e[32]=j,e[33]=k,e[34]=K,e[35]=H,e[36]=Z,e[37]=Q,e[38]=W,e[39]=ie,e[40]=Y,e[41]=ee,e[42]=te,e[43]=se,e[44]=ae,e[45]=re,e[46]=oe}else K=e[34],H=e[35],Z=e[36],Q=e[37],W=e[38],ie=e[39],Y=e[40],ee=e[41],te=e[42],se=e[43],ae=e[44],re=e[45],oe=e[46];let ce;e[97]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsxs(Ar,{className:"gap-2",children:[n.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),n.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[97]=ce):ce=e[97];let ge;e[98]!==W||e[99]!==h||e[100]!==A?(ge=h?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(He,{size:14,className:"animate-spin"}),"Loading prompts…"]}):A.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):A.map(Ve=>n.jsxs(Ee,{onClick:()=>W(Ve),className:"flex flex-col items-start gap-0.5",children:[n.jsx("span",{className:"font-medium text-sm capitalize",children:Ve.title||Xt(Ve.name,Ge(Ve._meta))}),Ve.description&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:Ve.description})]},Ve.name)),e[98]=W,e[99]=h,e[100]=A,e[101]=ge):ge=e[101];let G;e[102]!==ge?(G=n.jsxs(cn,{children:[ce,n.jsx(dn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:ge})]}),e[102]=ge,e[103]=G):G=e[103];let de,Ze;e[104]===Symbol.for("react.memo_cache_sentinel")?(de=n.jsx(Cr,{size:16}),Ze=n.jsx("span",{className:"flex-1",children:"Connections"}),e[104]=de,e[105]=Ze):(de=e[104],Ze=e[105]);let Oe;e[106]===Symbol.for("react.memo_cache_sentinel")?(Oe=n.jsx(w.Suspense,{children:n.jsx(ec,{})}),e[106]=Oe):Oe=e[106];let Ce;e[107]!==Z?(Ce=n.jsxs(Ee,{onClick:Z,children:[de,Ze,Oe]}),e[107]=Z,e[108]=Ce):Ce=e[108];let xe;e[109]!==K||e[110]!==ie||e[111]!==Y||e[112]!==G||e[113]!==Ce||e[114]!==ae||e[115]!==re||e[116]!==oe?(xe=n.jsxs(K,{align:ae,className:re,children:[oe,ie,Y,G,Ce]}),e[109]=K,e[110]=ie,e[111]=Y,e[112]=G,e[113]=Ce,e[114]=ae,e[115]=re,e[116]=oe,e[117]=xe):xe=e[117];let be;e[118]!==H||e[119]!==ee||e[120]!==te||e[121]!==se||e[122]!==xe?(be=n.jsxs(H,{open:ee,onOpenChange:te,children:[se,xe]}),e[118]=H,e[119]=ee,e[120]=te,e[121]=se,e[122]=xe,e[123]=be):be=e[123];let Ie;e[124]!==_||e[125]!==Q?(Ie=n.jsx(Fn,{prompt:_,setPrompt:C,onSubmit:Q}),e[124]=_,e[125]=Q,e[126]=Ie):Ie=e[126];let Ke;return e[127]!==be||e[128]!==Ie?(Ke=n.jsxs(n.Fragment,{children:[be,Ie]}),e[127]=be,e[128]=Ie,e[129]=Ke):Ke=e[129],Ke}function sc(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function ic(t){return t.capabilities?.includes("image")}const rc=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function oc(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1",children:rc.map(ac)}),t[0]=e):e=t[0],e}function ac(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function lc(t){const e=L.c(6),{onClick:s}=t;let i,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=z("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=n.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=n.jsx(oc,{}),a=n.jsx(eo,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=r,e[2]=o,e[3]=a):(i=e[0],r=e[1],o=e[2],a=e[3]);let d;return e[4]!==s?(d=n.jsxs("button",{type:"button",onClick:s,className:i,children:[r,o,a]}),e[4]=s,e[5]=d):d=e[5],d}const gt=48;function cc(){const t=L.c(9),[e,s]=w.useState("idle"),[i,r]=w.useState(""),[o,a]=w.useState(""),[d,l]=w.useState(Vc),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=w.useRef(null),p=w.useRef(0),x=w.useRef(!1),g=w.useRef(""),f=w.useRef(""),b=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0),V.current?.close().catch(uc),m.current?.getTracks().forEach(dc),c.current=null,V.current=null,m.current=null},t[0]=h):h=t[0];const y=h;let A;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const D=I=>{m.current=I;const P=new AudioContext;V.current=P;const k=P.createMediaStreamSource(I),N=P.createAnalyser();N.fftSize=128,N.smoothingTimeConstant=.8,k.connect(N),c.current=N;const R=new Uint8Array(N.frequencyBinCount),M=()=>{if(!c.current)return;c.current.getByteFrequencyData(R);const T=[];for(let F=0;F<gt;F++){const O=Math.floor(F/gt*R.length);T.push(Math.max(.04,(R[O]??0)/255))}l(T),p.current=requestAnimationFrame(M)};M()};A=async()=>{const I=window.SpeechRecognition||window.webkitSpeechRecognition;if(!I){s("unsupported");return}let P;try{P=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),f.current="",g.current="",x.current=!0,s("recording"),D(P);const k=new I;u.current=k,k.interimResults=!0,k.continuous=!0,k.lang=navigator.language||"en-US",k.onresult=N=>{let R="",M="";for(let T=N.resultIndex;T<N.results.length;T++){const F=N.results[T],O=F?.[0]?.transcript??"";F?.isFinal?M=M+O:R=R+O}M&&(g.current=g.current+M,r(g.current)),f.current=R,a(R)},k.onend=()=>{if(x.current)try{k.start()}catch{}};try{k.start()}catch{s("idle")}},t[1]=A}else A=t[1];const _=A;let C;t[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{x.current=!1,u.current?.stop(),y(),s("idle"),l(Array(gt).fill(.05)),a("");const D=(g.current+(f.current?" "+f.current:"")).trim();return r(""),g.current="",f.current="",D},t[2]=C):C=t[2];const S=C;let v;t[3]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{x.current=!1,u.current?.abort(),y(),s("idle"),r(""),a(""),l(Array(gt).fill(.05)),g.current="",f.current=""},t[3]=v):v=t[3];const j=v;let E;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==d?(E={status:e,transcript:i,interimTranscript:o,waveformData:d,isSupported:b,startRecording:_,stopRecording:S,cancelRecording:j},t[4]=o,t[5]=e,t[6]=i,t[7]=d,t[8]=E):E=t[8],E}function dc(t){return t.stop()}function uc(){}function Vc(){return Array(gt).fill(.05)}function mc(t){const e=L.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(fc),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=r):r=e[3],r}function fc(t,e){return n.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}const gn=[{value:"fast",label:"Fast",Icon:$i,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:Nr,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:zi,description:"Deeper reasoning"}];function pc(t){const e=L.c(17),{tier:s,onSelect:i}=t;let r;e[0]!==s?(r=gn.find(p=>p.value===s)??gn[1],e[0]=s,e[1]=r):r=e[1];const o=r,a=o.Icon;let d;e[2]!==a?(d=n.jsx(a,{size:14}),e[2]=a,e[3]=d):d=e[3];let l;e[4]!==o.label?(l=n.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=l):l=e[5];let u;e[6]!==d||e[7]!==l?(u=n.jsx(ks,{asChild:!0,children:n.jsxs(J,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[d,l]})}),e[6]=d,e[7]=l,e[8]=u):u=e[8];let V;e[9]!==i||e[10]!==s?(V=gn.map(p=>{const{value:x,label:g,Icon:f,description:b}=p;return n.jsxs(Ee,{onSelect:()=>i(x),children:[n.jsx(f,{size:16,className:"text-muted-foreground"}),n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx("span",{children:g}),n.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:b})]}),s===x&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},x)}),e[9]=i,e[10]=s,e[11]=V):V=e[11];let c;e[12]!==V?(c=n.jsx(Ns,{align:"end",className:"w-52 p-1.5",children:V}),e[12]=V,e[13]=c):c=e[13];let m;return e[14]!==u||e[15]!==c?(m=n.jsxs(Ss,{children:[u,c]}),e[14]=u,e[15]=c,e[16]=m):m=e[16],m}function hc(t,e){const s=L.c(5),{editor:i}=Zt(),[r,o]=w.useState(!1),a=w.useRef(0);let d,l;return s[0]!==i||s[1]!==e||s[2]!==t?(d=()=>{const u=p=>{p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),a.current=a.current+1,o(!0))},V=p=>{p.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},c=gc,m=p=>{if(p.preventDefault(),a.current=0,o(!1),!i||!t||!en(t))return;const x=p.dataTransfer?.files;if(!x||x.length===0)return;const{from:g}=i.state.selection;for(const f of Array.from(x))Un(i,t,f,g,e)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",V),window.addEventListener("dragover",c),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",V),window.removeEventListener("dragover",c),window.removeEventListener("drop",m)}},l=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=d,s[4]=l):(d=s[3],l=s[4]),w.useEffect(d,l),r}function gc(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function xc(t){const e=L.c(11),{selectedModel:s,onUnsupportedFile:i}=t,r=hc(s,i);let o;e[0]!==s?(o=en(s),e[0]=s,e[1]=o):o=e[1];const a=o,d=r?"opacity-100":"opacity-0 pointer-events-none",l=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let u;e[2]!==d||e[3]!==l?(u=z("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",d,l),e[2]=d,e[3]=l,e[4]=u):u=e[4];let V;e[5]!==s||e[6]!==a?(V=a?n.jsxs(n.Fragment,{children:[n.jsx(Ir,{size:24}),n.jsxs("span",{className:"text-sm font-medium",children:["Drop ",Fs(s)," here"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(Cs,{size:24}),n.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=a,e[7]=V):V=e[7];let c;return e[8]!==u||e[9]!==V?(c=n.jsx("div",{className:u,children:V}),e[8]=u,e[9]=V,e[10]=c):c=e[10],c}function bc(){const t=L.c(5),e=ct(),{org:s,locator:i}=ue();let r;return t[0]!==i||t[1]!==e||t[2]!==s.id||t[3]!==s.slug?(r=o=>{const{tiptapDoc:a,virtualMcp:d}=o,l=crypto.randomUUID(),u=d?.id??Tn(s.id).id;Wi(sessionStorage,i,l,{tiptapDoc:a}),e({to:"/$org/$taskId",params:{org:s.slug,taskId:l},search:{virtualmcpid:u,autosend:Gi}})},t[0]=i,t[1]=e,t[2]=s.id,t[3]=s.slug,t[4]=r):r=t[4],r}function yc({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=Ki(),i=Yi(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,d=s?.stop??(()=>{}),l=i?.taskId??"",u=i?.tasks??[],V=bc(),{selectedModel:c,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:x,imageModel:g,deepResearchModel:f,chatMode:b,setChatMode:h,simpleModeEnabled:y,simpleModeTier:A,setSimpleModeTier:_}=Yt(),{data:C}=Bt.useSession(),S=C?.user?.id,{org:v}=ue(),j=Tn(v.id).id,E=Sn(Yn),[D,I]=w.useState(!1),{unsupportedFile:P,onUnsupportedFile:k,clearUnsupportedFile:N}=Ea(),R=cc(),M=w.useRef(void 0),T=async()=>{M.current=K,await R.startRecording();const G=R.status==="recording"?"started":R.status==="unsupported"?"unsupported":R.status==="permission-denied"?"permission_denied":"unknown";$("chat_voice_started",{thread_id:l,outcome:G})},F=()=>{$("chat_voice_confirmed",{thread_id:l});const G=R.stopRecording();Y.current?.syncVoiceText(M.current,G),Y.current?.focus()},O=()=>{$("chat_voice_cancelled",{thread_id:l}),R.cancelRecording(),Y.current?.restoreContent(M.current)};w.useEffect(()=>{if(R.status!=="recording")return;const G=(R.transcript+(R.interimTranscript?" "+R.interimTranscript:"")).trim();Y.current?.syncVoiceText(M.current,G)},[R.transcript,R.interimTranscript,R.status]);const q=u.find(G=>G.id===l),[K,H]=w.useState(void 0),Z=G=>{H(G),x.current=G},Q=w.useRef(l);Q.current!==l&&(Q.current=l,H(void 0),x.current=void 0);const ie=[...r].reverse().find(G=>G.role==="assistant")?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow,Y=w.useRef(null),ee=b==="plan";w.useEffect(()=>{const G=de=>{ir(de)&&de.code==="KeyL"&&(de.preventDefault(),de.shiftKey&&h(b==="plan"?"default":"plan"),Y.current?.focus())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[b,h]);const te=Vr(r),se=[...r].reverse().find(G=>G.role==="assistant"&&G.metadata?.usage)?.metadata?.usage,ae=se?.contextTokens??(se?.totalTokens??0)-(se?.reasoningTokens??0),re=Sn(Yn),oe=!o&&!!c&&!p&&!Fo(K),ce=o||a,ge=G=>{G?.preventDefault(),o?($("chat_message_stopped",{thread_id:l}),d()):a?($("chat_message_stopped",{thread_id:l}),d()):oe&&K&&($("chat_message_sent",{thread_id:l||null,mode:b,model_id:c?.modelId??null,model_provider:c?.providerId??null,virtual_mcp_id:m?.id??null,submission:G?"button_or_enter":"programmatic"}),re(),s?s.sendMessage(K):V({tiptapDoc:K,virtualMcp:m}),Z(void 0))};return S&&q?.created_by&&q.created_by!==S?n.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n.jsx(Cs,{size:14,className:"shrink-0"}),n.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col w-full justify-end",children:n.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&n.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),s&&i&&n.jsx(tn,{}),n.jsx(Hl,{tiptapDoc:K,setTiptapDoc:Z,disabled:o||!c,enterToSubmit:!0,onSubmit:ge,children:n.jsxs("form",{onSubmit:ge,className:z("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[n.jsx(xc,{selectedModel:c,onUnsupportedFile:k}),n.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:n.jsx(Jl,{ref:Y,disabled:o||!c||R.status==="recording",virtualMcpId:m?.id??j,showFileUploader:!0,selectedModel:c,onUnsupportedFile:k})}),n.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:R.status==="recording"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n.jsx(mc,{data:R.waveformData.slice(0,28)}),n.jsx("button",{type:"button",onClick:O,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:n.jsx(pt,{size:16})}),n.jsx("button",{type:"button",onClick:F,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:n.jsx(Xe,{size:16})})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[n.jsx(Ra,{selectedModel:c,isStreaming:o,icon:n.jsx(Is,{size:16}),onUnsupportedFile:k}),n.jsx(nc,{disabled:o,onOpenConnections:()=>{$("connections_dialog_opened",{source:"tools_popover",mode:"add"}),I(!0)},virtualMcpId:m?.id??j}),ee&&n.jsxs("button",{type:"button",onClick:()=>{E(),$("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),h("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(_s,{size:14,className:"shrink-0"}),"Plan mode",n.jsx(pt,{size:14,className:"shrink-0 hidden group-hover:block"})]}),b==="gen-image"&&g&&n.jsxs("button",{type:"button",onClick:()=>{E(),$("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),h("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(yn,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:y?"Create image":g.title.includes(": ")?g.title.split(": ").slice(1).join(": "):g.title}),n.jsx(pt,{size:14,className:"shrink-0 hidden group-hover:block"})]}),b==="web-search"&&f&&n.jsxs("button",{type:"button",onClick:()=>{E(),$("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),h("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(lt,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:y?"Web search":f.title.includes(": ")?f.title.split(": ").slice(1).join(": "):f.title}),n.jsx(pt,{size:14,className:"shrink-0 hidden group-hover:block"})]}),ie&&ae>0&&n.jsx(mr,{usage:te,totalTokens:ae,contextWindow:ie,onOpenContextPanel:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[y?n.jsx(pc,{tier:A,onSelect:_}):n.jsx(Mr,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),R.isSupported&&!o&&!a&&n.jsx(J,{type:"button",onClick:T,variant:"ghost",size:"icon",className:z("size-8 rounded-lg transition-colors",R.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:R.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:n.jsx(Ui,{size:18})}),n.jsx(J,{type:ce?"button":"submit",onClick:G=>{ce&&(G.preventDefault(),G.stopPropagation(),d())},variant:oe||ce?"default":"ghost",size:"icon",disabled:!oe&&!ce,className:z("size-8 rounded-lg transition-all",!oe&&!ce&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:o?"Stop generating":a?"Cancel run":"Send message (Enter)",children:ce?n.jsx(Oi,{size:20}):n.jsx(kr,{size:20})})]})]})})]})},l),e&&n.jsx(lc,{onClick:()=>{$("connections_banner_clicked",{source:"home_chat_input"}),$("connections_dialog_opened",{source:"home_banner",mode:"add"}),I(!0)}})]})}),n.jsx(uo,{mode:"browse",open:D,onOpenChange:I,defaultTab:"all"}),n.jsx(Ta,{info:P,onClose:N})]})}const vc={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function ci(t){return`deco-credits-empty-dismissed:${t}`}function Ud(t){try{return localStorage.getItem(ci(t))==="1"}catch{return!1}}function wc(){const t=L.c(50),{org:e}=ue(),s=ct(),{decoKeyId:i}=Ws();let r;t[0]!==e.id||t[1]!==e.slug?(r={connectionId:kt,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=r):r=t[2];const o=qe(r),[a,d]=w.useState(!0),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g;t[3]!==e.id?(g=()=>{$("credits_empty_state_dismissed",{organization_id:e.id}),d(!1);try{localStorage.setItem(ci(e.id),"1")}catch{}},t[3]=e.id,t[4]=g):g=t[4];const f=g;let b,h;t[5]!==a||t[6]!==e.id?(b=()=>{a&&$("credits_empty_state_shown",{organization_id:e.id})},h=[a,e.id],t[5]=a,t[6]=e.id,t[7]=b,t[8]=h):(b=t[7],h=t[8]),w.useEffect(b,h);let y;t[9]!==o||t[10]!==m?(y=async K=>{const H=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:K,currency:m}});if(H?.isError)throw new Error(H.content?.[0]?.text??"Failed to get top-up URL");return H.structuredContent?.url},t[9]=o,t[10]=m,t[11]=y):y=t[11];let A;t[12]!==f?(A=K=>{K&&window.open(K,"_blank","noopener,noreferrer"),f()},t[12]=f,t[13]=A):A=t[13];let _;t[14]!==y||t[15]!==A?(_={mutationFn:y,onSuccess:A,onError:Ac},t[14]=y,t[15]=A,t[16]=_):_=t[16];const{mutate:C,isPending:S}=_n(_),v=parseFloat(l),j=!isNaN(v)&&v>=1;if(!a)return null;let E;t[17]!==f?(E=K=>!K&&f(),t[17]=f,t[18]=E):E=t[18];let D;t[19]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[19]=D):D=t[19];let I;t[20]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-100 dark:bg-amber-900/40 border border-amber-200/60 dark:border-amber-800/40 mx-auto",children:n.jsx(vs,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[20]=I):I=t[20];let P;t[21]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[D,n.jsxs(Fe,{className:"relative gap-3",children:[I,n.jsxs("div",{className:"text-center",children:[n.jsx(Ue,{className:"text-lg font-semibold",children:"This workspace has no credits"}),n.jsx(Kt,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[21]=P):P=t[21];let k;t[22]!==m||t[23]!==x||t[24]!==l||t[25]!==v||t[26]!==i||t[27]!==j||t[28]!==S||t[29]!==V||t[30]!==C?(k=i&&n.jsxs("div",{className:"px-6 pb-5",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(Ls,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:K=>{K&&p(K)},children:[n.jsx(Ft,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ft,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:vc[m].map(K=>{const{dollars:H,label:Z}=K;return n.jsxs("button",{type:"button",disabled:S,onClick:()=>{$("credits_topup_clicked",{amount_cents:H*100,currency:m,tier_label:Z,source:"empty_state"}),C(H*100)},className:z("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[x,H]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Z})]},H)})}),V?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:x}),n.jsx(_e,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:K=>u(K.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(J,{className:"h-10",disabled:!j||S,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(v*100),currency:m,tier_label:"custom",source:"empty_state"}),C(Math.round(v*100))},children:S?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>c(!0),children:"Enter custom amount"})]}),t[22]=m,t[23]=x,t[24]=l,t[25]=v,t[26]=i,t[27]=j,t[28]=S,t[29]=V,t[30]=C,t[31]=k):k=t[31];let N;t[32]!==f||t[33]!==s||t[34]!==e.slug?(N=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),f()},t[32]=f,t[33]=s,t[34]=e.slug,t[35]=N):N=t[35];let R;t[36]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Rs,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[36]=R):R=t[36];let M;t[37]!==N?(M=n.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:N,children:["Use your own provider",R]}),t[37]=N,t[38]=M):M=t[38];let T;t[39]!==f?(T=n.jsx(J,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:f,children:"Skip for now"}),t[39]=f,t[40]=T):T=t[40];let F;t[41]!==M||t[42]!==T?(F=n.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[M,T]}),t[41]=M,t[42]=T,t[43]=F):F=t[43];let O;t[44]!==k||t[45]!==F?(O=n.jsxs(Le,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:jc,children:[P,k,F]}),t[44]=k,t[45]=F,t[46]=O):O=t[46];let q;return t[47]!==O||t[48]!==E?(q=n.jsx(Me,{open:!0,onOpenChange:E,children:O}),t[47]=O,t[48]=E,t[49]=q):q=t[49],q}function jc(t){return t.preventDefault()}function Ac(t){ne.error(`Top-up failed: ${t.message}`)}function Sc(t){const e=L.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const r=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=z("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-emerald-50 dark:bg-emerald-950/30","border border-emerald-200/60 dark:border-emerald-800/40","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=n.jsx(vs,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let d;return e[4]!==r?(d=n.jsxs("div",{className:o,children:[a,n.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=d):d=e[5],d}function kc(){const t=L.c(8),{org:e}=ue(),s=ct();let i;t[0]!==s||t[1]!==e.slug?(i=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=i):i=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=z("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-amber-50 dark:bg-amber-950/30","border border-amber-200/60 dark:border-amber-800/40","hover:bg-amber-100/60 dark:hover:bg-amber-900/30","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=n.jsx(Ts,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=n.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let d;return t[6]!==i?(d=n.jsxs("button",{type:"button",onClick:i,className:r,children:[o,a]}),t[6]=i,t[7]=d):d=t[7],d}function Nc(t){const e=L.c(11),{className:s}=t;let i;e[0]!==s?(i=z("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex items-center gap-3",children:[r,n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:n.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,n.jsxs("div",{className:"flex items-end gap-2",children:[n.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),n.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[n.jsx(Tt,{align:"right",width:"w-3/4"}),n.jsx(Tt,{align:"left",width:"w-full",lines:3}),n.jsx(Tt,{align:"right",width:"w-2/3"}),n.jsx(Tt,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=d):d=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:n.jsx("div",{className:"relative flex-1",children:n.jsxs("div",{className:"space-y-2 p-2",children:[n.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),n.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=l):l=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex items-center gap-1",children:n.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=u):u=e[7];let V;e[8]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx("div",{className:"px-4 py-4",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:n.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[l,n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),n.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=V):V=e[8];let c;return e[9]!==i?(c=n.jsxs("div",{className:i,children:[a,d,V]}),e[9]=i,e[10]=c):c=e[10],c}function Tt(t){const e=L.c(22),{align:s,width:i,lines:r}=t,o=i===void 0?"w-full":i,a=r===void 0?1:r,d=s==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==d?(l=z("flex w-full gap-4 px-4 py-2",d),e[0]=d,e[1]=l):l=e[1];const u=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let V;e[2]!==u?(V=z("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=V):V=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=c):c=e[4];const m=s==="right"?"bg-muted":"bg-transparent border border-border/40";let p;e[5]!==m||e[6]!==o?(p=z("min-w-0 rounded-2xl p-4",m,o),e[5]=m,e[6]=o,e[7]=p):p=e[7];let x;e[8]!==a?(x=Array.from({length:a}),e[8]=a,e[9]=x):x=e[9];let g;e[10]!==a||e[11]!==x?(g=n.jsx("div",{className:"space-y-2",children:x.map((y,A)=>n.jsx("div",{className:z("h-3 rounded bg-muted-foreground/20 animate-pulse",A===a-1?"w-3/4":"w-full"),style:{animationDelay:`${A*.1}s`}},A))}),e[10]=a,e[11]=x,e[12]=g):g=e[12];let f;e[13]!==g||e[14]!==p?(f=n.jsx("div",{className:p,children:g}),e[13]=g,e[14]=p,e[15]=f):f=e[15];let b;e[16]!==f||e[17]!==V?(b=n.jsxs("div",{className:V,children:[c,f]}),e[16]=f,e[17]=V,e[18]=b):b=e[18];let h;return e[19]!==b||e[20]!==l?(h=n.jsx("div",{className:l,children:b}),e[19]=b,e[20]=l,e[21]=h):h=e[21],h}function _c(t){const e=L.c(5),{className:s,children:i}=t;let r;e[0]!==s?(r=z("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==i||e[3]!==r?(o=n.jsx("div",{className:r,children:i}),e[2]=i,e[3]=r,e[4]=o):o=e[4],o}function Cc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function Ic(t){const e=L.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:s}),e[0]=s,e[1]=i):i=e[1],i}function Rc(){const t=L.c(16),{messages:e,status:s}=Dn(),i=fr(e);let r;t[0]!==i?(r=i.at(-1),t[0]=i,t[1]=r):r=t[1];const o=r,a=s==="submitted"||s==="streaming";let d;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const l=e.at(-1),u=!a&&l?.role==="assistant"&&l.parts.filter(Ec).some(Pc),V=!a&&l?.role==="assistant"&&l.parts.some(Tc);let c;if(t[8]!==i||t[9]!==s){let p;t[11]!==i.length||t[12]!==s?(p=(x,g)=>n.jsx(qn,{pair:x,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${x.user.id}`),t[11]=i.length,t[12]=s,t[13]=p):p=t[13],c=i.slice(0,-1).map(p),t[8]=i,t[9]=s,t[10]=c}else c=t[10];let m;t[14]!==c?(m=n.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:c}),t[14]=c,t[15]=m):m=t[15],d=n.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[m,o&&n.jsx("div",{className:z("min-h-full min-w-0 max-w-2xl mx-auto w-full",(u||V)&&"pb-60"),children:n.jsx(qn,{pair:o,isLastPair:!0,status:s},`pair-${o?.user.id}`)})]}),t[2]=a,t[3]=o,t[4]=i,t[5]=e,t[6]=s,t[7]=d}else d=t[7];return d}function Tc(t){return"state"in t&&t.state==="approval-requested"}function Pc(t){return t.state==="input-available"}function Ec(t){return t.type==="tool-user_ask"}function Dc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const Od=Object.assign(_c,{Main:Cc,Messages:Rc,EmptyState:Ic,Footer:Dc,Input:yc,Provider:Hi,ActiveTaskProvider:Qi,Skeleton:Nc,IceBreakers:Wo,NoAiProviderEmptyState:Lr,CreditsEmptyState:wc,CreditsEyebrow:Sc,NoCreditsEyebrow:kc,CreditsExhaustedBanner:Gs});export{uo as A,Od as C,Dd as S,Hl as T,Jl as a,Fd as b,Md as c,Ld as d,Ws as u,Ud as w};
547
+ ${N}`}]}})},t[12]=x,t[13]=c,t[14]=m,t[15]=p,t[16]=E):E=t[16];const D=E,I=Sa;let P;t[17]!==u?(P=(N,R,M)=>{u({id:N,approved:R,...M?{reason:M}:{}})},t[17]=u,t[18]=P):P=t[18];const k=P;if(g){let N;return t[19]!==j||t[20]!==a||t[21]!==h?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(Ys,{userAskParts:h,isStreaming:a,onSubmit:j})}),t[19]=j,t[20]=a,t[21]=h,t[22]=N):N=t[22],N}if(f.length>0){let N;return t[23]!==D||t[24]!==a||t[25]!==f?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(oa,{plans:f,isStreaming:a,onApprove:D,onDismiss:I})}),t[23]=D,t[24]=a,t[25]=f,t[26]=N):N=t[26],N}if(y.length>0||a&&d){let N;return t[27]!==k||t[28]!==a||t[29]!==y?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0",children:n.jsx(na,{approvals:y,isStreaming:a,onRespond:k})}),t[27]=k,t[28]=a,t[29]=y,t[30]=N):N=t[30],N}if(!a&&e){if(xa(e)){let R;return t[31]!==s?(R=n.jsx(Gs,{onDismiss:s}),t[31]=s,t[32]=R):R=t[32],R}let N;return t[33]!==s||t[34]!==e||t[35]!==_?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Ot,{variant:"error",error:e,onDismiss:s,onFixInChat:_})}),t[33]=s,t[34]=e,t[35]=_,t[36]=N):N=t[36],N}if(!a&&i&&i!=="stop"&&!d){let N;return t[37]!==r||t[38]!==i||t[39]!==S?(N=n.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:n.jsx(Ot,{variant:"warning",finishReason:i,onDismiss:r,onContinue:S})}),t[37]=r,t[38]=i,t[39]=S,t[40]=N):N=t[40],N}return null}function Sa(){document.querySelector("[data-chat-input]")?.focus()}function ka(t){return t.state!=="output-available"}function Na(t){return t.type==="tool-user_ask"}tn.Error=function(e){return n.jsx(Ot,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};tn.Warning=function(e){return n.jsx(Ot,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};tn.UserAskQuestion=Ys;async function Un(t,e,s,i,r){if(!en(e)){ne.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Dr(o,e)){const d=Fs(e),l=e?.title??"This model";r?r({fileName:s.name,modelName:l,accepted:d}):ne.error(`"${s.name}" can't be attached`,{description:`${l} accepts ${d}.`});return}const a=10*1024*1024;if(s.size>a){ne.error(`File "${s.name}" exceeds 10MB limit`);return}try{const d=new FileReader,l=new Promise((c,m)=>{d.onload=()=>{const p=d.result;if(typeof p!="string"){m(new Error("Failed to read file as data URL"));return}const x=p.includes(",")?p.split(",")[1]??p:p;c(x)},d.onerror=m});d.readAsDataURL(s);const u=await l,V={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:u};cr(t,{from:i,to:i},V)}catch(d){console.error("Failed to process file:",d),ne.error(`Failed to load file "${s.name}"`)}}function _a(t){const e=L.c(8),{editor:s,selectedModel:i,onUnsupportedFile:r}=t,o=w.useRef(Ia);let a,d;e[0]!==s||e[1]!==r||e[2]!==i?(a=()=>{o.current=async(V,c)=>{await Un(s,i,V,c,r)}},d=[s,i,r],e[0]=s,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),w.useEffect(a,d);let l,u;return e[5]!==s?(l=()=>{if(s?.isDestroyed)return;const V=new bn("fileDropHandler");s.state.plugins.find(p=>p.spec.key===V)&&s.unregisterPlugin(V);const m=new pr({key:V,props:{handleDrop:(p,x,g,f)=>{if(f)return!1;const b=x.dataTransfer?.files;if(!b||b.length===0)return!1;x.preventDefault();const h=p.posAtCoords({left:x.clientX,top:x.clientY});if(!h)return!1;const y=Array.from(b),A=h.pos;for(const _ of y)o.current?.(_,A);return!0},handlePaste:(p,x)=>{const g=x.clipboardData?.items;if(!g)return!1;const f=Array.from(g).filter(Ca);if(f.length===0)return!1;x.preventDefault();const{from:b}=p.state.selection;for(const h of f){const y=h.getAsFile();y&&o.current?.(y,b)}return!0}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(V)}},u=[s],e[5]=s,e[6]=l,e[7]=u):(l=e[6],u=e[7]),w.useEffect(l,u),null}function Ca(t){return t.kind==="file"}function Ia(){return Promise.resolve()}function Ra(t){const e=L.c(24),{selectedModel:s,isStreaming:i,icon:r,onUnsupportedFile:o}=t,{editor:a}=Zt(),d=w.useRef(null);let l;e[0]!==s?(l=en(s),e[0]=s,e[1]=l):l=e[1];const u=l;let V;e[2]!==a||e[3]!==o||e[4]!==s?(V=async _=>{const C=_.target.files;if(!C||C.length===0||!a)return;const S=Array.from(C),{from:v}=a.state.selection,j=v;for(const E of S)await Un(a,s,E,j,o);d.current&&(d.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=V):V=e[5];const c=V;if(!a||!u)return null;let m;e[6]!==s?(m=Er(s),e[6]=s,e[7]=m):m=e[7];let p;e[8]!==c||e[9]!==i||e[10]!==m?(p=n.jsx("input",{ref:d,type:"file",multiple:!0,accept:m,className:"hidden",onChange:c,disabled:i}),e[8]=c,e[9]=i,e[10]=m,e[11]=p):p=e[11];const x=i||!u;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>d.current?.click(),e[12]=g):g=e[12];let f;e[13]!==r?(f=r??n.jsx(ys,{size:16}),e[13]=r,e[14]=f):f=e[14];let b;e[15]!==x||e[16]!==f?(b=n.jsx(bt,{asChild:!0,children:n.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:x,onClick:g,children:f})}),e[15]=x,e[16]=f,e[17]=b):b=e[17];let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(yt,{side:"top",children:"Add file"}),e[18]=h):h=e[18];let y;e[19]!==b?(y=n.jsxs(xt,{children:[b,h]}),e[19]=b,e[20]=y):y=e[20];let A;return e[21]!==y||e[22]!==p?(A=n.jsxs(n.Fragment,{children:[p,y]}),e[21]=y,e[22]=p,e[23]=A):A=e[23],A}function Ta(t){const e=L.c(26),{info:s,onClose:i}=t,r=s!==null;let o;e[0]!==i?(o=_=>!_&&i(),e[0]=i,e[1]=o):o=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(251,191,36,0.35) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(244,114,182,0.25) 0%, transparent 100%)"],e[2]=a):a=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:a.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[3]=d):d=e[3];let l,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:n.jsx(ps,{size:18})}),u=n.jsx(Ue,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=l,e[5]=u):(l=e[4],u=e[5]);const V=s?.fileName;let c;e[6]!==V?(c=n.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[d,n.jsxs(Fe,{className:"relative gap-4",children:[l,n.jsxs("div",{children:[u,n.jsxs(Kt,{className:"mt-1.5 text-sm leading-relaxed",children:[n.jsxs("span",{className:"font-medium text-foreground",children:["“",V,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=V,e[7]=c):c=e[7];const m=s?.modelName;let p;e[8]!==m?(p=n.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[m," accepts"]}),e[8]=m,e[9]=p):p=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ys,{size:14,className:"text-muted-foreground"}),e[10]=x):x=e[10];const g=s?.accepted;let f;e[11]!==g?(f=n.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[x,n.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=f):f=e[12];let b;e[13]!==p||e[14]!==f?(b=n.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:n.jsxs("div",{className:"rounded-xl border border-border p-4",children:[p,f]})}),e[13]=p,e[14]=f,e[15]=b):b=e[15];let h;e[16]!==i?(h=n.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:n.jsx(J,{onClick:i,children:"Got it"})}),e[16]=i,e[17]=h):h=e[17];let y;e[18]!==b||e[19]!==h||e[20]!==c?(y=n.jsxs(Le,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Pa,children:[c,b,h]}),e[18]=b,e[19]=h,e[20]=c,e[21]=y):y=e[21];let A;return e[22]!==r||e[23]!==y||e[24]!==o?(A=n.jsx(Me,{open:r,onOpenChange:o,children:y}),e[22]=r,e[23]=y,e[24]=o,e[25]=A):A=e[25],A}function Pa(t){return t.preventDefault()}function Ea(){const t=L.c(3),[e,s]=w.useState(null);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[0]=i):i=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:i},t[1]=e,t[2]=r):r=t[2],r}var Da=hr;var Ma=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],wn=Ma.join(","),Qs=typeof Element>"u",At=Qs?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,$t=!Qs&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},zt=function(e,s){var i;s===void 0&&(s=!0);var r=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):zt(e.parentNode));return a},La=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},Fa=function(e,s,i){if(zt(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(wn));return s&&At.call(e,wn)&&r.unshift(e),r=r.filter(i),r},jn=function(e,s,i){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!zt(a,!1))if(a.tagName==="SLOT"){var d=a.assignedElements(),l=d.length?d:a.children,u=jn(l,!0,i);i.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else{var V=At.call(a,wn);V&&i.filter(a)&&(s||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),m=!zt(c,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(c&&m){var p=jn(c===!0?a.children:c.children,!0,i);i.flatten?r.push.apply(r,p):r.push({scopeParent:a,candidates:p})}else o.unshift.apply(o,a.children)}}return r},Hs=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Js=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||La(e))&&!Hs(e)?0:e.tabIndex},Ua=function(e,s){var i=Js(e);return i<0&&s&&!Hs(e)?0:i},Oa=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Xs=function(e){return e.tagName==="INPUT"},$a=function(e){return Xs(e)&&e.type==="hidden"},za=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},Ba=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},qa=function(e){if(!e.name)return!0;var s=e.form||$t(e),i=function(d){return s.querySelectorAll('input[type="radio"][name="'+d+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=i(window.CSS.escape(e.name));else try{r=i(e.name)}catch(a){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",a.message),!1}var o=Ba(r,e.form);return!o||o===e},Ka=function(e){return Xs(e)&&e.type==="radio"},Ya=function(e){return Ka(e)&&!qa(e)},Wa=function(e){var s,i=e&&$t(e),r=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,d,l;for(o=!!((a=r)!==null&&a!==void 0&&(d=a.ownerDocument)!==null&&d!==void 0&&d.contains(r)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!o&&r;){var u,V,c;i=$t(r),r=(u=i)===null||u===void 0?void 0:u.host,o=!!((V=r)!==null&&V!==void 0&&(c=V.ownerDocument)!==null&&c!==void 0&&c.contains(r))}}return o},ss=function(e){var s=e.getBoundingClientRect(),i=s.width,r=s.height;return i===0&&r===0},Ga=function(e,s){var i=s.displayCheck,r=s.getShadowRoot;if(i==="full-native"&&"checkVisibility"in e){var o=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!o}if(getComputedStyle(e).visibility==="hidden")return!0;var a=At.call(e,"details>summary:first-of-type"),d=a?e.parentElement:e;if(At.call(d,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof r=="function"){for(var l=e;e;){var u=e.parentElement,V=$t(e);if(u&&!u.shadowRoot&&r(u)===!0)return ss(e);e.assignedSlot?e=e.assignedSlot:!u&&V!==e.ownerDocument?e=V.host:e=u}e=l}if(Wa(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return ss(e);return!1},Qa=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var i=0;i<s.children.length;i++){var r=s.children.item(i);if(r.tagName==="LEGEND")return At.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},Ha=function(e,s){return!(s.disabled||$a(s)||Ga(s,e)||za(s)||Qa(s))},is=function(e,s){return!(Ya(s)||Js(s)<0||!Ha(e,s))},Ja=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Zs=function(e){var s=[],i=[];return e.forEach(function(r,o){var a=!!r.scopeParent,d=a?r.scopeParent:r,l=Ua(d,a),u=a?Zs(r.candidates):d;l===0?a?s.push.apply(s,u):s.push(d):i.push({documentOrder:o,tabIndex:l,item:r,isScope:a,content:u})}),i.sort(Oa).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},ei=function(e,s){s=s||{};var i;return s.getShadowRoot?i=jn([e],s.includeContainer,{filter:is.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:Ja}):i=Fa(e,s.includeContainer,is.bind(null,s)),Zs(i)};function Xa(){return/apple/i.test(navigator.vendor)}const rs="data-floating-ui-focusable";function Za(t){let e=t.activeElement;for(;((s=e)==null||(s=s.shadowRoot)==null?void 0:s.activeElement)!=null;){var s;e=e.shadowRoot.activeElement}return e}function An(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&xi(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function ft(t){return"composedPath"in t?t.composedPath()[0]:t.target}function fn(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const s=t;return s.target!=null&&e.contains(s.target)}function el(t){return t.matches("html,body")}function St(t){return t?.ownerDocument||document}function tl(t){return t?t.hasAttribute(rs)?t:t.querySelector("["+rs+"]")||t:null}function Et(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...Et(t,r.id,s)])}function nl(t){return"nativeEvent"in t}var sl=typeof document<"u",il=function(){},Je=sl?w.useLayoutEffect:il;const rl={...hs},ol=rl.useInsertionEffect,al=ol||(t=>t());function at(t){const e=w.useRef(()=>{});return al(()=>{e.current=t}),w.useCallback(function(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}const ti=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ni(t,e){const s=ei(t,ti()),i=s.length;if(i===0)return;const r=Za(St(t)),o=s.indexOf(r),a=o===-1?e===1?0:i-1:o+e;return s[a]}function ll(t){return ni(St(t).body,1)||t}function cl(t){return ni(St(t).body,-1)||t}function pn(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!An(s,i)}function dl(t){ei(t,ti()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function os(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const i=s.dataset.tabindex;delete s.dataset.tabindex,i?s.setAttribute("tabindex",i):s.removeAttribute("tabindex")})}const ul="data-floating-ui-focusable",as="active",ls="selected",Vl={...hs};let cs=!1,ml=0;const ds=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+ml++;function fl(){const[t,e]=w.useState(()=>cs?ds():void 0);return Je(()=>{t==null&&e(ds())},[]),w.useEffect(()=>{cs=!0},[]),t}const pl=Vl.useId,On=pl||fl;function hl(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var i;(i=t.get(e))==null||i.delete(s)}}}const gl=w.createContext(null),xl=w.createContext(null),si=()=>{var t;return((t=w.useContext(gl))==null?void 0:t.id)||null},ii=()=>w.useContext(xl);function $n(t){return"data-floating-ui-"+t}const bl={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},us=w.forwardRef(function(e,s){const[i,r]=w.useState();Je(()=>{Xa()&&r("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[$n("focus-guard")]:"",style:bl};return n.jsx("span",{...e,...o})}),yl={clipPath:"inset(50%)",position:"fixed",top:0,left:0},ri=w.createContext(null),Vs=$n("portal");function vl(t){t===void 0&&(t={});const{id:e,root:s}=t,i=On(),r=jl(),[o,a]=w.useState(null),d=w.useRef(null);return Je(()=>()=>{o?.remove(),queueMicrotask(()=>{d.current=null})},[o]),Je(()=>{if(!i||d.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=i,u.setAttribute(Vs,""),l.appendChild(u),d.current=u,a(u)},[e,i]),Je(()=>{if(s===null||!i||d.current)return;let l=s||r?.portalNode;l&&!Si(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const V=document.createElement("div");V.id=i,V.setAttribute(Vs,""),l=u||l,l.appendChild(V),d.current=V,a(V)},[e,s,i,r]),o}function wl(t){const{children:e,id:s,root:i,preserveTabOrder:r=!0}=t,o=vl({id:s,root:i}),[a,d]=w.useState(null),l=w.useRef(null),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=a?.modal,p=a?.open,x=!!a&&!a.modal&&a.open&&r&&!!(i||o);return w.useEffect(()=>{if(!o||!r||m)return;function g(f){o&&pn(f)&&(f.type==="focusin"?os:dl)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,m]),w.useEffect(()=>{o&&(p||os(o))},[p,o]),n.jsxs(ri.Provider,{value:w.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:V,afterInsideRef:c,portalNode:o,setFocusManagerState:d}),[r,o]),children:[x&&o&&n.jsx(us,{"data-type":"outside",ref:l,onFocus:g=>{if(pn(g,o)){var f;(f=V.current)==null||f.focus()}else{const b=a?a.domReference:null,h=cl(b);h?.focus()}}}),x&&o&&n.jsx("span",{"aria-owns":o.id,style:yl}),o&&yi.createPortal(e,o),x&&o&&n.jsx(us,{"data-type":"outside",ref:u,onFocus:g=>{if(pn(g,o)){var f;(f=c.current)==null||f.focus()}else{const b=a?a.domReference:null,h=ll(b);h?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const jl=()=>w.useContext(ri),Al={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Sl={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},ms=t=>{var e,s;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(s=t?.outsidePress)!=null?s:!0}};function kl(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:d=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:V=!1,referencePressEvent:c="pointerdown",ancestorScroll:m=!1,bubbles:p,capture:x}=e,g=ii(),f=at(typeof l=="function"?l:()=>!1),b=typeof l=="function"?f:l,h=w.useRef(!1),{escapeKey:y,outsidePress:A}=ms(p),{escapeKey:_,outsidePress:C}=ms(x),S=w.useRef(!1),v=at(k=>{var N;if(!s||!a||!d||k.key!=="Escape"||S.current)return;const R=(N=o.current.floatingContext)==null?void 0:N.nodeId,M=g?Et(g.nodesRef.current,R):[];if(!y&&(k.stopPropagation(),M.length>0)){let T=!0;if(M.forEach(F=>{var O;if((O=F.context)!=null&&O.open&&!F.context.dataRef.current.__escapeKeyBubbles){T=!1;return}}),!T)return}i(!1,nl(k)?k.nativeEvent:k,"escape-key")}),j=at(k=>{var N;const R=()=>{var M;v(k),(M=ft(k))==null||M.removeEventListener("keydown",R)};(N=ft(k))==null||N.addEventListener("keydown",R)}),E=at(k=>{var N;const R=o.current.insideReactTree;o.current.insideReactTree=!1;const M=h.current;if(h.current=!1,u==="click"&&M||R||typeof b=="function"&&!b(k))return;const T=ft(k),F="["+$n("inert")+"]",O=St(r.floating).querySelectorAll(F);let q=De(T)?T:null;for(;q&&!ln(q);){const Q=wi(q);if(ln(Q)||!De(Q))break;q=Q}if(O.length&&De(T)&&!el(T)&&!An(T,r.floating)&&Array.from(O).every(Q=>!An(q,Q)))return;if(ji(T)&&P){const Q=ln(T),W=Ai(T),ie=/auto|scroll/,Y=Q||ie.test(W.overflowX),ee=Q||ie.test(W.overflowY),te=Y&&T.clientWidth>0&&T.scrollWidth>T.clientWidth,se=ee&&T.clientHeight>0&&T.scrollHeight>T.clientHeight,ae=W.direction==="rtl",re=se&&(ae?k.offsetX<=T.offsetWidth-T.clientWidth:k.offsetX>T.clientWidth),oe=te&&k.offsetY>T.clientHeight;if(re||oe)return}const K=(N=o.current.floatingContext)==null?void 0:N.nodeId,H=g&&Et(g.nodesRef.current,K).some(Q=>{var W;return fn(k,(W=Q.context)==null?void 0:W.elements.floating)});if(fn(k,r.floating)||fn(k,r.domReference)||H)return;const Z=g?Et(g.nodesRef.current,K):[];if(Z.length>0){let Q=!0;if(Z.forEach(W=>{var ie;if((ie=W.context)!=null&&ie.open&&!W.context.dataRef.current.__outsidePressBubbles){Q=!1;return}}),!Q)return}i(!1,k,"outside-press")}),D=at(k=>{var N;const R=()=>{var M;E(k),(M=ft(k))==null||M.removeEventListener(u,R)};(N=ft(k))==null||N.addEventListener(u,R)});w.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=y,o.current.__outsidePressBubbles=A;let k=-1;function N(O){i(!1,O,"ancestor-scroll")}function R(){window.clearTimeout(k),S.current=!0}function M(){k=window.setTimeout(()=>{S.current=!1},vi()?5:0)}const T=St(r.floating);d&&(T.addEventListener("keydown",_?j:v,_),T.addEventListener("compositionstart",R),T.addEventListener("compositionend",M)),b&&T.addEventListener(u,C?D:E,C);let F=[];return m&&(De(r.domReference)&&(F=an(r.domReference)),De(r.floating)&&(F=F.concat(an(r.floating))),!De(r.reference)&&r.reference&&r.reference.contextElement&&(F=F.concat(an(r.reference.contextElement)))),F=F.filter(O=>{var q;return O!==((q=T.defaultView)==null?void 0:q.visualViewport)}),F.forEach(O=>{O.addEventListener("scroll",N,{passive:!0})}),()=>{d&&(T.removeEventListener("keydown",_?j:v,_),T.removeEventListener("compositionstart",R),T.removeEventListener("compositionend",M)),b&&T.removeEventListener(u,C?D:E,C),F.forEach(O=>{O.removeEventListener("scroll",N)}),window.clearTimeout(k)}},[o,r,d,b,u,s,i,m,a,y,A,v,_,j,E,C,D]),w.useEffect(()=>{o.current.insideReactTree=!1},[o,b,u]);const I=w.useMemo(()=>({onKeyDown:v,...V&&{[Al[c]]:k=>{i(!1,k.nativeEvent,"reference-press")},...c!=="click"&&{onClick(k){i(!1,k.nativeEvent,"reference-press")}}}}),[v,i,V,c]),P=w.useMemo(()=>{function k(N){N.button===0&&(h.current=!0)}return{onKeyDown:v,onMouseDown:k,onMouseUp:k,[Sl[u]]:()=>{o.current.insideReactTree=!0}}},[v,u,o]);return w.useMemo(()=>a?{reference:I,floating:P}:{},[a,I,P])}function Nl(t){const{open:e=!1,onOpenChange:s,elements:i}=t,r=On(),o=w.useRef({}),[a]=w.useState(()=>hl()),d=si()!=null,[l,u]=w.useState(i.reference),V=at((p,x,g)=>{o.current.openEvent=p?x:void 0,a.emit("openchange",{open:p,event:x,reason:g,nested:d}),s?.(p,x,g)}),c=w.useMemo(()=>({setPositionReference:u}),[]),m=w.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return w.useMemo(()=>({dataRef:o,open:e,onOpenChange:V,elements:m,events:a,floatingId:r,refs:c}),[e,V,m,a,r,c])}function _l(t){t===void 0&&(t={});const{nodeId:e}=t,s=Nl({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,r=i.elements,[o,a]=w.useState(null),[d,l]=w.useState(null),V=r?.domReference||o,c=w.useRef(null),m=ii();Je(()=>{V&&(c.current=V)},[V]);const p=bi({...t,elements:{...r,...d&&{reference:d}}}),x=w.useCallback(y=>{const A=De(y)?{getBoundingClientRect:()=>y.getBoundingClientRect(),getClientRects:()=>y.getClientRects(),contextElement:y}:y;l(A),p.refs.setReference(A)},[p.refs]),g=w.useCallback(y=>{(De(y)||y===null)&&(c.current=y,a(y)),(De(p.refs.reference.current)||p.refs.reference.current===null||y!==null&&!De(y))&&p.refs.setReference(y)},[p.refs]),f=w.useMemo(()=>({...p.refs,setReference:g,setPositionReference:x,domReference:c}),[p.refs,g,x]),b=w.useMemo(()=>({...p.elements,domReference:V}),[p.elements,V]),h=w.useMemo(()=>({...p,...i,refs:f,elements:b,nodeId:e}),[p,f,b,e,i]);return Je(()=>{i.dataRef.current.floatingContext=h;const y=m?.nodesRef.current.find(A=>A.id===e);y&&(y.context=h)}),w.useMemo(()=>({...p,context:h,refs:f,elements:b}),[p,f,b,h])}function hn(t,e,s){const i=new Map,r=s==="item";let o=t;if(r&&t){const{[as]:a,[ls]:d,...l}=t;o=l}return{...s==="floating"&&{tabIndex:-1,[ul]:""},...o,...e.map(a=>{const d=a?a[s]:null;return typeof d=="function"?t?d(t):null:d}).concat(t).reduce((a,d)=>(d&&Object.entries(d).forEach(l=>{let[u,V]=l;if(!(r&&[as,ls].includes(u)))if(u.indexOf("on")===0){if(i.has(u)||i.set(u,[]),typeof V=="function"){var c;(c=i.get(u))==null||c.push(V),a[u]=function(){for(var m,p=arguments.length,x=new Array(p),g=0;g<p;g++)x[g]=arguments[g];return(m=i.get(u))==null?void 0:m.map(f=>f(...x)).find(f=>f!==void 0)}}}else a[u]=V}),a),{})}}function Cl(t){t===void 0&&(t=[]);const e=t.map(d=>d?.reference),s=t.map(d=>d?.floating),i=t.map(d=>d?.item),r=w.useCallback(d=>hn(d,t,"reference"),e),o=w.useCallback(d=>hn(d,t,"floating"),s),a=w.useCallback(d=>hn(d,t,"item"),i);return w.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const Il=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Rl(t,e){var s,i;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:d=!0,role:l="dialog"}=e,u=On(),V=((s=o.domReference)==null?void 0:s.id)||u,c=w.useMemo(()=>{var h;return((h=tl(o.floating))==null?void 0:h.id)||a},[o.floating,a]),m=(i=Il.get(l))!=null?i:l,x=si()!=null,g=w.useMemo(()=>m==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:r?c:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":r?c:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:V},...m==="menu"&&x&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[m,c,x,r,V,l]),f=w.useMemo(()=>{const h={id:c,...m&&{role:m}};return m==="tooltip"||l==="label"?h:{...h,...m==="menu"&&{"aria-labelledby":V}}},[m,c,V,l]),b=w.useCallback(h=>{let{active:y,selected:A}=h;const _={role:"option",...y&&{id:c+"-fui-option"}};switch(l){case"select":case"combobox":return{..._,"aria-selected":A}}return{}},[c,l]);return w.useMemo(()=>d?{reference:g,floating:f,item:b}:{},[d,g,f,b])}function Tl(t){const e=L.c(26),{editor:s,query:i,items:r,onSelect:o,onClose:a}=t,[d,l]=w.useState(0),u=w.useRef(r),V=w.useRef(d),c=w.useRef(o),m=w.useRef(a),p=w.useDeferredValue(i);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{l(0)},e[0]=x):x=e[0];let g;e[1]!==p?(g=[p],e[1]=p,e[2]=g):g=e[2],w.useEffect(x,g);let f,b;e[3]!==r.length||e[4]!==d?(f=()=>{d>=r.length&&r.length>0&&l(0)},b=[r.length,d],e[3]=r.length,e[4]=d,e[5]=f,e[6]=b):(f=e[5],b=e[6]),w.useEffect(f,b);let h,y;e[7]!==r?(h=()=>{u.current=r},y=[r],e[7]=r,e[8]=h,e[9]=y):(h=e[8],y=e[9]),w.useEffect(h,y);let A,_;e[10]!==d?(A=()=>{V.current=d},_=[d],e[10]=d,e[11]=A,e[12]=_):(A=e[11],_=e[12]),w.useEffect(A,_);let C,S;e[13]!==o?(S=()=>{c.current=o},C=[o],e[13]=o,e[14]=C,e[15]=S):(C=e[14],S=e[15]),w.useEffect(S,C);let v,j;e[16]!==a?(v=()=>{m.current=a},j=[a],e[16]=a,e[17]=v,e[18]=j):(v=e[17],j=e[18]),w.useEffect(v,j);let E;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(E=()=>{const k=s.view.dom;if(s?.isDestroyed||!k)return;const N=M=>{const T=u.current;if(!T.length)return!1;const F=()=>l(q=>(q+1)%T.length),O=()=>l(q=>(q-1+T.length)%T.length);switch(M.key){case"ArrowUp":return M.preventDefault(),O(),!0;case"ArrowDown":return M.preventDefault(),F(),!0;case"Tab":return M.preventDefault(),M.shiftKey?O():F(),!0;case"Home":return M.preventDefault(),l(0),!0;case"End":return M.preventDefault(),l(T.length-1),!0;case"Enter":{if(M.isComposing)return!1;M.preventDefault();const q=V.current;return q!==-1&&T[q]&&c.current?.(T[q],q),!0}case"Escape":return M.preventDefault(),m.current?.(),!0;default:return!1}},R=M=>{N(M)};return k.addEventListener("keydown",R,!0),()=>{k?.removeEventListener("keydown",R,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=E):E=e[21];let D;e[22]!==s?(D=[s],e[22]=s,e[23]=D):D=e[23],w.useEffect(E,D);const I=r.length?d:void 0;let P;return e[24]!==I?(P={selectedIndex:I,setSelectedIndex:l},e[24]=I,e[25]=P):P=e[25],P}function Pl(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const oi=w.createContext(void 0);function ai(){const t=w.useContext(oi);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function El({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:r}){const[o,a]=w.useReducer(Pl,{open:!1,element:null,query:"",range:null,selectedItem:null}),d=w.useRef(r);return d.current=r,w.useEffect(()=>{if(t?.isDestroyed)return;const l=s instanceof bn?s:new bn(s);t.state.plugins.find(c=>c.spec.key===l)&&t.unregisterPlugin(l);const V=Fr({pluginKey:l,editor:t,char:e,allow(c){const m=t.state.doc.resolve(c.range.from);for(let p=m.depth;p>0;p--)if(m.node(p).type.name==="image")return!1;return!(i&&!i(c))},command(){},render:()=>({onStart:c=>{a({type:"ON_START",payload:{element:c.decorationNode??null,query:c.query,range:c.range}}),d.current?.(!0)},onUpdate:c=>{a({type:"ON_UPDATE",payload:{element:c.decorationNode??null,query:c.query,range:c.range}})},onKeyDown:c=>c.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),d.current?.(!1)}}),items:()=>[]});return t.registerPlugin(V),()=>{t?.isDestroyed||t.unregisterPlugin(l)}},[t,s,e,a,i]),{state:o,dispatch:a}}function Dl({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:r,dispatch:o}=ai(),a=w.useDeferredValue(r.query),{data:d}=ki({queryKey:ve.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),l=()=>{o({type:"ON_EXIT"})},u=async(c,m)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:c});try{const{view:p}=t,g=p.state.selection.$to.nodeAfter?.text?.startsWith(" "),f=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(f.to+=1),await i({range:f,item:c})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):l()}catch{l()}}},{selectedIndex:V}=Tl({editor:t,query:a,items:d,onSelect:u,onClose:l});return{selectedItem:r.selectedItem,items:d,selectedIndex:V,close:l,onSelect:u}}function Ml({children:t}){const{state:e,dispatch:s}=ai(),{open:i,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:d,context:l}=_l({placement:"bottom-start",open:i,onOpenChange:m=>{m||o()},elements:{reference:r},middleware:[Ni(10),_i(),Ci()],whileElementsMounted:Ii}),u=kl(l,{outsidePress:m=>!(m.target instanceof Element&&m.target.closest(".ProseMirror"))}),V=Rl(l,{role:"listbox"}),{getFloatingProps:c}=Cl([u,V]);return i?n.jsx(wl,{children:n.jsx("div",{ref:a.setFloating,style:d,...c(),className:"z-50 w-auto min-w-[360px] max-w-[520px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const Ll=t=>{const e=L.c(29),{item:s,isSelected:i,onSelect:r,isLoading:o,ref:a}=t;let d;if(e[0]!==s){const C=Ge(s._meta);d=s.title||Xt(s.name,C),e[0]=s,e[1]=d}else d=e[1];const l=d,u=s.description||null,V=s.icon,c=i&&"bg-accent text-accent-foreground",m=o&&"pointer-events-none opacity-50";let p;e[2]!==c||e[3]!==m?(p=z("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",c,m),e[2]=c,e[3]=m,e[4]=p):p=e[4];let x;e[5]!==V||e[6]!==l?(x=V!==void 0&&n.jsx(En,{icon:V,name:l,size:"xs",className:"mr-2"}),e[5]=V,e[6]=l,e[7]=x):x=e[7];let g;e[8]!==l?(g=n.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:l}),e[8]=l,e[9]=g):g=e[9];let f;e[10]!==o?(f=o&&n.jsx(Mt,{size:"xs"}),e[10]=o,e[11]=f):f=e[11];let b;e[12]!==g||e[13]!==f?(b=n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,f]}),e[12]=g,e[13]=f,e[14]=b):b=e[14];let h;e[15]!==u?(h=u&&n.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:u}),e[15]=u,e[16]=h):h=e[16];let y;e[17]!==b||e[18]!==h?(y=n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[b,h]}),e[17]=b,e[18]=h,e[19]=y):y=e[19];let A;e[20]!==s.drillable?(A=s.drillable&&n.jsx("kbd",{className:"shrink-0 ml-2 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground bg-muted border border-border rounded",children:"↵"}),e[20]=s.drillable,e[21]=A):A=e[21];let _;return e[22]!==r||e[23]!==a||e[24]!==y||e[25]!==A||e[26]!==p||e[27]!==x?(_=n.jsxs("div",{ref:a,onClick:r,className:p,children:[x,y,A]}),e[22]=r,e[23]=a,e[24]=y,e[25]=A,e[26]=p,e[27]=x,e[28]=_):_=e[28],_},Fl=t=>{const e=L.c(18),{editor:s,queryKey:i,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==i?(a={editor:s,queryKey:i,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a):a=e[4];const{items:d,selectedIndex:l,onSelect:u,selectedItem:V}=Dl(a);if(!d.length){let x;return e[5]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=x):x=e[5],x}let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=c):c=e[6];let m;if(e[7]!==u||e[8]!==d||e[9]!==l||e[10]!==V?.name){let x;e[12]!==u||e[13]!==l||e[14]!==V?.name?(x=(g,f)=>n.jsx(Ll,{item:g,isSelected:f===l,ref:f===l?$l:void 0,onSelect:()=>u(g,f),isLoading:V?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=V?.name,e[15]=x):x=e[15],m=d.map(x),e[7]=u,e[8]=d,e[9]=l,e[10]=V?.name,e[11]=m}else m=e[11];let p;return e[16]!==m?(p=n.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:c,children:n.jsx("div",{className:"p-1",children:m})}),e[16]=m,e[17]=p):p=e[17],p};function Ul(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"p-1",children:[...Array(3)].map(Ol)}),t[0]=e):e=t[0],e}function Ol(t,e){return n.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[n.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),n.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function li(t){const e=L.c(18),{editor:s,char:i,pluginKey:r,queryKey:o,queryFn:a,onSelect:d,allow:l,onOpenChange:u}=t;let V;e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==u||e[4]!==r?(V={editor:s,char:i,pluginKey:r,allow:l,onOpenChange:u},e[0]=l,e[1]=i,e[2]=s,e[3]=u,e[4]=r,e[5]=V):V=e[5];const{state:c,dispatch:m}=El(V);let p;e[6]!==m||e[7]!==c?(p={state:c,dispatch:m},e[6]=m,e[7]=c,e[8]=p):p=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Ul,{}),e[9]=x):x=e[9];let g;e[10]!==s||e[11]!==d||e[12]!==a||e[13]!==o?(g=n.jsx(Ml,{children:n.jsx(w.Suspense,{fallback:x,children:n.jsx(Fl,{editor:s,queryKey:o,queryFn:a,onSelect:d})})}),e[10]=s,e[11]=d,e[12]=a,e[13]=o,e[14]=g):g=e[14];let f;return e[15]!==p||e[16]!==g?(f=n.jsx(oi.Provider,{value:p,children:g}),e[15]=p,e[16]=g,e[17]=f):f=e[17],f}function $l(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const zl=[{name:"agents",title:"Agents",description:"Mention an agent to hand off work",kind:"category",drillable:!0},{name:"resources",title:"Resources",description:"Attach a resource as context",kind:"category",drillable:!0}],Bl=({editor:t,virtualMcpId:e})=>{const s=qt(),{org:i}=ue(),r=er(),o=qe({connectionId:e,orgId:i.id,orgSlug:i.slug}),a=ve.virtualMcpResources(e,i.id),[d,l]=w.useState("categories"),u=w.useRef(d);u.current=d;const V=w.useRef(null),c=w.useRef(!1),m=["at-mention",i.id,e??"default",d],p=async({item:f,range:b})=>{if($("chat_picker_item_selected",{picker:"@",item_kind:f.kind,item_name:f.name}),f.kind!=="category"&&(c.current=!0),f.kind==="category")return l(f.name==="agents"?"agents":"resources"),!1;if(f.kind==="agent"&&f.agentId){wt(t,b,{id:f.agentId,name:f.name,metadata:{agentId:f.agentId,title:f.name},char:"@"}),l("categories");return}if(f.kind==="resource"&&f.uri&&o){try{const h=await Us(o,f.uri);wt(t,b,{id:f.uri,name:f.uri,metadata:h.contents,char:"@"})}catch(h){console.error("[at-mention] Failed to fetch resource:",h),ne.error("Failed to load resource. Please try again.")}l("categories");return}},x=async f=>{const{query:b}=f,h=u.current;if(h==="categories"){if(!b.trim())return zl;const _=b.toLowerCase(),C=r.filter(v=>v.status==="active"&&(!v.id||!Bn(v.id))&&v.id!==e&&(v.title.toLowerCase().includes(_)||v.description?.toLowerCase().includes(_))).map(v=>({name:v.title,title:v.title,description:v.description??void 0,icon:v.icon??null,kind:"agent",agentId:v.id})),S=await(async()=>{if(!o)return[];let v=s.getQueryData(a);return v||(v=await s.fetchQuery({queryKey:a,queryFn:()=>vt(o),staleTime:6e4})),(v?.resources??[]).filter(j=>j.uri.toLowerCase().includes(_)||j.name?.toLowerCase().includes(_)||j.description?.toLowerCase().includes(_)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}))})();return[...C,...S]}if(h==="agents"){let _=r.filter(C=>C.status==="active"&&(!C.id||!Bn(C.id))&&C.id!==e);if(b.trim()){const C=b.toLowerCase();_=_.filter(S=>S.title.toLowerCase().includes(C)||S.description?.toLowerCase().includes(C))}return _.map(C=>({name:C.title,title:C.title,description:C.description??void 0,icon:C.icon??null,kind:"agent",agentId:C.id}))}if(!o)return[];let y=s.getQueryData(a);y?s.fetchQuery({queryKey:a,queryFn:()=>vt(o),staleTime:6e4}).catch(()=>{}):y=await s.fetchQuery({queryKey:a,queryFn:()=>vt(o),staleTime:6e4});let A=y?.resources??[];if(b.trim()){const _=b.toLowerCase();A=A.filter(C=>C.uri.toLowerCase().includes(_)||C.name?.toLowerCase().includes(_)||C.description?.toLowerCase().includes(_))}return A.map(_=>({name:_.name??_.uri,title:_.name,description:_.description,kind:"resource",uri:_.uri}))},g=f=>{if(f)V.current=Date.now(),c.current=!1,$("chat_picker_opened",{picker:"@"});else{const b=V.current;$("chat_picker_closed",{picker:"@",outcome:c.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),V.current=null,l("categories")}};return n.jsx(li,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:x,onSelect:p,onOpenChange:g})};function ql(t,e,s){const i=tr(t),r=Ti(),o=new Map(r.map(u=>[u.id,u])),a=(i?.connections??[]).map(u=>u.connection_id),{data:d}=In({queryKey:ve.promptConnectionMap(e,a),queryFn:async()=>{const u={};return await Promise.all(a.map(async V=>{try{const c=await Pi({connectionId:V,orgId:e,orgSlug:s}),m=await Lt(c);for(const p of m.prompts)p.name in u||(u[p.name]=V)}catch{}})),u},staleTime:6e4,enabled:a.length>0}),l=new Map;for(const[u,V]of Object.entries(d??{})){const c=o.get(V);c&&l.set(u,c)}return l}async function fs(t,e,s,i,r,o){try{const a=await Ln(s,i,o);wt(t,e,{id:i,name:Mn(i,r),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),ne.error("Failed to load prompt. Please try again.")}}async function Kl(t,e,s,i){try{const r=await Us(s,i);wt(t,e,{id:i,name:i,metadata:r.contents,char:"/"})}catch(r){console.error("[slash] Failed to fetch resource:",r),ne.error("Failed to load resource. Please try again.")}}const Yl=({editor:t,virtualMcpId:e})=>{const s=qt(),{org:i}=ue(),r=qe({connectionId:e,orgId:i.id,orgSlug:i.slug}),o=ql(e,i.id,i.slug),a=w.useRef(o);a.current=o;const d=ve.virtualMcpPrompts(e,i.id),l=ve.virtualMcpResources(e,i.id),u=["slash-mention",i.id,e??"default"],[V,c]=w.useState(null),m=w.useRef(null),p=w.useRef(!1),x=async({item:h,range:y})=>{if($("chat_picker_item_selected",{picker:"/",item_kind:h.kind,item_name:h.name}),p.current=!0,!!r)if(h.kind==="prompt"){if(h.arguments&&h.arguments.length>0){c({range:y,item:h});return}const A=Ge(h._meta);await fs(t,y,r,h.name,A)}else h.uri&&await Kl(t,y,r,h.uri)},g=async h=>{if(!V||!r)return;const{range:y,item:A}=V,_=Ge(A._meta);await fs(t,y,r,A.name,_,h),c(null)},f=async h=>{const{query:y}=h;if(!r)return[];const[A,_]=await Promise.all([Wl(s,d,r),Gl(s,l,r)]),C=y.trim().toLowerCase(),S=(A??[]).filter(j=>!C||j.name.toLowerCase().includes(C)||j.title?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C)).map(j=>({name:j.name,title:j.title,description:j.description,icon:a.current.get(j.name)?.icon??null,kind:"prompt",arguments:j.arguments,_meta:j._meta})),v=(_??[]).filter(j=>!C||j.uri.toLowerCase().includes(C)||j.name?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C)).map(j=>({name:j.name??j.uri,title:j.name,description:j.description,kind:"resource",uri:j.uri}));return[...S,...v]},b=V?.item.kind==="prompt"?{name:V.item.name,arguments:V.item.arguments,description:V.item.description}:null;return n.jsxs(n.Fragment,{children:[n.jsx(li,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:u,queryFn:f,onSelect:x,onOpenChange:h=>{if(h)m.current=Date.now(),p.current=!1,$("chat_picker_opened",{picker:"/"});else{const y=m.current;$("chat_picker_closed",{picker:"/",outcome:p.current?"selected":"dismissed",duration_ms:y?Date.now()-y:null}),m.current=null}}}),n.jsx(Fn,{prompt:b,setPrompt:()=>c(null),onSubmit:g})]})};async function Wl(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Lt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Lt(s),staleTime:6e4}),i?.prompts??[]}async function Gl(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>vt(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>vt(s),staleTime:6e4}),i?.resources??[]}function Ql(t){return[br.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Da.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),dr,ur]}function Hl({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:r,onSubmit:o,children:a}){const d=w.useRef(o),l=w.useRef(e),u=w.useRef(i),V=w.useRef(r),c=gr({extensions:Ql(V),content:t||"",editorProps:{attributes:{"data-chat-input":"true",class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(m,p)=>p.key==="Enter"&&!p.shiftKey&&u.current?(p.preventDefault(),d.current?.(),!0):!1},onUpdate:({editor:m})=>{l.current(m?.getJSON())}});return w.useEffect(()=>{c?.setEditable(!s)},[c,s]),w.useEffect(()=>{d.current=o},[o]),w.useEffect(()=>{l.current=e},[e]),w.useEffect(()=>{u.current=i},[i]),w.useEffect(()=>{V.current=r},[r]),w.useEffect(()=>{if(c?.isDestroyed)return;const m=JSON.stringify(c?.getJSON()),p=JSON.stringify(t||{type:"doc",content:[]});m!==p&&c.commands.setContent(t||{type:"doc",content:[]})},[c,t]),n.jsx(xr.Provider,{value:{editor:c},children:a})}function Jl(t){const e=L.c(26),{disabled:s,virtualMcpId:i,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:d,className:l}=t,u=s===void 0?!1:s,V=r===void 0?!1:r,{editor:c}=Zt();let m,p;if(e[0]!==c?(m=()=>({focus:()=>{c?.commands.focus()},clear:()=>{c?.commands.clearContent(!0)},appendText:v=>{if(!c)return;const j=c.state.doc.textContent.trim()==="";c.commands.focus("end"),j||c.commands.insertContent(" "),c.commands.insertContent(v)},syncVoiceText:(v,j)=>{if(c&&(c.commands.setContent(v||{type:"doc",content:[]}),j)){c.commands.focus("end");const E=c.state.doc.textContent.trim().length>0;c.commands.insertContent(E?" "+j:j)}},restoreContent:v=>{c&&c.commands.setContent(v||{type:"doc",content:[]})}}),p=[c],e[0]=c,e[1]=m,e[2]=p):(m=e[1],p=e[2]),w.useImperativeHandle(d??null,m,p),!c)return null;const x=u&&"cursor-not-allowed opacity-70",g=u&&"[&_.ProseMirror]:cursor-not-allowed";let f;e[3]!==l||e[4]!==x||e[5]!==g?(f=z("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",l,"[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",x,g),e[3]=l,e[4]=x,e[5]=g,e[6]=f):f=e[6];let b;e[7]!==c||e[8]!==f?(b=n.jsx(yr,{editor:c,className:f}),e[7]=c,e[8]=f,e[9]=b):b=e[9];const h=i??null;let y;e[10]!==c||e[11]!==h?(y=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Yl,{editor:c,virtualMcpId:h})}),e[10]=c,e[11]=h,e[12]=y):y=e[12];const A=i??null;let _;e[13]!==c||e[14]!==A?(_=n.jsx(w.Suspense,{fallback:null,children:n.jsx(Bl,{editor:c,virtualMcpId:A})}),e[13]=c,e[14]=A,e[15]=_):_=e[15];let C;e[16]!==c||e[17]!==a||e[18]!==o||e[19]!==V?(C=V&&o?n.jsx(_a,{editor:c,selectedModel:o,onUnsupportedFile:a}):null,e[16]=c,e[17]=a,e[18]=o,e[19]=V,e[20]=C):C=e[20];let S;return e[21]!==y||e[22]!==_||e[23]!==C||e[24]!==b?(S=n.jsxs(n.Fragment,{children:[b,y,_,C]}),e[21]=y,e[22]=_,e[23]=C,e[24]=b,e[25]=S):S=e[25],S}function Sn(t){const e=L.c(3),[s]=Cn();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Ur(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=i):i=e[2],i}const Xl={name:"switch-005",dataUri:"data:audio/mpeg;base64,SUQzBAAAAAAAIlRTU0VAAAAOAAADTGF2ZjYyLjMuMTAwAAAAAAAAAAAAAAD/+1DAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABkAABU4ABMTEx0dHR0nJycnMTExMTs7OztERERETk5OTlhYWFhiYmJibGxsbHZ2dnZ/f39/iYmJiZOTk5OdnZ2dp6enp7GxsbG7u7u7xMTExM7Ozs7Y2NjY4uLi4uzs7Oz29vb2/////wAAAABMYXZjNjIuMTEAAAAAAAAAAAAAAAAkBVYAAAAAAAAVOPCP8KUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//tQxAAACEwDXvQRAAG8Ii93HtACUCAABAKCJwfaCEHwfeoEAQdEAYygIHBOCAIAgCAJh9QIOg+D5/ygPh/wfB8DuKAgCHyn9QPh/5SCDv+CEHAQdxOD4B27c39tbckkqYbBAYAN9bNJLB+aXAf5wQAKdzxfbmrVIRQ4xNx3HwnoDmLhfMhgJiiw/HREXNCHqjvHEPEG8QjBYlxQNepJAT0kC8ip6JzSWj1TasoG+iyycbf2Uil1ovf1f/oUtR1qP+s1WSBFKoAAU02BDjMhuP/7UsQEgws8bRpd8YABJYPeBf9wCGXTGxBYcw5AJFMFMAmQQAhGAxgLBgHIAMYAAALhgAchipbe/91aU1VV4zcZj1Vf1XgYCIMBNrsBAIGs9/Ue4i/xFPeqCqwViI9/UeLf///rOngdA3OPHFjmOBv+EQnGahgaZxVplmkAH5JadDTQlNCEuGNiWYbCCONWdUJg6HXNazFdu1T+VgaEpOP70exv7f2/4b/yH//2/4cqCX/zWRUrIw+IPNMNlDnjAXQas/I4AzmYifA0tMSCgQDF//tSxBCDSzzi3k/sQwEyCtjJ/rBZAk+Uqj1YhA5YMCAAMwgOUchTkK7OR7LbMl0W1H6SvzG0Q2ZzfKUhnmTobv9DNhS1v7P8h//8Gv8gTRt1jReZ7YEjmMQg9hhwwMycHooasFmZyjcZGBKJD+IwbMCQQLoi+IQXCcIoydKoilI2MWFS5uJdDEu2taRrYI2ZSqKY50pJLv2NfjUAAuQAMfqVQ/T3PDQgMJMeEZ45hJzY6MNoFMxqTj1zNGQKJjAxEsSCBgQJBSIL0mcKYQJfVAn/+1LEGwLKlEKrD3MiYcuMkVa/wABB8Vh6M1q1epbvXwWBURhkyEhWZ/////////////9gjZ/Wt4w+4MNMCpE4TBYQl4w1IHvMDdA2zBngBMwc8COMDhCpDAfgOAAgrBgNYU+YC0FBGAkAMpgWoSCYAGESGBGAKBgXgJOdiOJmMCmNwCYNDJhYRPykRCJhTBnEUzlsjv4UNLj/z97n3Mv/7z1nZqyitYAZIqErIwMwJAqEw0GAAMFptJMaqFwB8CQIWlhuhuDAwNjfuwrQFAYXCf/7UsQVAA+9PTP42gYRdiIu9zBwAPbFUCi0DAhgNcS+7cDwVgM05A9bUDeuQMyE/u3CygVISgZhpIau/9PhdQG2C9DpxZZJmn/dn/Psmt0EFm////l84ThUTopE4VD/9JkubOGasTvN30C20G21qgUCkVCoUCgPMywrPCGly27V5q5t24vl/8jSlSAPCxzNseNCw3oh3NGBu4BZJ5hv7DRSfR/+eWG7nA8IKh2Olv5iz3q5m3//Joxo3JqNyYkSuGt/k6D4DeoBOHmHdl0dkZYA//tSxAUAC4B1Z/2DADEcA17Z/uhI4Yoik/TrZo+ww7UtmpW4LDWu2IacoJKJJeTSM+ZmAYBEiU+ZnnAwCn1VVVV6JUJQVnioKhrgqdKgqGpUFeCp0sDR3ztQNREDRUFioKuxKCpYGQBlRIBk+aLwb8KblGQVDdphPYTUdBOGbVpAaTF6ZdjEV0iRUZRCYkA4oUQDx5zqDugtXvza/7fuNNvfZ+j9v+T/2f//J/4cAAOTpE5K4zksR9MfIB+TDcQTI4gNs1XKAzEFUrGkxABYEBb/+1LEEYNKrEjgT/TCwYYVmUX+mHoKgWhKU5Eiw9SFIRmppw+3fYo4siPhUFeexM8KgIO6wVuPDDy01qeRaVbw357//y3+o8M0pBNlNLCGBzGKwyYw2IIFOE1WNTjRM6x8MlA1AxDhUHTAkEiyKpnbWrLcaOBotBUKbk1pypcWDAIK00AhKLGkUco6q9VWvM53mcaq3tVa8zjTM/tX//EDP//////////XAAmrwAAPoKwcw0ShDCZD/BQlhzinxQdorsOuXTEIC01ZkJyu4k/qPP/7UsQUAEjkrrkvZaPBIRXUoe5QObfMhYKX9RVgTPqCSCaSCaSC0XVdV1f/////6IAlguuAJSiDRNloNBsZg+0+Ts8MMCn81WUTRAlIi+GHECD0y8AWDIqswYsxGOSKVV7MqOni8tkVOip0fZX/////9HrMCbAz2EHGS4GKAAiRAAAYAcDdKd4G6Z/nwYgJ0ZAIgZyC8aPAs/iPBhwMpWDQNARltNS5Y61v//9i8Yl4SkFkIGTkAc0UBrIYLPA4MYBEy+YLMRuY4nhTC3hZA68H//tSxCoAyQC6mY6CkWDJBIsBz/QUrgNmahSzcrYw0/HhfnMAZBojDsgTFkDR5MDkG/DZEbk2FCmowqdqv2TYABiJwqqYjaQRGZ1URZ1DhSsdiHX/GBu0QpzIBNSaLqZ0ARkwFARxMrpt/Eh47mbQAhhU6sisFUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LESoHHJCRaj/dmYAIAQAAQAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsSLg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7UsShg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+1LEoYPAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV//tSxKGDwAABpAAAACAAADSAAAAEVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy4xMDBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",duration:.609,format:"mp3",license:"CC0",author:"Kenney"},Zl=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function ec(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1.5",children:Zl.map(tc)}),t[0]=e):e=t[0],e}function tc(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function nc(t){const e=L.c(130),{disabled:s,onOpenConnections:i,virtualMcpId:r}=t,[o,a]=w.useState(!1),d=Sn(Xl),{org:l}=ue(),{editor:u}=Zt();let V;e[0]!==l.id||e[1]!==l.slug||e[2]!==r?(V={connectionId:r,orgId:l.id,orgSlug:l.slug},e[0]=l.id,e[1]=l.slug,e[2]=r,e[3]=V):V=e[3];const c=qe(V);let m;e[4]!==l.id||e[5]!==r?(m=ve.virtualMcpPrompts(r,l.id),e[4]=l.id,e[5]=r,e[6]=m):m=e[6];const p=m;let x;e[7]!==c?(x=()=>Lt(c),e[7]=c,e[8]=x):x=e[8];const g=o&&!!c;let f;e[9]!==p||e[10]!==x||e[11]!==g?(f={queryKey:p,queryFn:x,staleTime:6e4,enabled:g},e[9]=p,e[10]=x,e[11]=g,e[12]=f):f=e[12];const{data:b,isLoading:h}=In(f);let y;e[13]!==b?.prompts?(y=b?.prompts??[],e[13]=b?.prompts,e[14]=y):y=e[14];const A=y,[_,C]=w.useState(null),{credentialId:S,imageModel:v,setImageModel:j,deepResearchModel:E,setDeepResearchModel:D,chatMode:I,setChatMode:P,simpleModeEnabled:k}=Yt(),N=I==="plan",[R,M]=w.useState(!1),[T,F]=w.useState(!1),{models:O,isLoading:q}=Pr(R||T?S??void 0:void 0);let K,H,Z,Q,W,ie,Y,ee,te,se,ae,re,oe;if(e[15]!==_||e[16]!==O||e[17]!==I||e[18]!==c||e[19]!==E||e[20]!==s||e[21]!==u||e[22]!==v||e[23]!==R||e[24]!==q||e[25]!==N||e[26]!==i||e[27]!==o||e[28]!==d||e[29]!==T||e[30]!==P||e[31]!==D||e[32]!==j||e[33]!==k){const Ve=O.filter(ic),ut=O.filter(sc);let we;e[47]!==I||e[48]!==N||e[49]!==d||e[50]!==P?(we=()=>{d();const B=N?"default":"plan";$("chat_mode_changed",{from_mode:I,to_mode:B,source:"tools_popover"}),P(B),a(!1)},e[47]=I,e[48]=N,e[49]=d,e[50]=P,e[51]=we):we=e[51];const Re=we;let je;e[52]!==i?(je=()=>{i(),a(!1)},e[52]=i,e[53]=je):je=e[53],Z=je;let Ae;e[54]!==c||e[55]!==u?(Ae=async(B,Ye)=>{if(!u||!c)return;const Vt=Ge(B._meta),mt={from:u.state.selection.from,to:u.state.selection.to};try{const di=await Ln(c,B.name,Ye);wt(u,mt,{id:B.name,name:Mn(B.name,Vt),metadata:di.messages,char:"/"})}catch{ne.error("Failed to load prompt. Please try again.")}},e[54]=c,e[55]=u,e[56]=Ae):Ae=e[56];const ye=Ae;let $e;e[57]!==ye?($e=async B=>{a(!1);const Ye=!!(B.arguments&&B.arguments.length>0);if($("chat_prompt_inserted",{prompt_name:B.name,with_arguments:Ye}),Ye){C(B);return}await ye(B)},e[57]=ye,e[58]=$e):$e=e[58],W=$e;let U;e[59]!==_||e[60]!==ye?(U=async B=>{_&&(await ye(_,B),C(null))},e[59]=_,e[60]=ye,e[61]=U):U=e[61],Q=U;let X;e[62]!==d||e[63]!==j?(X=B=>{d(),$("chat_image_model_selected",{model_id:B.modelId,model_title:B.title,provider:B.providerId??null}),j(B),a(!1)},e[62]=d,e[63]=j,e[64]=X):X=e[64];const Se=X;let ke;e[65]!==d||e[66]!==D?(ke=B=>{d(),$("chat_search_model_selected",{model_id:B.modelId,model_title:B.title,provider:B.providerId??null}),D(B),a(!1)},e[65]=d,e[66]=D,e[67]=ke):ke=e[67];const Te=ke;let ze;e[68]!==I||e[69]!==d||e[70]!==P?(ze=()=>{d();const B=I==="gen-image"?"default":"gen-image";$("chat_mode_changed",{from_mode:I,to_mode:B,source:"tools_popover"}),P(B),a(!1)},e[68]=I,e[69]=d,e[70]=P,e[71]=ze):ze=e[71];const Be=ze;let le;e[72]!==I||e[73]!==d||e[74]!==P?(le=()=>{d();const B=I==="web-search"?"default":"web-search";$("chat_mode_changed",{from_mode:I,to_mode:B,source:"tools_popover"}),P(B),a(!1)},e[72]=I,e[73]=d,e[74]=P,e[75]=le):le=e[75];const Pe=le,et=I==="gen-image",tt=I==="web-search";H=Ss,ee=o,e[76]!==I||e[77]!==o?(te=B=>{B&&!o&&$("chat_tools_popover_opened",{chat_mode:I}),a(B)},e[76]=I,e[77]=o,e[78]=te):te=e[78];let Nt,_t;e[79]===Symbol.for("react.memo_cache_sentinel")?(Nt=n.jsx(Fi,{size:14}),_t=n.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[79]=Nt,e[80]=_t):(Nt=e[79],_t=e[80]),e[81]!==s?(se=n.jsx(ks,{asChild:!0,children:n.jsxs(J,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[Nt,_t]})}),e[81]=s,e[82]=se):se=e[82],K=Ns,ae="start",re="w-52 p-1.5";const nn=N&&"text-violet-600 dark:text-violet-400";let nt;e[83]!==nn?(nt=z(nn),e[83]=nn,e[84]=nt):nt=e[84];const sn=N&&"text-violet-500";let st;e[85]!==sn?(st=z(sn),e[85]=sn,e[86]=st):st=e[86];let it;e[87]!==st?(it=n.jsx(_s,{size:16,className:st}),e[87]=st,e[88]=it):it=e[88];let Ct;e[89]===Symbol.for("react.memo_cache_sentinel")?(Ct=n.jsx("span",{className:"flex-1",children:"Plan mode"}),e[89]=Ct):Ct=e[89];let rt;e[90]!==N?(rt=N&&n.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[90]=N,e[91]=rt):rt=e[91],e[92]!==Re||e[93]!==nt||e[94]!==it||e[95]!==rt?(oe=n.jsxs(Ee,{onClick:Re,className:nt,children:[it,Ct,rt]}),e[92]=Re,e[93]=nt,e[94]=it,e[95]=rt,e[96]=oe):oe=e[96],ie=k?n.jsxs(Ee,{onClick:Be,className:z(et&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(yn,{size:16,className:z(et&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),et&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):n.jsxs(cn,{open:R,onOpenChange:M,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(Ee,{onClick:Be,disabled:!v,className:z("flex-1 rounded-r-none pr-1",et&&"text-pink-600 dark:text-pink-400"),children:[n.jsx(yn,{size:16,className:z(et&&"text-pink-500")}),n.jsx("span",{className:"flex-1",children:"Create image"}),et&&n.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),n.jsx(zn,{className:z("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Kn,{size:14})})]}),n.jsx(dn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:q?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(He,{size:14,className:"animate-spin"}),"Loading models…"]}):Ve.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):Ve.map(B=>{const Ye=v?.modelId===B.modelId,Vt=Wn(B),mt=B.title.includes(": ")?B.title.split(": ").slice(1).join(": "):B.title;return n.jsxs(Ee,{onClick:()=>Se(B),className:"flex items-center gap-2",children:[n.jsx("img",{src:Vt,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:mt}),Ye&&n.jsx(Xe,{size:14,className:"text-pink-500 shrink-0"})]},B.modelId)})})]}),Y=k?n.jsxs(Ee,{onClick:Pe,className:z(tt&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(lt,{size:16,className:z(tt&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),tt&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):E&&n.jsxs(cn,{open:T,onOpenChange:F,children:[n.jsxs("div",{className:"flex items-center rounded-lg",children:[n.jsxs(Ee,{onClick:Pe,className:z("flex-1 rounded-r-none pr-1",tt&&"text-blue-600 dark:text-blue-400"),children:[n.jsx(lt,{size:16,className:z(tt&&"text-blue-500")}),n.jsx("span",{className:"flex-1",children:"Web search"}),tt&&n.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),n.jsx(zn,{className:z("flex items-center justify-center rounded-r-lg rounded-l-none px-1.5 py-1.5 text-muted-foreground outline-hidden select-none","hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-[state=open]:bg-accent data-[state=open]:text-accent-foreground"),children:n.jsx(Kn,{size:14})})]}),n.jsx(dn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:q?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(He,{size:14,className:"animate-spin"}),"Loading models…"]}):ut.map(B=>{const Ye=E?.modelId===B.modelId,Vt=Wn(B),mt=B.title.includes(": ")?B.title.split(": ").slice(1).join(": "):B.title;return n.jsxs(Ee,{onClick:()=>Te(B),className:"flex items-center gap-2",children:[n.jsx("img",{src:Vt,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),n.jsx("span",{className:"flex-1 text-sm truncate",children:mt}),Ye&&n.jsx(Xe,{size:14,className:"text-blue-500 shrink-0"})]},B.modelId)})})]}),e[15]=_,e[16]=O,e[17]=I,e[18]=c,e[19]=E,e[20]=s,e[21]=u,e[22]=v,e[23]=R,e[24]=q,e[25]=N,e[26]=i,e[27]=o,e[28]=d,e[29]=T,e[30]=P,e[31]=D,e[32]=j,e[33]=k,e[34]=K,e[35]=H,e[36]=Z,e[37]=Q,e[38]=W,e[39]=ie,e[40]=Y,e[41]=ee,e[42]=te,e[43]=se,e[44]=ae,e[45]=re,e[46]=oe}else K=e[34],H=e[35],Z=e[36],Q=e[37],W=e[38],ie=e[39],Y=e[40],ee=e[41],te=e[42],se=e[43],ae=e[44],re=e[45],oe=e[46];let ce;e[97]===Symbol.for("react.memo_cache_sentinel")?(ce=n.jsxs(Ar,{className:"gap-2",children:[n.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),n.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[97]=ce):ce=e[97];let ge;e[98]!==W||e[99]!==h||e[100]!==A?(ge=h?n.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[n.jsx(He,{size:14,className:"animate-spin"}),"Loading prompts…"]}):A.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):A.map(Ve=>n.jsxs(Ee,{onClick:()=>W(Ve),className:"flex flex-col items-start gap-0.5",children:[n.jsx("span",{className:"font-medium text-sm capitalize",children:Ve.title||Xt(Ve.name,Ge(Ve._meta))}),Ve.description&&n.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:Ve.description})]},Ve.name)),e[98]=W,e[99]=h,e[100]=A,e[101]=ge):ge=e[101];let G;e[102]!==ge?(G=n.jsxs(cn,{children:[ce,n.jsx(dn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:ge})]}),e[102]=ge,e[103]=G):G=e[103];let de,Ze;e[104]===Symbol.for("react.memo_cache_sentinel")?(de=n.jsx(Cr,{size:16}),Ze=n.jsx("span",{className:"flex-1",children:"Connections"}),e[104]=de,e[105]=Ze):(de=e[104],Ze=e[105]);let Oe;e[106]===Symbol.for("react.memo_cache_sentinel")?(Oe=n.jsx(w.Suspense,{children:n.jsx(ec,{})}),e[106]=Oe):Oe=e[106];let Ce;e[107]!==Z?(Ce=n.jsxs(Ee,{onClick:Z,children:[de,Ze,Oe]}),e[107]=Z,e[108]=Ce):Ce=e[108];let xe;e[109]!==K||e[110]!==ie||e[111]!==Y||e[112]!==G||e[113]!==Ce||e[114]!==ae||e[115]!==re||e[116]!==oe?(xe=n.jsxs(K,{align:ae,className:re,children:[oe,ie,Y,G,Ce]}),e[109]=K,e[110]=ie,e[111]=Y,e[112]=G,e[113]=Ce,e[114]=ae,e[115]=re,e[116]=oe,e[117]=xe):xe=e[117];let be;e[118]!==H||e[119]!==ee||e[120]!==te||e[121]!==se||e[122]!==xe?(be=n.jsxs(H,{open:ee,onOpenChange:te,children:[se,xe]}),e[118]=H,e[119]=ee,e[120]=te,e[121]=se,e[122]=xe,e[123]=be):be=e[123];let Ie;e[124]!==_||e[125]!==Q?(Ie=n.jsx(Fn,{prompt:_,setPrompt:C,onSubmit:Q}),e[124]=_,e[125]=Q,e[126]=Ie):Ie=e[126];let Ke;return e[127]!==be||e[128]!==Ie?(Ke=n.jsxs(n.Fragment,{children:[be,Ie]}),e[127]=be,e[128]=Ie,e[129]=Ke):Ke=e[129],Ke}function sc(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function ic(t){return t.capabilities?.includes("image")}const rc=[{src:"/connections/github.png",name:"GitHub"},{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/linear.png",name:"Linear"},{src:"/connections/shopify.png",name:"Shopify"},{src:"/connections/firecrawl.png",name:"Firecrawl"},{src:"/connections/perplexity.png",name:"Perplexity"}];function oc(){const t=L.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center -space-x-1",children:rc.map(ac)}),t[0]=e):e=t[0],e}function ac(t){return n.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function lc(t){const e=L.c(6),{onClick:s}=t;let i,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=z("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=n.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=n.jsx(oc,{}),a=n.jsx(eo,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=r,e[2]=o,e[3]=a):(i=e[0],r=e[1],o=e[2],a=e[3]);let d;return e[4]!==s?(d=n.jsxs("button",{type:"button",onClick:s,className:i,children:[r,o,a]}),e[4]=s,e[5]=d):d=e[5],d}const gt=48;function cc(){const t=L.c(9),[e,s]=w.useState("idle"),[i,r]=w.useState(""),[o,a]=w.useState(""),[d,l]=w.useState(Vc),u=w.useRef(null),V=w.useRef(null),c=w.useRef(null),m=w.useRef(null),p=w.useRef(0),x=w.useRef(!1),g=w.useRef(""),f=w.useRef(""),b=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0),V.current?.close().catch(uc),m.current?.getTracks().forEach(dc),c.current=null,V.current=null,m.current=null},t[0]=h):h=t[0];const y=h;let A;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const D=I=>{m.current=I;const P=new AudioContext;V.current=P;const k=P.createMediaStreamSource(I),N=P.createAnalyser();N.fftSize=128,N.smoothingTimeConstant=.8,k.connect(N),c.current=N;const R=new Uint8Array(N.frequencyBinCount),M=()=>{if(!c.current)return;c.current.getByteFrequencyData(R);const T=[];for(let F=0;F<gt;F++){const O=Math.floor(F/gt*R.length);T.push(Math.max(.04,(R[O]??0)/255))}l(T),p.current=requestAnimationFrame(M)};M()};A=async()=>{const I=window.SpeechRecognition||window.webkitSpeechRecognition;if(!I){s("unsupported");return}let P;try{P=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),f.current="",g.current="",x.current=!0,s("recording"),D(P);const k=new I;u.current=k,k.interimResults=!0,k.continuous=!0,k.lang=navigator.language||"en-US",k.onresult=N=>{let R="",M="";for(let T=N.resultIndex;T<N.results.length;T++){const F=N.results[T],O=F?.[0]?.transcript??"";F?.isFinal?M=M+O:R=R+O}M&&(g.current=g.current+M,r(g.current)),f.current=R,a(R)},k.onend=()=>{if(x.current)try{k.start()}catch{}};try{k.start()}catch{s("idle")}},t[1]=A}else A=t[1];const _=A;let C;t[2]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{x.current=!1,u.current?.stop(),y(),s("idle"),l(Array(gt).fill(.05)),a("");const D=(g.current+(f.current?" "+f.current:"")).trim();return r(""),g.current="",f.current="",D},t[2]=C):C=t[2];const S=C;let v;t[3]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{x.current=!1,u.current?.abort(),y(),s("idle"),r(""),a(""),l(Array(gt).fill(.05)),g.current="",f.current=""},t[3]=v):v=t[3];const j=v;let E;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==d?(E={status:e,transcript:i,interimTranscript:o,waveformData:d,isSupported:b,startRecording:_,stopRecording:S,cancelRecording:j},t[4]=o,t[5]=e,t[6]=i,t[7]=d,t[8]=E):E=t[8],E}function dc(t){return t.stop()}function uc(){}function Vc(){return Array(gt).fill(.05)}function mc(t){const e=L.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(fc),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=n.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=r):r=e[3],r}function fc(t,e){return n.jsx("div",{className:"w-[2px] shrink-0 rounded-full bg-chart-2 transition-[height] duration-75 ease-out",style:{height:`${Math.max(4,Math.round(t*40))}px`}},e)}const gn=[{value:"fast",label:"Fast",Icon:$i,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:Nr,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:zi,description:"Deeper reasoning"}];function pc(t){const e=L.c(17),{tier:s,onSelect:i}=t;let r;e[0]!==s?(r=gn.find(p=>p.value===s)??gn[1],e[0]=s,e[1]=r):r=e[1];const o=r,a=o.Icon;let d;e[2]!==a?(d=n.jsx(a,{size:14}),e[2]=a,e[3]=d):d=e[3];let l;e[4]!==o.label?(l=n.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=l):l=e[5];let u;e[6]!==d||e[7]!==l?(u=n.jsx(ks,{asChild:!0,children:n.jsxs(J,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[d,l]})}),e[6]=d,e[7]=l,e[8]=u):u=e[8];let V;e[9]!==i||e[10]!==s?(V=gn.map(p=>{const{value:x,label:g,Icon:f,description:b}=p;return n.jsxs(Ee,{onSelect:()=>i(x),children:[n.jsx(f,{size:16,className:"text-muted-foreground"}),n.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[n.jsx("span",{children:g}),n.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:b})]}),s===x&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},x)}),e[9]=i,e[10]=s,e[11]=V):V=e[11];let c;e[12]!==V?(c=n.jsx(Ns,{align:"end",className:"w-52 p-1.5",children:V}),e[12]=V,e[13]=c):c=e[13];let m;return e[14]!==u||e[15]!==c?(m=n.jsxs(Ss,{children:[u,c]}),e[14]=u,e[15]=c,e[16]=m):m=e[16],m}function hc(t,e){const s=L.c(5),{editor:i}=Zt(),[r,o]=w.useState(!1),a=w.useRef(0);let d,l;return s[0]!==i||s[1]!==e||s[2]!==t?(d=()=>{const u=p=>{p.dataTransfer?.types.includes("Files")&&(p.preventDefault(),a.current=a.current+1,o(!0))},V=p=>{p.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},c=gc,m=p=>{if(p.preventDefault(),a.current=0,o(!1),!i||!t||!en(t))return;const x=p.dataTransfer?.files;if(!x||x.length===0)return;const{from:g}=i.state.selection;for(const f of Array.from(x))Un(i,t,f,g,e)};return window.addEventListener("dragenter",u),window.addEventListener("dragleave",V),window.addEventListener("dragover",c),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",u),window.removeEventListener("dragleave",V),window.removeEventListener("dragover",c),window.removeEventListener("drop",m)}},l=[i,t,e],s[0]=i,s[1]=e,s[2]=t,s[3]=d,s[4]=l):(d=s[3],l=s[4]),w.useEffect(d,l),r}function gc(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function xc(t){const e=L.c(11),{selectedModel:s,onUnsupportedFile:i}=t,r=hc(s,i);let o;e[0]!==s?(o=en(s),e[0]=s,e[1]=o):o=e[1];const a=o,d=r?"opacity-100":"opacity-0 pointer-events-none",l=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let u;e[2]!==d||e[3]!==l?(u=z("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",d,l),e[2]=d,e[3]=l,e[4]=u):u=e[4];let V;e[5]!==s||e[6]!==a?(V=a?n.jsxs(n.Fragment,{children:[n.jsx(Ir,{size:24}),n.jsxs("span",{className:"text-sm font-medium",children:["Drop ",Fs(s)," here"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(Cs,{size:24}),n.jsx("span",{className:"text-sm font-medium",children:"This model can't read attachments — switch to one with vision or file support"})]}),e[5]=s,e[6]=a,e[7]=V):V=e[7];let c;return e[8]!==u||e[9]!==V?(c=n.jsx("div",{className:u,children:V}),e[8]=u,e[9]=V,e[10]=c):c=e[10],c}function bc(){const t=L.c(5),e=ct(),{org:s,locator:i}=ue();let r;return t[0]!==i||t[1]!==e||t[2]!==s.id||t[3]!==s.slug?(r=o=>{const{tiptapDoc:a,virtualMcp:d}=o,l=crypto.randomUUID(),u=d?.id??Tn(s.id).id;Wi(sessionStorage,i,l,{tiptapDoc:a}),e({to:"/$org/$taskId",params:{org:s.slug,taskId:l},search:{virtualmcpid:u,autosend:Gi}})},t[0]=i,t[1]=e,t[2]=s.id,t[3]=s.slug,t[4]=r):r=t[4],r}function yc({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=Ki(),i=Yi(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,d=s?.stop??(()=>{}),l=i?.taskId??"",u=i?.tasks??[],V=bc(),{selectedModel:c,selectedVirtualMcp:m,isModelsLoading:p,tiptapDocRef:x,imageModel:g,deepResearchModel:f,chatMode:b,setChatMode:h,simpleModeEnabled:y,simpleModeTier:A,setSimpleModeTier:_}=Yt(),{data:C}=Bt.useSession(),S=C?.user?.id,{org:v}=ue(),j=Tn(v.id).id,E=Sn(Yn),[D,I]=w.useState(!1),{unsupportedFile:P,onUnsupportedFile:k,clearUnsupportedFile:N}=Ea(),R=cc(),M=w.useRef(void 0),T=async()=>{M.current=K,await R.startRecording();const G=R.status==="recording"?"started":R.status==="unsupported"?"unsupported":R.status==="permission-denied"?"permission_denied":"unknown";$("chat_voice_started",{thread_id:l,outcome:G})},F=()=>{$("chat_voice_confirmed",{thread_id:l});const G=R.stopRecording();Y.current?.syncVoiceText(M.current,G),Y.current?.focus()},O=()=>{$("chat_voice_cancelled",{thread_id:l}),R.cancelRecording(),Y.current?.restoreContent(M.current)};w.useEffect(()=>{if(R.status!=="recording")return;const G=(R.transcript+(R.interimTranscript?" "+R.interimTranscript:"")).trim();Y.current?.syncVoiceText(M.current,G)},[R.transcript,R.interimTranscript,R.status]);const q=u.find(G=>G.id===l),[K,H]=w.useState(void 0),Z=G=>{H(G),x.current=G},Q=w.useRef(l);Q.current!==l&&(Q.current=l,H(void 0),x.current=void 0);const ie=[...r].reverse().find(G=>G.role==="assistant")?.metadata?.modelLimits?.contextWindow??c?.limits?.contextWindow,Y=w.useRef(null),ee=b==="plan";w.useEffect(()=>{const G=de=>{ir(de)&&de.code==="KeyL"&&(de.preventDefault(),de.shiftKey&&h(b==="plan"?"default":"plan"),Y.current?.focus())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[b,h]);const te=Vr(r),se=[...r].reverse().find(G=>G.role==="assistant"&&G.metadata?.usage)?.metadata?.usage,ae=se?.contextTokens??(se?.totalTokens??0)-(se?.reasoningTokens??0),re=Sn(Yn),oe=!o&&!!c&&!p&&!Fo(K),ce=o||a,ge=G=>{G?.preventDefault(),o?($("chat_message_stopped",{thread_id:l}),d()):a?($("chat_message_stopped",{thread_id:l}),d()):oe&&K&&($("chat_message_sent",{thread_id:l||null,mode:b,model_id:c?.modelId??null,model_provider:c?.providerId??null,virtual_mcp_id:m?.id??null,submission:G?"button_or_enter":"programmatic"}),re(),s?s.sendMessage(K):V({tiptapDoc:K,virtualMcp:m}),Z(void 0))};return S&&q?.created_by&&q.created_by!==S?n.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n.jsx(Cs,{size:14,className:"shrink-0"}),n.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-col w-full justify-end",children:n.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&n.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),s&&i&&n.jsx(tn,{}),n.jsx(Hl,{tiptapDoc:K,setTiptapDoc:Z,disabled:o||!c,enterToSubmit:!0,onSubmit:ge,children:n.jsxs("form",{onSubmit:ge,className:z("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[n.jsx(xc,{selectedModel:c,onUnsupportedFile:k}),n.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:n.jsx(Jl,{ref:Y,disabled:o||!c||R.status==="recording",virtualMcpId:m?.id??j,showFileUploader:!0,selectedModel:c,onUnsupportedFile:k})}),n.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:R.status==="recording"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n.jsx(mc,{data:R.waveformData.slice(0,28)}),n.jsx("button",{type:"button",onClick:O,className:"flex items-center justify-center size-8 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Cancel recording",children:n.jsx(pt,{size:16})}),n.jsx("button",{type:"button",onClick:F,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:n.jsx(Xe,{size:16})})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[n.jsx(Ra,{selectedModel:c,isStreaming:o,icon:n.jsx(Is,{size:16}),onUnsupportedFile:k}),n.jsx(nc,{disabled:o,onOpenConnections:()=>{$("connections_dialog_opened",{source:"tools_popover",mode:"add"}),I(!0)},virtualMcpId:m?.id??j}),ee&&n.jsxs("button",{type:"button",onClick:()=>{E(),$("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),h("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(_s,{size:14,className:"shrink-0"}),"Plan mode",n.jsx(pt,{size:14,className:"shrink-0 hidden group-hover:block"})]}),b==="gen-image"&&g&&n.jsxs("button",{type:"button",onClick:()=>{E(),$("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),h("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-pink-600 dark:text-pink-400 hover:bg-pink-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(yn,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:y?"Create image":g.title.includes(": ")?g.title.split(": ").slice(1).join(": "):g.title}),n.jsx(pt,{size:14,className:"shrink-0 hidden group-hover:block"})]}),b==="web-search"&&f&&n.jsxs("button",{type:"button",onClick:()=>{E(),$("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),h("default")},className:"flex items-center gap-1.5 h-8 rounded-lg px-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-500/10 group whitespace-nowrap animate-in fade-in duration-200",children:[n.jsx(lt,{size:14,className:"shrink-0"}),n.jsx("span",{className:"max-w-[120px] truncate",children:y?"Web search":f.title.includes(": ")?f.title.split(": ").slice(1).join(": "):f.title}),n.jsx(pt,{size:14,className:"shrink-0 hidden group-hover:block"})]}),ie&&ae>0&&n.jsx(mr,{usage:te,totalTokens:ae,contextWindow:ie,onOpenContextPanel:t})]}),n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[y?n.jsx(pc,{tier:A,onSelect:_}):n.jsx(Mr,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),R.isSupported&&!o&&!a&&n.jsx(J,{type:"button",onClick:T,variant:"ghost",size:"icon",className:z("size-8 rounded-lg transition-colors",R.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:R.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:n.jsx(Ui,{size:18})}),n.jsx(J,{type:ce?"button":"submit",onClick:G=>{ce&&(G.preventDefault(),G.stopPropagation(),d())},variant:oe||ce?"default":"ghost",size:"icon",disabled:!oe&&!ce,className:z("size-8 rounded-lg transition-all",!oe&&!ce&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:o?"Stop generating":a?"Cancel run":"Send message (Enter)",children:ce?n.jsx(Oi,{size:20}):n.jsx(kr,{size:20})})]})]})})]})},l),e&&n.jsx(lc,{onClick:()=>{$("connections_banner_clicked",{source:"home_chat_input"}),$("connections_dialog_opened",{source:"home_banner",mode:"add"}),I(!0)}})]})}),n.jsx(uo,{mode:"browse",open:D,onOpenChange:I,defaultTab:"all"}),n.jsx(Ta,{info:P,onClose:N})]})}const vc={usd:[{dollars:10,label:"Starter"},{dollars:20,label:"Popular"},{dollars:100,label:"Best value"}],brl:[{dollars:50,label:"Starter"},{dollars:100,label:"Popular"},{dollars:500,label:"Best value"}]};function ci(t){return`deco-credits-empty-dismissed:${t}`}function Od(t){try{return localStorage.getItem(ci(t))==="1"}catch{return!1}}function wc(){const t=L.c(50),{org:e}=ue(),s=ct(),{decoKeyId:i}=Ws();let r;t[0]!==e.id||t[1]!==e.slug?(r={connectionId:kt,orgId:e.id,orgSlug:e.slug},t[0]=e.id,t[1]=e.slug,t[2]=r):r=t[2];const o=qe(r),[a,d]=w.useState(!0),[l,u]=w.useState(""),[V,c]=w.useState(!1),[m,p]=w.useState("usd"),x=m==="brl"?"R$":"$";let g;t[3]!==e.id?(g=()=>{$("credits_empty_state_dismissed",{organization_id:e.id}),d(!1);try{localStorage.setItem(ci(e.id),"1")}catch{}},t[3]=e.id,t[4]=g):g=t[4];const f=g;let b,h;t[5]!==a||t[6]!==e.id?(b=()=>{a&&$("credits_empty_state_shown",{organization_id:e.id})},h=[a,e.id],t[5]=a,t[6]=e.id,t[7]=b,t[8]=h):(b=t[7],h=t[8]),w.useEffect(b,h);let y;t[9]!==o||t[10]!==m?(y=async K=>{const H=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:K,currency:m}});if(H?.isError)throw new Error(H.content?.[0]?.text??"Failed to get top-up URL");return H.structuredContent?.url},t[9]=o,t[10]=m,t[11]=y):y=t[11];let A;t[12]!==f?(A=K=>{K&&window.open(K,"_blank","noopener,noreferrer"),f()},t[12]=f,t[13]=A):A=t[13];let _;t[14]!==y||t[15]!==A?(_={mutationFn:y,onSuccess:A,onError:Ac},t[14]=y,t[15]=A,t[16]=_):_=t[16];const{mutate:C,isPending:S}=_n(_),v=parseFloat(l),j=!isNaN(v)&&v>=1;if(!a)return null;let E;t[17]!==f?(E=K=>!K&&f(),t[17]=f,t[18]=E):E=t[18];let D;t[19]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx("div",{className:"absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-amber-500/8 to-transparent pointer-events-none rounded-t-lg"}),t[19]=D):D=t[19];let I;t[20]===Symbol.for("react.memo_cache_sentinel")?(I=n.jsx("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-100 dark:bg-amber-900/40 border border-amber-200/60 dark:border-amber-800/40 mx-auto",children:n.jsx(vs,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[20]=I):I=t[20];let P;t[21]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[D,n.jsxs(Fe,{className:"relative gap-3",children:[I,n.jsxs("div",{className:"text-center",children:[n.jsx(Ue,{className:"text-lg font-semibold",children:"This workspace has no credits"}),n.jsx(Kt,{className:"mt-2 text-[13px] leading-relaxed max-w-[320px] mx-auto",children:"Your free credits were used in another workspace. Add credits to use AI here."})]})]})]}),t[21]=P):P=t[21];let k;t[22]!==m||t[23]!==x||t[24]!==l||t[25]!==v||t[26]!==i||t[27]!==j||t[28]!==S||t[29]!==V||t[30]!==C?(k=i&&n.jsxs("div",{className:"px-6 pb-5",children:[n.jsx("div",{className:"mb-4",children:n.jsxs(Ls,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:K=>{K&&p(K)},children:[n.jsx(Ft,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),n.jsx(Ft,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),n.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:vc[m].map(K=>{const{dollars:H,label:Z}=K;return n.jsxs("button",{type:"button",disabled:S,onClick:()=>{$("credits_topup_clicked",{amount_cents:H*100,currency:m,tier_label:Z,source:"empty_state"}),C(H*100)},className:z("relative flex flex-col items-center gap-1 py-6 rounded-xl border transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-wait","border-border hover:border-foreground/20 hover:bg-muted/30"),children:[n.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[x,H]}),n.jsx("span",{className:"text-xs text-muted-foreground",children:Z})]},H)})}),V?n.jsxs("div",{className:"flex gap-2 mt-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:x}),n.jsx(_e,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:K=>u(K.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),n.jsx(J,{className:"h-10",disabled:!j||S,onClick:()=>{$("credits_topup_clicked",{amount_cents:Math.round(v*100),currency:m,tier_label:"custom",source:"empty_state"}),C(Math.round(v*100))},children:S?"Opening...":"Add"})]}):n.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>c(!0),children:"Enter custom amount"})]}),t[22]=m,t[23]=x,t[24]=l,t[25]=v,t[26]=i,t[27]=j,t[28]=S,t[29]=V,t[30]=C,t[31]=k):k=t[31];let N;t[32]!==f||t[33]!==s||t[34]!==e.slug?(N=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),f()},t[32]=f,t[33]=s,t[34]=e.slug,t[35]=N):N=t[35];let R;t[36]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(Rs,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[36]=R):R=t[36];let M;t[37]!==N?(M=n.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:N,children:["Use your own provider",R]}),t[37]=N,t[38]=M):M=t[38];let T;t[39]!==f?(T=n.jsx(J,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:f,children:"Skip for now"}),t[39]=f,t[40]=T):T=t[40];let F;t[41]!==M||t[42]!==T?(F=n.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[M,T]}),t[41]=M,t[42]=T,t[43]=F):F=t[43];let O;t[44]!==k||t[45]!==F?(O=n.jsxs(Le,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:jc,children:[P,k,F]}),t[44]=k,t[45]=F,t[46]=O):O=t[46];let q;return t[47]!==O||t[48]!==E?(q=n.jsx(Me,{open:!0,onOpenChange:E,children:O}),t[47]=O,t[48]=E,t[49]=q):q=t[49],q}function jc(t){return t.preventDefault()}function Ac(t){ne.error(`Top-up failed: ${t.message}`)}function Sc(t){const e=L.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const r=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=z("inline-flex items-center gap-1.5 px-3 py-1 rounded-full","bg-emerald-50 dark:bg-emerald-950/30","border border-emerald-200/60 dark:border-emerald-800/40","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),a=n.jsx(vs,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let d;return e[4]!==r?(d=n.jsxs("div",{className:o,children:[a,n.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=d):d=e[5],d}function kc(){const t=L.c(8),{org:e}=ue(),s=ct();let i;t[0]!==s||t[1]!==e.slug?(i=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=i):i=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=z("inline-flex items-center gap-1.5 px-3 py-1 rounded-full cursor-pointer","bg-amber-50 dark:bg-amber-950/30","border border-amber-200/60 dark:border-amber-800/40","hover:bg-amber-100/60 dark:hover:bg-amber-900/30","transition-colors duration-150","animate-in fade-in-0 slide-in-from-bottom-2 duration-300"),o=n.jsx(Ts,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=n.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let d;return t[6]!==i?(d=n.jsxs("button",{type:"button",onClick:i,className:r,children:[o,a]}),t[6]=i,t[7]=d):d=t[7],d}function Nc(t){const e=L.c(11),{className:s}=t;let i;e[0]!==s?(i=z("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsxs("div",{className:"flex items-center gap-3",children:[r,n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),n.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),e[3]=o):o=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:n.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,n.jsxs("div",{className:"flex items-end gap-2",children:[n.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),n.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[n.jsx(Tt,{align:"right",width:"w-3/4"}),n.jsx(Tt,{align:"left",width:"w-full",lines:3}),n.jsx(Tt,{align:"right",width:"w-2/3"}),n.jsx(Tt,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=d):d=e[5];let l;e[6]===Symbol.for("react.memo_cache_sentinel")?(l=n.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:n.jsx("div",{className:"relative flex-1",children:n.jsxs("div",{className:"space-y-2 p-2",children:[n.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),n.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=l):l=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx("div",{className:"flex items-center gap-1",children:n.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=u):u=e[7];let V;e[8]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx("div",{className:"px-4 py-4",children:n.jsx("div",{className:"mx-auto w-full max-w-2xl",children:n.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[l,n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[u,n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),n.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=V):V=e[8];let c;return e[9]!==i?(c=n.jsxs("div",{className:i,children:[a,d,V]}),e[9]=i,e[10]=c):c=e[10],c}function Tt(t){const e=L.c(22),{align:s,width:i,lines:r}=t,o=i===void 0?"w-full":i,a=r===void 0?1:r,d=s==="right"?"flex-row-reverse":"flex-row";let l;e[0]!==d?(l=z("flex w-full gap-4 px-4 py-2",d),e[0]=d,e[1]=l):l=e[1];const u=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let V;e[2]!==u?(V=z("flex min-w-0 flex-col gap-2",u),e[2]=u,e[3]=V):V=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=c):c=e[4];const m=s==="right"?"bg-muted":"bg-transparent border border-border/40";let p;e[5]!==m||e[6]!==o?(p=z("min-w-0 rounded-2xl p-4",m,o),e[5]=m,e[6]=o,e[7]=p):p=e[7];let x;e[8]!==a?(x=Array.from({length:a}),e[8]=a,e[9]=x):x=e[9];let g;e[10]!==a||e[11]!==x?(g=n.jsx("div",{className:"space-y-2",children:x.map((y,A)=>n.jsx("div",{className:z("h-3 rounded bg-muted-foreground/20 animate-pulse",A===a-1?"w-3/4":"w-full"),style:{animationDelay:`${A*.1}s`}},A))}),e[10]=a,e[11]=x,e[12]=g):g=e[12];let f;e[13]!==g||e[14]!==p?(f=n.jsx("div",{className:p,children:g}),e[13]=g,e[14]=p,e[15]=f):f=e[15];let b;e[16]!==f||e[17]!==V?(b=n.jsxs("div",{className:V,children:[c,f]}),e[16]=f,e[17]=V,e[18]=b):b=e[18];let h;return e[19]!==b||e[20]!==l?(h=n.jsx("div",{className:l,children:b}),e[19]=b,e[20]=l,e[21]=h):h=e[21],h}function _c(t){const e=L.c(5),{className:s,children:i}=t;let r;e[0]!==s?(r=z("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==i||e[3]!==r?(o=n.jsx("div",{className:r,children:i}),e[2]=i,e[3]=r,e[4]=o):o=e[4],o}function Cc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function Ic(t){const e=L.c(2),{children:s}=t;let i;return e[0]!==s?(i=n.jsx("div",{className:"h-full w-full flex items-center justify-center max-w-2xl mx-auto",children:s}),e[0]=s,e[1]=i):i=e[1],i}function Rc(){const t=L.c(16),{messages:e,status:s}=Dn(),i=fr(e);let r;t[0]!==i?(r=i.at(-1),t[0]=i,t[1]=r):r=t[1];const o=r,a=s==="submitted"||s==="streaming";let d;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const l=e.at(-1),u=!a&&l?.role==="assistant"&&l.parts.filter(Ec).some(Pc),V=!a&&l?.role==="assistant"&&l.parts.some(Tc);let c;if(t[8]!==i||t[9]!==s){let p;t[11]!==i.length||t[12]!==s?(p=(x,g)=>n.jsx(qn,{pair:x,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${x.user.id}`),t[11]=i.length,t[12]=s,t[13]=p):p=t[13],c=i.slice(0,-1).map(p),t[8]=i,t[9]=s,t[10]=c}else c=t[10];let m;t[14]!==c?(m=n.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:c}),t[14]=c,t[15]=m):m=t[15],d=n.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[m,o&&n.jsx("div",{className:z("min-h-full min-w-0 max-w-2xl mx-auto w-full",(u||V)&&"pb-60"),children:n.jsx(qn,{pair:o,isLastPair:!0,status:s},`pair-${o?.user.id}`)})]}),t[2]=a,t[3]=o,t[4]=i,t[5]=e,t[6]=s,t[7]=d}else d=t[7];return d}function Tc(t){return"state"in t&&t.state==="approval-requested"}function Pc(t){return t.state==="input-available"}function Ec(t){return t.type==="tool-user_ask"}function Dc(t){const e=L.c(5),{children:s,className:i}=t;let r;e[0]!==i?(r=z("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=n.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const $d=Object.assign(_c,{Main:Cc,Messages:Rc,EmptyState:Ic,Footer:Dc,Input:yc,Provider:Hi,ActiveTaskProvider:Qi,Skeleton:Nc,IceBreakers:Wo,NoAiProviderEmptyState:Lr,CreditsEmptyState:wc,CreditsEyebrow:Sc,NoCreditsEyebrow:kc,CreditsExhaustedBanner:Gs});export{uo as A,$d as C,Md as S,Hl as T,Jl as a,Ud as b,Ld as c,Fd as d,Ws as u,Od as w};