decocms 2.279.0 → 2.279.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/client/assets/{AlertCircle-CfFyE8cr.js → AlertCircle-BnQT18aF.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-Da5yRbDu.js → ArrowNarrowLeft-C9kLhY7x.js} +1 -1
  3. package/dist/client/assets/{CheckCircle-D2fQEgC-.js → CheckCircle-Cs-97qLz.js} +1 -1
  4. package/dist/client/assets/{ChevronDown-CEm8bH9z.js → ChevronDown-DK8QUWOr.js} +1 -1
  5. package/dist/client/assets/{ChevronRight-DyTRIsvx.js → ChevronRight-FLwTFysc.js} +1 -1
  6. package/dist/client/assets/{ChevronUp-E63-b_P9.js → ChevronUp-DpoyT3Mx.js} +1 -1
  7. package/dist/client/assets/{Container-CJG3ExgA.js → Container-BioTKt13.js} +1 -1
  8. package/dist/client/assets/{LinkExternal01-D16-VOGQ.js → LinkExternal01-x8IH3HPT.js} +1 -1
  9. package/dist/client/assets/{Lock01-B8wqomxu.js → Lock01-D77tMj01.js} +1 -1
  10. package/dist/client/assets/{Palette-v9pwEnA4.js → Palette-AK3X7q7E.js} +1 -1
  11. package/dist/client/assets/{Play-D8DNxfum.js → Play-CBnQYPj8.js} +1 -1
  12. package/dist/client/assets/{Plus-ZF7w6L4O.js → Plus-DDAfDw-O.js} +1 -1
  13. package/dist/client/assets/{SearchMd-Cnjv3UQP.js → SearchMd-DY4wMwzx.js} +1 -1
  14. package/dist/client/assets/{Settings02-D6EvGHhW.js → Settings02-XkpqnrJC.js} +1 -1
  15. package/dist/client/assets/{Star01-Duh2LG2L.js → Star01-4Y5nWGjE.js} +1 -1
  16. package/dist/client/assets/{Sun-pL1WUVwn.js → Sun-DHZd7DXq.js} +1 -1
  17. package/dist/client/assets/{Tool01-BF1lV-4S.js → Tool01-BQx_QkPV.js} +1 -1
  18. package/dist/client/assets/{Trash01-B-dX5IVT.js → Trash01-CChmuBav.js} +1 -1
  19. package/dist/client/assets/{Upload01-ObPiK9Gt.js → Upload01-DNNaYKi-.js} +1 -1
  20. package/dist/client/assets/{User01-CIx0aqsB.js → User01-BP1wQdKX.js} +1 -1
  21. package/dist/client/assets/{Users03-CCOKfSZN.js → Users03-DuReHFEk.js} +1 -1
  22. package/dist/client/assets/{X-qpFUx-Vy.js → X-BpK79C1U.js} +1 -1
  23. package/dist/client/assets/{XCircle-bGl0e4GB.js → XCircle-NQPpx_1o.js} +1 -1
  24. package/dist/client/assets/{Zap-MsLTEH0A.js → Zap-DZ80UrUJ.js} +1 -1
  25. package/dist/client/assets/{ZapSquare-C-4TuG6U.js → ZapSquare-BzqjfXvk.js} +1 -1
  26. package/dist/client/assets/{accordion-BwZCqJLV.js → accordion-BnLbYmWD.js} +1 -1
  27. package/dist/client/assets/{agent-icon-DBW-xznI.js → agent-icon-CItqy-K1.js} +1 -1
  28. package/dist/client/assets/{agents-list-CS1AuC8H.js → agents-list-DXLO803R.js} +1 -1
  29. package/dist/client/assets/ai-providers-D4RVtvEP.js +1 -0
  30. package/dist/client/assets/{alert-dialog-BBucwhbQ.js → alert-dialog-BiQ8dmMn.js} +1 -1
  31. package/dist/client/assets/{auth-catchall-RbsBNuQ5.js → auth-catchall-1bhqwPSp.js} +1 -1
  32. package/dist/client/assets/{automation-list-row-xmvI2ZpZ.js → automation-list-row-Dcp8P3LE.js} +1 -1
  33. package/dist/client/assets/{automations-CxcNaqNr.js → automations-C-rFf6h9.js} +1 -1
  34. package/dist/client/assets/{avatar-CrY-QYa1.js → avatar-Br-mHNNE.js} +1 -1
  35. package/dist/client/assets/{badge-DFmhmXN4.js → badge-CExLRIph.js} +1 -1
  36. package/dist/client/assets/{brand-context-CA6uA8-f.js → brand-context-bl_t2qji.js} +1 -1
  37. package/dist/client/assets/{card-CAUJapuJ.js → card-Bi6fzNxY.js} +1 -1
  38. package/dist/client/assets/{chat-context-D0rB5W6o.js → chat-context-ZY2xyfov.js} +1 -1
  39. package/dist/client/assets/{checkbox-FzuPLTLu.js → checkbox-CSWuHjiA.js} +1 -1
  40. package/dist/client/assets/{collection-detail-BKeI5Mej.js → collection-detail-DyZnJOMN.js} +1 -1
  41. package/dist/client/assets/{collection-display-button-BQh1Gx1X.js → collection-display-button-Zw4ajKnX.js} +1 -1
  42. package/dist/client/assets/{collection-search-C1X9xWrk.js → collection-search-B2uexuf4.js} +1 -1
  43. package/dist/client/assets/{collection-table-wrapper-BkYiSJ2_.js → collection-table-wrapper-6GE-7Iwx.js} +1 -1
  44. package/dist/client/assets/{collection-tabs-DyGLUrer.js → collection-tabs-BAZJIsSw.js} +1 -1
  45. package/dist/client/assets/{collections-D0TgU2mm.js → collections-DY3yi6mH.js} +1 -1
  46. package/dist/client/assets/{command-quthPAw7.js → command-CVo7-d2L.js} +1 -1
  47. package/dist/client/assets/{connection-card-hgxEw9QB.js → connection-card-CE6WfLhf.js} +1 -1
  48. package/dist/client/assets/{connection-detail-B830AX1z.js → connection-detail-BgcOQ6g7.js} +1 -1
  49. package/dist/client/assets/{connection-form-helpers-CiJ8SQZJ.js → connection-form-helpers-Cp1W4tWB.js} +1 -1
  50. package/dist/client/assets/{connections-BHdj71bg.js → connections-CUncSKj1.js} +1 -1
  51. package/dist/client/assets/{constants-C7N_XM1Z.js → constants-1IZfBK2U.js} +1 -1
  52. package/dist/client/assets/{constants-DYe7zuza.js → constants-C5faKoYI.js} +1 -1
  53. package/dist/client/assets/{dialog-VsnyL-XQ.js → dialog-D93zmoD4.js} +1 -1
  54. package/dist/client/assets/{drawer-BA2JOP-U.js → drawer-Du6ov_Kn.js} +1 -1
  55. package/dist/client/assets/{dropdown-menu-C5jBP7Fw.js → dropdown-menu-BKbYv7Wd.js} +1 -1
  56. package/dist/client/assets/{dynamic-plugin-layout-ZUCbr1b5.js → dynamic-plugin-layout-DmHVrzBJ.js} +1 -1
  57. package/dist/client/assets/{empty-state-Be673n_P.js → empty-state-_2I1J11o.js} +1 -1
  58. package/dist/client/assets/{empty-state-BOUL-w18.js → empty-state-pBS5unOo.js} +1 -1
  59. package/dist/client/assets/{extract-connection-data-BZeMYWDa.js → extract-connection-data-BLTghne6.js} +1 -1
  60. package/dist/client/assets/{features-Cfc61NK4.js → features-DghF3VeY.js} +1 -1
  61. package/dist/client/assets/{form-Cm4BWKO3.js → form-CGR8HWXm.js} +1 -1
  62. package/dist/client/assets/{general-nBrnHWgU.js → general-D1YED4E-.js} +1 -1
  63. package/dist/client/assets/{index-BBCNNn_r.js → index-1FVmDgDY.js} +1 -1
  64. package/dist/client/assets/{index-B21DFJvX.js → index-BZ_OMQZt.js} +1 -1
  65. package/dist/client/assets/{index-1tgFNQN6.js → index-Bg9PL9wv.js} +1 -1
  66. package/dist/client/assets/{index-CazZCRq6.js → index-BjLZ4w3C.js} +1 -1
  67. package/dist/client/assets/{index-BIoyZkNb.js → index-C4h_7_D2.js} +1 -1
  68. package/dist/client/assets/{index-D7Lqg2_V.js → index-CALmHFdS.js} +1 -1
  69. package/dist/client/assets/{index-D2Sh5ySY.js → index-CFAZ0UvD.js} +4 -4
  70. package/dist/client/assets/{index-BdiKcIpp.js → index-CcwB0eWr.js} +1 -1
  71. package/dist/client/assets/{index-Dj3wFV1t.js → index-DfVs9Fb7.js} +2 -2
  72. package/dist/client/assets/{index-_BXT4fTT.js → index-OTlMXMDz.js} +1 -1
  73. package/dist/client/assets/{infiniteQueryObserver-CTx2Ye7N.js → infiniteQueryObserver-C_0qvJ_M.js} +1 -1
  74. package/dist/client/assets/{input-DFZSZH1u.js → input-DCH6MuqU.js} +1 -1
  75. package/dist/client/assets/{integration-icon-DoBfii_Q.js → integration-icon-BEqEqACj.js} +1 -1
  76. package/dist/client/assets/{label-CinsfmY9.js → label-DdsMT8c-.js} +1 -1
  77. package/dist/client/assets/{layout-B3KnVa9R.js → layout-CKrDvxp3.js} +1 -1
  78. package/dist/client/assets/{lean-canvas-recruit-modal-BU5okOF7.js → lean-canvas-recruit-modal-tEiAB2yp.js} +1 -1
  79. package/dist/client/assets/{login-DsoYRzXP.js → login-DXHTnDWS.js} +1 -1
  80. package/dist/client/assets/{members-429sWXVs.js → members-CojjCpV-.js} +1 -1
  81. package/dist/client/assets/{monaco-editor-DoFCKNPl.js → monaco-editor-Oc7ncdnn.js} +1 -1
  82. package/dist/client/assets/{monitoring-stats-row-CTzCdFf0.js → monitoring-stats-row-D0DqYxIT.js} +1 -1
  83. package/dist/client/assets/{oauth-callback-C9Yjhdcq.js → oauth-callback-BWe_o07y.js} +1 -1
  84. package/dist/client/assets/{oauth-callback-ai-provider-DrhZwXBr.js → oauth-callback-ai-provider-DXvjreuF.js} +1 -1
  85. package/dist/client/assets/{onboarding-ZX_rVkwm.js → onboarding-BSWtwFa_.js} +1 -1
  86. package/dist/client/assets/{org-layout-BdgTfERv.js → org-layout-o5Z_Avu_.js} +1 -1
  87. package/dist/client/assets/{org-plugin-layout-Dz89NZ2c.js → org-plugin-layout-C0Qr-bgj.js} +1 -1
  88. package/dist/client/assets/{plugin-empty-state-Dm1cZM5g.js → plugin-empty-state-KnYPKHH6.js} +1 -1
  89. package/dist/client/assets/{plugin-header-BME200Pl.js → plugin-header-BNYbNczy.js} +1 -1
  90. package/dist/client/assets/{plugin-layout-Dg-4s9bf.js → plugin-layout-BG7P0aOZ.js} +1 -1
  91. package/dist/client/assets/{popover-DkcEXeJ2.js → popover-DdVefIGO.js} +1 -1
  92. package/dist/client/assets/{profile-whmeOhpn.js → profile-Dbu66jp4.js} +1 -1
  93. package/dist/client/assets/{project-app-view-DQAduvBB.js → project-app-view-DA-h2zTN.js} +1 -1
  94. package/dist/client/assets/registry-ChRKVXby.js +2 -0
  95. package/dist/client/assets/{registry-layout-zkTenTgZ.js → registry-layout-BG3p8JCQ.js} +1 -1
  96. package/dist/client/assets/{required-auth-layout-C6A_rjeR.js → required-auth-layout-DYfQDmqT.js} +1 -1
  97. package/dist/client/assets/{reset-password-CIOKWLsJ.js → reset-password-BDAMxGLn.js} +1 -1
  98. package/dist/client/assets/{scroll-area-DMYp9AgI.js → scroll-area-DTSNhfSU.js} +1 -1
  99. package/dist/client/assets/{search-input-Dazz3BtE.js → search-input-Byx2xO-2.js} +1 -1
  100. package/dist/client/assets/{select-4thHDt_Z.js → select-DL2N1Ojk.js} +1 -1
  101. package/dist/client/assets/{select-model-DWwA5nzG.js → select-model-LSEQrmLs.js} +1 -1
  102. package/dist/client/assets/{settings-layout-C3HofuKN.js → settings-layout-BCsxldpQ.js} +1 -1
  103. package/dist/client/assets/{shell-layout-DjPNQ4AH.js → shell-layout-lbN_BpLZ.js} +1 -1
  104. package/dist/client/assets/{skeleton-BdOhMM7L.js → skeleton-BpYnrXqd.js} +1 -1
  105. package/dist/client/assets/{sso-CNnZ0vJo.js → sso-UEGQ47Rv.js} +1 -1
  106. package/dist/client/assets/{store-D3-SS7Im.js → store-Ci22rcpd.js} +1 -1
  107. package/dist/client/assets/store-registry-DN8TZ1-U.js +2 -0
  108. package/dist/client/assets/{switch-B0c3heP8.js → switch-hDHC0QC1.js} +1 -1
  109. package/dist/client/assets/{table-HIiBelyW.js → table-CVQKMZ4_.js} +1 -1
  110. package/dist/client/assets/{tabs-BXWnZ-yB.js → tabs-C8FOFJ-h.js} +1 -1
  111. package/dist/client/assets/{task-status-DfkGkEmj.js → task-status-B774WcT0.js} +1 -1
  112. package/dist/client/assets/{textarea-CR3Wtkt8.js → textarea-BfCktOTF.js} +1 -1
  113. package/dist/client/assets/{toggle-group-COSjIR8f.js → toggle-group-DGj9s9yL.js} +1 -1
  114. package/dist/client/assets/{tools-list-BVkXIuQ8.js → tools-list-fuhfQMY2.js} +1 -1
  115. package/dist/client/assets/{types-DY60ZwCm.js → types-Bl0Y3GIR.js} +1 -1
  116. package/dist/client/assets/{use-ai-providers-CcA_yab6.js → use-ai-providers-BQCK5TM6.js} +1 -1
  117. package/dist/client/assets/{use-collections-Dlf9asbR.js → use-collections-Cn1cjJI2.js} +1 -1
  118. package/dist/client/assets/{use-connection-CNCuQvuX.js → use-connection-v8UC3xgU.js} +1 -1
  119. package/dist/client/assets/{use-copy-UL6gZ4LC.js → use-copy-DzNo1Zoi.js} +1 -1
  120. package/dist/client/assets/{use-create-virtual-mcp-CjqWoNj1.js → use-create-virtual-mcp-BeLev0H_.js} +1 -1
  121. package/dist/client/assets/{use-decopilot-events-BnKYuJvL.js → use-decopilot-events-CsTog7XJ.js} +1 -1
  122. package/dist/client/assets/{use-delete-connection-DdCOYKB6.js → use-delete-connection-mZOtWtVX.js} +1 -1
  123. package/dist/client/assets/{use-infinite-scroll-CatVEyLa.js → use-infinite-scroll-CK-WkWgZ.js} +1 -1
  124. package/dist/client/assets/{use-list-state-DBSg2drf.js → use-list-state-o8FZCyfy.js} +1 -1
  125. package/dist/client/assets/{use-mcp-tools-B6V19xvt.js → use-mcp-tools-BVhu3fJT.js} +1 -1
  126. package/dist/client/assets/{use-members-B8xFiKS7.js → use-members-DMhj1AWA.js} +1 -1
  127. package/dist/client/assets/{use-mobile-C_Neq23J.js → use-mobile-C3SuD1BB.js} +1 -1
  128. package/dist/client/assets/{use-navigate-to-agent-C0g9x11z.js → use-navigate-to-agent-D20v17MW.js} +1 -1
  129. package/dist/client/assets/{use-org-sso-DkKTWbST.js → use-org-sso-BsaVtwph.js} +1 -1
  130. package/dist/client/assets/{use-organization-settings-DV1cm49I.js → use-organization-settings-D1wrG6LV.js} +1 -1
  131. package/dist/client/assets/{use-registry-connections-DwyKWiF1.js → use-registry-connections-BoLdmnjr.js} +1 -1
  132. package/dist/client/assets/{use-status-sounds-CiqdINTO.js → use-status-sounds-ZCyKnAaZ.js} +1 -1
  133. package/dist/client/assets/{use-tasks-opPZutfY.js → use-tasks-DWNA1VlE.js} +1 -1
  134. package/dist/client/assets/{use-view-mode-Bjh-6ZT_.js → use-view-mode-DYGwSWVE.js} +1 -1
  135. package/dist/client/assets/{use-virtual-mcp-DXZnUcpg.js → use-virtual-mcp-CsGx_ml1.js} +1 -1
  136. package/dist/client/assets/useInfiniteQuery-7lHgA-BR.js +1 -0
  137. package/dist/client/assets/{user-DYxfnX1N.js → user-DyF77FBA.js} +1 -1
  138. package/dist/client/assets/{view-mode-toggle-BGpJZykq.js → view-mode-toggle-Cbb2hSFi.js} +1 -1
  139. package/dist/client/assets/{workflow-OVrWljFu.js → workflow-CnMTPULT.js} +1 -1
  140. package/dist/client/assets/workflow-detail-Dr8bEPzC.js +1 -0
  141. package/dist/client/index.html +1 -1
  142. package/dist/server/cli.js +1631 -389
  143. package/dist/server/node_modules/ansi-regex/index.d.ts +33 -0
  144. package/dist/server/node_modules/ansi-regex/index.js +14 -0
  145. package/dist/server/node_modules/ansi-regex/package.json +61 -0
  146. package/dist/server/node_modules/ansi-regex/readme.md +66 -0
  147. package/dist/server/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  148. package/dist/server/node_modules/emoji-regex/README.md +107 -0
  149. package/dist/server/node_modules/emoji-regex/index.d.ts +3 -0
  150. package/dist/server/node_modules/emoji-regex/index.js +4 -0
  151. package/dist/server/node_modules/emoji-regex/index.mjs +4 -0
  152. package/dist/server/node_modules/emoji-regex/package.json +45 -0
  153. package/dist/server/node_modules/onetime/index.d.ts +64 -0
  154. package/dist/server/node_modules/onetime/index.js +44 -0
  155. package/dist/server/node_modules/onetime/license +9 -0
  156. package/dist/server/node_modules/onetime/package.json +43 -0
  157. package/dist/server/node_modules/onetime/readme.md +94 -0
  158. package/dist/server/server.js +1679 -437
  159. package/package.json +1 -1
  160. package/dist/client/assets/ai-providers-Dc9Qa6xm.js +0 -1
  161. package/dist/client/assets/registry-UmlS2hsK.js +0 -2
  162. package/dist/client/assets/store-registry-BfuvvvI3.js +0 -2
  163. package/dist/client/assets/useInfiniteQuery-jUfAfl-E.js +0 -1
  164. package/dist/client/assets/workflow-detail-DunweIZq.js +0 -1
  165. package/dist/server/node_modules/get-east-asian-width/index.d.ts +0 -60
  166. package/dist/server/node_modules/get-east-asian-width/index.js +0 -30
  167. package/dist/server/node_modules/get-east-asian-width/lookup-data.js +0 -18
  168. package/dist/server/node_modules/get-east-asian-width/lookup.js +0 -135
  169. package/dist/server/node_modules/get-east-asian-width/package.json +0 -71
  170. package/dist/server/node_modules/get-east-asian-width/readme.md +0 -65
  171. package/dist/server/node_modules/get-east-asian-width/utilities.js +0 -24
  172. package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
  173. package/dist/server/node_modules/postgres-array/index.js +0 -97
  174. package/dist/server/node_modules/postgres-array/license +0 -21
  175. package/dist/server/node_modules/postgres-array/package.json +0 -35
  176. package/dist/server/node_modules/postgres-array/readme.md +0 -43
  177. package/dist/server/node_modules/xtend/.jshintrc +0 -30
  178. package/dist/server/node_modules/xtend/LICENSE +0 -20
  179. package/dist/server/node_modules/xtend/README.md +0 -32
  180. package/dist/server/node_modules/xtend/immutable.js +0 -19
  181. package/dist/server/node_modules/xtend/mutable.js +0 -17
  182. package/dist/server/node_modules/xtend/package.json +0 -55
  183. package/dist/server/node_modules/xtend/test.js +0 -103
  184. /package/dist/server/node_modules/{get-east-asian-width → ansi-regex}/license +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DQAduvBB.js","assets/index-Dj3wFV1t.js","assets/index-L4qcWzMc.css","assets/task-status-DfkGkEmj.js","assets/agent-icon-DBW-xznI.js","assets/AlertCircle-CfFyE8cr.js","assets/Tool01-BF1lV-4S.js","assets/SearchMd-Cnjv3UQP.js","assets/ArrowNarrowLeft-Da5yRbDu.js","assets/XCircle-bGl0e4GB.js","assets/ZapSquare-C-4TuG6U.js","assets/Users03-CCOKfSZN.js","assets/CheckCircle-D2fQEgC-.js","assets/ChevronDown-CEm8bH9z.js","assets/ChevronRight-DyTRIsvx.js","assets/ChevronUp-E63-b_P9.js","assets/Container-CJG3ExgA.js","assets/Star01-Duh2LG2L.js","assets/Palette-v9pwEnA4.js","assets/index-BIoyZkNb.js","assets/use-mobile-C_Neq23J.js","assets/X-qpFUx-Vy.js","assets/LinkExternal01-D16-VOGQ.js","assets/Lock01-B8wqomxu.js","assets/Sun-pL1WUVwn.js","assets/Play-D8DNxfum.js","assets/Plus-ZF7w6L4O.js","assets/Settings02-D6EvGHhW.js","assets/Trash01-B-dX5IVT.js","assets/Upload01-ObPiK9Gt.js","assets/User01-CIx0aqsB.js","assets/Zap-MsLTEH0A.js","assets/scroll-area-DMYp9AgI.js","assets/select-4thHDt_Z.js","assets/use-copy-UL6gZ4LC.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-VsnyL-XQ.js","assets/content-blocks-o63cs2vh.js","assets/types-DY60ZwCm.js","assets/constants-C7N_XM1Z.js","assets/chat-context-D0rB5W6o.js","assets/use-virtual-mcp-DXZnUcpg.js","assets/use-collections-Dlf9asbR.js","assets/use-ai-providers-CcA_yab6.js","assets/use-decopilot-events-BnKYuJvL.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-opPZutfY.js","assets/use-organization-settings-DV1cm49I.js","assets/shell-layout-DjPNQ4AH.js","assets/required-auth-layout-C6A_rjeR.js","assets/use-org-sso-DkKTWbST.js","assets/integration-icon-DoBfii_Q.js","assets/use-mcp-tools-B6V19xvt.js"])))=>i.map(i=>d[i]);
2
- import{o as Mt,r as S,p as $m,q as zm,e as B,s as be,K as lt,n as Fi,a as Br,v as js,w as Or,x as Hi,j as r,B as oe,y as Et,c as Y,E as ks,z as pe,C as Wi,_ as Fm,t as se,f as Ke,D as ol,F as Hm,R as Sh,G as Wm,H as ws,I as wo,J as us,L as Um,M as Vo,P as Km,Q as qm,T as Gm,U as Ym,V as wh,W as Xm,X as Jm,Y as Qm,Z as Zm,$ as cc,l as Ee,b as St,u as ep,a0 as pr,a1 as vn,a2 as al,a3 as ll,g as $r,a4 as Vh,d as vi,a5 as tp,a6 as sp,a7 as ip,a8 as rp,a9 as Ch,aa as jh,ab as np,ac as op,ad as ap,ae as Ft,af as lp,ag as cp,ah as dp,ai as hp,aj as Zi,ak as up,al as fp,am as mp,an as pp,ao as kh,ap as gp,aq as _p,ar as xp,as as vp,at as bp,au as yp,av as Sp,aw as wp,ax as Vp,ay as Cp,az as Nh,aA as bn,aB as jp,aC as Ai,aD as nn,aE as Ah,aF as kp,aG as Np}from"./index-Dj3wFV1t.js";import{u as oi,a as Ui,b as es,A as Ap,C as Ep,c as ra,d as Ip,e as Zn,f as dc,t as Rp}from"./chat-context-D0rB5W6o.js";import{d as eo,g as ii,c as Tp,s as cl,t as Dp,a as Mp,M as Pp,i as Lp,b as Cr,e as Bp,F as Op,f as Eh,S as $p,u as zp,h as hc,j as Fp,k as Hp,l as na,r as Wp,m as Up,p as Ih,n as Kp,o as qp,q as dl,G as Gp,L as Yp,v as Xp,w as Jp,x as Qp,y as Zp}from"./task-status-DfkGkEmj.js";import{S as jr,u as to,P as oa,a as eg,b as tg,c as sg,E as ig,i as rg,d as ng,e as Rh}from"./scroll-area-DMYp9AgI.js";import{T as Mi,u as Ds,a as tt,b as st,c as it}from"./use-mobile-C_Neq23J.js";import{D as gs,a as _s,b as hl,c as ls,d as cs,e as so}from"./dialog-VsnyL-XQ.js";import{D as io,a as bi,b as yi,c as Si,d as og,e as ag,f as lg}from"./drawer-BA2JOP-U.js";import{C as Th}from"./collection-search-C1X9xWrk.js";import{S as Wt,u as Me,g as ro,i as Mn,c as cg,W as Os,a as dg,b as ul}from"./constants-C7N_XM1Z.js";import{u as Dh,g as fl,T as Mh,a as yn,l as Pn,b as Co,c as hg}from"./tabs-BXWnZ-yB.js";import{F as Pi,a as It,b as Rt,c as rs,d as Tt,e as Dt,f as ug}from"./form-Cm4BWKO3.js";import{I as bt}from"./input-DFZSZH1u.js";import{i as Ph,u as zr,r as Lh}from"./shell-layout-DjPNQ4AH.js";import{D as ot,a as Sn,b as wn,c as Ns,d as As,e as Es,f as Bh,g as Oh,h as uc}from"./dropdown-menu-C5jBP7Fw.js";import{t as fg,i as $h,n as zh,A as zs,a as Fh,b as ml,s as ri,c as mg,d as pg,e as Hh,f as Wh,g as gg,h as pl,j as gr,k as _g,l as gl,m as xg,o as vg,p as Fr,q as Hr,r as bg,u as fc,v as mc,w as yg,x as Sg,y as pc,z as wg,B as _l,C as Uh,D as aa,E as jo,F as gc,G as Vg,H as Cg,I as jg,J as kg,K as Kh,L as qh,M as Gh,N as Yh,O as _c,P as Ng,Q as _r,R as Ag,S as Eg,T as Ig,U as Xh}from"./agent-icon-DBW-xznI.js";import{n as Jh,a as la,i as Rg,b as Tg,c as Dg}from"./ZapSquare-C-4TuG6U.js";import{i as Jt,t as kr}from"./ChevronDown-CEm8bH9z.js";import{s as Ti}from"./Star01-Duh2LG2L.js";import{a as ca,t as xl}from"./Tool01-BF1lV-4S.js";import{i as Qh}from"./Lock01-B8wqomxu.js";import{s as Qt}from"./Plus-ZF7w6L4O.js";import{i as Zh}from"./Upload01-ObPiK9Gt.js";import{i as Xs}from"./X-qpFUx-Vy.js";import{i as ni}from"./AlertCircle-CfFyE8cr.js";import{S as Qs,a as Zs,b as Ht,c as ei,d as ti}from"./select-4thHDt_Z.js";import{i as vl,a as bl,b as Mg}from"./SearchMd-Cnjv3UQP.js";import{i as no,t as Pg,a as Lg,b as Bg,c as Og,d as $g,e as Li,f as eu}from"./XCircle-bGl0e4GB.js";import{T as tu,a as Ln}from"./toggle-group-COSjIR8f.js";import{u as yl,a as su}from"./use-ai-providers-CcA_yab6.js";import{m as oo,g as zg,i as Fg,a as iu,M as ru,N as Hg}from"./select-model-DWwA5nzG.js";import{S as Wg,A as Ug,a as Kg,b as qg,c as Gg,R as nu,d as Yg,e as Xg}from"./accordion-BwZCqJLV.js";import{r as ou,l as xr,u as Jg,g as Qg}from"./types-DY60ZwCm.js";import{u as ao,a as ts,b as Sl}from"./use-virtual-mcp-DXZnUcpg.js";import{u as Wr,a as wl,b as Vl}from"./use-connection-CNCuQvuX.js";import{p as Zg,q as xc}from"./question-004-sINsf4GQ.js";import{g as vc}from"./ai-providers-logos-CS4PCiqI.js";import{g as au,s as lu}from"./connection-slug-eyAPH6o3.js";import{u as cu,a as du,g as e_,C as ko}from"./connection-card-hgxEw9QB.js";import{C as hu}from"./collection-tabs-DyGLUrer.js";import{g as uu}from"./constants-DYe7zuza.js";import{T as da}from"./textarea-CR3Wtkt8.js";import{n as Vn}from"./Container-CJG3ExgA.js";import{c as t_,i as on,a as bc,E as s_,p as i_,b as r_,d as n_}from"./connection-form-helpers-CiJ8SQZJ.js";import{u as yc}from"./use-infinite-scroll-CatVEyLa.js";import{u as o_,C as a_,a as Sc,b as wc,c as l_,d as c_,e as d_,f as h_}from"./command-quthPAw7.js";import{g as u_,e as f_,a as m_}from"./extract-connection-data-BZeMYWDa.js";import{B as Vc}from"./badge-DFmhmXN4.js";import{i as Cl}from"./ChevronRight-DyTRIsvx.js";import{I as Ms}from"./integration-icon-DoBfii_Q.js";import{S as Bi}from"./skeleton-BdOhMM7L.js";import{a as lo}from"./Users03-CCOKfSZN.js";import{I as Bn,S as fu,G as p_,L as g_,a as __,b as mu}from"./lean-canvas-recruit-modal-BU5okOF7.js";import{u as co,a as pu}from"./use-navigate-to-agent-C0g9x11z.js";import{u as gu}from"./use-create-virtual-mcp-CjqWoNj1.js";import{i as x_}from"./CheckCircle-D2fQEgC-.js";import{P as ai,a as li,b as ci}from"./popover-DkcEXeJ2.js";import{u as wi,a as v_}from"./use-mcp-tools-B6V19xvt.js";import{E as Oi}from"./empty-state-BOUL-w18.js";import{u as b_}from"./use-decopilot-events-BnKYuJvL.js";import{i as $i}from"./Zap-MsLTEH0A.js";import{i as _u,S as Ur,a as Kr,b as xs,u as qr,c as ms,d as Zt,e as xu,f as vu,g as y_,h as bu,j as yu,P as fs,k as S_,l as w_,m as V_,n as C_,o as j_,p as k_}from"./index-BIoyZkNb.js";import{A as Cc}from"./avatar-CrY-QYa1.js";import{n as N_,a as A_,i as E_}from"./Sun-pL1WUVwn.js";import{a as Gr}from"./Settings02-D6EvGHhW.js";import{A as jl,a as kl,b as Nl,c as Al,d as El,e as Il,f as Rl,g as Su}from"./alert-dialog-BBucwhbQ.js";import"./index-1tgFNQN6.js";import{u as wu}from"./use-tasks-opPZutfY.js";import{u as I_}from"./use-status-sounds-CiqdINTO.js";import{T as R_,u as Vu}from"./tools-list-BVkXIuQ8.js";import{u as No}from"./unwrap-tool-result-BYXdCQMg.js";import{C as T_,a as jc}from"./card-CAUJapuJ.js";import{L as vr}from"./label-CinsfmY9.js";import{S as ha}from"./switch-B0c3heP8.js";import{i as Cn}from"./Play-D8DNxfum.js";import{s as ua}from"./Trash01-B-dX5IVT.js";import{C as D_}from"./checkbox-FzuPLTLu.js";import{n as Vi}from"./LinkExternal01-D16-VOGQ.js";import{V as M_}from"./view-mode-toggle-BGpJZykq.js";import{U as P_}from"./user-DYxfnX1N.js";import{u as Yr,a as L_,b as B_,c as O_,A as $_,d as z_}from"./automation-list-row-xmvI2ZpZ.js";import{S as F_}from"./search-input-Dazz3BtE.js";import"./use-collections-Dlf9asbR.js";import"./use-organization-settings-DV1cm49I.js";import"./use-copy-UL6gZ4LC.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-C6A_rjeR.js";import"./use-org-sso-DkKTWbST.js";import"./ArrowNarrowLeft-Da5yRbDu.js";import"./ChevronUp-E63-b_P9.js";import"./Palette-v9pwEnA4.js";import"./User01-CIx0aqsB.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-DwyKWiF1.js";import"./useInfiniteQuery-jUfAfl-E.js";import"./infiniteQueryObserver-CTx2Ye7N.js";import"./collections-D0TgU2mm.js";import"./index-B21DFJvX.js";import"./create-sse-subscription-CxkOgzKf.js";function H_(t,e){const s=Mt(e);return W_({filters:{...t,status:"pending"}},s).length}function kc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function W_(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),n=S.useRef(null);return n.current===null&&(n.current=kc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=$m(n.current,kc(s,i.current));n.current!==a&&(n.current=a,zm.schedule(o))}),[s]),()=>n.current,()=>n.current)}function U_(t,e){const s=B.c(37),{org:i,locator:n}=be();let o;s[0]!==i.id?(o={connectionId:Wt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Me(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=lt.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Fi(u);let m;s[11]!==a||s[12]!==e?(m=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const j=y.content,w=Array.isArray(j)&&j[0]&&typeof j[0]=="object"?j[0].text??"Create failed":"Create failed";throw new Error(w)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=m):m=s[13];let f;s[14]!==n||s[15]!==i.id||s[16]!==h||s[17]!==l?(f=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:lt.tasksPrefix(n)}),h.refetch()},s[14]=n,s[15]=i.id,s[16]=h,s[17]=l,s[18]=f):f=s[18];let p;s[19]!==m||s[20]!==f?(p={mutationFn:m,onSuccess:f},s[19]=m,s[20]=f,s[21]=p):p=s[21];const g=Br(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function K_(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return js(e)}function q_(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Tl(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:n}=t,o=S.useId();let a;if(e[0]!==s){const D=s?K_(s):js({});a=Or(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?q_(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Hi(u);let m;e[7]!==s?.arguments?(m=s?.arguments??[],e[7]=s?.arguments,e[8]=m):m=e[8];const f=m;let p;e[9]!==h||e[10]!==n||e[11]!==i?(p=async D=>{await n(D),i(null),h.reset()},e[9]=h,e[10]=n,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||eo(s.name,ii(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=r.jsx(gs,{children:r.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=r.jsxs(_s,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let j;e[27]!==h||e[28]!==g?(j=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=j):j=e[29];let w;if(e[30]!==f||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>r.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:z}=O;return r.jsxs(Rt,{children:[r.jsxs(rs,{className:"text-xs",children:[P.name,P.required?null:r.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),r.jsx(Tt,{children:r.jsx(bt,{...z,value:z.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),r.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],w=f.map(D),e[30]=f,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=w}else w=e[33];let V;e[37]!==v?(V=()=>v(!1),e[37]=v,e[38]=V):V=e[38];let k;e[39]!==h.formState.isSubmitting||e[40]!==V?(k=r.jsx(oe,{type:"button",variant:"ghost",onClick:V,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=V,e[41]=k):k=e[41];const R=!h.formState.isValid||h.formState.isSubmitting;let T;e[42]!==h.formState.isSubmitting?(T=h.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=T):T=e[43];let E;e[44]!==o||e[45]!==R||e[46]!==T?(E=r.jsx(oe,{type:"submit",form:o,disabled:R,children:T}),e[44]=o,e[45]=R,e[46]=T,e[47]=E):E=e[47];let N;e[48]!==k||e[49]!==E?(N=r.jsxs(hl,{children:[k,E]}),e[48]=k,e[49]=E,e[50]=N):N=e[50];let A;e[51]!==o||e[52]!==j||e[53]!==w||e[54]!==N?(A=r.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:j,children:[w,N]}),e[51]=o,e[52]=j,e[53]=w,e[54]=N,e[55]=A):A=e[55];let I;e[56]!==h||e[57]!==A?(I=r.jsx(Pi,{...h,children:A}),e[56]=h,e[57]=A,e[58]=I):I=e[58];let M;e[59]!==C||e[60]!==I?(M=r.jsxs(ls,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,I]}),e[59]=C,e[60]=I,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=r.jsx(cs,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function G_(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 Y_(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Nc=3,Cu="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",X_="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function ju(t){const e=B.c(46),{item:s,onSelect:i,isLoading:n,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const w=ii(c._meta);d=c.title??eo(c.name,w),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let w;e[4]!==i||e[5]!==c?(w=()=>i(c),e[4]=i,e[5]=c,e[6]=w):w=e[6];const V=o||n,k=n&&"bg-accent/40",R=(o||n)&&"cursor-not-allowed opacity-50";let T;e[7]!==k||e[8]!==R?(T=Y(X_,"hover:bg-accent/60 text-foreground",k,R),e[7]=k,e[8]=R,e[9]=T):T=e[9];let E;e[10]!==u?(E=r.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=E):E=e[11];let N;e[12]!==n?(N=n&&r.jsx(jr,{size:"xs"}),e[12]=n,e[13]=N):N=e[13];let A;e[14]!==E||e[15]!==N?(A=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[E,N]}),e[14]=E,e[15]=N,e[16]=A):A=e[16];let I;e[17]!==h?(I=h&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=I):I=e[18];let M;return e[19]!==A||e[20]!==I||e[21]!==w||e[22]!==V||e[23]!==T?(M=r.jsxs("button",{type:"button",onClick:w,disabled:V,className:T,children:[A,I]}),e[19]=A,e[20]=I,e[21]=w,e[22]=V,e[23]=T,e[24]=M):M=e[24],M}let m;e[25]!==i||e[26]!==c?(m=()=>i(c),e[25]=i,e[26]=c,e[27]=m):m=e[27];const f=o||n,p=n&&"bg-muted/50",g=(o||n)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=Y(Cu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=r.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==n?(x=n&&r.jsx(jr,{size:"xs"}),e[33]=n,e[34]=x):x=e[34];let b;e[35]!==m||e[36]!==f||e[37]!==_||e[38]!==v||e[39]!==x?(b=r.jsx(tt,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:m,disabled:f,className:_,children:[v,x]})}),e[35]=m,e[36]=f,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=r.jsx(st,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let j;return e[43]!==b||e[44]!==C?(j=r.jsxs(it,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=j):j=e[45],j}function J_(t){const e=B.c(41),{items:s,open:i,onOpenChange:n,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(V=>{const k=l.toLowerCase();return V.prompt.name.toLowerCase().includes(k)||(V.prompt.title??"").toLowerCase().includes(k)||(V.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,m=Ds();let f;e[3]!==h.length||e[4]!==l?(f=h.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=f):f=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==n||e[10]!==o){let V;e[12]!==d||e[13]!==a?.name||e[14]!==n||e[15]!==o?(V=k=>r.jsx(ju,{item:k,variant:"card",onSelect:R=>{n(!1),o(R)},isLoading:a?.name===k.prompt.name,isDisabled:d&&a?.name!==k.prompt.name},k.prompt.name),e[12]=d,e[13]=a?.name,e[14]=n,e[15]=o,e[16]=V):V=e[16],p=h.map(V),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=n,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==f||e[18]!==p?(g=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[f,p]})}),e[17]=f,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{V.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=r.jsx(Th,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(m){let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(io,{className:"sr-only",children:r.jsx(bi,{children:"All prompts"})}),e[23]=V):V=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let R;e[25]!==_||e[26]!==b?(R=r.jsxs(yi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,k,b,_]}),e[25]=_,e[26]=b,e[27]=R):R=e[27];let T;return e[28]!==n||e[29]!==i||e[30]!==R?(T=r.jsx(Mi,{delayDuration:400,children:r.jsx(Si,{open:i,onOpenChange:n,children:R})}),e[28]=n,e[29]=i,e[30]=R,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(_s,{className:"sr-only",children:r.jsx(gs,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let j;e[34]!==_||e[35]!==b?(j=r.jsxs(ls,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=j):j=e[36];let w;return e[37]!==n||e[38]!==i||e[39]!==j?(w=r.jsx(Mi,{delayDuration:400,children:r.jsx(cs,{open:i,onOpenChange:n,children:j})}),e[37]=n,e[38]=i,e[39]=j,e[40]=w):w=e[40],w}function Q_(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:n,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==n||e[2]!==i){const v=s.slice(0,Nc);let x;e[6]!==s?(x=s.slice(Nc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!n;let b;e[8]!==d||e[9]!==n?.name||e[10]!==i?(b=y=>r.jsx(ju,{item:y,onSelect:i,isLoading:n?.name===y.prompt.name,isDisabled:d&&n?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=n?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=n,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let m;e[12]!==o?(m=Y("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let f;e[14]!==c.length||e[15]!==d?(f=c.length>0&&r.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:Y(Cu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=f):f=e[16];let p;e[17]!==h||e[18]!==m||e[19]!==f?(p=r.jsxs("div",{className:m,children:[h,f]}),e[17]=h,e[18]=m,e[19]=f,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==n||e[23]!==a||e[24]!==i?(g=r.jsx(J_,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:n}),e[21]=s,e[22]=n,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=r.jsxs(Mi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function Z_(){return null}function ex(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 tx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Ui(),{tiptapDocRef:n}=oi(),{org:o}=be();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Me(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Dh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let m;e[7]!==h?(m=h.map(sx),e[7]=h,e[8]=m):m=e[8];const f=m;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(ex,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==n?(b=async(A,I)=>{if(!l){pe.error("MCP client not available"),_({type:"RESET"});return}try{const M=await fl(l,A.name,I);_({type:"RESET"});const L=Y_(n.current,{type:"paragraph",content:[Tp({id:A.name,name:cl(A.name,ii(A._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),pe.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=n,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async A=>{if(A.arguments&&A.arguments.length>0){_({type:"SELECT_PROMPT",prompt:A}),x(A);return}_({type:"START_LOADING",prompt:A}),await y(A)},e[14]=y,e[15]=C):C=e[15];const j=C;let w;e[16]!==v||e[17]!==y?(w=async A=>{v&&(_({type:"START_LOADING",prompt:v,arguments:A}),x(null),await y(v,A))},e[16]=v,e[17]=y,e[18]=w):w=e[18];const V=w;if(f.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let R;e[19]!==j||e[20]!==f||e[21]!==k?(R=r.jsx(Q_,{items:f,onSelect:j,loadingPrompt:k}),e[19]=j,e[20]=f,e[21]=k,e[22]=R):R=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{x(null),_({type:"RESET"})},e[23]=T):T=e[23];let E;e[24]!==v||e[25]!==V?(E=r.jsx(Tl,{prompt:v,setPrompt:T,onSubmit:V}),e[24]=v,e[25]=V,e[26]=E):E=e[26];let N;return e[27]!==R||e[28]!==E?(N=r.jsxs(r.Fragment,{children:[R,E]}),e[27]=R,e[28]=E,e[29]=N):N=e[29],N}function sx(t){return{prompt:t}}function ix(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=oi(),{org:n}=be();let o;e[0]!==n.id?(o=ro(n.id),e[0]=n.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=Y("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Z_,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=r.jsx(tx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let m;e[7]!==d||e[8]!==h?(m=r.jsx(ks,{fallback:null,children:r.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=m):m=e[9];let f;return e[10]!==c||e[11]!==m?(f=r.jsx("div",{className:c,children:m}),e[10]=c,e[11]=m,e[12]=f):f=e[12],f}function ku(t){const e=B.c(21),{current:s,total:i,onPrev:n,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=Y("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(vl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==a||e[5]!==c?(u=r.jsx("button",{type:"button",onClick:n,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=n,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let m;e[7]!==h||e[8]!==i?(m=r.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=m):m=e[9];const f=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=Y("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(no,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==f?(v=r.jsx("button",{type:"button",onClick:o,disabled:f,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=f,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==m?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,m,v]}),e[17]=v,e[18]=u,e[19]=m,e[20]=x):x=e[20],x}function On(t){const e=B.c(18),{title:s,children:i,footerLeft:n,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=Y("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=r.jsx("div",{className:"flex items-center gap-2 p-4",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=r.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==n?(h=r.jsx("div",{children:n}),e[6]=n,e[7]=h):h=e[7];let m;e[8]!==o?(m=r.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=m):m=e[9];let f;e[10]!==h||e[11]!==m?(f=r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[h,m]})}),e[10]=h,e[11]=m,e[12]=f):f=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==f?(p=r.jsxs("div",{className:c,children:[d,u,f]}),e[13]=c,e[14]=d,e[15]=u,e[16]=f,e[17]=p):p=e[17],p}const rx="User denied this tool call, give other alternatives.",nx=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function ox(t){const e=B.c(9),{onYolo:s}=t,[i,n]=Wi();let o;e[0]!==s||e[1]!==i||e[2]!==n?(o=u=>{const h=u;n({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=n,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(ei,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:lx,children:r.jsx(ti,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Qs,{children:nx.map(ax)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=r.jsxs(Zs,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function ax(t){return r.jsx(Ht,{value:t.value,children:t.label},t.value)}function lx(t){return t.stopPropagation()}function cx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.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 n;return e[3]!==i?(n=r.jsx("div",{className:"px-4",children:r.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]=n):n=e[4],n}function dx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[n,o]=S.useState(0),a=Math.min(n,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,rx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let m;e[6]!==s||e[7]!==i?(m=()=>{for(const N of s)i(N.approvalId,!0)},e[6]=s,e[7]=i,e[8]=m):m=e[8];const f=m;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==f?(x=r.jsx(ox,{onYolo:f}),e[14]=f,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=r.jsx(ku,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let j;e[24]!==d?(j=r.jsx(oe,{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:d,children:"Deny"}),e[24]=d,e[25]=j):j=e[25];let w;e[26]!==s.length||e[27]!==f?(w=s.length>1&&r.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:f,children:"Accept All"}),e[26]=s.length,e[27]=f,e[28]=w):w=e[28];let V;e[29]!==h?(V=r.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=V):V=e[30];let k;e[31]!==w||e[32]!==V||e[33]!==j?(k=r.jsxs(r.Fragment,{children:[j,w,V]}),e[31]=w,e[32]=V,e[33]=j,e[34]=k):k=e[34];const R=k;let T;e[35]!==l.input?(T=r.jsx(cx,{input:l.input}),e[35]=l.input,e[36]=T):T=e[36];let E;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==R||e[40]!==T?(E=r.jsx(On,{title:l.friendlyName,footerLeft:C,footerRight:R,children:T}),e[37]=l.friendlyName,e[38]=C,e[39]=R,e[40]=T,e[41]=E):E=e[41],E}function hx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(fg,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function ux(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:n}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(hx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==n?(o=r.jsx(dx,{approvals:s,onRespond:n}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function fx(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:Dp(Mp(i)),input:s.input})}return e}function mx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:n}=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 l;e[3]!==n?(l=r.jsx(oe,{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:n,children:"Keep iterating"}),e[3]=n,e[4]=l):l=e[4];let c;e[5]!==a?(c=r.jsx(oe,{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]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=r.jsxs(r.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(Pp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let m;return e[12]!==u||e[13]!==h?(m=r.jsx(On,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=m):m=e[14],m}function px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function gx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:n,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(px,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==n||e[5]!==o?(c=r.jsx(mx,{plan:l,onApprove:n,onDismiss:o}),e[3]=l,e[4]=n,e[5]=o,e[6]=c):c=e[6],c}function _x(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 Ac=js({response:Et().min(1,"Response is required")}),xx=js({response:Et().min(1,"Please select or enter an option")}),vx=js({response:Fm(["yes","no"])});function bx(t){switch(t.type){case"text":return Ac;case"choice":return xx;case"confirm":return vx;default:return Ac}}function yx(t){const e={};for(const s of t)e[s.toolCallId]=bx(s.input);return js(e)}function Sx(t){const e=B.c(6),{control:s,name:i,placeholder:n}=t;let o;e[0]!==n?(o=l=>{const{field:c}=l;return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...c,type:"text",placeholder:n||"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"})]})})}),r.jsx(Dt,{})]})},e[0]=n,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=r.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Nu(t,e){const s=B.c(4);let i,n;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},n=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=n):(i=s[2],n=s[3]),S.useEffect(i,n)}function wx(t){const e=B.c(9),{control:s,name:i,options:n}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==n?(d=m=>{c.current?.onChange(n[m]??""),a(!1)},e[0]=n,e[1]=d):d=e[1],Nu(n.length,d),n.length===0)return null;let u;e[2]!==o||e[3]!==n?(u=m=>{const{field:f}=m;c.current=f;const p=o||!!f.value&&!n.includes(f.value);return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[n.map((g,_)=>{const v=f.value===g;return r.jsxs("button",{type:"button",onClick:()=>{f.onChange(g??""),a(!1)},className:Y("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),r.jsxs("div",{className:Y("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),n.includes(f.value)&&f.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),p?r.jsx("input",{ref:l,type:"text",value:f.value,onChange:g=>f.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"}):r.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),r.jsx(Dt,{})]})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=r.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Vx(t){const e=B.c(6),{control:s,name:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=["yes","no"],e[0]=n):n=e[0];const o=n,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Nu(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const f=h.value===m;return r.jsxs("button",{type:"button",onClick:()=>h.onChange(m),className:Y("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",f&&"bg-accent/50",!f&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",f?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),r.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=r.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Ec(t){const e=B.c(13),{input:s,control:i,name:n}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==n?(o=r.jsx(Sx,{control:i,name:n,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=n,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 l;return e[6]!==i||e[7]!==n||e[8]!==a?(l=r.jsx(wx,{control:i,name:n,options:a}),e[6]=i,e[7]=n,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==n?(o=r.jsx(Vx,{control:i,name:n}),e[10]=i,e[11]=n,e[12]=o):o=e[12],o}default:return null}}function Cx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),n=yx(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Hi({resolver:Or(n),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,m=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},f=()=>{o.setValue(`${s}.response`,"user has skip this question"),m()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=r.jsxs(r.Fragment,{children:[r.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:f,className:"h-7",children:"Skip"}),r.jsx(oe,{type:"button",size:"sm",disabled:!c,onClick:m,className:Y("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=r.jsx(ku,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(On,{title:x.input?.prompt??"Question",footerRight:_,children:r.jsx(Ec,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(Mh,{value:s,onValueChange:i,children:t.map(x=>r.jsx(yn,{value:x.toolCallId,className:"mt-0",children:r.jsx(On,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:r.jsx(Ec,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function jx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Pg,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Au(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:n}=t;let o;e[0]!==s?(o=s.filter(kx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(jx,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==n||e[4]!==a?(l=r.jsx(Cx,{parts:a,onSubmit:n}),e[3]=n,e[4]=a,e[5]=l):l=e[5],l}function kx(t){return t.state==="input-available"}const Ic=new Map;function ho(){const{org:t}=be(),e=Me({connectionId:Wt,orgId:t.id}),s=yl(),i=s.find(_=>_.providerId==="deco"),{data:n,isLoading:o,refetch:a,isFetching:l}=Fi({queryKey:lt.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=n?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Ic.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&se("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Ic.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,m=c!=null&&c>0,f=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:m,isZeroBalance:f,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Nx(t){return t?t.message.startsWith("[CREDITS]"):!1}const Ax={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"}]},Ex=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Eu(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=be(),n=Ke(),{decoKeyId:o}=ho();let a;e[0]!==i.id?(a={connectionId:Wt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Me(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[m,f]=S.useState("usd"),p=m==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{se("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==m?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:m}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=m,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Tx},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=Br(b),j=parseFloat(c),w=!isNaN(j)&&j>=1;let V;e[13]!==s?(V=D=>!D&&s?.(),e[13]=s,e[14]=V):V=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=["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[15]=k):k=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:k.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=R):R=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[R,r.jsxs(_s,{className:"relative gap-4",children:[r.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"}),r.jsxs("div",{children:[r.jsx(gs,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(so,{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[17]=T):T=e[17];let E;e[18]!==m||e[19]!==p||e[20]!==c||e[21]!==j||e[22]!==o||e[23]!==w||e[24]!==C||e[25]!==u||e[26]!==y?(E=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(tu,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:D=>{D&&f(D)},children:[r.jsx(Ln,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Ln,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Ax[m].map(D=>{const{dollars:P,label:O}=D;return r.jsxs("button",{type:"button",disabled:C,onClick:()=>{se("credits_topup_clicked",{amount_cents:P*100,currency:m,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:Y("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:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(bt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(oe,{className:"h-10",disabled:!w||C,onClick:()=>{se("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:m,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(j*100))},children:C?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Ex.map(Ix)})]}),e[18]=m,e[19]=p,e[20]=c,e[21]=j,e[22]=o,e[23]=w,e[24]=C,e[25]=u,e[26]=y,e[27]=E):E=e[27];let N;e[28]!==s?(N=r.jsx(oe,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=N):N=e[29];let A;e[30]!==n||e[31]!==s||e[32]!==i.slug?(A=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{n({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=n,e[31]=s,e[32]=i.slug,e[33]=A):A=e[33];let I;e[34]!==N||e[35]!==A?(I=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[N,A]}),e[34]=N,e[35]=A,e[36]=I):I=e[36];let M;e[37]!==E||e[38]!==I?(M=r.jsxs(ls,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Rx,children:[T,E,I]}),e[37]=E,e[38]=I,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==V?(L=r.jsx(cs,{open:!0,onOpenChange:V,children:M}),e[40]=M,e[41]=V,e[42]=L):L=e[42],L}function Ix(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Rx(t){return t.preventDefault()}function Tx(t){pe.error(`Top-up failed: ${t.message}`)}const Dx={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 $n(t){const e=B.c(32),{variant:s,onDismiss:i}=t,n=s==="error",o=n?"Error occurred":"Response incomplete",a=n?t.error.message:Dx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=n?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=n?"text-destructive":"text-amber-600 dark:text-amber-500",d=n?ni:ol;let u;e[0]!==l?(u=Y("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=Y("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let m;e[4]!==d?(m=r.jsx(d,{size:16}),e[4]=d,e[5]=m):m=e[5];let f;e[6]!==h||e[7]!==m?(f=r.jsx("div",{className:h,children:m}),e[6]=h,e[7]=m,e[8]=f):f=e[8];let p;e[9]!==c?(p=Y("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=r.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=r.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==n||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=r.jsx("div",{className:"flex gap-2",children:n?r.jsxs(r.Fragment,{children:[r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),r.jsx(oe,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=n,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=r.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Xs,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=r.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==f||e[30]!==x?(C=r.jsx("div",{className:"px-0.5",children:r.jsxs("div",{className:u,children:[f,x,y]})}),e[27]=u,e[28]=y,e[29]=f,e[30]=x,e[31]=C):C=e[31],C}function uo(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:n,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Ui(),[h,m]=Wi(),{virtualMcpId:f,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const I=o.at(-1);x=I?.role==="assistant"?I.parts.filter(Lx):null,g=x?.filter(Px)?.length,_=I?.role==="assistant"?_x(I.parts):[],v=I?.role==="assistant"?fx(I.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let j;t[8]!==u?(j=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=j):j=t[9];const w=j;let V;t[10]!==c?(V=(I,M)=>{c({tool:"user_ask",toolCallId:I.toolCallId,output:{response:M}})},t[10]=c,t[11]=V):V=t[11];const k=V;let R;t[12]!==p||t[13]!==h||t[14]!==m||t[15]!==f?(R=I=>{m({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:f,message:{parts:[{type:"text",text:`Implement this plan:
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DA-h2zTN.js","assets/index-DfVs9Fb7.js","assets/index-L4qcWzMc.css","assets/task-status-B774WcT0.js","assets/agent-icon-CItqy-K1.js","assets/AlertCircle-BnQT18aF.js","assets/Tool01-BQx_QkPV.js","assets/SearchMd-DY4wMwzx.js","assets/ArrowNarrowLeft-C9kLhY7x.js","assets/XCircle-NQPpx_1o.js","assets/ZapSquare-BzqjfXvk.js","assets/Users03-DuReHFEk.js","assets/CheckCircle-Cs-97qLz.js","assets/ChevronDown-DK8QUWOr.js","assets/ChevronRight-FLwTFysc.js","assets/ChevronUp-DpoyT3Mx.js","assets/Container-BioTKt13.js","assets/Star01-4Y5nWGjE.js","assets/Palette-AK3X7q7E.js","assets/index-C4h_7_D2.js","assets/use-mobile-C3SuD1BB.js","assets/X-BpK79C1U.js","assets/LinkExternal01-x8IH3HPT.js","assets/Lock01-D77tMj01.js","assets/Sun-DHZd7DXq.js","assets/Play-CBnQYPj8.js","assets/Plus-DDAfDw-O.js","assets/Settings02-XkpqnrJC.js","assets/Trash01-CChmuBav.js","assets/Upload01-DNNaYKi-.js","assets/User01-BP1wQdKX.js","assets/Zap-DZ80UrUJ.js","assets/scroll-area-DTSNhfSU.js","assets/select-DL2N1Ojk.js","assets/use-copy-DzNo1Zoi.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-D93zmoD4.js","assets/content-blocks-o63cs2vh.js","assets/types-Bl0Y3GIR.js","assets/constants-1IZfBK2U.js","assets/chat-context-ZY2xyfov.js","assets/use-virtual-mcp-CsGx_ml1.js","assets/use-collections-Cn1cjJI2.js","assets/use-ai-providers-BQCK5TM6.js","assets/use-decopilot-events-CsTog7XJ.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-DWNA1VlE.js","assets/use-organization-settings-D1wrG6LV.js","assets/shell-layout-lbN_BpLZ.js","assets/required-auth-layout-DYfQDmqT.js","assets/use-org-sso-BsaVtwph.js","assets/integration-icon-BEqEqACj.js","assets/use-mcp-tools-BVhu3fJT.js"])))=>i.map(i=>d[i]);
2
+ import{o as Mt,r as S,p as $m,q as zm,e as B,s as be,K as lt,n as Fi,a as Br,v as js,w as Or,x as Hi,j as r,B as oe,y as Et,c as Y,E as ks,z as pe,C as Wi,_ as Fm,t as se,f as Ke,D as ol,F as Hm,R as Sh,G as Wm,H as ws,I as wo,J as us,L as Um,M as Vo,P as Km,Q as qm,T as Gm,U as Ym,V as wh,W as Xm,X as Jm,Y as Qm,Z as Zm,$ as cc,l as Ee,b as St,u as ep,a0 as pr,a1 as vn,a2 as al,a3 as ll,g as $r,a4 as Vh,d as vi,a5 as tp,a6 as sp,a7 as ip,a8 as rp,a9 as Ch,aa as jh,ab as np,ac as op,ad as ap,ae as Ft,af as lp,ag as cp,ah as dp,ai as hp,aj as Zi,ak as up,al as fp,am as mp,an as pp,ao as kh,ap as gp,aq as _p,ar as xp,as as vp,at as bp,au as yp,av as Sp,aw as wp,ax as Vp,ay as Cp,az as Nh,aA as bn,aB as jp,aC as Ai,aD as nn,aE as Ah,aF as kp,aG as Np}from"./index-DfVs9Fb7.js";import{u as oi,a as Ui,b as es,A as Ap,C as Ep,c as ra,d as Ip,e as Zn,f as dc,t as Rp}from"./chat-context-ZY2xyfov.js";import{d as eo,g as ii,c as Tp,s as cl,t as Dp,a as Mp,M as Pp,i as Lp,b as Cr,e as Bp,F as Op,f as Eh,S as $p,u as zp,h as hc,j as Fp,k as Hp,l as na,r as Wp,m as Up,p as Ih,n as Kp,o as qp,q as dl,G as Gp,L as Yp,v as Xp,w as Jp,x as Qp,y as Zp}from"./task-status-B774WcT0.js";import{S as jr,u as to,P as oa,a as eg,b as tg,c as sg,E as ig,i as rg,d as ng,e as Rh}from"./scroll-area-DTSNhfSU.js";import{T as Mi,u as Ds,a as tt,b as st,c as it}from"./use-mobile-C3SuD1BB.js";import{D as gs,a as _s,b as hl,c as ls,d as cs,e as so}from"./dialog-D93zmoD4.js";import{D as io,a as bi,b as yi,c as Si,d as og,e as ag,f as lg}from"./drawer-Du6ov_Kn.js";import{C as Th}from"./collection-search-B2uexuf4.js";import{S as Wt,u as Me,g as ro,i as Mn,c as cg,W as Os,a as dg,b as ul}from"./constants-1IZfBK2U.js";import{u as Dh,g as fl,T as Mh,a as yn,l as Pn,b as Co,c as hg}from"./tabs-C8FOFJ-h.js";import{F as Pi,a as It,b as Rt,c as rs,d as Tt,e as Dt,f as ug}from"./form-CGR8HWXm.js";import{I as bt}from"./input-DCH6MuqU.js";import{i as Ph,u as zr,r as Lh}from"./shell-layout-lbN_BpLZ.js";import{D as ot,a as Sn,b as wn,c as Ns,d as As,e as Es,f as Bh,g as Oh,h as uc}from"./dropdown-menu-BKbYv7Wd.js";import{t as fg,i as $h,n as zh,A as zs,a as Fh,b as ml,s as ri,c as mg,d as pg,e as Hh,f as Wh,g as gg,h as pl,j as gr,k as _g,l as gl,m as xg,o as vg,p as Fr,q as Hr,r as bg,u as fc,v as mc,w as yg,x as Sg,y as pc,z as wg,B as _l,C as Uh,D as aa,E as jo,F as gc,G as Vg,H as Cg,I as jg,J as kg,K as Kh,L as qh,M as Gh,N as Yh,O as _c,P as Ng,Q as _r,R as Ag,S as Eg,T as Ig,U as Xh}from"./agent-icon-CItqy-K1.js";import{n as Jh,a as la,i as Rg,b as Tg,c as Dg}from"./ZapSquare-BzqjfXvk.js";import{i as Jt,t as kr}from"./ChevronDown-DK8QUWOr.js";import{s as Ti}from"./Star01-4Y5nWGjE.js";import{a as ca,t as xl}from"./Tool01-BQx_QkPV.js";import{i as Qh}from"./Lock01-D77tMj01.js";import{s as Qt}from"./Plus-DDAfDw-O.js";import{i as Zh}from"./Upload01-DNNaYKi-.js";import{i as Xs}from"./X-BpK79C1U.js";import{i as ni}from"./AlertCircle-BnQT18aF.js";import{S as Qs,a as Zs,b as Ht,c as ei,d as ti}from"./select-DL2N1Ojk.js";import{i as vl,a as bl,b as Mg}from"./SearchMd-DY4wMwzx.js";import{i as no,t as Pg,a as Lg,b as Bg,c as Og,d as $g,e as Li,f as eu}from"./XCircle-NQPpx_1o.js";import{T as tu,a as Ln}from"./toggle-group-DGj9s9yL.js";import{u as yl,a as su}from"./use-ai-providers-BQCK5TM6.js";import{m as oo,g as zg,i as Fg,a as iu,M as ru,N as Hg}from"./select-model-LSEQrmLs.js";import{S as Wg,A as Ug,a as Kg,b as qg,c as Gg,R as nu,d as Yg,e as Xg}from"./accordion-BnLbYmWD.js";import{r as ou,l as xr,u as Jg,g as Qg}from"./types-Bl0Y3GIR.js";import{u as ao,a as ts,b as Sl}from"./use-virtual-mcp-CsGx_ml1.js";import{u as Wr,a as wl,b as Vl}from"./use-connection-v8UC3xgU.js";import{p as Zg,q as xc}from"./question-004-sINsf4GQ.js";import{g as vc}from"./ai-providers-logos-CS4PCiqI.js";import{g as au,s as lu}from"./connection-slug-eyAPH6o3.js";import{u as cu,a as du,g as e_,C as ko}from"./connection-card-CE6WfLhf.js";import{C as hu}from"./collection-tabs-BAZJIsSw.js";import{g as uu}from"./constants-C5faKoYI.js";import{T as da}from"./textarea-BfCktOTF.js";import{n as Vn}from"./Container-BioTKt13.js";import{c as t_,i as on,a as bc,E as s_,p as i_,b as r_,d as n_}from"./connection-form-helpers-Cp1W4tWB.js";import{u as yc}from"./use-infinite-scroll-CK-WkWgZ.js";import{u as o_,C as a_,a as Sc,b as wc,c as l_,d as c_,e as d_,f as h_}from"./command-CVo7-d2L.js";import{g as u_,e as f_,a as m_}from"./extract-connection-data-BLTghne6.js";import{B as Vc}from"./badge-CExLRIph.js";import{i as Cl}from"./ChevronRight-FLwTFysc.js";import{I as Ms}from"./integration-icon-BEqEqACj.js";import{S as Bi}from"./skeleton-BpYnrXqd.js";import{a as lo}from"./Users03-DuReHFEk.js";import{I as Bn,S as fu,G as p_,L as g_,a as __,b as mu}from"./lean-canvas-recruit-modal-tEiAB2yp.js";import{u as co,a as pu}from"./use-navigate-to-agent-D20v17MW.js";import{u as gu}from"./use-create-virtual-mcp-BeLev0H_.js";import{i as x_}from"./CheckCircle-Cs-97qLz.js";import{P as ai,a as li,b as ci}from"./popover-DdVefIGO.js";import{u as wi,a as v_}from"./use-mcp-tools-BVhu3fJT.js";import{E as Oi}from"./empty-state-pBS5unOo.js";import{u as b_}from"./use-decopilot-events-CsTog7XJ.js";import{i as $i}from"./Zap-DZ80UrUJ.js";import{i as _u,S as Ur,a as Kr,b as xs,u as qr,c as ms,d as Zt,e as xu,f as vu,g as y_,h as bu,j as yu,P as fs,k as S_,l as w_,m as V_,n as C_,o as j_,p as k_}from"./index-C4h_7_D2.js";import{A as Cc}from"./avatar-Br-mHNNE.js";import{n as N_,a as A_,i as E_}from"./Sun-DHZd7DXq.js";import{a as Gr}from"./Settings02-XkpqnrJC.js";import{A as jl,a as kl,b as Nl,c as Al,d as El,e as Il,f as Rl,g as Su}from"./alert-dialog-BiQ8dmMn.js";import"./index-Bg9PL9wv.js";import{u as wu}from"./use-tasks-DWNA1VlE.js";import{u as I_}from"./use-status-sounds-ZCyKnAaZ.js";import{T as R_,u as Vu}from"./tools-list-fuhfQMY2.js";import{u as No}from"./unwrap-tool-result-BYXdCQMg.js";import{C as T_,a as jc}from"./card-Bi6fzNxY.js";import{L as vr}from"./label-DdsMT8c-.js";import{S as ha}from"./switch-hDHC0QC1.js";import{i as Cn}from"./Play-CBnQYPj8.js";import{s as ua}from"./Trash01-CChmuBav.js";import{C as D_}from"./checkbox-CSWuHjiA.js";import{n as Vi}from"./LinkExternal01-x8IH3HPT.js";import{V as M_}from"./view-mode-toggle-Cbb2hSFi.js";import{U as P_}from"./user-DyF77FBA.js";import{u as Yr,a as L_,b as B_,c as O_,A as $_,d as z_}from"./automation-list-row-Dcp8P3LE.js";import{S as F_}from"./search-input-Byx2xO-2.js";import"./use-collections-Cn1cjJI2.js";import"./use-organization-settings-D1wrG6LV.js";import"./use-copy-DzNo1Zoi.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./required-auth-layout-DYfQDmqT.js";import"./use-org-sso-BsaVtwph.js";import"./ArrowNarrowLeft-C9kLhY7x.js";import"./ChevronUp-DpoyT3Mx.js";import"./Palette-AK3X7q7E.js";import"./User01-BP1wQdKX.js";import"./formatDistanceToNow-Cb2QZZJn.js";import"./use-registry-connections-BoLdmnjr.js";import"./useInfiniteQuery-7lHgA-BR.js";import"./infiniteQueryObserver-C_0qvJ_M.js";import"./collections-DY3yi6mH.js";import"./index-BZ_OMQZt.js";import"./create-sse-subscription-CxkOgzKf.js";function H_(t,e){const s=Mt(e);return W_({filters:{...t,status:"pending"}},s).length}function kc(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function W_(t={},e){const s=Mt(e).getMutationCache(),i=S.useRef(t),n=S.useRef(null);return n.current===null&&(n.current=kc(s,t)),S.useEffect(()=>{i.current=t}),S.useSyncExternalStore(S.useCallback(o=>s.subscribe(()=>{const a=$m(n.current,kc(s,i.current));n.current!==a&&(n.current=a,zm.schedule(o))}),[s]),()=>n.current,()=>n.current)}function U_(t,e){const s=B.c(37),{org:i,locator:n}=be();let o;s[0]!==i.id?(o={connectionId:Wt,orgId:i.id},s[0]=i.id,s[1]=o):o=s[1];const a=Me(o),l=Mt();let c;s[2]!==t||s[3]!==i.id?(c=lt.ensureTask(i.id,t),s[2]=t,s[3]=i.id,s[4]=c):c=s[4];let d;s[5]!==a||s[6]!==t?(d=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[5]=a,s[6]=t,s[7]=d):d=s[7];let u;s[8]!==c||s[9]!==d?(u={queryKey:c,queryFn:d,retry:!1,refetchOnWindowFocus:!1},s[8]=c,s[9]=d,s[10]=u):u=s[10];const h=Fi(u);let m;s[11]!==a||s[12]!==e?(m=async b=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:b,virtual_mcp_id:e}}});if(y.isError){const j=y.content,w=Array.isArray(j)&&j[0]&&typeof j[0]=="object"?j[0].text??"Create failed":"Create failed";throw new Error(w)}return y.structuredContent.item},s[11]=a,s[12]=e,s[13]=m):m=s[13];let f;s[14]!==n||s[15]!==i.id||s[16]!==h||s[17]!==l?(f=()=>{l.invalidateQueries({predicate:b=>b.queryKey[1]===i.id&&b.queryKey[3]==="collection"&&b.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:lt.tasksPrefix(n)}),h.refetch()},s[14]=n,s[15]=i.id,s[16]=h,s[17]=l,s[18]=f):f=s[18];let p;s[19]!==m||s[20]!==f?(p={mutationFn:m,onSuccess:f},s[19]=m,s[20]=f,s[21]=p):p=s[21];const g=Br(p);let _,v;if(s[22]!==g||s[23]!==t||s[24]!==h.data||s[25]!==h.isSuccess?(_=()=>{!h.isSuccess||h.data||g.isPending||g.variables!==t&&g.mutate(t)},v=[t,h.isSuccess,h.data,g],s[22]=g,s[23]=t,s[24]=h.data,s[25]=h.isSuccess,s[26]=_,s[27]=v):(_=s[26],v=s[27]),S.useEffect(_,v),h.isLoading){let b;return s[28]===Symbol.for("react.memo_cache_sentinel")?(b={status:"loading"},s[28]=b):b=s[28],b}if(h.isError){const b=h.error;let y;return s[29]!==b?(y={status:"error",error:b},s[29]=b,s[30]=y):y=s[30],y}if(h.isSuccess&&h.data){let b;return s[31]!==h.data?(b={status:"ready",task:h.data},s[31]=h.data,s[32]=b):b=s[32],b}if(g.isPending||h.isSuccess&&!h.data){let b;return s[33]===Symbol.for("react.memo_cache_sentinel")?(b={status:"creating"},s[33]=b):b=s[33],b}if(g.isError){let b;return s[34]!==g.error?(b={status:"error",error:g.error},s[34]=g.error,s[35]=b):b=s[35],b}let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[36]=x):x=s[36],x}function K_(t){const e={};for(const s of t.arguments??[])e[s.name]=s.required?Et().min(1,"Required"):Et();return js(e)}function q_(t){const e={};for(const s of t.arguments??[])e[s.name]="";return e}function Tl(t){const e=B.c(65),{prompt:s,setPrompt:i,onSubmit:n}=t,o=S.useId();let a;if(e[0]!==s){const D=s?K_(s):js({});a=Or(D),e[0]=s,e[1]=a}else a=e[1];const c=a;let d;e[2]!==s?(d=s?q_(s):{},e[2]=s,e[3]=d):d=e[3];let u;e[4]!==c||e[5]!==d?(u={resolver:c,defaultValues:d,mode:"onChange"},e[4]=c,e[5]=d,e[6]=u):u=e[6];const h=Hi(u);let m;e[7]!==s?.arguments?(m=s?.arguments??[],e[7]=s?.arguments,e[8]=m):m=e[8];const f=m;let p;e[9]!==h||e[10]!==n||e[11]!==i?(p=async D=>{await n(D),i(null),h.reset()},e[9]=h,e[10]=n,e[11]=i,e[12]=p):p=e[12];const g=p;let _;e[13]!==h||e[14]!==i?(_=D=>{D||(h.reset(),i(null))},e[13]=h,e[14]=i,e[15]=_):_=e[15];const v=_;if(!s)return null;let x;e[16]!==s._meta||e[17]!==s.name||e[18]!==s.title?(x=s.title||eo(s.name,ii(s._meta)),e[16]=s._meta,e[17]=s.name,e[18]=s.title,e[19]=x):x=e[19];let b;e[20]!==x?(b=r.jsx(gs,{children:r.jsx("span",{className:"capitalize",children:x})}),e[20]=x,e[21]=b):b=e[21];let y;e[22]!==s.description?(y=s.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.description}),e[22]=s.description,e[23]=y):y=e[23];let C;e[24]!==y||e[25]!==b?(C=r.jsxs(_s,{children:[b,y]}),e[24]=y,e[25]=b,e[26]=C):C=e[26];let j;e[27]!==h||e[28]!==g?(j=D=>{D.stopPropagation(),h.handleSubmit(g)(D)},e[27]=h,e[28]=g,e[29]=j):j=e[29];let w;if(e[30]!==f||e[31]!==h.control||e[32]!==h.formState.isSubmitting){let D;e[34]!==h.control||e[35]!==h.formState.isSubmitting?(D=P=>r.jsx(It,{control:h.control,name:P.name,render:O=>{const{field:z}=O;return r.jsxs(Rt,{children:[r.jsxs(rs,{className:"text-xs",children:[P.name,P.required?null:r.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),r.jsx(Tt,{children:r.jsx(bt,{...z,value:z.value??"",required:P.required,placeholder:P.description??"",className:"h-9",disabled:h.formState.isSubmitting})}),r.jsx(Dt,{})]})}},P.name),e[34]=h.control,e[35]=h.formState.isSubmitting,e[36]=D):D=e[36],w=f.map(D),e[30]=f,e[31]=h.control,e[32]=h.formState.isSubmitting,e[33]=w}else w=e[33];let V;e[37]!==v?(V=()=>v(!1),e[37]=v,e[38]=V):V=e[38];let k;e[39]!==h.formState.isSubmitting||e[40]!==V?(k=r.jsx(oe,{type:"button",variant:"ghost",onClick:V,disabled:h.formState.isSubmitting,children:"Cancel"}),e[39]=h.formState.isSubmitting,e[40]=V,e[41]=k):k=e[41];const R=!h.formState.isValid||h.formState.isSubmitting;let T;e[42]!==h.formState.isSubmitting?(T=h.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"}),"Loading..."]}):"Use prompt",e[42]=h.formState.isSubmitting,e[43]=T):T=e[43];let E;e[44]!==o||e[45]!==R||e[46]!==T?(E=r.jsx(oe,{type:"submit",form:o,disabled:R,children:T}),e[44]=o,e[45]=R,e[46]=T,e[47]=E):E=e[47];let N;e[48]!==k||e[49]!==E?(N=r.jsxs(hl,{children:[k,E]}),e[48]=k,e[49]=E,e[50]=N):N=e[50];let A;e[51]!==o||e[52]!==j||e[53]!==w||e[54]!==N?(A=r.jsxs("form",{id:o,className:"space-y-4 py-4",autoComplete:"off",onSubmit:j,children:[w,N]}),e[51]=o,e[52]=j,e[53]=w,e[54]=N,e[55]=A):A=e[55];let I;e[56]!==h||e[57]!==A?(I=r.jsx(Pi,{...h,children:A}),e[56]=h,e[57]=A,e[58]=I):I=e[58];let M;e[59]!==C||e[60]!==I?(M=r.jsxs(ls,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[C,I]}),e[59]=C,e[60]=I,e[61]=M):M=e[61];let L;return e[62]!==v||e[63]!==M?(L=r.jsx(cs,{open:!0,onOpenChange:v,children:M}),e[62]=v,e[63]=M,e[64]=L):L=e[64],L}function G_(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 Y_(t,e){return{type:"doc",content:[...t?.content??[],e].filter(Boolean)}}const Nc=3,Cu="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",X_="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function ju(t){const e=B.c(46),{item:s,onSelect:i,isLoading:n,isDisabled:o,variant:a}=t,l=a===void 0?"pill":a,{prompt:c}=s;let d;if(e[0]!==c._meta||e[1]!==c.name||e[2]!==c.title){const w=ii(c._meta);d=c.title??eo(c.name,w),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const u=d,h=c.description||null;if(l==="card"){let w;e[4]!==i||e[5]!==c?(w=()=>i(c),e[4]=i,e[5]=c,e[6]=w):w=e[6];const V=o||n,k=n&&"bg-accent/40",R=(o||n)&&"cursor-not-allowed opacity-50";let T;e[7]!==k||e[8]!==R?(T=Y(X_,"hover:bg-accent/60 text-foreground",k,R),e[7]=k,e[8]=R,e[9]=T):T=e[9];let E;e[10]!==u?(E=r.jsx("span",{className:"font-medium truncate capitalize",children:u}),e[10]=u,e[11]=E):E=e[11];let N;e[12]!==n?(N=n&&r.jsx(jr,{size:"xs"}),e[12]=n,e[13]=N):N=e[13];let A;e[14]!==E||e[15]!==N?(A=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[E,N]}),e[14]=E,e[15]=N,e[16]=A):A=e[16];let I;e[17]!==h?(I=h&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:h}),e[17]=h,e[18]=I):I=e[18];let M;return e[19]!==A||e[20]!==I||e[21]!==w||e[22]!==V||e[23]!==T?(M=r.jsxs("button",{type:"button",onClick:w,disabled:V,className:T,children:[A,I]}),e[19]=A,e[20]=I,e[21]=w,e[22]=V,e[23]=T,e[24]=M):M=e[24],M}let m;e[25]!==i||e[26]!==c?(m=()=>i(c),e[25]=i,e[26]=c,e[27]=m):m=e[27];const f=o||n,p=n&&"bg-muted/50",g=(o||n)&&"cursor-not-allowed opacity-50";let _;e[28]!==p||e[29]!==g?(_=Y(Cu,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=_):_=e[30];let v;e[31]!==u?(v=r.jsx("span",{className:"capitalize",children:u}),e[31]=u,e[32]=v):v=e[32];let x;e[33]!==n?(x=n&&r.jsx(jr,{size:"xs"}),e[33]=n,e[34]=x):x=e[34];let b;e[35]!==m||e[36]!==f||e[37]!==_||e[38]!==v||e[39]!==x?(b=r.jsx(tt,{asChild:!0,children:r.jsxs("button",{type:"button",onClick:m,disabled:f,className:_,children:[v,x]})}),e[35]=m,e[36]=f,e[37]=_,e[38]=v,e[39]=x,e[40]=b):b=e[40];const y=h??u;let C;e[41]!==y?(C=r.jsx(st,{side:"top",className:"max-w-xs",children:r.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=C):C=e[42];let j;return e[43]!==b||e[44]!==C?(j=r.jsxs(it,{delayDuration:400,children:[b,C]}),e[43]=b,e[44]=C,e[45]=j):j=e[45],j}function J_(t){const e=B.c(41),{items:s,open:i,onOpenChange:n,onSelect:o,loadingPrompt:a}=t,[l,c]=S.useState(""),d=!!a;let u;e[0]!==s||e[1]!==l?(u=l.trim()?s.filter(V=>{const k=l.toLowerCase();return V.prompt.name.toLowerCase().includes(k)||(V.prompt.title??"").toLowerCase().includes(k)||(V.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=u):u=e[2];const h=u,m=Ds();let f;e[3]!==h.length||e[4]!==l?(f=h.length===0&&r.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=h.length,e[4]=l,e[5]=f):f=e[5];let p;if(e[6]!==h||e[7]!==d||e[8]!==a?.name||e[9]!==n||e[10]!==o){let V;e[12]!==d||e[13]!==a?.name||e[14]!==n||e[15]!==o?(V=k=>r.jsx(ju,{item:k,variant:"card",onSelect:R=>{n(!1),o(R)},isLoading:a?.name===k.prompt.name,isDisabled:d&&a?.name!==k.prompt.name},k.prompt.name),e[12]=d,e[13]=a?.name,e[14]=n,e[15]=o,e[16]=V):V=e[16],p=h.map(V),e[6]=h,e[7]=d,e[8]=a?.name,e[9]=n,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==f||e[18]!==p?(g=r.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[f,p]})}),e[17]=f,e[18]=p,e[19]=g):g=e[19];const _=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=V=>{V.key==="Escape"&&c("")},e[20]=v):v=e[20];let x;e[21]!==l?(x=r.jsx(Th,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=x):x=e[22];const b=x;if(m){let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(io,{className:"sr-only",children:r.jsx(bi,{children:"All prompts"})}),e[23]=V):V=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let R;e[25]!==_||e[26]!==b?(R=r.jsxs(yi,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[V,k,b,_]}),e[25]=_,e[26]=b,e[27]=R):R=e[27];let T;return e[28]!==n||e[29]!==i||e[30]!==R?(T=r.jsx(Mi,{delayDuration:400,children:r.jsx(Si,{open:i,onOpenChange:n,children:R})}),e[28]=n,e[29]=i,e[30]=R,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(_s,{className:"sr-only",children:r.jsx(gs,{children:"All prompts"})}),e[32]=y):y=e[32];let C;e[33]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=C):C=e[33];let j;e[34]!==_||e[35]!==b?(j=r.jsxs(ls,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,C,b,_]}),e[34]=_,e[35]=b,e[36]=j):j=e[36];let w;return e[37]!==n||e[38]!==i||e[39]!==j?(w=r.jsx(Mi,{delayDuration:400,children:r.jsx(cs,{open:i,onOpenChange:n,children:j})}),e[37]=n,e[38]=i,e[39]=j,e[40]=w):w=e[40],w}function Q_(t){const e=B.c(29),{items:s,onSelect:i,loadingPrompt:n,className:o}=t,[a,l]=S.useState(!1);if(s.length===0)return null;let c,d,u;if(e[0]!==s||e[1]!==n||e[2]!==i){const v=s.slice(0,Nc);let x;e[6]!==s?(x=s.slice(Nc),e[6]=s,e[7]=x):x=e[7],c=x,d=!!n;let b;e[8]!==d||e[9]!==n?.name||e[10]!==i?(b=y=>r.jsx(ju,{item:y,onSelect:i,isLoading:n?.name===y.prompt.name,isDisabled:d&&n?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=n?.name,e[10]=i,e[11]=b):b=e[11],u=v.map(b),e[0]=s,e[1]=n,e[2]=i,e[3]=c,e[4]=d,e[5]=u}else c=e[3],d=e[4],u=e[5];const h=u;let m;e[12]!==o?(m=Y("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=m):m=e[13];let f;e[14]!==c.length||e[15]!==d?(f=c.length>0&&r.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:Y(Cu,"hover:bg-muted/70 hover:text-foreground",d&&"opacity-50 cursor-not-allowed"),children:["+",c.length," more"]}),e[14]=c.length,e[15]=d,e[16]=f):f=e[16];let p;e[17]!==h||e[18]!==m||e[19]!==f?(p=r.jsxs("div",{className:m,children:[h,f]}),e[17]=h,e[18]=m,e[19]=f,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==n||e[23]!==a||e[24]!==i?(g=r.jsx(J_,{items:s,open:a,onOpenChange:l,onSelect:i,loadingPrompt:n}),e[21]=s,e[22]=n,e[23]=a,e[24]=i,e[25]=g):g=e[25];let _;return e[26]!==p||e[27]!==g?(_=r.jsxs(Mi,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=_):_=e[28],_}function Z_(){return null}function ex(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 tx(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:i}=Ui(),{tiptapDocRef:n}=oi(),{org:o}=be();let a;e[0]!==s||e[1]!==o.id?(a={connectionId:s,orgId:o.id},e[0]=s,e[1]=o.id,e[2]=a):a=e[2];const l=Me(a);let c;e[3]!==l?(c={client:l,staleTime:6e4},e[3]=l,e[4]=c):c=e[4];const{data:d}=Dh(c);let u;e[5]!==d?.prompts?(u=d?.prompts??[],e[5]=d?.prompts,e[6]=u):u=e[6];const h=u;let m;e[7]!==h?(m=h.map(sx),e[7]=h,e[8]=m):m=e[8];const f=m;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={stage:"idle"},e[9]=p):p=e[9];const[g,_]=S.useReducer(ex,p),[v,x]=S.useState(null);let b;e[10]!==l||e[11]!==i||e[12]!==n?(b=async(A,I)=>{if(!l){pe.error("MCP client not available"),_({type:"RESET"});return}try{const M=await fl(l,A.name,I);_({type:"RESET"});const L=Y_(n.current,{type:"paragraph",content:[Tp({id:A.name,name:cl(A.name,ii(A._meta)),metadata:M.messages,char:"/"})]});await i(L)}catch(M){console.error("[ice-breakers] Failed to fetch prompt:",M),pe.error("Failed to load prompt. Please try again."),_({type:"RESET"})}},e[10]=l,e[11]=i,e[12]=n,e[13]=b):b=e[13];const y=b;let C;e[14]!==y?(C=async A=>{if(A.arguments&&A.arguments.length>0){_({type:"SELECT_PROMPT",prompt:A}),x(A);return}_({type:"START_LOADING",prompt:A}),await y(A)},e[14]=y,e[15]=C):C=e[15];const j=C;let w;e[16]!==v||e[17]!==y?(w=async A=>{v&&(_({type:"START_LOADING",prompt:v,arguments:A}),x(null),await y(v,A))},e[16]=v,e[17]=y,e[18]=w):w=e[18];const V=w;if(f.length===0)return null;const k=g.stage==="loading"?g.prompt:null;let R;e[19]!==j||e[20]!==f||e[21]!==k?(R=r.jsx(Q_,{items:f,onSelect:j,loadingPrompt:k}),e[19]=j,e[20]=f,e[21]=k,e[22]=R):R=e[22];let T;e[23]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{x(null),_({type:"RESET"})},e[23]=T):T=e[23];let E;e[24]!==v||e[25]!==V?(E=r.jsx(Tl,{prompt:v,setPrompt:T,onSubmit:V}),e[24]=v,e[25]=V,e[26]=E):E=e[26];let N;return e[27]!==R||e[28]!==E?(N=r.jsxs(r.Fragment,{children:[R,E]}),e[27]=R,e[28]=E,e[29]=N):N=e[29],N}function sx(t){return{prompt:t}}function ix(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:i}=oi(),{org:n}=be();let o;e[0]!==n.id?(o=ro(n.id),e[0]=n.id,e[1]=o):o=e[1];const a=o.id,l=i?.id??a;let c;e[2]!==s?(c=Y("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(Z_,{}),e[4]=u):u=e[4];let h;e[5]!==l?(h=r.jsx(tx,{connectionId:l}),e[5]=l,e[6]=h):h=e[6];let m;e[7]!==d||e[8]!==h?(m=r.jsx(ks,{fallback:null,children:r.jsx(S.Suspense,{fallback:u,children:h},d)}),e[7]=d,e[8]=h,e[9]=m):m=e[9];let f;return e[10]!==c||e[11]!==m?(f=r.jsx("div",{className:c,children:m}),e[10]=c,e[11]=m,e[12]=f):f=e[12],f}function ku(t){const e=B.c(21),{current:s,total:i,onPrev:n,onNext:o}=t;if(i<=1)return null;const a=s===0,l=s===0?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let c;e[0]!==l?(c=Y("p-0.5 rounded transition-colors",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(vl,{size:14}),e[2]=d):d=e[2];let u;e[3]!==n||e[4]!==a||e[5]!==c?(u=r.jsx("button",{type:"button",onClick:n,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=n,e[4]=a,e[5]=c,e[6]=u):u=e[6];const h=s+1;let m;e[7]!==h||e[8]!==i?(m=r.jsxs("span",{className:"tabular-nums text-xs",children:[h," of ",i]}),e[7]=h,e[8]=i,e[9]=m):m=e[9];const f=s===i-1,p=s===i-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=Y("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx(no,{size:14}),e[12]=_):_=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==f?(v=r.jsx("button",{type:"button",onClick:o,disabled:f,className:g,"aria-label":"Next question",children:_}),e[13]=o,e[14]=g,e[15]=f,e[16]=v):v=e[16];let x;return e[17]!==v||e[18]!==u||e[19]!==m?(x=r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[u,m,v]}),e[17]=v,e[18]=u,e[19]=m,e[20]=x):x=e[20],x}function On(t){const e=B.c(18),{title:s,children:i,footerLeft:n,footerRight:o,className:a}=t,l=a??"border-border";let c;e[0]!==l?(c=Y("flex flex-col rounded-xl bg-background border shadow-md w-[calc(100%-16px)] max-w-[584px] mx-auto mb-[-16px]",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=r.jsx("div",{className:"flex items-center gap-2 p-4",children:r.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:s})}),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==i?(u=r.jsx("div",{className:"overflow-clip pb-4",children:i}),e[4]=i,e[5]=u):u=e[5];let h;e[6]!==n?(h=r.jsx("div",{children:n}),e[6]=n,e[7]=h):h=e[7];let m;e[8]!==o?(m=r.jsx("div",{className:"flex items-center gap-2",children:o}),e[8]=o,e[9]=m):m=e[9];let f;e[10]!==h||e[11]!==m?(f=r.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[h,m]})}),e[10]=h,e[11]=m,e[12]=f):f=e[12];let p;return e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==f?(p=r.jsxs("div",{className:c,children:[d,u,f]}),e[13]=c,e[14]=d,e[15]=u,e[16]=f,e[17]=p):p=e[17],p}const rx="User denied this tool call, give other alternatives.",nx=[{value:"readonly",label:"Ask before edit"},{value:"auto",label:"Auto approve"}];function ox(t){const e=B.c(9),{onYolo:s}=t,[i,n]=Wi();let o;e[0]!==s||e[1]!==i||e[2]!==n?(o=u=>{const h=u;n({...i,toolApprovalLevel:h}),h==="auto"&&s()},e[0]=s,e[1]=i,e[2]=n,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(ei,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:lx,children:r.jsx(ti,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(Qs,{children:nx.map(ax)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==i.toolApprovalLevel?(d=r.jsxs(Zs,{value:i.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=i.toolApprovalLevel,e[8]=d):d=e[8],d}function ax(t){return r.jsx(Ht,{value:t.value,children:t.label},t.value)}function lx(t){return t.stopPropagation()}function cx(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.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 n;return e[3]!==i?(n=r.jsx("div",{className:"px-4",children:r.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]=n):n=e[4],n}function dx(t){const e=B.c(42),{approvals:s,onRespond:i}=t,[n,o]=S.useState(0),a=Math.min(n,s.length-1),l=s[a];if(!l)return null;let c;e[0]!==l.approvalId||e[1]!==i?(c=()=>{i(l.approvalId,!1,rx)},e[0]=l.approvalId,e[1]=i,e[2]=c):c=e[2];const d=c;let u;e[3]!==l.approvalId||e[4]!==i?(u=()=>{i(l.approvalId,!0)},e[3]=l.approvalId,e[4]=i,e[5]=u):u=e[5];const h=u;let m;e[6]!==s||e[7]!==i?(m=()=>{for(const N of s)i(N.approvalId,!0)},e[6]=s,e[7]=i,e[8]=m):m=e[8];const f=m;let p;e[9]!==a?(p=()=>{a>0&&o(a-1)},e[9]=a,e[10]=p):p=e[10];const g=p;let _;e[11]!==s.length||e[12]!==a?(_=()=>{a<s.length-1&&o(a+1)},e[11]=s.length,e[12]=a,e[13]=_):_=e[13];const v=_;let x;e[14]!==f?(x=r.jsx(ox,{onYolo:f}),e[14]=f,e[15]=x):x=e[15];let b;e[16]!==s.length||e[17]!==v||e[18]!==g||e[19]!==a?(b=r.jsx(ku,{current:a,total:s.length,onPrev:g,onNext:v}),e[16]=s.length,e[17]=v,e[18]=g,e[19]=a,e[20]=b):b=e[20];let y;e[21]!==x||e[22]!==b?(y=r.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[21]=x,e[22]=b,e[23]=y):y=e[23];const C=y;let j;e[24]!==d?(j=r.jsx(oe,{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:d,children:"Deny"}),e[24]=d,e[25]=j):j=e[25];let w;e[26]!==s.length||e[27]!==f?(w=s.length>1&&r.jsx(oe,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:f,children:"Accept All"}),e[26]=s.length,e[27]=f,e[28]=w):w=e[28];let V;e[29]!==h?(V=r.jsx(oe,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:h,children:"Accept"}),e[29]=h,e[30]=V):V=e[30];let k;e[31]!==w||e[32]!==V||e[33]!==j?(k=r.jsxs(r.Fragment,{children:[j,w,V]}),e[31]=w,e[32]=V,e[33]=j,e[34]=k):k=e[34];const R=k;let T;e[35]!==l.input?(T=r.jsx(cx,{input:l.input}),e[35]=l.input,e[36]=T):T=e[36];let E;return e[37]!==l.friendlyName||e[38]!==C||e[39]!==R||e[40]!==T?(E=r.jsx(On,{title:l.friendlyName,footerLeft:C,footerRight:R,children:T}),e[37]=l.friendlyName,e[38]=C,e[39]=R,e[40]=T,e[41]=E):E=e[41],E}function hx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(fg,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function ux(t){const e=B.c(4),{approvals:s,isStreaming:i,onRespond:n}=t;if(i&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(hx,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;let o;return e[1]!==s||e[2]!==n?(o=r.jsx(dx,{approvals:s,onRespond:n}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function fx(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:Dp(Mp(i)),input:s.input})}return e}function mx(t){const e=B.c(15),{plan:s,onApprove:i,onDismiss:n}=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 l;e[3]!==n?(l=r.jsx(oe,{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:n,children:"Keep iterating"}),e[3]=n,e[4]=l):l=e[4];let c;e[5]!==a?(c=r.jsx(oe,{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]=c):c=e[6];let d;e[7]!==l||e[8]!==c?(d=r.jsxs(r.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const u=d;let h;e[10]!==s.plan?(h=r.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:r.jsx(Pp,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[10]=s.plan,e[11]=h):h=e[11];let m;return e[12]!==u||e[13]!==h?(m=r.jsx(On,{title:"Implementation Plan",footerRight:u,className:"border-dashed border-purple-500",children:h}),e[12]=u,e[13]=h,e[14]=m):m=e[14],m}function px(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Jt,{className:"size-5 text-purple-500 shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function gx(t){const e=B.c(7),{plans:s,isStreaming:i,onApprove:n,onDismiss:o}=t;if(i&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(px,{}),e[0]=d):d=e[0],d}let a;e[1]!==s?(a=s.at(-1),e[1]=s,e[2]=a):a=e[2];const l=a;if(!l)return null;let c;return e[3]!==l||e[4]!==n||e[5]!==o?(c=r.jsx(mx,{plan:l,onApprove:n,onDismiss:o}),e[3]=l,e[4]=n,e[5]=o,e[6]=c):c=e[6],c}function _x(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 Ac=js({response:Et().min(1,"Response is required")}),xx=js({response:Et().min(1,"Please select or enter an option")}),vx=js({response:Fm(["yes","no"])});function bx(t){switch(t.type){case"text":return Ac;case"choice":return xx;case"confirm":return vx;default:return Ac}}function yx(t){const e={};for(const s of t)e[s.toolCallId]=bx(s.input);return js(e)}function Sx(t){const e=B.c(6),{control:s,name:i,placeholder:n}=t;let o;e[0]!==n?(o=l=>{const{field:c}=l;return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"px-2",children:r.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),r.jsx("input",{...c,type:"text",placeholder:n||"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"})]})})}),r.jsx(Dt,{})]})},e[0]=n,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==i||e[4]!==o?(a=r.jsx(It,{control:s,name:i,render:o}),e[2]=s,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Nu(t,e){const s=B.c(4);let i,n;s[0]!==t||s[1]!==e?(i=()=>{const o=a=>{const l=a.target.tagName;if(l==="INPUT"||l==="TEXTAREA"||a.metaKey||a.ctrlKey||a.altKey)return;const c=Number.parseInt(a.key,10);c>=1&&c<=t&&(a.preventDefault(),e(c-1))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},n=[t,e],s[0]=t,s[1]=e,s[2]=i,s[3]=n):(i=s[2],n=s[3]),S.useEffect(i,n)}function wx(t){const e=B.c(9),{control:s,name:i,options:n}=t,[o,a]=S.useState(!1),l=S.useRef(null),c=S.useRef(null);let d;if(e[0]!==n?(d=m=>{c.current?.onChange(n[m]??""),a(!1)},e[0]=n,e[1]=d):d=e[1],Nu(n.length,d),n.length===0)return null;let u;e[2]!==o||e[3]!==n?(u=m=>{const{field:f}=m;c.current=f;const p=o||!!f.value&&!n.includes(f.value);return r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[n.map((g,_)=>{const v=f.value===g;return r.jsxs("button",{type:"button",onClick:()=>{f.onChange(g??""),a(!1)},className:Y("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",v&&"bg-accent/50",!v&&"hover:bg-accent/30"),"aria-label":`Select ${g}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",v?"bg-chart-1 text-white":"bg-muted text-foreground"),children:_+1}),r.jsx("span",{className:"text-sm text-foreground truncate",children:g})]},`${_}-${g}`)}),r.jsxs("div",{className:Y("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",p&&"bg-accent/50",!p&&"hover:bg-accent/30"),onClick:()=>{a(!0),n.includes(f.value)&&f.onChange(""),setTimeout(()=>l.current?.focus(),0)},children:[r.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:r.jsx($h,{size:16,className:"text-muted-foreground"})}),p?r.jsx("input",{ref:l,type:"text",value:f.value,onChange:g=>f.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"}):r.jsx("span",{className:"text-sm text-foreground/25",children:"Something else..."})]})]})}),r.jsx(Dt,{})]})},e[2]=o,e[3]=n,e[4]=u):u=e[4];let h;return e[5]!==s||e[6]!==i||e[7]!==u?(h=r.jsx(It,{control:s,name:i,render:u}),e[5]=s,e[6]=i,e[7]=u,e[8]=h):h=e[8],h}function Vx(t){const e=B.c(6),{control:s,name:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=["yes","no"],e[0]=n):n=e[0];const o=n,a=S.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=u=>{a.current?.onChange(o[u]??"")},e[1]=l):l=e[1],Nu(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=u=>{const{field:h}=u;return a.current=h,r.jsxs(Rt,{children:[r.jsx(Tt,{children:r.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(m=>{const f=h.value===m;return r.jsxs("button",{type:"button",onClick:()=>h.onChange(m),className:Y("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",f&&"bg-accent/50",!f&&"hover:bg-accent/30"),"aria-label":`Confirm ${m}`,children:[r.jsx("span",{className:Y("flex items-center justify-center size-6 rounded-md text-sm shrink-0",f?"bg-chart-1 text-white":"bg-muted text-foreground"),children:m==="yes"?1:2}),r.jsx("span",{className:"text-sm text-foreground capitalize",children:m})]},m)})})}),r.jsx(Dt,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==i?(d=r.jsx(It,{control:s,name:i,render:c}),e[3]=s,e[4]=i,e[5]=d):d=e[5],d}function Ec(t){const e=B.c(13),{input:s,control:i,name:n}=t;switch(s.type){case"text":{let o;return e[0]!==i||e[1]!==s.default||e[2]!==n?(o=r.jsx(Sx,{control:i,name:n,placeholder:s.default}),e[0]=i,e[1]=s.default,e[2]=n,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 l;return e[6]!==i||e[7]!==n||e[8]!==a?(l=r.jsx(wx,{control:i,name:n,options:a}),e[6]=i,e[7]=n,e[8]=a,e[9]=l):l=e[9],l}case"confirm":{let o;return e[10]!==i||e[11]!==n?(o=r.jsx(Vx,{control:i,name:n}),e[10]=i,e[11]=n,e[12]=o):o=e[12],o}default:return null}}function Cx({parts:t,onSubmit:e}){const[s,i]=S.useState(t[0]?.toolCallId??""),n=yx(t.map(x=>({toolCallId:x.toolCallId,input:x.input}))),o=Hi({resolver:Or(n),defaultValues:Object.fromEntries(t.map(x=>[x.toolCallId,{response:""}]))}),a=o.watch(),l=t.findIndex(x=>x.toolCallId===s),c=!!a[s]?.response,d=t.every(x=>!!a[x.toolCallId]?.response),u=x=>{for(const b of t){const y=x[b.toolCallId]?.response;y&&e(b,y)}},h=x=>t.find(b=>!x[b.toolCallId]?.response&&b.toolCallId!==s)??null,m=()=>{const x=o.getValues();if(t.every(y=>!!x[y.toolCallId]?.response))o.handleSubmit(u)();else{const y=h(x);y&&i(y.toolCallId)}},f=()=>{o.setValue(`${s}.response`,"user has skip this question"),m()},p=()=>{if(l>0){const x=t[l-1];x&&i(x.toolCallId)}},g=()=>{if(l<t.length-1){const x=t[l+1];x&&i(x.toolCallId)}},_=r.jsxs(r.Fragment,{children:[r.jsx(oe,{type:"button",variant:"outline",size:"sm",onClick:f,className:"h-7",children:"Skip"}),r.jsx(oe,{type:"button",size:"sm",disabled:!c,onClick:m,className:Y("h-7",c?"":"opacity-50"),children:d?"Submit":"Next"})]}),v=r.jsx(ku,{current:l,total:t.length,onPrev:p,onNext:g});if(t.length===1){const x=t[0];return x?.input?r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(On,{title:x.input?.prompt??"Question",footerRight:_,children:r.jsx(Ec,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})})}):null}return r.jsx(Pi,{...o,children:r.jsx("form",{onSubmit:o.handleSubmit(u),autoComplete:"off",children:r.jsx(Mh,{value:s,onValueChange:i,children:t.map(x=>r.jsx(yn,{value:x.toolCallId,className:"mt-0",children:r.jsx(On,{title:x.input?.prompt??"Question",footerLeft:v,footerRight:_,children:r.jsx(Ec,{input:x.input,control:o.control,name:`${x.toolCallId}.response`})})},x.toolCallId))})})})}function jx(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.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:[r.jsx(Pg,{className:"size-5 text-muted-foreground shimmer"}),r.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function Au(t){const e=B.c(6),{userAskParts:s,isStreaming:i,onSubmit:n}=t;let o;e[0]!==s?(o=s.filter(kx),e[0]=s,e[1]=o):o=e[1];const a=o;if(i){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(jx,{}),e[2]=c):c=e[2],c}if(a.length===0)return null;let l;return e[3]!==n||e[4]!==a?(l=r.jsx(Cx,{parts:a,onSubmit:n}),e[3]=n,e[4]=a,e[5]=l):l=e[5],l}function kx(t){return t.state==="input-available"}const Ic=new Map;function ho(){const{org:t}=be(),e=Me({connectionId:Wt,orgId:t.id}),s=yl(),i=s.find(_=>_.providerId==="deco"),{data:n,isLoading:o,refetch:a,isFetching:l}=Fi({queryKey:lt.aiProviderCredits(t.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{const _=await e.callTool({name:"AI_PROVIDER_CREDITS",arguments:{providerId:"deco"}});return _?.isError?null:_.structuredContent??null}}),c=n?.balanceCents??null,d=c!=null?c/100:null,u=S.useRef(new Map);if(c!=null){const _=Ic.get(t.id);u.current.get(t.id)&&_!=null&&c>_&&se("credits_topped_up_detected",{organization_id:t.id,delta_cents:c-_,previous_balance_cents:_,new_balance_cents:c}),Ic.set(t.id,c),u.current.set(t.id,!0)}const h=!!i,m=c!=null&&c>0,f=c!=null&&c===0,p=c!=null&&c===200,g=s.length>0&&s.every(_=>_.providerId==="deco");return{hasDecoKey:h,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:m,isZeroBalance:f,isInitialFreeCredit:p,hasOnlyDecoProvider:g,isLoading:o,isFetching:l,refetch:a}}function Nx(t){return t?t.message.startsWith("[CREDITS]"):!1}const Ax={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"}]},Ex=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function Eu(t){const e=B.c(43),{onDismiss:s}=t,{org:i}=be(),n=Ke(),{decoKeyId:o}=ho();let a;e[0]!==i.id?(a={connectionId:Wt,orgId:i.id},e[0]=i.id,e[1]=a):a=e[1];const l=Me(a),[c,d]=S.useState(""),[u,h]=S.useState(!1),[m,f]=S.useState("usd"),p=m==="brl"?"R$":"$";let g,_;e[2]!==i.id?(g=()=>{se("credits_exhausted_shown",{organization_id:i.id})},_=[i.id],e[2]=i.id,e[3]=g,e[4]=_):(g=e[3],_=e[4]),S.useEffect(g,_);let v;e[5]!==l||e[6]!==m?(v=async D=>{const P=await l.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:D,currency:m}});if(P?.isError)throw new Error(P.content?.[0]?.text??"Failed to get top-up URL");return P.structuredContent?.url},e[5]=l,e[6]=m,e[7]=v):v=e[7];let x;e[8]!==s?(x=D=>{D&&window.open(D,"_blank","noopener,noreferrer"),s?.()},e[8]=s,e[9]=x):x=e[9];let b;e[10]!==v||e[11]!==x?(b={mutationFn:v,onSuccess:x,onError:Tx},e[10]=v,e[11]=x,e[12]=b):b=e[12];const{mutate:y,isPending:C}=Br(b),j=parseFloat(c),w=!isNaN(j)&&j>=1;let V;e[13]!==s?(V=D=>!D&&s?.(),e[13]=s,e[14]=V):V=e[14];let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=["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[15]=k):k=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:k.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[16]=R):R=e[16];let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[R,r.jsxs(_s,{className:"relative gap-4",children:[r.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"}),r.jsxs("div",{children:[r.jsx(gs,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),r.jsx(so,{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[17]=T):T=e[17];let E;e[18]!==m||e[19]!==p||e[20]!==c||e[21]!==j||e[22]!==o||e[23]!==w||e[24]!==C||e[25]!==u||e[26]!==y?(E=o&&r.jsxs("div",{className:"px-8 pt-5 pb-6",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(tu,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:D=>{D&&f(D)},children:[r.jsx(Ln,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Ln,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsxs("div",{className:"rounded-xl border border-border p-5",children:[r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Ax[m].map(D=>{const{dollars:P,label:O}=D;return r.jsxs("button",{type:"button",disabled:C,onClick:()=>{se("credits_topup_clicked",{amount_cents:P*100,currency:m,tier_label:O,source:"exhausted_banner"}),y(P*100)},className:Y("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:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,P]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:O})]},P)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(bt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:D=>d(D.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(oe,{className:"h-10",disabled:!w||C,onClick:()=>{se("credits_topup_clicked",{amount_cents:Math.round(j*100),currency:m,tier_label:"custom",source:"exhausted_banner"}),y(Math.round(j*100))},children:C?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),r.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:Ex.map(Ix)})]}),e[18]=m,e[19]=p,e[20]=c,e[21]=j,e[22]=o,e[23]=w,e[24]=C,e[25]=u,e[26]=y,e[27]=E):E=e[27];let N;e[28]!==s?(N=r.jsx(oe,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[28]=s,e[29]=N):N=e[29];let A;e[30]!==n||e[31]!==s||e[32]!==i.slug?(A=r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{n({to:"/$org/settings/ai-providers",params:{org:i.slug}}),s?.()},children:"Manage providers"}),e[30]=n,e[31]=s,e[32]=i.slug,e[33]=A):A=e[33];let I;e[34]!==N||e[35]!==A?(I=r.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[N,A]}),e[34]=N,e[35]=A,e[36]=I):I=e[36];let M;e[37]!==E||e[38]!==I?(M=r.jsxs(ls,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Rx,children:[T,E,I]}),e[37]=E,e[38]=I,e[39]=M):M=e[39];let L;return e[40]!==M||e[41]!==V?(L=r.jsx(cs,{open:!0,onOpenChange:V,children:M}),e[40]=M,e[41]=V,e[42]=L):L=e[42],L}function Ix(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:r.jsx(Jt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Rx(t){return t.preventDefault()}function Tx(t){pe.error(`Top-up failed: ${t.message}`)}const Dx={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 $n(t){const e=B.c(32),{variant:s,onDismiss:i}=t,n=s==="error",o=n?"Error occurred":"Response incomplete",a=n?t.error.message:Dx[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`,l=n?"border-destructive/30 bg-destructive/5":"border-amber-500/30 bg-amber-500/5",c=n?"text-destructive":"text-amber-600 dark:text-amber-500",d=n?ni:ol;let u;e[0]!==l?(u=Y("flex items-start gap-2 px-3 py-2.5 rounded-lg border border-dashed text-sm w-full mb-2 shadow",l),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==c?(h=Y("mt-0.5 shrink-0",c),e[2]=c,e[3]=h):h=e[3];let m;e[4]!==d?(m=r.jsx(d,{size:16}),e[4]=d,e[5]=m):m=e[5];let f;e[6]!==h||e[7]!==m?(f=r.jsx("div",{className:h,children:m}),e[6]=h,e[7]=m,e[8]=f):f=e[8];let p;e[9]!==c?(p=Y("text-xs mb-1 font-medium",c),e[9]=c,e[10]=p):p=e[10];let g;e[11]!==p||e[12]!==o?(g=r.jsx("div",{className:p,children:o}),e[11]=p,e[12]=o,e[13]=g):g=e[13];let _;e[14]!==a?(_=r.jsx("div",{className:"text-xs line-clamp-2 text-muted-foreground mb-2",children:a}),e[14]=a,e[15]=_):_=e[15];let v;e[16]!==n||e[17]!==t.onContinue||e[18]!==t.onFixInChat?(v=r.jsx("div",{className:"flex gap-2",children:n?r.jsxs(r.Fragment,{children:[r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}),r.jsx(oe,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}):r.jsx(oe,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"})}),e[16]=n,e[17]=t.onContinue,e[18]=t.onFixInChat,e[19]=v):v=e[19];let x;e[20]!==g||e[21]!==_||e[22]!==v?(x=r.jsxs("div",{className:"flex-1 min-w-0",children:[g,_,v]}),e[20]=g,e[21]=_,e[22]=v,e[23]=x):x=e[23];let b;e[24]===Symbol.for("react.memo_cache_sentinel")?(b=r.jsx(Xs,{size:14}),e[24]=b):b=e[24];let y;e[25]!==i?(y=r.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Dismiss",children:b}),e[25]=i,e[26]=y):y=e[26];let C;return e[27]!==u||e[28]!==y||e[29]!==f||e[30]!==x?(C=r.jsx("div",{className:"px-0.5",children:r.jsxs("div",{className:u,children:[f,x,y]})}),e[27]=u,e[28]=y,e[29]=f,e[30]=x,e[31]=C):C=e[31],C}function uo(){const t=B.c(41),{error:e,clearError:s,finishReason:i,clearFinishReason:n,messages:o,isStreaming:a,isWaitingForApprovals:l,addToolOutput:c,addToolApprovalResponse:d,sendMessage:u}=Ui(),[h,m]=Wi(),{virtualMcpId:f,createTaskWithMessage:p}=es();let g,_,v,x;if(t[0]!==o){const I=o.at(-1);x=I?.role==="assistant"?I.parts.filter(Lx):null,g=x?.filter(Px)?.length,_=I?.role==="assistant"?_x(I.parts):[],v=I?.role==="assistant"?fx(I.parts):[],t[0]=o,t[1]=g,t[2]=_,t[3]=v,t[4]=x}else g=t[1],_=t[2],v=t[3],x=t[4];const b=v;let y;t[5]!==e||t[6]!==u?(y=()=>{if(e){const M={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};u(M)}},t[5]=e,t[6]=u,t[7]=y):y=t[7];const C=y;let j;t[8]!==u?(j=()=>{u({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[8]=u,t[9]=j):j=t[9];const w=j;let V;t[10]!==c?(V=(I,M)=>{c({tool:"user_ask",toolCallId:I.toolCallId,output:{response:M}})},t[10]=c,t[11]=V):V=t[11];const k=V;let R;t[12]!==p||t[13]!==h||t[14]!==m||t[15]!==f?(R=I=>{m({...h,toolApprovalLevel:"auto"}),p({virtualMcpId:f,message:{parts:[{type:"text",text:`Implement this plan:
3
3
 
4
4
  ${I}`}]}})},t[12]=p,t[13]=h,t[14]=m,t[15]=f,t[16]=R):R=t[16];const T=R,E=Mx;let N;t[17]!==d?(N=(I,M,L)=>{d({id:I,approved:M,...L?{reason:L}:{}})},t[17]=d,t[18]=N):N=t[18];const A=N;if(g){let I;return t[19]!==k||t[20]!==a||t[21]!==x?(I=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(Au,{userAskParts:x,isStreaming:a,onSubmit:k})}),t[19]=k,t[20]=a,t[21]=x,t[22]=I):I=t[22],I}if(_.length>0){let I;return t[23]!==T||t[24]!==a||t[25]!==_?(I=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(gx,{plans:_,isStreaming:a,onApprove:T,onDismiss:E})}),t[23]=T,t[24]=a,t[25]=_,t[26]=I):I=t[26],I}if(b.length>0||a&&l){let I;return t[27]!==A||t[28]!==a||t[29]!==b?(I=r.jsx("div",{className:"absolute bottom-full left-0 right-0",children:r.jsx(ux,{approvals:b,isStreaming:a,onRespond:A})}),t[27]=A,t[28]=a,t[29]=b,t[30]=I):I=t[30],I}if(!a&&e){if(Nx(e)){let M;return t[31]!==s?(M=r.jsx(Eu,{onDismiss:s}),t[31]=s,t[32]=M):M=t[32],M}let I;return t[33]!==s||t[34]!==e||t[35]!==C?(I=r.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:r.jsx($n,{variant:"error",error:e,onDismiss:s,onFixInChat:C})}),t[33]=s,t[34]=e,t[35]=C,t[36]=I):I=t[36],I}if(!a&&i&&i!=="stop"&&!l){let I;return t[37]!==n||t[38]!==i||t[39]!==w?(I=r.jsx("div",{className:"absolute bottom-full left-0 right-0 bg-background",children:r.jsx($n,{variant:"warning",finishReason:i,onDismiss:n,onContinue:w})}),t[37]=n,t[38]=i,t[39]=w,t[40]=I):I=t[40],I}return null}function Mx(){document.querySelector("[data-chat-input]")?.focus()}function Px(t){return t.state!=="output-available"}function Lx(t){return t.type==="tool-user_ask"}uo.Error=function(e){return r.jsx($n,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};uo.Warning=function(e){return r.jsx($n,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};uo.UserAskQuestion=Au;async function Dl(t,e,s,i,n){if(!oo(e)){pe.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Fg(o,e)){const l=iu(e),c=e?.title??"This model";n?n({fileName:s.name,modelName:c,accepted:l}):pe.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}. PowerPoint, Word, and Excel files aren't supported yet.`});return}const a=10*1024*1024;if(s.size>a){pe.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((h,m)=>{l.onload=()=>{const f=l.result;if(typeof f!="string"){m(new Error("Failed to read file as data URL"));return}const p=f.includes(",")?f.split(",")[1]??f:f;h(p)},l.onerror=m});l.readAsDataURL(s);const d=await c,u={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};Lp(t,{from:i,to:i},u)}catch(l){console.error("Failed to process file:",l),pe.error(`Failed to load file "${s.name}"`)}}function Bx(t){const e=B.c(8),{editor:s,selectedModel:i,onUnsupportedFile:n}=t,o=S.useRef($x);let a,l;e[0]!==s||e[1]!==n||e[2]!==i?(a=()=>{o.current=async(u,h)=>{await Dl(s,i,u,h,n)}},l=[s,i,n],e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=l):(a=e[3],l=e[4]),S.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const u=new oa("fileDropHandler");s.state.plugins.find(f=>f.spec.key===u)&&s.unregisterPlugin(u);const m=new eg({key:u,props:{handleDrop:(f,p,g,_)=>{if(_)return!1;const v=p.dataTransfer?.files;if(!v||v.length===0)return!1;p.preventDefault();const x=f.posAtCoords({left:p.clientX,top:p.clientY});if(!x)return!1;const b=Array.from(v),y=x.pos;for(const C of b)o.current?.(C,y);return!0},handlePaste:(f,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const _=Array.from(g).filter(Ox);if(_.length===0)return!1;p.preventDefault();const{from:v}=f.state.selection;for(const x of _){const b=x.getAsFile();b&&o.current?.(b,v)}return!0}}});return s.registerPlugin(m),()=>{s?.isDestroyed||s.unregisterPlugin(u)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),S.useEffect(c,d),null}function Ox(t){return t.kind==="file"}function $x(){return Promise.resolve()}function zx(t){const e=B.c(24),{selectedModel:s,isStreaming:i,icon:n,onUnsupportedFile:o}=t,{editor:a}=to(),l=S.useRef(null);let c;e[0]!==s?(c=oo(s),e[0]=s,e[1]=c):c=e[1];const d=c;let u;e[2]!==a||e[3]!==o||e[4]!==s?(u=async C=>{const j=C.target.files;if(!j||j.length===0||!a)return;const w=Array.from(j),{from:V}=a.state.selection,k=V;for(const R of w)await Dl(a,s,R,k,o);l.current&&(l.current.value="")},e[2]=a,e[3]=o,e[4]=s,e[5]=u):u=e[5];const h=u;if(!a||!d)return null;let m;e[6]!==s?(m=zg(s),e[6]=s,e[7]=m):m=e[7];let f;e[8]!==h||e[9]!==i||e[10]!==m?(f=r.jsx("input",{ref:l,type:"file",multiple:!0,accept:m,className:"hidden",onChange:h,disabled:i}),e[8]=h,e[9]=i,e[10]=m,e[11]=f):f=e[11];const p=i||!d;let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=()=>l.current?.click(),e[12]=g):g=e[12];let _;e[13]!==n?(_=n??r.jsx(zh,{size:16}),e[13]=n,e[14]=_):_=e[14];let v;e[15]!==p||e[16]!==_?(v=r.jsx(tt,{asChild:!0,children:r.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"text-muted-foreground/75",disabled:p,onClick:g,children:_})}),e[15]=p,e[16]=_,e[17]=v):v=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(st,{side:"top",children:"Add file"}),e[18]=x):x=e[18];let b;e[19]!==v?(b=r.jsxs(it,{children:[v,x]}),e[19]=v,e[20]=b):b=e[20];let y;return e[21]!==b||e[22]!==f?(y=r.jsxs(r.Fragment,{children:[f,b]}),e[21]=b,e[22]=f,e[23]=y):y=e[23],y}const Fx=["PowerPoint (.pptx)","Word documents (.docx)","Excel spreadsheets (.xlsx)"];function Hx(t){const e=B.c(29),{info:s,onClose:i}=t,n=s!==null;let o;e[0]!==i?(o=w=>!w&&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 l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=r.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]=l):l=e[3];let c,d;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:r.jsx(ol,{size:18})}),d=r.jsx(gs,{className:"text-xl font-semibold tracking-tight",children:"File type not supported"}),e[4]=c,e[5]=d):(c=e[4],d=e[5]);const u=s?.fileName;let h;e[6]!==u?(h=r.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,r.jsxs(_s,{className:"relative gap-4",children:[c,r.jsxs("div",{children:[d,r.jsxs(so,{className:"mt-1.5 text-sm leading-relaxed",children:[r.jsxs("span",{className:"font-medium text-foreground",children:["“",u,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=u,e[7]=h):h=e[7];const m=s?.modelName;let f;e[8]!==m?(f=r.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[m," accepts"]}),e[8]=m,e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(zh,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let _;e[11]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,r.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=_):_=e[12];let v;e[13]!==f||e[14]!==_?(v=r.jsxs("div",{className:"rounded-xl border border-border p-4",children:[f,_]}),e[13]=f,e[14]=_,e[15]=v):v=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsxs("div",{className:"rounded-xl bg-muted/25 border border-border/50 p-4 space-y-2",children:[r.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Not supported yet"}),Fx.map(Wx)]}),e[16]=x):x=e[16];let b;e[17]!==v?(b=r.jsxs("div",{className:"px-8 pt-3 pb-6 space-y-3",children:[v,x]}),e[17]=v,e[18]=b):b=e[18];let y;e[19]!==i?(y=r.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:r.jsx(oe,{onClick:i,children:"Got it"})}),e[19]=i,e[20]=y):y=e[20];let C;e[21]!==b||e[22]!==y||e[23]!==h?(C=r.jsxs(ls,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Ux,children:[h,b,y]}),e[21]=b,e[22]=y,e[23]=h,e[24]=C):C=e[24];let j;return e[25]!==n||e[26]!==C||e[27]!==o?(j=r.jsx(cs,{open:n,onOpenChange:o,children:C}),e[25]=n,e[26]=C,e[27]=o,e[28]=j):j=e[28],j}function Wx(t){return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-muted shrink-0",children:r.jsx(Xs,{size:10,className:"text-muted-foreground"})}),r.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function Ux(t){return t.preventDefault()}function Kx(){const t=B.c(3),[e,s]=S.useState(null);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>s(null),t[0]=i):i=t[0];let n;return t[1]!==e?(n={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:i},t[1]=e,t[2]=n):n=t[2],n}var qx=tg;var Gx=["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] *)"],fa=Gx.join(","),Iu=typeof Element>"u",Nr=Iu?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,zn=!Iu&&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},Fn=function(e,s){var i;s===void 0&&(s=!0);var n=e==null||(i=e.getAttribute)===null||i===void 0?void 0:i.call(e,"inert"),o=n===""||n==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):Fn(e.parentNode));return a},Yx=function(e){var s,i=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return i===""||i==="true"},Xx=function(e,s,i){if(Fn(e))return[];var n=Array.prototype.slice.apply(e.querySelectorAll(fa));return s&&Nr.call(e,fa)&&n.unshift(e),n=n.filter(i),n},ma=function(e,s,i){for(var n=[],o=Array.from(e);o.length;){var a=o.shift();if(!Fn(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=ma(c,!0,i);i.flatten?n.push.apply(n,d):n.push({scopeParent:a,candidates:d})}else{var u=Nr.call(a,fa);u&&i.filter(a)&&(s||!e.includes(a))&&n.push(a);var h=a.shadowRoot||typeof i.getShadowRoot=="function"&&i.getShadowRoot(a),m=!Fn(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(h&&m){var f=ma(h===!0?a.children:h.children,!0,i);i.flatten?n.push.apply(n,f):n.push({scopeParent:a,candidates:f})}else o.unshift.apply(o,a.children)}}return n},Ru=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},Tu=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Yx(e))&&!Ru(e)?0:e.tabIndex},Jx=function(e,s){var i=Tu(e);return i<0&&s&&!Ru(e)?0:i},Qx=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},Du=function(e){return e.tagName==="INPUT"},Zx=function(e){return Du(e)&&e.type==="hidden"},e1=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(i){return i.tagName==="SUMMARY"});return s},t1=function(e,s){for(var i=0;i<e.length;i++)if(e[i].checked&&e[i].form===s)return e[i]},s1=function(e){if(!e.name)return!0;var s=e.form||zn(e),i=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},n;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")n=i(window.CSS.escape(e.name));else try{n=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=t1(n,e.form);return!o||o===e},i1=function(e){return Du(e)&&e.type==="radio"},r1=function(e){return i1(e)&&!s1(e)},n1=function(e){var s,i=e&&zn(e),n=(s=i)===null||s===void 0?void 0:s.host,o=!1;if(i&&i!==e){var a,l,c;for(o=!!((a=n)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(n)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&n;){var d,u,h;i=zn(n),n=(d=i)===null||d===void 0?void 0:d.host,o=!!((u=n)!==null&&u!==void 0&&(h=u.ownerDocument)!==null&&h!==void 0&&h.contains(n))}}return o},Rc=function(e){var s=e.getBoundingClientRect(),i=s.width,n=s.height;return i===0&&n===0},o1=function(e,s){var i=s.displayCheck,n=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=Nr.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(Nr.call(l,"details:not([open]) *"))return!0;if(!i||i==="full"||i==="full-native"||i==="legacy-full"){if(typeof n=="function"){for(var c=e;e;){var d=e.parentElement,u=zn(e);if(d&&!d.shadowRoot&&n(d)===!0)return Rc(e);e.assignedSlot?e=e.assignedSlot:!d&&u!==e.ownerDocument?e=u.host:e=d}e=c}if(n1(e))return!e.getClientRects().length;if(i!=="legacy-full")return!0}else if(i==="non-zero-area")return Rc(e);return!1},a1=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 n=s.children.item(i);if(n.tagName==="LEGEND")return Nr.call(s,"fieldset[disabled] *")?!0:!n.contains(e)}return!0}s=s.parentElement}return!1},l1=function(e,s){return!(s.disabled||Zx(s)||o1(s,e)||e1(s)||a1(s))},Tc=function(e,s){return!(r1(s)||Tu(s)<0||!l1(e,s))},c1=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},Mu=function(e){var s=[],i=[];return e.forEach(function(n,o){var a=!!n.scopeParent,l=a?n.scopeParent:n,c=Jx(l,a),d=a?Mu(n.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):i.push({documentOrder:o,tabIndex:c,item:n,isScope:a,content:d})}),i.sort(Qx).reduce(function(n,o){return o.isScope?n.push.apply(n,o.content):n.push(o.content),n},[]).concat(s)},Pu=function(e,s){s=s||{};var i;return s.getShadowRoot?i=ma([e],s.includeContainer,{filter:Tc.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:c1}):i=Xx(e,s.includeContainer,Tc.bind(null,s)),Mu(i)};function d1(){return/apple/i.test(navigator.vendor)}const Dc="data-floating-ui-focusable";function h1(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 pa(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&Hm(s)){let i=e;for(;i;){if(t===i)return!0;i=i.parentNode||i.host}}return!1}function er(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Ao(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 u1(t){return t.matches("html,body")}function Ar(t){return t?.ownerDocument||document}function f1(t){return t?t.hasAttribute(Dc)?t:t.querySelector("["+Dc+"]")||t:null}function jn(t,e,s){return s===void 0&&(s=!0),t.filter(n=>{var o;return n.parentId===e&&(!s||((o=n.context)==null?void 0:o.open))}).flatMap(n=>[n,...jn(t,n.id,s)])}function m1(t){return"nativeEvent"in t}var p1=typeof document<"u",g1=function(){},pi=p1?S.useLayoutEffect:g1;const _1={...Sh},x1=_1.useInsertionEffect,v1=x1||(t=>t());function Ei(t){const e=S.useRef(()=>{});return v1(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}const Lu=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Bu(t,e){const s=Pu(t,Lu()),i=s.length;if(i===0)return;const n=h1(Ar(t)),o=s.indexOf(n),a=o===-1?e===1?0:i-1:o+e;return s[a]}function b1(t){return Bu(Ar(t).body,1)||t}function y1(t){return Bu(Ar(t).body,-1)||t}function Eo(t,e){const s=e||t.currentTarget,i=t.relatedTarget;return!i||!pa(s,i)}function S1(t){Pu(t,Lu()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function Mc(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 w1="data-floating-ui-focusable",Pc="active",Lc="selected",V1={...Sh};let Bc=!1,C1=0;const Oc=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+C1++;function j1(){const[t,e]=S.useState(()=>Bc?Oc():void 0);return pi(()=>{t==null&&e(Oc())},[]),S.useEffect(()=>{Bc=!0},[]),t}const k1=V1.useId,Ml=k1||j1;function N1(){const t=new Map;return{emit(e,s){var i;(i=t.get(e))==null||i.forEach(n=>n(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 A1=S.createContext(null),E1=S.createContext(null),Ou=()=>{var t;return((t=S.useContext(A1))==null?void 0:t.id)||null},$u=()=>S.useContext(E1);function Pl(t){return"data-floating-ui-"+t}const I1={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},$c=S.forwardRef(function(e,s){const[i,n]=S.useState();pi(()=>{d1()&&n("button")},[]);const o={ref:s,tabIndex:0,role:i,"aria-hidden":i?void 0:!0,[Pl("focus-guard")]:"",style:I1};return r.jsx("span",{...e,...o})}),R1={clipPath:"inset(50%)",position:"fixed",top:0,left:0},zu=S.createContext(null),zc=Pl("portal");function T1(t){t===void 0&&(t={});const{id:e,root:s}=t,i=Ml(),n=M1(),[o,a]=S.useState(null),l=S.useRef(null);return pi(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),pi(()=>{if(!i||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=i,d.setAttribute(zc,""),c.appendChild(d),l.current=d,a(d)},[e,i]),pi(()=>{if(s===null||!i||l.current)return;let c=s||n?.portalNode;c&&!Ym(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const u=document.createElement("div");u.id=i,u.setAttribute(zc,""),c=d||c,c.appendChild(u),l.current=u,a(u)},[e,s,i,n]),o}function D1(t){const{children:e,id:s,root:i,preserveTabOrder:n=!0}=t,o=T1({id:s,root:i}),[a,l]=S.useState(null),c=S.useRef(null),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),m=a?.modal,f=a?.open,p=!!a&&!a.modal&&a.open&&n&&!!(i||o);return S.useEffect(()=>{if(!o||!n||m)return;function g(_){o&&Eo(_)&&(_.type==="focusin"?Mc:S1)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,n,m]),S.useEffect(()=>{o&&(f||Mc(o))},[f,o]),r.jsxs(zu.Provider,{value:S.useMemo(()=>({preserveTabOrder:n,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:u,afterInsideRef:h,portalNode:o,setFocusManagerState:l}),[n,o]),children:[p&&o&&r.jsx($c,{"data-type":"outside",ref:c,onFocus:g=>{if(Eo(g,o)){var _;(_=u.current)==null||_.focus()}else{const v=a?a.domReference:null,x=y1(v);x?.focus()}}}),p&&o&&r.jsx("span",{"aria-owns":o.id,style:R1}),o&&us.createPortal(e,o),p&&o&&r.jsx($c,{"data-type":"outside",ref:d,onFocus:g=>{if(Eo(g,o)){var _;(_=h.current)==null||_.focus()}else{const v=a?a.domReference:null,x=b1(v);x?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const M1=()=>S.useContext(zu),P1={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},L1={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Fc=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 B1(t,e){e===void 0&&(e={});const{open:s,onOpenChange:i,elements:n,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:u=!1,referencePressEvent:h="pointerdown",ancestorScroll:m=!1,bubbles:f,capture:p}=e,g=$u(),_=Ei(typeof c=="function"?c:()=>!1),v=typeof c=="function"?_:c,x=S.useRef(!1),{escapeKey:b,outsidePress:y}=Fc(f),{escapeKey:C,outsidePress:j}=Fc(p),w=S.useRef(!1),V=Ei(A=>{var I;if(!s||!a||!l||A.key!=="Escape"||w.current)return;const M=(I=o.current.floatingContext)==null?void 0:I.nodeId,L=g?jn(g.nodesRef.current,M):[];if(!b&&(A.stopPropagation(),L.length>0)){let D=!0;if(L.forEach(P=>{var O;if((O=P.context)!=null&&O.open&&!P.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}i(!1,m1(A)?A.nativeEvent:A,"escape-key")}),k=Ei(A=>{var I;const M=()=>{var L;V(A),(L=er(A))==null||L.removeEventListener("keydown",M)};(I=er(A))==null||I.addEventListener("keydown",M)}),R=Ei(A=>{var I;const M=o.current.insideReactTree;o.current.insideReactTree=!1;const L=x.current;if(x.current=!1,d==="click"&&L||M||typeof v=="function"&&!v(A))return;const D=er(A),P="["+Pl("inert")+"]",O=Ar(n.floating).querySelectorAll(P);let z=ws(D)?D:null;for(;z&&!Vo(z);){const G=Km(z);if(Vo(G)||!ws(G))break;z=G}if(O.length&&ws(D)&&!u1(D)&&!pa(D,n.floating)&&Array.from(O).every(G=>!pa(z,G)))return;if(qm(D)&&N){const G=Vo(D),W=Gm(D),H=/auto|scroll/,Z=G||H.test(W.overflowX),q=G||H.test(W.overflowY),K=Z&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,te=q&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,ee=W.direction==="rtl",X=te&&(ee?A.offsetX<=D.offsetWidth-D.clientWidth:A.offsetX>D.clientWidth),ie=K&&A.offsetY>D.clientHeight;if(X||ie)return}const $=(I=o.current.floatingContext)==null?void 0:I.nodeId,U=g&&jn(g.nodesRef.current,$).some(G=>{var W;return Ao(A,(W=G.context)==null?void 0:W.elements.floating)});if(Ao(A,n.floating)||Ao(A,n.domReference)||U)return;const F=g?jn(g.nodesRef.current,$):[];if(F.length>0){let G=!0;if(F.forEach(W=>{var H;if((H=W.context)!=null&&H.open&&!W.context.dataRef.current.__outsidePressBubbles){G=!1;return}}),!G)return}i(!1,A,"outside-press")}),T=Ei(A=>{var I;const M=()=>{var L;R(A),(L=er(A))==null||L.removeEventListener(d,M)};(I=er(A))==null||I.addEventListener(d,M)});S.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let A=-1;function I(O){i(!1,O,"ancestor-scroll")}function M(){window.clearTimeout(A),w.current=!0}function L(){A=window.setTimeout(()=>{w.current=!1},Um()?5:0)}const D=Ar(n.floating);l&&(D.addEventListener("keydown",C?k:V,C),D.addEventListener("compositionstart",M),D.addEventListener("compositionend",L)),v&&D.addEventListener(d,j?T:R,j);let P=[];return m&&(ws(n.domReference)&&(P=wo(n.domReference)),ws(n.floating)&&(P=P.concat(wo(n.floating))),!ws(n.reference)&&n.reference&&n.reference.contextElement&&(P=P.concat(wo(n.reference.contextElement)))),P=P.filter(O=>{var z;return O!==((z=D.defaultView)==null?void 0:z.visualViewport)}),P.forEach(O=>{O.addEventListener("scroll",I,{passive:!0})}),()=>{l&&(D.removeEventListener("keydown",C?k:V,C),D.removeEventListener("compositionstart",M),D.removeEventListener("compositionend",L)),v&&D.removeEventListener(d,j?T:R,j),P.forEach(O=>{O.removeEventListener("scroll",I)}),window.clearTimeout(A)}},[o,n,l,v,d,s,i,m,a,b,y,V,C,k,R,j,T]),S.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const E=S.useMemo(()=>({onKeyDown:V,...u&&{[P1[h]]:A=>{i(!1,A.nativeEvent,"reference-press")},...h!=="click"&&{onClick(A){i(!1,A.nativeEvent,"reference-press")}}}}),[V,i,u,h]),N=S.useMemo(()=>{function A(I){I.button===0&&(x.current=!0)}return{onKeyDown:V,onMouseDown:A,onMouseUp:A,[L1[d]]:()=>{o.current.insideReactTree=!0}}},[V,d,o]);return S.useMemo(()=>a?{reference:E,floating:N}:{},[a,E,N])}function O1(t){const{open:e=!1,onOpenChange:s,elements:i}=t,n=Ml(),o=S.useRef({}),[a]=S.useState(()=>N1()),l=Ou()!=null,[c,d]=S.useState(i.reference),u=Ei((f,p,g)=>{o.current.openEvent=f?p:void 0,a.emit("openchange",{open:f,event:p,reason:g,nested:l}),s?.(f,p,g)}),h=S.useMemo(()=>({setPositionReference:d}),[]),m=S.useMemo(()=>({reference:c||i.reference||null,floating:i.floating||null,domReference:i.reference}),[c,i.reference,i.floating]);return S.useMemo(()=>({dataRef:o,open:e,onOpenChange:u,elements:m,events:a,floatingId:n,refs:h}),[e,u,m,a,n,h])}function $1(t){t===void 0&&(t={});const{nodeId:e}=t,s=O1({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||s,n=i.elements,[o,a]=S.useState(null),[l,c]=S.useState(null),u=n?.domReference||o,h=S.useRef(null),m=$u();pi(()=>{u&&(h.current=u)},[u]);const f=Wm({...t,elements:{...n,...l&&{reference:l}}}),p=S.useCallback(b=>{const y=ws(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),f.refs.setReference(y)},[f.refs]),g=S.useCallback(b=>{(ws(b)||b===null)&&(h.current=b,a(b)),(ws(f.refs.reference.current)||f.refs.reference.current===null||b!==null&&!ws(b))&&f.refs.setReference(b)},[f.refs]),_=S.useMemo(()=>({...f.refs,setReference:g,setPositionReference:p,domReference:h}),[f.refs,g,p]),v=S.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),x=S.useMemo(()=>({...f,...i,refs:_,elements:v,nodeId:e}),[f,_,v,e,i]);return pi(()=>{i.dataRef.current.floatingContext=x;const b=m?.nodesRef.current.find(y=>y.id===e);b&&(b.context=x)}),S.useMemo(()=>({...f,context:x,refs:_,elements:v}),[f,_,v,x])}function Io(t,e,s){const i=new Map,n=s==="item";let o=t;if(n&&t){const{[Pc]:a,[Lc]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[w1]:""},...o,...e.map(a=>{const l=a?a[s]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((a,l)=>(l&&Object.entries(l).forEach(c=>{let[d,u]=c;if(!(n&&[Pc,Lc].includes(d)))if(d.indexOf("on")===0){if(i.has(d)||i.set(d,[]),typeof u=="function"){var h;(h=i.get(d))==null||h.push(u),a[d]=function(){for(var m,f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return(m=i.get(d))==null?void 0:m.map(_=>_(...p)).find(_=>_!==void 0)}}}else a[d]=u}),a),{})}}function z1(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),i=t.map(l=>l?.item),n=S.useCallback(l=>Io(l,t,"reference"),e),o=S.useCallback(l=>Io(l,t,"floating"),s),a=S.useCallback(l=>Io(l,t,"item"),i);return S.useMemo(()=>({getReferenceProps:n,getFloatingProps:o,getItemProps:a}),[n,o,a])}const F1=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function H1(t,e){var s,i;e===void 0&&(e={});const{open:n,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=Ml(),u=((s=o.domReference)==null?void 0:s.id)||d,h=S.useMemo(()=>{var x;return((x=f1(o.floating))==null?void 0:x.id)||a},[o.floating,a]),m=(i=F1.get(c))!=null?i:c,p=Ou()!=null,g=S.useMemo(()=>m==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:n?h:void 0}:{"aria-expanded":n?"true":"false","aria-haspopup":m==="alertdialog"?"dialog":m,"aria-controls":n?h:void 0,...m==="listbox"&&{role:"combobox"},...m==="menu"&&{id:u},...m==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[m,h,p,n,u,c]),_=S.useMemo(()=>{const x={id:h,...m&&{role:m}};return m==="tooltip"||c==="label"?x:{...x,...m==="menu"&&{"aria-labelledby":u}}},[m,h,u,c]),v=S.useCallback(x=>{let{active:b,selected:y}=x;const C={role:"option",...b&&{id:h+"-fui-option"}};switch(c){case"select":case"combobox":return{...C,"aria-selected":y}}return{}},[h,c]);return S.useMemo(()=>l?{reference:g,floating:_,item:v}:{},[l,g,_,v])}function W1(t){const e=B.c(26),{editor:s,query:i,items:n,onSelect:o,onClose:a}=t,[l,c]=S.useState(0),d=S.useRef(n),u=S.useRef(l),h=S.useRef(o),m=S.useRef(a),f=S.useDeferredValue(i);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==f?(g=[f],e[1]=f,e[2]=g):g=e[2],S.useEffect(p,g);let _,v;e[3]!==n.length||e[4]!==l?(_=()=>{l>=n.length&&n.length>0&&c(0)},v=[n.length,l],e[3]=n.length,e[4]=l,e[5]=_,e[6]=v):(_=e[5],v=e[6]),S.useEffect(_,v);let x,b;e[7]!==n?(x=()=>{d.current=n},b=[n],e[7]=n,e[8]=x,e[9]=b):(x=e[8],b=e[9]),S.useEffect(x,b);let y,C;e[10]!==l?(y=()=>{u.current=l},C=[l],e[10]=l,e[11]=y,e[12]=C):(y=e[11],C=e[12]),S.useEffect(y,C);let j,w;e[13]!==o?(w=()=>{h.current=o},j=[o],e[13]=o,e[14]=j,e[15]=w):(j=e[14],w=e[15]),S.useEffect(w,j);let V,k;e[16]!==a?(V=()=>{m.current=a},k=[a],e[16]=a,e[17]=V,e[18]=k):(V=e[17],k=e[18]),S.useEffect(V,k);let R;e[19]!==s.isDestroyed||e[20]!==s.view.dom?(R=()=>{const A=s.view.dom;if(s?.isDestroyed||!A)return;const I=L=>{const D=d.current;if(!D.length)return!1;const P=()=>c(z=>(z+1)%D.length),O=()=>c(z=>(z-1+D.length)%D.length);switch(L.key){case"ArrowUp":return L.preventDefault(),O(),!0;case"ArrowDown":return L.preventDefault(),P(),!0;case"Tab":return L.preventDefault(),L.shiftKey?O():P(),!0;case"Home":return L.preventDefault(),c(0),!0;case"End":return L.preventDefault(),c(D.length-1),!0;case"Enter":{if(L.isComposing)return!1;L.preventDefault();const z=u.current;return z!==-1&&D[z]&&h.current?.(D[z],z),!0}case"Escape":return L.preventDefault(),m.current?.(),!0;default:return!1}},M=L=>{I(L)};return A.addEventListener("keydown",M,!0),()=>{A?.removeEventListener("keydown",M,!0)}},e[19]=s.isDestroyed,e[20]=s.view.dom,e[21]=R):R=e[21];let T;e[22]!==s?(T=[s],e[22]=s,e[23]=T):T=e[23],S.useEffect(R,T);const E=n.length?l:void 0;let N;return e[24]!==E?(N={selectedIndex:E,setSelectedIndex:c},e[24]=E,e[25]=N):N=e[25],N}function U1(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 Fu=S.createContext(void 0);function Hu(){const t=S.useContext(Fu);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function K1({editor:t,char:e,pluginKey:s,allow:i,onOpenChange:n}){const[o,a]=S.useReducer(U1,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=S.useRef(n);return l.current=n,S.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof oa?s:new oa(s);t.state.plugins.find(h=>h.spec.key===c)&&t.unregisterPlugin(c);const u=Wg({pluginKey:c,editor:t,char:e,allow(h){const m=t.state.doc.resolve(h.range.from);for(let f=m.depth;f>0;f--)if(m.node(f).type.name==="image")return!1;return!(i&&!i(h))},command(){},render:()=>({onStart:h=>{a({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}}),l.current?.(!0)},onUpdate:h=>{a({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(u),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,i]),{state:o,dispatch:a}}function q1({editor:t,queryKey:e,queryFn:s,onSelect:i}){const{state:n,dispatch:o}=Hu(),a=S.useDeferredValue(n.query),{data:l}=wh({queryKey:lt.suggestionItems(e,n.open,a),queryFn:()=>n.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(h,m)=>{if(!(n.selectedItem!==null||!n.range)){o({type:"SET_SELECTED_ITEM",payload:h});try{const{view:f}=t,g=f.state.selection.$to.nodeAfter?.text?.startsWith(" "),_=n.range?{...n.range}:{from:0,to:0};g&&n.range&&(_.to+=1),await i({range:_,item:h})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:u}=W1({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:n.selectedItem,items:l,selectedIndex:u,close:c,onSelect:d}}function G1({children:t}){const{state:e,dispatch:s}=Hu(),{open:i,element:n}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=$1({placement:"bottom-start",open:i,onOpenChange:m=>{m||o()},elements:{reference:n},middleware:[Xm(10),Jm(),Qm()],whileElementsMounted:Zm}),d=B1(c,{outsidePress:m=>!(m.target instanceof Element&&m.target.closest(".ProseMirror"))}),u=H1(c,{role:"listbox"}),{getFloatingProps:h}=z1([d,u]);return i?r.jsx(D1,{children:r.jsx("div",{ref:a.setFloating,style:l,...h(),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 Y1=t=>{const e=B.c(29),{item:s,isSelected:i,onSelect:n,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const j=ii(s._meta);l=s.title||eo(s.name,j),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,u=s.icon,h=i&&"bg-accent text-accent-foreground",m=o&&"pointer-events-none opacity-50";let f;e[2]!==h||e[3]!==m?(f=Y("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",h,m),e[2]=h,e[3]=m,e[4]=f):f=e[4];let p;e[5]!==u||e[6]!==c?(p=u!==void 0&&r.jsx(zs,{icon:u,name:c,size:"xs",className:"mr-2"}),e[5]=u,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=r.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let _;e[10]!==o?(_=o&&r.jsx(jr,{size:"xs"}),e[10]=o,e[11]=_):_=e[11];let v;e[12]!==g||e[13]!==_?(v=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,_]}),e[12]=g,e[13]=_,e[14]=v):v=e[14];let x;e[15]!==d?(x=d&&r.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=x):x=e[16];let b;e[17]!==v||e[18]!==x?(b=r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,x]}),e[17]=v,e[18]=x,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&r.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]=y):y=e[21];let C;return e[22]!==n||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==f||e[27]!==p?(C=r.jsxs("div",{ref:a,onClick:n,className:f,children:[p,b,y]}),e[22]=n,e[23]=a,e[24]=b,e[25]=y,e[26]=f,e[27]=p,e[28]=C):C=e[28],C},X1=t=>{const e=B.c(18),{editor:s,queryKey:i,queryFn:n,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==n||e[3]!==i?(a={editor:s,queryKey:i,queryFn:n,onSelect:o},e[0]=s,e[1]=o,e[2]=n,e[3]=i,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:u}=q1(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=r.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]=p):p=e[5],p}let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=h):h=e[6];let m;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==u?.name){let p;e[12]!==d||e[13]!==c||e[14]!==u?.name?(p=(g,_)=>r.jsx(Y1,{item:g,isSelected:_===c,ref:_===c?Z1:void 0,onSelect:()=>d(g,_),isLoading:u?.name===g.name},g.name),e[12]=d,e[13]=c,e[14]=u?.name,e[15]=p):p=e[15],m=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=u?.name,e[11]=m}else m=e[11];let f;return e[16]!==m?(f=r.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:h,children:r.jsx("div",{className:"p-1",children:m})}),e[16]=m,e[17]=f):f=e[17],f};function J1(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"p-1",children:[...Array(3)].map(Q1)}),t[0]=e):e=t[0],e}function Q1(t,e){return r.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[r.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),r.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function Wu(t){const e=B.c(18),{editor:s,char:i,pluginKey:n,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let u;e[0]!==c||e[1]!==i||e[2]!==s||e[3]!==d||e[4]!==n?(u={editor:s,char:i,pluginKey:n,allow:c,onOpenChange:d},e[0]=c,e[1]=i,e[2]=s,e[3]=d,e[4]=n,e[5]=u):u=e[5];const{state:h,dispatch:m}=K1(u);let f;e[6]!==m||e[7]!==h?(f={state:h,dispatch:m},e[6]=m,e[7]=h,e[8]=f):f=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(J1,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=r.jsx(G1,{children:r.jsx(S.Suspense,{fallback:p,children:r.jsx(X1,{editor:s,queryKey:o,queryFn:a,onSelect:l})})}),e[10]=s,e[11]=l,e[12]=a,e[13]=o,e[14]=g):g=e[14];let _;return e[15]!==f||e[16]!==g?(_=r.jsx(Fu.Provider,{value:f,children:g}),e[15]=f,e[16]=g,e[17]=_):_=e[17],_}function Z1(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const ev=[{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}],tv=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=be(),n=ao(),o=Me({connectionId:e,orgId:i.id}),a=lt.virtualMcpResources(e,i.id),[l,c]=S.useState("categories"),d=S.useRef(l);d.current=l;const u=S.useRef(null),h=S.useRef(!1),m=["at-mention",i.id,e??"default",l],f=async({item:_,range:v})=>{if(se("chat_picker_item_selected",{picker:"@",item_kind:_.kind,item_name:_.name}),_.kind!=="category"&&(h.current=!0),_.kind==="category")return c(_.name==="agents"?"agents":"resources"),!1;if(_.kind==="agent"&&_.agentId){Cr(t,v,{id:_.agentId,name:_.name,metadata:{agentId:_.agentId,title:_.name},char:"@"}),c("categories");return}if(_.kind==="resource"&&_.uri&&o){try{const x=await ou(o,_.uri);Cr(t,v,{id:_.uri,name:_.uri,metadata:x.contents,char:"@"})}catch(x){console.error("[at-mention] Failed to fetch resource:",x),pe.error("Failed to load resource. Please try again.")}c("categories");return}},p=async _=>{const{query:v}=_,x=d.current;if(x==="categories"){if(!v.trim())return ev;const C=v.toLowerCase(),j=n.filter(V=>V.status==="active"&&(!V.id||!Mn(V.id))&&V.id!==e&&(V.title.toLowerCase().includes(C)||V.description?.toLowerCase().includes(C))).map(V=>({name:V.title,title:V.title,description:V.description??void 0,icon:V.icon??null,kind:"agent",agentId:V.id})),w=await(async()=>{if(!o)return[];let V=s.getQueryData(a);return V||(V=await s.fetchQuery({queryKey:a,queryFn:()=>xr(o),staleTime:6e4})),(V?.resources??[]).filter(k=>k.uri.toLowerCase().includes(C)||k.name?.toLowerCase().includes(C)||k.description?.toLowerCase().includes(C)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}))})();return[...j,...w]}if(x==="agents"){let C=n.filter(j=>j.status==="active"&&(!j.id||!Mn(j.id))&&j.id!==e);if(v.trim()){const j=v.toLowerCase();C=C.filter(w=>w.title.toLowerCase().includes(j)||w.description?.toLowerCase().includes(j))}return C.map(j=>({name:j.title,title:j.title,description:j.description??void 0,icon:j.icon??null,kind:"agent",agentId:j.id}))}if(!o)return[];let b=s.getQueryData(a);b?s.fetchQuery({queryKey:a,queryFn:()=>xr(o),staleTime:6e4}).catch(()=>{}):b=await s.fetchQuery({queryKey:a,queryFn:()=>xr(o),staleTime:6e4});let y=b?.resources??[];if(v.trim()){const C=v.toLowerCase();y=y.filter(j=>j.uri.toLowerCase().includes(C)||j.name?.toLowerCase().includes(C)||j.description?.toLowerCase().includes(C))}return y.map(C=>({name:C.name??C.uri,title:C.name,description:C.description,kind:"resource",uri:C.uri}))},g=_=>{if(_)u.current=Date.now(),h.current=!1,se("chat_picker_opened",{picker:"@"});else{const v=u.current;se("chat_picker_closed",{picker:"@",outcome:h.current?"selected":"dismissed",duration_ms:v?Date.now()-v:null}),u.current=null,c("categories")}};return r.jsx(Wu,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:p,onSelect:f,onOpenChange:g})};function sv(t,e){const s=ts(t),i=Wr(),n=new Map(i.map(c=>[c.id,c])),o=(s?.connections??[]).map(c=>c.connection_id),{data:a}=Fi({queryKey:lt.promptConnectionMap(e,o),queryFn:async()=>{const c={};return await Promise.all(o.map(async d=>{try{const u=await cg({connectionId:d,orgId:e}),h=await Pn(u);for(const m of h.prompts)m.name in c||(c[m.name]=d)}catch{}})),c},staleTime:6e4,enabled:o.length>0}),l=new Map;for(const[c,d]of Object.entries(a??{})){const u=n.get(d);u&&l.set(c,u)}return l}async function Hc(t,e,s,i,n,o){try{const a=await fl(s,i,o);Cr(t,e,{id:i,name:cl(i,n),metadata:a.messages,char:"/"})}catch(a){console.error("[slash] Failed to fetch prompt:",a),pe.error("Failed to load prompt. Please try again.")}}async function iv(t,e,s,i){try{const n=await ou(s,i);Cr(t,e,{id:i,name:i,metadata:n.contents,char:"/"})}catch(n){console.error("[slash] Failed to fetch resource:",n),pe.error("Failed to load resource. Please try again.")}}const rv=({editor:t,virtualMcpId:e})=>{const s=Mt(),{org:i}=be(),n=Me({connectionId:e,orgId:i.id}),o=sv(e,i.id),a=S.useRef(o);a.current=o;const l=lt.virtualMcpPrompts(e,i.id),c=lt.virtualMcpResources(e,i.id),d=["slash-mention",i.id,e??"default"],[u,h]=S.useState(null),m=S.useRef(null),f=S.useRef(!1),p=async({item:x,range:b})=>{if(se("chat_picker_item_selected",{picker:"/",item_kind:x.kind,item_name:x.name}),f.current=!0,!!n)if(x.kind==="prompt"){if(x.arguments&&x.arguments.length>0){h({range:b,item:x});return}const y=ii(x._meta);await Hc(t,b,n,x.name,y)}else x.uri&&await iv(t,b,n,x.uri)},g=async x=>{if(!u||!n)return;const{range:b,item:y}=u,C=ii(y._meta);await Hc(t,b,n,y.name,C,x),h(null)},_=async x=>{const{query:b}=x;if(!n)return[];const[y,C]=await Promise.all([nv(s,l,n),ov(s,c,n)]),j=b.trim().toLowerCase(),w=(y??[]).filter(k=>!j||k.name.toLowerCase().includes(j)||k.title?.toLowerCase().includes(j)||k.description?.toLowerCase().includes(j)).map(k=>({name:k.name,title:k.title,description:k.description,icon:a.current.get(k.name)?.icon??null,kind:"prompt",arguments:k.arguments,_meta:k._meta})),V=(C??[]).filter(k=>!j||k.uri.toLowerCase().includes(j)||k.name?.toLowerCase().includes(j)||k.description?.toLowerCase().includes(j)).map(k=>({name:k.name??k.uri,title:k.name,description:k.description,kind:"resource",uri:k.uri}));return[...w,...V]},v=u?.item.kind==="prompt"?{name:u.item.name,arguments:u.item.arguments,description:u.item.description}:null;return r.jsxs(r.Fragment,{children:[r.jsx(Wu,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:d,queryFn:_,onSelect:p,onOpenChange:x=>{if(x)m.current=Date.now(),f.current=!1,se("chat_picker_opened",{picker:"/"});else{const b=m.current;se("chat_picker_closed",{picker:"/",outcome:f.current?"selected":"dismissed",duration_ms:b?Date.now()-b:null}),m.current=null}}}),r.jsx(Tl,{prompt:v,setPrompt:()=>h(null),onSubmit:g})]})};async function nv(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>Pn(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>Pn(s),staleTime:6e4}),i?.prompts??[]}async function ov(t,e,s){let i=t.getQueryData(e);return i?t.fetchQuery({queryKey:e,queryFn:()=>xr(s),staleTime:6e4}).catch(()=>{}):i=await t.fetchQuery({queryKey:e,queryFn:()=>xr(s),staleTime:6e4}),i?.resources??[]}function av(t){return[rg.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),qx.configure({placeholder:()=>t.current??"Ask anything, / for prompts, @ for agents & resources...",showOnlyWhenEditable:!1}),Bp,Op]}function Uu({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:i=!1,placeholder:n,onSubmit:o,children:a}){const l=S.useRef(o),c=S.useRef(e),d=S.useRef(i),u=S.useRef(n),h=sg({extensions:av(u),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,f)=>f.key==="Enter"&&!f.shiftKey&&d.current?(f.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:m})=>{c.current(m?.getJSON())}});return S.useEffect(()=>{h?.setEditable(!s)},[h,s]),S.useEffect(()=>{l.current=o},[o]),S.useEffect(()=>{c.current=e},[e]),S.useEffect(()=>{d.current=i},[i]),S.useEffect(()=>{u.current=n},[n]),S.useEffect(()=>{if(h?.isDestroyed)return;const m=JSON.stringify(h?.getJSON()),f=JSON.stringify(t||{type:"doc",content:[]});m!==f&&h.commands.setContent(t||{type:"doc",content:[]})},[h,t]),r.jsx(ig.Provider,{value:{editor:h},children:a})}function Ku(t){const e=B.c(26),{disabled:s,virtualMcpId:i,showFileUploader:n,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,u=n===void 0?!1:n,{editor:h}=to();let m,f;if(e[0]!==h?(m=()=>({focus:()=>{h?.commands.focus()},clear:()=>{h?.commands.clearContent(!0)},appendText:V=>{if(!h)return;const k=h.state.doc.textContent.trim()==="";h.commands.focus("end"),k||h.commands.insertContent(" "),h.commands.insertContent(V)},syncVoiceText:(V,k)=>{if(h&&(h.commands.setContent(V||{type:"doc",content:[]}),k)){h.commands.focus("end");const R=h.state.doc.textContent.trim().length>0;h.commands.insertContent(R?" "+k:k)}},restoreContent:V=>{h&&h.commands.setContent(V||{type:"doc",content:[]})}}),f=[h],e[0]=h,e[1]=m,e[2]=f):(m=e[1],f=e[2]),S.useImperativeHandle(l??null,m,f),!h)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let _;e[3]!==c||e[4]!==p||e[5]!==g?(_=Y("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col",c,"[&_.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",p,g),e[3]=c,e[4]=p,e[5]=g,e[6]=_):_=e[6];let v;e[7]!==h||e[8]!==_?(v=r.jsx(ng,{editor:h,className:_}),e[7]=h,e[8]=_,e[9]=v):v=e[9];const x=i??null;let b;e[10]!==h||e[11]!==x?(b=r.jsx(S.Suspense,{fallback:null,children:r.jsx(rv,{editor:h,virtualMcpId:x})}),e[10]=h,e[11]=x,e[12]=b):b=e[12];const y=i??null;let C;e[13]!==h||e[14]!==y?(C=r.jsx(S.Suspense,{fallback:null,children:r.jsx(tv,{editor:h,virtualMcpId:y})}),e[13]=h,e[14]=y,e[15]=C):C=e[15];let j;e[16]!==h||e[17]!==a||e[18]!==o||e[19]!==u?(j=u&&o?r.jsx(Bx,{editor:h,selectedModel:o,onUnsupportedFile:a}):null,e[16]=h,e[17]=a,e[18]=o,e[19]=u,e[20]=j):j=e[20];let w;return e[21]!==b||e[22]!==C||e[23]!==j||e[24]!==v?(w=r.jsxs(r.Fragment,{children:[v,b,C,j]}),e[21]=b,e[22]=C,e[23]=j,e[24]=v,e[25]=w):w=e[25],w}function ga(t){const e=B.c(3),[s]=Wi();let i;return e[0]!==s.enableSounds||e[1]!==t?(i=()=>{s.enableSounds&&Zg(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 lv={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"},cv=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function dv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1.5",children:cv.map(hv)}),t[0]=e):e=t[0],e}function hv(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function uv(t){const e=B.c(129),{disabled:s,onOpenConnections:i,virtualMcpId:n}=t,[o,a]=S.useState(!1),l=ga(lv),{org:c}=be(),{editor:d}=to();let u;e[0]!==c.id||e[1]!==n?(u={connectionId:n,orgId:c.id},e[0]=c.id,e[1]=n,e[2]=u):u=e[2];const h=Me(u);let m;e[3]!==c.id||e[4]!==n?(m=lt.virtualMcpPrompts(n,c.id),e[3]=c.id,e[4]=n,e[5]=m):m=e[5];const f=m;let p;e[6]!==h?(p=()=>Pn(h),e[6]=h,e[7]=p):p=e[7];const g=o&&!!h;let _;e[8]!==f||e[9]!==p||e[10]!==g?(_={queryKey:f,queryFn:p,staleTime:6e4,enabled:g},e[8]=f,e[9]=p,e[10]=g,e[11]=_):_=e[11];const{data:v,isLoading:x}=Fi(_);let b;e[12]!==v?.prompts?(b=v?.prompts??[],e[12]=v?.prompts,e[13]=b):b=e[13];const y=b,[C,j]=S.useState(null),{credentialId:w,imageModel:V,setImageModel:k,deepResearchModel:R,setDeepResearchModel:T,chatMode:E,setChatMode:N,simpleModeEnabled:A}=oi(),I=E==="plan",[M,L]=S.useState(!1),[D,P]=S.useState(!1),{models:O,isLoading:z}=su(M||D?w??void 0:void 0);let $,U,F,G,W,H,Z,q,K,te,ee,X,ie;if(e[14]!==C||e[15]!==O||e[16]!==E||e[17]!==h||e[18]!==R||e[19]!==s||e[20]!==d||e[21]!==V||e[22]!==M||e[23]!==z||e[24]!==I||e[25]!==i||e[26]!==o||e[27]!==l||e[28]!==D||e[29]!==N||e[30]!==T||e[31]!==k||e[32]!==A){const J=O.filter(mv),le=O.filter(fv);let Se;e[46]!==E||e[47]!==I||e[48]!==l||e[49]!==N?(Se=()=>{l();const _e=I?"default":"plan";se("chat_mode_changed",{from_mode:E,to_mode:_e,source:"tools_popover"}),N(_e),a(!1)},e[46]=E,e[47]=I,e[48]=l,e[49]=N,e[50]=Se):Se=e[50];const Ne=Se;let Be;e[51]!==i?(Be=()=>{i(),a(!1)},e[51]=i,e[52]=Be):Be=e[52],F=Be;let Oe;e[53]!==h||e[54]!==d?(Oe=async(_e,Ot)=>{if(!d||!h)return;const $t=ii(_e._meta),ds={from:d.state.selection.from,to:d.state.selection.to};try{const Qi=await fl(h,_e.name,Ot);Cr(d,ds,{id:_e.name,name:cl(_e.name,$t),metadata:Qi.messages,char:"/"})}catch{pe.error("Failed to load prompt. Please try again.")}},e[53]=h,e[54]=d,e[55]=Oe):Oe=e[55];const He=Oe;let Je;e[56]!==He?(Je=async _e=>{a(!1);const Ot=!!(_e.arguments&&_e.arguments.length>0);if(se("chat_prompt_inserted",{prompt_name:_e.name,with_arguments:Ot}),Ot){j(_e);return}await He(_e)},e[56]=He,e[57]=Je):Je=e[57],W=Je;let dt;e[58]!==C||e[59]!==He?(dt=async _e=>{C&&(await He(C,_e),j(null))},e[58]=C,e[59]=He,e[60]=dt):dt=e[60],G=dt;let ge;e[61]!==l||e[62]!==k?(ge=_e=>{l(),se("chat_image_model_selected",{model_id:_e.modelId,model_title:_e.title,provider:_e.providerId??null}),k(_e),a(!1)},e[61]=l,e[62]=k,e[63]=ge):ge=e[63];const ke=ge;let Qe;e[64]!==l||e[65]!==T?(Qe=_e=>{l(),se("chat_search_model_selected",{model_id:_e.modelId,model_title:_e.title,provider:_e.providerId??null}),T(_e),a(!1)},e[64]=l,e[65]=T,e[66]=Qe):Qe=e[66];const Ct=Qe;let Pe;e[67]!==E||e[68]!==l||e[69]!==N?(Pe=()=>{l();const _e=E==="gen-image"?"default":"gen-image";se("chat_mode_changed",{from_mode:E,to_mode:_e,source:"tools_popover"}),N(_e),a(!1)},e[67]=E,e[68]=l,e[69]=N,e[70]=Pe):Pe=e[70];const Kt=Pe;let jt;e[71]!==E||e[72]!==l||e[73]!==N?(jt=()=>{l();const _e=E==="web-search"?"default":"web-search";se("chat_mode_changed",{from_mode:E,to_mode:_e,source:"tools_popover"}),N(_e),a(!1)},e[71]=E,e[72]=l,e[73]=N,e[74]=jt):jt=e[74];const Ae=jt,Ie=E==="gen-image",qe=E==="web-search";U=Ns,q=o,e[75]!==E||e[76]!==o?(K=_e=>{_e&&!o&&se("chat_tools_popover_opened",{chat_mode:E}),a(_e)},e[75]=E,e[76]=o,e[77]=K):K=e[77];let qt,_t;e[78]===Symbol.for("react.memo_cache_sentinel")?(qt=r.jsx(Fh,{size:14}),_t=r.jsx("span",{className:"hidden sm:inline",children:"Tools"}),e[78]=qt,e[79]=_t):(qt=e[78],_t=e[79]),e[80]!==s?(te=r.jsx(As,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"ghost",size:"default",disabled:s,className:"text-muted-foreground hover:text-foreground",children:[qt,_t]})}),e[80]=s,e[81]=te):te=e[81],$=Es,ee="start",X="w-52 p-1.5";const xt=I&&"text-violet-600 dark:text-violet-400";let vt;e[82]!==xt?(vt=Y(xt),e[82]=xt,e[83]=vt):vt=e[83];const vs=I&&"text-violet-500";let $e;e[84]!==vs?($e=Y(vs),e[84]=vs,e[85]=$e):$e=e[85];let kt;e[86]!==$e?(kt=r.jsx(Jh,{size:16,className:$e}),e[86]=$e,e[87]=kt):kt=e[87];let Nt;e[88]===Symbol.for("react.memo_cache_sentinel")?(Nt=r.jsx("span",{className:"flex-1",children:"Plan mode"}),e[88]=Nt):Nt=e[88];let wt;e[89]!==I?(wt=I&&r.jsx("span",{className:"text-xs text-violet-500 font-medium",children:"On"}),e[89]=I,e[90]=wt):wt=e[90],e[91]!==Ne||e[92]!==vt||e[93]!==kt||e[94]!==wt?(ie=r.jsxs(ot,{onClick:Ne,className:vt,children:[kt,Nt,wt]}),e[91]=Ne,e[92]=vt,e[93]=kt,e[94]=wt,e[95]=ie):ie=e[95],H=A?r.jsxs(ot,{onClick:Kt,className:Y(Ie&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(ca,{size:16,className:Y(Ie&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),Ie&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}):r.jsxs(Sn,{open:M,onOpenChange:L,children:[r.jsxs("div",{className:"flex items-center rounded-lg",children:[r.jsxs(ot,{onClick:Kt,disabled:!V,className:Y("flex-1 rounded-r-none pr-1",Ie&&"text-pink-600 dark:text-pink-400"),children:[r.jsx(ca,{size:16,className:Y(Ie&&"text-pink-500")}),r.jsx("span",{className:"flex-1",children:"Create image"}),Ie&&r.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),r.jsx(cc,{className:Y("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:r.jsx(kr,{size:14})})]}),r.jsx(wn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:z?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ee,{size:14,className:"animate-spin"}),"Loading models…"]}):J.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No image models available"}):J.map(_e=>{const Ot=V?.modelId===_e.modelId,$t=vc(_e),ds=_e.title.includes(": ")?_e.title.split(": ").slice(1).join(": "):_e.title;return r.jsxs(ot,{onClick:()=>ke(_e),className:"flex items-center gap-2",children:[r.jsx("img",{src:$t,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:ds}),Ot&&r.jsx(Jt,{size:14,className:"text-pink-500 shrink-0"})]},_e.modelId)})})]}),Z=A?r.jsxs(ot,{onClick:Ae,className:Y(qe&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Ti,{size:16,className:Y(qe&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),qe&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}):R&&r.jsxs(Sn,{open:D,onOpenChange:P,children:[r.jsxs("div",{className:"flex items-center rounded-lg",children:[r.jsxs(ot,{onClick:Ae,className:Y("flex-1 rounded-r-none pr-1",qe&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(Ti,{size:16,className:Y(qe&&"text-blue-500")}),r.jsx("span",{className:"flex-1",children:"Web search"}),qe&&r.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),r.jsx(cc,{className:Y("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:r.jsx(kr,{size:14})})]}),r.jsx(wn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:z?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ee,{size:14,className:"animate-spin"}),"Loading models…"]}):le.map(_e=>{const Ot=R?.modelId===_e.modelId,$t=vc(_e),ds=_e.title.includes(": ")?_e.title.split(": ").slice(1).join(": "):_e.title;return r.jsxs(ot,{onClick:()=>Ct(_e),className:"flex items-center gap-2",children:[r.jsx("img",{src:$t,alt:"",className:"size-4 shrink-0 rounded-sm dark:bg-white dark:p-px"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:ds}),Ot&&r.jsx(Jt,{size:14,className:"text-blue-500 shrink-0"})]},_e.modelId)})})]}),e[14]=C,e[15]=O,e[16]=E,e[17]=h,e[18]=R,e[19]=s,e[20]=d,e[21]=V,e[22]=M,e[23]=z,e[24]=I,e[25]=i,e[26]=o,e[27]=l,e[28]=D,e[29]=N,e[30]=T,e[31]=k,e[32]=A,e[33]=$,e[34]=U,e[35]=F,e[36]=G,e[37]=W,e[38]=H,e[39]=Z,e[40]=q,e[41]=K,e[42]=te,e[43]=ee,e[44]=X,e[45]=ie}else $=e[33],U=e[34],F=e[35],G=e[36],W=e[37],H=e[38],Z=e[39],q=e[40],K=e[41],te=e[42],ee=e[43],X=e[44],ie=e[45];let re;e[96]===Symbol.for("react.memo_cache_sentinel")?(re=r.jsxs(Bh,{className:"gap-2",children:[r.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),r.jsx("span",{className:"flex-1",children:"Prompts"})]}),e[96]=re):re=e[96];let he;e[97]!==W||e[98]!==x||e[99]!==y?(he=x?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[r.jsx(Ee,{size:14,className:"animate-spin"}),"Loading prompts…"]}):y.length===0?r.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):y.map(J=>r.jsxs(ot,{onClick:()=>W(J),className:"flex flex-col items-start gap-0.5",children:[r.jsx("span",{className:"font-medium text-sm capitalize",children:J.title||eo(J.name,ii(J._meta))}),J.description&&r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:J.description})]},J.name)),e[97]=W,e[98]=x,e[99]=y,e[100]=he):he=e[100];let xe;e[101]!==he?(xe=r.jsxs(Sn,{children:[re,r.jsx(wn,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:he})]}),e[101]=he,e[102]=xe):xe=e[102];let ae,ue;e[103]===Symbol.for("react.memo_cache_sentinel")?(ae=r.jsx(Lg,{size:16}),ue=r.jsx("span",{className:"flex-1",children:"Connections"}),e[103]=ae,e[104]=ue):(ae=e[103],ue=e[104]);let me;e[105]===Symbol.for("react.memo_cache_sentinel")?(me=r.jsx(S.Suspense,{children:r.jsx(dv,{})}),e[105]=me):me=e[105];let fe;e[106]!==F?(fe=r.jsxs(ot,{onClick:F,children:[ae,ue,me]}),e[106]=F,e[107]=fe):fe=e[107];let ce;e[108]!==$||e[109]!==H||e[110]!==Z||e[111]!==xe||e[112]!==fe||e[113]!==ee||e[114]!==X||e[115]!==ie?(ce=r.jsxs($,{align:ee,className:X,children:[ie,H,Z,xe,fe]}),e[108]=$,e[109]=H,e[110]=Z,e[111]=xe,e[112]=fe,e[113]=ee,e[114]=X,e[115]=ie,e[116]=ce):ce=e[116];let ve;e[117]!==U||e[118]!==q||e[119]!==K||e[120]!==te||e[121]!==ce?(ve=r.jsxs(U,{open:q,onOpenChange:K,children:[te,ce]}),e[117]=U,e[118]=q,e[119]=K,e[120]=te,e[121]=ce,e[122]=ve):ve=e[122];let Ce;e[123]!==C||e[124]!==G?(Ce=r.jsx(Tl,{prompt:C,setPrompt:j,onSubmit:G}),e[123]=C,e[124]=G,e[125]=Ce):Ce=e[125];let Te;return e[126]!==ve||e[127]!==Ce?(Te=r.jsxs(r.Fragment,{children:[ve,Ce]}),e[126]=ve,e[127]=Ce,e[128]=Te):Te=e[128],Te}function fv(t){const e=t.modelId.toLowerCase().replace(/[^a-z0-9]/g,"");return e.includes("sonar")||e.includes("deepresearch")}function mv(t){return t.capabilities?.includes("image")}function pv({open:t,onOpenChange:e,onCreated:s}){const{org:i}=be(),{data:n}=St.useSession(),{stdioEnabled:o}=ep(),a=Ds(),l=wl(),c=cu(),u=du(c,"").items,h=Hi({resolver:Or(t_),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=h.watch("ui_type"),f=h.watch("connection_url"),p=h.watch("npx_package"),g=on({uiType:m,connectionUrl:f??"",npxPackage:p??""})??bc({uiType:m,connectionUrl:f??"",registryItems:u}),_=w=>{const V=w.trim();if(!V)return;const k=!!h.formState.dirtyFields.title,R=!!h.formState.dirtyFields.description,T=!!h.formState.dirtyFields.env_vars,E=A=>{if(A&&(!k&&!h.getValues("title").trim()&&A.title&&h.setValue("title",A.title,{shouldDirty:!1}),!R&&!(h.getValues("description")??"").trim()&&A.description&&h.setValue("description",A.description,{shouldDirty:!1}),!T&&A.envVarKeys?.length)){const I=h.getValues("env_vars")??[],M=new Set(I.map(D=>D.key)),L=A.envVarKeys.filter(D=>!M.has(D));L.length>0&&h.setValue("env_vars",[...I,...L.map(D=>({key:D,value:""}))],{shouldDirty:!0})}},N=i_(V);if(N&&o){h.setValue("ui_type","NPX",{shouldDirty:!0}),h.setValue("npx_package",N.packageName,{shouldDirty:!0}),h.setValue("connection_url","",{shouldDirty:!0}),h.setValue("connection_token",null,{shouldDirty:!0}),E(on({uiType:"NPX",npxPackage:N.packageName}));return}if(V.startsWith("http://")||V.startsWith("https://")){const A=m==="HTTP"||m==="SSE"||m==="Websocket"?m:"HTTP";h.setValue("ui_type",A,{shouldDirty:!0}),h.setValue("connection_url",V,{shouldDirty:!0}),E(on({uiType:A,connectionUrl:V})??bc({uiType:A,connectionUrl:V,registryItems:u}));return}m==="NPX"&&E(on({uiType:"NPX",npxPackage:V}))},v=w=>{w||h.reset(),e(w)},x=async w=>{let V,k=null,R=null,T=null;w.ui_type==="NPX"?(V="STDIO",k="",T=r_(w.npx_package||"",w.env_vars||[])):w.ui_type==="STDIO"?(V="STDIO",k="",T=n_(w.stdio_command||"",w.stdio_args||"",w.stdio_cwd,w.env_vars||[])):(V=w.ui_type,k=w.connection_url||"",R=w.connection_token||null);const E=uu("conn");try{await l.create.mutateAsync({id:E,title:w.title,description:w.description||null,connection_type:V,connection_url:k,connection_token:R,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:n?.user?.id||"system",organization_id:i.id,icon:w.icon??null,app_name:null,app_id:null,connection_headers:T,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),h.reset(),e(!1),s?.(E)}catch{pe.error("Failed to create connection")}},b="Create Connection",y="Create a custom connection in your organization. Fill in the details below.",C=h.formState.isSubmitting?"Saving...":"Create Connection",j=r.jsxs("div",{className:"grid gap-4",children:[r.jsx(It,{control:h.control,name:"ui_type",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Type *"}),r.jsxs(Zs,{value:w.value,onValueChange:w.onChange,children:[r.jsx(Tt,{children:r.jsx(ei,{children:r.jsx(ti,{})})}),r.jsxs(Qs,{children:[r.jsx(Ht,{value:"HTTP",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ti,{className:"w-4 h-4"}),"HTTP"]})}),r.jsx(Ht,{value:"SSE",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ti,{className:"w-4 h-4"}),"SSE"]})}),r.jsx(Ht,{value:"Websocket",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Ti,{className:"w-4 h-4"}),"Websocket"]})}),o&&r.jsxs(r.Fragment,{children:[r.jsx(Ht,{value:"NPX",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"w-4 h-4"}),"NPX Package"]})}),r.jsx(Ht,{value:"STDIO",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(ml,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),r.jsx(Dt,{})]})}),m==="NPX"&&r.jsx(It,{control:h.control,name:"npx_package",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"NPM Package *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"@perplexity-ai/mcp-server",...w,value:w.value??"",onPaste:V=>{const k=V.clipboardData.getData("text");k&&(V.preventDefault(),h.setValue("npx_package",k.trim(),{shouldDirty:!0}),_(k))},onBlur:V=>{_(V.target.value),w.onBlur()}})}),r.jsx(Dt,{})]})}),m==="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[r.jsx(It,{control:h.control,name:"stdio_command",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Command *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"node, bun, python...",...w,value:w.value??""})}),r.jsx(Dt,{})]})}),r.jsx(It,{control:h.control,name:"stdio_args",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Arguments"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"arg1 arg2 --flag value",...w,value:w.value??""})}),r.jsx(Dt,{})]})})]}),r.jsx(It,{control:h.control,name:"stdio_cwd",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Working Directory"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"/path/to/project (optional)",...w,value:w.value??""})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),r.jsx(Dt,{})]})})]}),(m==="NPX"||m==="STDIO")&&r.jsx(It,{control:h.control,name:"env_vars",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Environment Variables"}),r.jsx(Tt,{children:r.jsx(s_,{value:w.value??[],onChange:w.onChange})}),r.jsx(Dt,{})]})}),m!=="NPX"&&m!=="STDIO"&&r.jsxs(r.Fragment,{children:[r.jsx(It,{control:h.control,name:"connection_url",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"URL *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"https://example.com/mcp",...w,value:w.value??"",onPaste:V=>{const k=V.clipboardData.getData("text");k&&(V.preventDefault(),h.setValue("connection_url",k.trim(),{shouldDirty:!0}),_(k))},onBlur:V=>{_(V.target.value),w.onBlur()}})}),r.jsx(Dt,{})]})}),r.jsx(It,{control:h.control,name:"connection_token",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:g?.token?.label??"Token (optional)"}),r.jsx(Tt,{children:r.jsx(bt,{type:"password",placeholder:g?.token?.placeholder??"Bearer token or API key",className:"ph-no-capture",...w,value:w.value??""})}),g?.token?.helperText&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.id==="github"&&r.jsxs(r.Fragment,{children:[" ","·"," ",r.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"})]})]}),r.jsx(Dt,{})]})})]}),r.jsx(It,{control:h.control,name:"title",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Name *"}),r.jsx(Tt,{children:r.jsx(bt,{placeholder:"My Connection",...w})}),r.jsx(Dt,{})]})}),r.jsx(It,{control:h.control,name:"description",render:({field:w})=>r.jsxs(Rt,{children:[r.jsx(rs,{children:"Description"}),r.jsx(Tt,{children:r.jsx(da,{placeholder:"A brief description of this connection",rows:3,...w,value:w.value??""})}),r.jsx(Dt,{})]})})]});return a?r.jsx(Si,{open:t,onOpenChange:v,children:r.jsxs(yi,{className:"max-h-[90vh]",children:[r.jsx(io,{className:"pb-2",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1 text-left",children:[r.jsx(bi,{children:b}),r.jsx(og,{className:"mt-1",children:y})]}),r.jsx(ag,{asChild:!0,children:r.jsx(oe,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:r.jsx(ri,{size:16})})})]})}),r.jsx(Pi,{...h,children:r.jsxs("form",{onSubmit:h.handleSubmit(x),children:[r.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:j}),r.jsx(lg,{children:r.jsx(oe,{type:"submit",disabled:h.formState.isSubmitting,className:"w-full",children:C})})]})})]})}):r.jsx(cs,{open:t,onOpenChange:v,children:r.jsxs(ls,{className:"sm:max-w-[525px]",children:[r.jsxs(_s,{children:[r.jsx(gs,{children:b}),r.jsx(so,{children:y})]}),r.jsx(Pi,{...h,children:r.jsxs("form",{onSubmit:h.handleSubmit(x),children:[r.jsx("div",{className:"py-4",children:j}),r.jsxs(hl,{children:[r.jsx(oe,{type:"button",variant:"outline",onClick:()=>v(!1),children:"Cancel"}),r.jsx(oe,{type:"submit",disabled:h.formState.isSubmitting,className:"min-w-40",children:C})]})]})})]})})}function gv(t){const e=B.c(79),{mode:s,agentId:i,addedConnectionIds:n,onAdd:o,onCloneAndAdd:a,onConnectAndAdd:l,connectingItemId:c,search:d,onCreateConnection:u,onBrowseNavigate:h,defaultTab:m}=t,f=s===void 0?"add":s,p=m===void 0?"connected":m,{org:g}=be(),_=S.useDeferredValue(d),v=d!==_;let x;e[0]!==_?(x=_.toLowerCase(),e[0]=_,e[1]=x):x=e[1];const b=x;let y;e[2]!==p?(y=ge=>ge??p,e[2]=p,e[3]=y):y=e[3];const[C,j]=al(ll.connectionsTab(g.slug)+(p==="all"?":home-modal":":agent-modal"),y);let w;e[4]!==C||e[5]!==j?(w=ge=>{ge!==C&&se("connections_dialog_tab_changed",{to_tab:ge}),j(ge)},e[4]=C,e[5]=j,e[6]=w):w=e[6];const V=w;let k;e[7]!==g.id?(k={connectionId:Wt,orgId:g.id},e[7]=g.id,e[8]=k):k=e[8];const R=Me(k);let T,E,N;if(e[9]!==R||e[10]!==_||e[11]!==g.id){N=_?.trim()?{operator:"or",conditions:[{field:["title"],operator:"contains",value:_.trim()},{field:["description"],operator:"contains",value:_.trim()}]}:void 0;const ge={...N&&{where:N},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},ke=JSON.stringify(ge);E=o_,T=lt.collectionListInfinite(R,g.id,"","CONNECTIONS",ke),e[9]=R,e[10]=_,e[11]=g.id,e[12]=T,e[13]=E,e[14]=N}else T=e[12],E=e[13],N=e[14];let A;e[15]!==R||e[16]!==N?(A=async ge=>{const{pageParam:ke}=ge,Qe=ke===void 0?0:ke;return(await R.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...N&&{where:N},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Qe}})).structuredContent},e[15]=R,e[16]=N,e[17]=A):A=e[17];let I;e[18]!==T||e[19]!==A?(I={queryKey:T,queryFn:A,initialPageParam:0,getNextPageParam:Sv,staleTime:3e4},e[18]=T,e[19]=A,e[20]=I):I=e[20];const{data:M,fetchNextPage:L,hasNextPage:D,isFetchingNextPage:P}=E(I),O=M?.pages.flatMap(yv)??[],z=e_(O),$=new Set(O.filter(bv).map(vv)),U=cu(),F=du(U,_),G=yc(F.loadMore,F.hasMore,F.isLoadingMore),W=yc(L,D??!1,P),H=C==="all"||!!b,Z=H?F.items.filter(ge=>{const ke=u_(ge);return!(ke&&$.has(ke))}):[],q=Z.filter(xv),K=Z.filter(_v);let te;e[21]!==n?(te=ge=>ge.some(ke=>n.has(ke.id)),e[21]=n,e[22]=te):te=e[22];const ee=te;let X;e[23]!==n||e[24]!==i||e[25]!==c||e[26]!==ee||e[27]!==f||e[28]!==o||e[29]!==h||e[30]!==a?(X=(ge,ke,Qe,Ct,Pe)=>{const Kt=ee(Pe),jt=Pe.find(Ie=>!n.has(Ie.id)),Ae=Pe[0];if(f==="browse"){const Ie=au(Ae);return r.jsx(ko,{connection:{title:ke,icon:Qe,description:Pe.length>1?`${Pe.length} instances`:Ct??void 0},fallbackIcon:r.jsx(Vn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs(Vc,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Jt,{size:11})," Connected"]}),onClick:()=>{se("connection_browse_clicked",{app_name:Ae.app_name??null,connection_id:Ae.id,instances_count:Pe.length}),h?.(Ie)}},ge)}return r.jsx(ko,{connection:{title:ke,icon:Qe,description:Ct},fallbackIcon:r.jsx(Vn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsxs("div",{className:"flex items-center gap-1.5",children:[Kt&&r.jsxs(Vc,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Jt,{size:11})," Added"]}),r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Ie=>{Ie.stopPropagation(),jt?(se("connection_add_clicked",{action:"use_existing",app_name:Ae.app_name??null,connection_id:jt.id}),i&&se("agent_connection_attached",{agent_id:i,connection_id:jt.id,app_name:Ae.app_name??null,mode:"existing"}),o(jt.id)):(se("connection_add_clicked",{action:"clone",app_name:Ae.app_name??null,base_connection_id:Ae.id}),a(Ae))},children:"Add"})]})},ge)},e[23]=n,e[24]=i,e[25]=c,e[26]=ee,e[27]=f,e[28]=o,e[29]=h,e[30]=a,e[31]=X):X=e[31];const ie=X;let re;e[32]!==c||e[33]!==f||e[34]!==l?(re=ge=>{const ke=ge._meta?.["mcp.mesh"],Qe=ke?.friendlyName||ke?.friendly_name||ge.server?.title||ge.title||ge.server?.name||ge.name||ge.id||"",Ct=ge.server?.description||ge.description||null,Pe=ge.server?.icons?.[0]?.src||m_(ge.server?.repository)||null;return r.jsx(ko,{connection:{title:Qe,description:Ct,icon:Pe},fallbackIcon:r.jsx(Vn,{}),headerActionsAlwaysVisible:!0,headerActions:r.jsx(oe,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:Kt=>{Kt.stopPropagation(),se("connection_add_clicked",{action:"connect_new",registry_item_id:ge.id,app_name:ge._meta?.["mcp.mesh"]?.friendlyName||ge.server?.name||ge.name||null}),l(ge)},children:c===ge.id?r.jsx(Ee,{size:14,className:"animate-spin"}):f==="browse"?"Connect":"Add"})},`catalog-${ge.id}`)},e[32]=c,e[33]=f,e[34]=l,e[35]=re):re=e[35];const he=re;let xe;e[36]!==C||e[37]!==V||e[38]!==u||e[39]!==b?(xe=!b&&r.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[r.jsx(hu,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:C,onTabChange:ge=>V(ge)}),r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{se("connections_dialog_custom_clicked"),u()},children:[r.jsx(Qt,{size:12}),"Custom Connection"]})]}),e[36]=C,e[37]=V,e[38]=u,e[39]=b,e[40]=xe):xe=e[40];const ae=v&&"opacity-50 pointer-events-none";let ue;e[41]!==ae?(ue=Y("flex-1 overflow-auto p-5 transition-opacity duration-150",ae),e[41]=ae,e[42]=ue):ue=e[42];const me="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let fe;e[43]!==ie?(fe=ge=>{if(ge.type==="group")return ie(ge.key,ge.title,ge.icon,null,ge.connections);const ke=ge.connection;return ie(ke.id,ke.title,ke.icon,ke.description??null,[ke])},e[43]=ie,e[44]=fe):fe=e[44];const ce=z.map(fe);let ve;e[45]!==W?(ve=r.jsx("div",{ref:W,className:"col-span-full h-1"}),e[45]=W,e[46]=ve):ve=e[46];let Ce;e[47]!==P?(Ce=P&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Ee,{size:24,className:"animate-spin text-muted-foreground"})}),e[47]=P,e[48]=Ce):Ce=e[48];const Te=H&&q.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx(Bg,{size:13,className:"text-muted-foreground shrink-0"}),r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),J=H&&q.map(he),le=H&&K.length>0&&r.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[r.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),r.jsx("div",{className:"flex-1 h-px bg-border"})]}),Se=H&&K.map(he);let Ne;e[49]!==G||e[50]!==U||e[51]!==H?(Ne=H&&U.length>0&&r.jsx("div",{ref:G,className:"col-span-full h-1"}),e[49]=G,e[50]=U,e[51]=H,e[52]=Ne):Ne=e[52];let Be;e[53]!==F.isLoadingMore||e[54]!==H?(Be=H&&F.isLoadingMore&&r.jsx("div",{className:"col-span-full flex justify-center py-6",children:r.jsx(Ee,{size:24,className:"animate-spin text-muted-foreground"})}),e[53]=F.isLoadingMore,e[54]=H,e[55]=Be):Be=e[55];let Oe;e[56]!==ce||e[57]!==ve||e[58]!==Ce||e[59]!==Te||e[60]!==J||e[61]!==le||e[62]!==Se||e[63]!==Ne||e[64]!==Be?(Oe=r.jsxs("div",{className:me,children:[ce,ve,Ce,Te,J,le,Se,Ne,Be]}),e[56]=ce,e[57]=ve,e[58]=Ce,e[59]=Te,e[60]=J,e[61]=le,e[62]=Se,e[63]=Ne,e[64]=Be,e[65]=Oe):Oe=e[65];let He;e[66]!==C||e[67]!==z.length||e[68]!==K||e[69]!==d||e[70]!==q?(He=z.length===0&&q.length===0&&K.length===0&&r.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:d?`No connections match "${d}"`:C==="connected"?"No connections yet":"No connections available"}),e[66]=C,e[67]=z.length,e[68]=K,e[69]=d,e[70]=q,e[71]=He):He=e[71];let Je;e[72]!==ue||e[73]!==Oe||e[74]!==He?(Je=r.jsxs("div",{className:ue,children:[Oe,He]}),e[72]=ue,e[73]=Oe,e[74]=He,e[75]=Je):Je=e[75];let dt;return e[76]!==xe||e[77]!==Je?(dt=r.jsxs(r.Fragment,{children:[xe,Je]}),e[76]=xe,e[77]=Je,e[78]=dt):dt=e[78],dt}function _v(t){return!t.verified&&!t._meta?.["mcp.mesh"]?.verified&&!t.meta?.verified}function xv(t){return t.verified||t._meta?.["mcp.mesh"]?.verified||t.meta?.verified}function vv(t){return t.app_name}function bv(t){return t.app_name}function yv(t){return t?.items??[]}function Sv(t,e){if(t?.hasMore)return e.reduce(wv,0)}function wv(t,e){return t+(e?.items?.length??0)}function Ll({open:t,onOpenChange:e,defaultTab:s,initialSearch:i="",...n}){const o=n.mode??"add",a="agentId"in n?n.agentId:void 0,l="addedConnectionIds"in n?n.addedConnectionIds??new Set:new Set,c="onAdd"in n&&n.onAdd?n.onAdd:V=>{},d=(V,k,R)=>{a&&se("agent_connection_attached",{agent_id:a,connection_id:V,app_name:k,mode:R})},[u,h]=S.useState(null),[m,f]=S.useState(i),[p,g]=S.useState(!1),{org:_}=be(),{data:v}=St.useSession(),x=wl(),b=Mt(),y=Ke(),C=V=>{e(!1),y({to:"/$org/settings/connections/$appSlug",params:{org:_.slug,appSlug:V}})},j=async V=>{h(V.app_name??V.id);try{const R=`${V.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,E=(await x.create.mutateAsync({title:R,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,N=new URL(`/mcp/${E}`,window.location.origin),A=await pr({url:N.href,token:null});if(A.supportsOAuth&&!A.isAuthenticated){const{token:I,tokenInfo:M,error:L}=await vn({connectionId:E,scope:"offline_access"});if(L||!I){se("connection_oauth_failed",{connection_id:E,flow:"clone",error:L??"no_token"}),pe.error(`Authentication failed: ${L??"no token received"}`),await x.delete.mutateAsync(E);return}if(se("connection_oauth_succeeded",{connection_id:E,flow:"clone"}),M)try{(await fetch(`/api/connections/${E}/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 x.update.mutateAsync({id:E,data:{}}):await x.update.mutateAsync({id:E,data:{connection_token:I}})}catch{await x.update.mutateAsync({id:E,data:{connection_token:I}})}else await x.update.mutateAsync({id:E,data:{connection_token:I}});await b.invalidateQueries({queryKey:lt.isMCPAuthenticated(N.href,null)})}d(E,V.app_name??null,"clone"),c(E)}catch(k){console.error("Failed to add connection:",k),pe.error("Failed to add connection")}finally{h(null)}},w=async V=>{if(!(!_||!v?.user?.id)){h(V.id);try{const k=f_(V,_.id,v.user.id,{remoteIndex:0}),R=k.connection_type==="STDIO",T=!!k.connection_url,E=R&&k.connection_headers&&typeof k.connection_headers=="object"&&"command"in k.connection_headers;if(!T&&!E){pe.error("This MCP Server cannot be connected: no connection method available"),h(null);return}const{id:N}=await x.create.mutateAsync(k),A=new URL(`/mcp/${N}`,window.location.origin),I=await pr({url:A.href,token:null});if(I.supportsOAuth&&!I.isAuthenticated){const{token:M,tokenInfo:L,error:D}=await vn({connectionId:N,scope:"offline_access"});if(D||!M){se("connection_oauth_failed",{connection_id:N,flow:"connect_new",error:D??"no_token"}),pe.error(`Authentication failed: ${D??"no token received"}`),d(N,k.app_name??null,"new"),c(N);return}if(se("connection_oauth_succeeded",{connection_id:N,flow:"connect_new"}),L)try{(await fetch(`/api/connections/${N}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:L.accessToken,refreshToken:L.refreshToken,expiresIn:L.expiresIn,scope:L.scope,clientId:L.clientId,clientSecret:L.clientSecret,tokenEndpoint:L.tokenEndpoint})})).ok?await x.update.mutateAsync({id:N,data:{}}):await x.update.mutateAsync({id:N,data:{connection_token:M}})}catch{await x.update.mutateAsync({id:N,data:{connection_token:M}})}else await x.update.mutateAsync({id:N,data:{connection_token:M}});await b.invalidateQueries({queryKey:lt.isMCPAuthenticated(A.href,null)}),pe.success("Connected and authenticated")}else pe.success("Connected");d(N,k.app_name??null,"new"),c(N)}catch(k){console.error("Failed to connect:",k),pe.error("Failed to connect")}finally{h(null)}}};return r.jsxs(cs,{open:t,onOpenChange:e,children:[r.jsxs(ls,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[r.jsx(_s,{className:"px-6 pt-5 pb-0 shrink-0",children:r.jsx(gs,{className:"text-base font-semibold",children:o==="browse"?"Connections":"Add Connection"})}),r.jsx("div",{className:"pt-3 shrink-0",children:r.jsx(Th,{value:m,onChange:f,placeholder:"Search connections..."})}),r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:24,className:"animate-spin text-muted-foreground"})}),children:r.jsx(gv,{mode:o,agentId:a,addedConnectionIds:l,onAdd:c,onCloneAndAdd:j,onConnectAndAdd:w,connectingItemId:u,search:m,onCreateConnection:()=>g(!0),onBrowseNavigate:C,defaultTab:s})})]}),r.jsx(pv,{open:p,onOpenChange:g,onCreated:async V=>{g(!1);const k=new URL(`/mcp/${V}`,window.location.origin),R=await pr({url:k.href,token:null});if(R.supportsOAuth&&!R.isAuthenticated){const{token:T,tokenInfo:E,error:N}=await vn({connectionId:V,scope:"offline_access"});if(N||!T){se("connection_oauth_failed",{connection_id:V,flow:"custom_create",error:N??"no_token"}),pe.error(`Authentication failed: ${N??"no token received"}`),await x.delete.mutateAsync(V);return}if(se("connection_oauth_succeeded",{connection_id:V,flow:"custom_create"}),E)try{(await fetch(`/api/connections/${V}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:E.accessToken,refreshToken:E.refreshToken,expiresIn:E.expiresIn,scope:E.scope,clientId:E.clientId,clientSecret:E.clientSecret,tokenEndpoint:E.tokenEndpoint})})).ok?await x.update.mutateAsync({id:V,data:{}}):await x.update.mutateAsync({id:V,data:{connection_token:T}})}catch{await x.update.mutateAsync({id:V,data:{connection_token:T}})}else await x.update.mutateAsync({id:V,data:{connection_token:T}});await b.invalidateQueries({queryKey:lt.isMCPAuthenticated(k.href,null)})}d(V,null,"custom"),c(V),e(!1)}})]})}const Vv=[{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 Cv(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex items-center -space-x-1",children:Vv.map(jv)}),t[0]=e):e=t[0],e}function jv(t){return r.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function kv(t){const e=B.c(6),{onClick:s}=t;let i,n,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Y("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),n=r.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=r.jsx(Cv,{}),a=r.jsx(Cl,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=i,e[1]=n,e[2]=o,e[3]=a):(i=e[0],n=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=r.jsxs("button",{type:"button",onClick:s,className:i,children:[n,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const cr=48;function Nv(){const t=B.c(9),[e,s]=S.useState("idle"),[i,n]=S.useState(""),[o,a]=S.useState(""),[l,c]=S.useState(Iv),d=S.useRef(null),u=S.useRef(null),h=S.useRef(null),m=S.useRef(null),f=S.useRef(0),p=S.useRef(!1),g=S.useRef(""),_=S.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{f.current&&(cancelAnimationFrame(f.current),f.current=0),u.current?.close().catch(Ev),m.current?.getTracks().forEach(Av),h.current=null,u.current=null,m.current=null},t[0]=x):x=t[0];const b=x;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const T=E=>{m.current=E;const N=new AudioContext;u.current=N;const A=N.createMediaStreamSource(E),I=N.createAnalyser();I.fftSize=128,I.smoothingTimeConstant=.8,A.connect(I),h.current=I;const M=new Uint8Array(I.frequencyBinCount),L=()=>{if(!h.current)return;h.current.getByteFrequencyData(M);const D=[];for(let P=0;P<cr;P++){const O=Math.floor(P/cr*M.length);D.push(Math.max(.04,(M[O]??0)/255))}c(D),f.current=requestAnimationFrame(L)};L()};y=async()=>{const E=window.SpeechRecognition||window.webkitSpeechRecognition;if(!E){s("unsupported");return}let N;try{N=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}n(""),a(""),_.current="",g.current="",p.current=!0,s("recording"),T(N);const A=new E;d.current=A,A.interimResults=!0,A.continuous=!0,A.lang=navigator.language||"en-US",A.onresult=I=>{let M="",L="";for(let D=I.resultIndex;D<I.results.length;D++){const P=I.results[D],O=P?.[0]?.transcript??"";P?.isFinal?L=L+O:M=M+O}L&&(g.current=g.current+L,n(g.current)),_.current=M,a(M)},A.onend=()=>{if(p.current)try{A.start()}catch{}};try{A.start()}catch{s("idle")}},t[1]=y}else y=t[1];const C=y;let j;t[2]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(cr).fill(.05)),a("");const T=(g.current+(_.current?" "+_.current:"")).trim();return n(""),g.current="",_.current="",T},t[2]=j):j=t[2];const w=j;let V;t[3]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),n(""),a(""),c(Array(cr).fill(.05)),g.current="",_.current=""},t[3]=V):V=t[3];const k=V;let R;return t[4]!==o||t[5]!==e||t[6]!==i||t[7]!==l?(R={status:e,transcript:i,interimTranscript:o,waveformData:l,isSupported:v,startRecording:C,stopRecording:w,cancelRecording:k},t[4]=o,t[5]=e,t[6]=i,t[7]=l,t[8]=R):R=t[8],R}function Av(t){return t.stop()}function Ev(){}function Iv(){return Array(cr).fill(.05)}function Rv(t){const e=B.c(4),{data:s}=t;let i;e[0]!==s?(i=s.map(Tv),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:i}),e[2]=i,e[3]=n):n=e[3],n}function Tv(t,e){return r.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 Ro=[{value:"fast",label:"Fast",Icon:Wh,description:"Quicker responses"},{value:"smart",label:"Smart",Icon:xl,description:"Balanced quality"},{value:"thinking",label:"Thinking",Icon:gg,description:"Deeper reasoning"}];function Dv(t){const e=B.c(17),{tier:s,onSelect:i}=t;let n;e[0]!==s?(n=Ro.find(f=>f.value===s)??Ro[1],e[0]=s,e[1]=n):n=e[1];const o=n,a=o.Icon;let l;e[2]!==a?(l=r.jsx(a,{size:14}),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o.label?(c=r.jsx("span",{className:"hidden sm:inline",children:o.label}),e[4]=o.label,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==c?(d=r.jsx(As,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"ghost",size:"default",className:"text-muted-foreground hover:text-foreground",children:[l,c]})}),e[6]=l,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==i||e[10]!==s?(u=Ro.map(f=>{const{value:p,label:g,Icon:_,description:v}=f;return r.jsxs(ot,{onSelect:()=>i(p),children:[r.jsx(_,{size:16,className:"text-muted-foreground"}),r.jsxs("div",{className:"flex flex-col gap-0.5 flex-1",children:[r.jsx("span",{children:g}),r.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:v})]}),s===p&&r.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"On"})]},p)}),e[9]=i,e[10]=s,e[11]=u):u=e[11];let h;e[12]!==u?(h=r.jsx(Es,{align:"end",className:"w-52 p-1.5",children:u}),e[12]=u,e[13]=h):h=e[13];let m;return e[14]!==d||e[15]!==h?(m=r.jsxs(Ns,{children:[d,h]}),e[14]=d,e[15]=h,e[16]=m):m=e[16],m}function Mv(t,e){const s=B.c(7),{editor:i}=to(),[n,o]=S.useState(!1),a=S.useRef(0);let l;s[0]!==i||s[1]!==e||s[2]!==t?(l=()=>{const d=f=>{f.dataTransfer?.types.includes("Files")&&(f.preventDefault(),a.current=a.current+1,o(!0))},u=f=>{f.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},h=Pv,m=f=>{if(f.preventDefault(),a.current=0,o(!1),!i||!t||!oo(t))return;const p=f.dataTransfer?.files;if(!p||p.length===0)return;const{from:g}=i.state.selection;for(const _ of Array.from(p))Dl(i,t,_,g,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",u),window.addEventListener("dragover",h),window.addEventListener("drop",m),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",u),window.removeEventListener("dragover",h),window.removeEventListener("drop",m)}},s[0]=i,s[1]=e,s[2]=t,s[3]=l):l=s[3];let c;return s[4]!==i||s[5]!==t?(c=[i,t],s[4]=i,s[5]=t,s[6]=c):c=s[6],S.useEffect(l,c),n}function Pv(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function Lv(t){const e=B.c(11),{selectedModel:s,onUnsupportedFile:i}=t,n=Mv(s,i);let o;e[0]!==s?(o=oo(s),e[0]=s,e[1]=o):o=e[1];const a=o,l=n?"opacity-100":"opacity-0 pointer-events-none",c=a?"border-primary/40 text-primary/70":"border-destructive/30 text-destructive/70";let d;e[2]!==l||e[3]!==c?(d=Y("absolute inset-0 z-20 rounded-xl flex flex-col items-center justify-center gap-2 bg-muted border-2 border-dashed transition-opacity",l,c),e[2]=l,e[3]=c,e[4]=d):d=e[4];let u;e[5]!==s||e[6]!==a?(u=a?r.jsxs(r.Fragment,{children:[r.jsx(Zh,{size:24}),r.jsxs("span",{className:"text-sm font-medium",children:["Drop ",iu(s)," here"]})]}):r.jsxs(r.Fragment,{children:[r.jsx(Qh,{size:24}),r.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]=u):u=e[7];let h;return e[8]!==d||e[9]!==u?(h=r.jsx("div",{className:d,children:u}),e[8]=d,e[9]=u,e[10]=h):h=e[10],h}function Bv({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const{messages:s,isStreaming:i,isRunInProgress:n,sendMessage:o,stop:a}=Ui(),{taskId:l,tasks:c}=es(),{selectedModel:d,selectedVirtualMcp:u,isModelsLoading:h,tiptapDocRef:m,imageModel:f,deepResearchModel:p,chatMode:g,setChatMode:_,simpleModeEnabled:v,simpleModeTier:x,setSimpleModeTier:b}=oi(),{data:y}=St.useSession(),C=y?.user?.id,{org:j}=be(),w=ro(j.id).id,V=ga(xc),[k,R]=S.useState(!1),{unsupportedFile:T,onUnsupportedFile:E,clearUnsupportedFile:N}=Kx(),A=Nv(),I=S.useRef(void 0),M=async()=>{I.current=O,await A.startRecording();const re=A.status==="recording"?"started":A.status==="unsupported"?"unsupported":A.status==="permission-denied"?"permission_denied":"unknown";se("chat_voice_started",{thread_id:l,outcome:re})},L=()=>{se("chat_voice_confirmed",{thread_id:l});const re=A.stopRecording();W.current?.syncVoiceText(I.current,re),W.current?.focus()},D=()=>{se("chat_voice_cancelled",{thread_id:l}),A.cancelRecording(),W.current?.restoreContent(I.current)};S.useEffect(()=>{if(A.status!=="recording")return;const re=(A.transcript+(A.interimTranscript?" "+A.interimTranscript:"")).trim();W.current?.syncVoiceText(I.current,re)},[A.transcript,A.interimTranscript,A.status]);const P=c.find(re=>re.id===l),[O,z]=S.useState(void 0),$=re=>{z(re),m.current=re},U=S.useRef(l);U.current!==l&&(U.current=l,z(void 0),m.current=void 0);const G=[...s].reverse().find(re=>re.role==="assistant")?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow,W=S.useRef(null),H=g==="plan";S.useEffect(()=>{const re=he=>{Ph(he)&&he.code==="KeyL"&&(he.preventDefault(),he.shiftKey&&_(g==="plan"?"default":"plan"),W.current?.focus())};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[g,_]);const Z=Eh(s),q=[...s].reverse().find(re=>re.role==="assistant"&&re.metadata?.usage)?.metadata?.usage,K=q?.contextTokens??(q?.totalTokens??0)-(q?.reasoningTokens??0),te=ga(xc),ee=!i&&!!d&&!h&&!G_(O),X=i||n,ie=re=>{re?.preventDefault(),i?(se("chat_message_stopped",{thread_id:l}),a()):n?(se("chat_message_stopped",{thread_id:l}),a()):ee&&O&&(se("chat_message_sent",{thread_id:l,mode:g,model_id:d?.modelId??null,model_provider:d?.providerId??null,virtual_mcp_id:u?.id??null,submission:re?"button_or_enter":"programmatic"}),te(),o(O),$(void 0))};return C&&P?.created_by&&P.created_by!==C?r.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:[r.jsx(Qh,{size:14,className:"shrink-0"}),r.jsx("span",{className:"text-sm",children:"Read only — you're viewing someone else's thread"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-col w-full justify-end",children:r.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&r.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),r.jsx(uo,{}),r.jsx(Uu,{tiptapDoc:O,setTiptapDoc:$,disabled:i||!d,enterToSubmit:!0,onSubmit:ie,children:r.jsxs("form",{onSubmit:ie,className:Y("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-background dark:bg-muted card-shadow"),children:[r.jsx(Lv,{selectedModel:d,onUnsupportedFile:E}),r.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:r.jsx(Ku,{ref:W,disabled:i||!d||A.status==="recording",virtualMcpId:u?.id??w,showFileUploader:!0,selectedModel:d,onUnsupportedFile:E})}),r.jsx("div",{className:"flex items-center justify-between p-2.5 gap-1",children:A.status==="recording"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r.jsx(Rv,{data:A.waveformData.slice(0,28)}),r.jsx("button",{type:"button",onClick:D,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:r.jsx(Xs,{size:16})}),r.jsx("button",{type:"button",onClick:L,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:r.jsx(Jt,{size:16})})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:[r.jsx(zx,{selectedModel:d,isStreaming:i,icon:r.jsx(Qt,{size:16}),onUnsupportedFile:E}),r.jsx(uv,{disabled:i,onOpenConnections:()=>{se("connections_dialog_opened",{source:"tools_popover",mode:"add"}),R(!0)},virtualMcpId:u?.id??w}),H&&r.jsxs("button",{type:"button",onClick:()=>{V(),se("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),_("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:[r.jsx(Jh,{size:14,className:"shrink-0"}),"Plan mode",r.jsx(Xs,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="gen-image"&&f&&r.jsxs("button",{type:"button",onClick:()=>{V(),se("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),_("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:[r.jsx(ca,{size:14,className:"shrink-0"}),r.jsx("span",{className:"max-w-[120px] truncate",children:v?"Create image":f.title.includes(": ")?f.title.split(": ").slice(1).join(": "):f.title}),r.jsx(Xs,{size:14,className:"shrink-0 hidden group-hover:block"})]}),g==="web-search"&&p&&r.jsxs("button",{type:"button",onClick:()=>{V(),se("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),_("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:[r.jsx(Ti,{size:14,className:"shrink-0"}),r.jsx("span",{className:"max-w-[120px] truncate",children:v?"Web search":p.title.includes(": ")?p.title.split(": ").slice(1).join(": "):p.title}),r.jsx(Xs,{size:14,className:"shrink-0 hidden group-hover:block"})]}),G&&K>0&&r.jsx($p,{usage:Z,totalTokens:K,contextWindow:G,onOpenContextPanel:t})]}),r.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[v?r.jsx(Dv,{tier:x,onSelect:b}):r.jsx(ru,{placeholder:"Model",variant:"borderless",className:"h-8 text-sm py-2 min-w-0"}),A.isSupported&&!i&&!n&&r.jsx(oe,{type:"button",onClick:M,variant:"ghost",size:"icon",className:Y("size-8 rounded-lg transition-colors",A.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:A.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:r.jsx(mg,{size:18})}),r.jsx(oe,{type:X?"button":"submit",onClick:re=>{X&&(re.preventDefault(),re.stopPropagation(),a())},variant:ee||X?"default":"ghost",size:"icon",disabled:!ee&&!X,className:Y("size-8 rounded-lg transition-all",!ee&&!X&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:i?"Stop generating":n?"Cancel run":"Send message (Enter)",children:X?r.jsx(pg,{size:20}):r.jsx(Hh,{size:20})})]})]})})]})},l),e&&r.jsx(kv,{onClick:()=>{se("connections_banner_clicked",{source:"home_chat_input"}),se("connections_dialog_opened",{source:"home_banner",mode:"add"}),R(!0)}})]})}),r.jsx(Ll,{mode:"browse",open:k,onOpenChange:R,defaultTab:"all"}),r.jsx(Hx,{info:T,onClose:N})]})}const Ov={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 qu(t){return`deco-credits-empty-dismissed:${t}`}function $v(t){try{return localStorage.getItem(qu(t))==="1"}catch{return!1}}function zv(){const t=B.c(49),{org:e}=be(),s=Ke(),{decoKeyId:i}=ho();let n;t[0]!==e.id?(n={connectionId:Wt,orgId:e.id},t[0]=e.id,t[1]=n):n=t[1];const o=Me(n),[a,l]=S.useState(!0),[c,d]=S.useState(""),[u,h]=S.useState(!1),[m,f]=S.useState("usd"),p=m==="brl"?"R$":"$";let g;t[2]!==e.id?(g=()=>{se("credits_empty_state_dismissed",{organization_id:e.id}),l(!1);try{localStorage.setItem(qu(e.id),"1")}catch{}},t[2]=e.id,t[3]=g):g=t[3];const _=g;let v,x;t[4]!==a||t[5]!==e.id?(v=()=>{a&&se("credits_empty_state_shown",{organization_id:e.id})},x=[a,e.id],t[4]=a,t[5]=e.id,t[6]=v,t[7]=x):(v=t[6],x=t[7]),S.useEffect(v,x);let b;t[8]!==o||t[9]!==m?(b=async $=>{const U=await o.callTool({name:"AI_PROVIDER_TOPUP_URL",arguments:{providerId:"deco",amountCents:$,currency:m}});if(U?.isError)throw new Error(U.content?.[0]?.text??"Failed to get top-up URL");return U.structuredContent?.url},t[8]=o,t[9]=m,t[10]=b):b=t[10];let y;t[11]!==_?(y=$=>{$&&window.open($,"_blank","noopener,noreferrer"),_()},t[11]=_,t[12]=y):y=t[12];let C;t[13]!==b||t[14]!==y?(C={mutationFn:b,onSuccess:y,onError:Hv},t[13]=b,t[14]=y,t[15]=C):C=t[15];const{mutate:j,isPending:w}=Br(C),V=parseFloat(c),k=!isNaN(V)&&V>=1;if(!a)return null;let R;t[16]!==_?(R=$=>!$&&_(),t[16]=_,t[17]=R):R=t[17];let T;t[18]===Symbol.for("react.memo_cache_sentinel")?(T=r.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[18]=T):T=t[18];let E;t[19]===Symbol.for("react.memo_cache_sentinel")?(E=r.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:r.jsx(pl,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[19]=E):E=t[19];let N;t[20]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[T,r.jsxs(_s,{className:"relative gap-3",children:[E,r.jsxs("div",{className:"text-center",children:[r.jsx(gs,{className:"text-lg font-semibold",children:"This workspace has no credits"}),r.jsx(so,{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[20]=N):N=t[20];let A;t[21]!==m||t[22]!==p||t[23]!==c||t[24]!==V||t[25]!==i||t[26]!==k||t[27]!==w||t[28]!==u||t[29]!==j?(A=i&&r.jsxs("div",{className:"px-6 pb-5",children:[r.jsx("div",{className:"mb-4",children:r.jsxs(tu,{type:"single",variant:"outline",size:"sm",value:m,onValueChange:$=>{$&&f($)},children:[r.jsx(Ln,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),r.jsx(Ln,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),r.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:Ov[m].map($=>{const{dollars:U,label:F}=$;return r.jsxs("button",{type:"button",disabled:w,onClick:()=>{se("credits_topup_clicked",{amount_cents:U*100,currency:m,tier_label:F,source:"empty_state"}),j(U*100)},className:Y("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:[r.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[p,U]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:F})]},U)})}),u?r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:p}),r.jsx(bt,{type:"number",min:"1",step:"1",placeholder:"50",value:c,onChange:$=>d($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),r.jsx(oe,{className:"h-10",disabled:!k||w,onClick:()=>{se("credits_topup_clicked",{amount_cents:Math.round(V*100),currency:m,tier_label:"custom",source:"empty_state"}),j(Math.round(V*100))},children:w?"Opening...":"Add"})]}):r.jsx("button",{type:"button",className:"w-full mt-2.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",onClick:()=>h(!0),children:"Enter custom amount"})]}),t[21]=m,t[22]=p,t[23]=c,t[24]=V,t[25]=i,t[26]=k,t[27]=w,t[28]=u,t[29]=j,t[30]=A):A=t[30];let I;t[31]!==_||t[32]!==s||t[33]!==e.slug?(I=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),_()},t[31]=_,t[32]=s,t[33]=e.slug,t[34]=I):I=t[34];let M;t[35]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(no,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[35]=M):M=t[35];let L;t[36]!==I?(L=r.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:I,children:["Use your own provider",M]}),t[36]=I,t[37]=L):L=t[37];let D;t[38]!==_?(D=r.jsx(oe,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:_,children:"Skip for now"}),t[38]=_,t[39]=D):D=t[39];let P;t[40]!==L||t[41]!==D?(P=r.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[L,D]}),t[40]=L,t[41]=D,t[42]=P):P=t[42];let O;t[43]!==A||t[44]!==P?(O=r.jsxs(ls,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Fv,children:[N,A,P]}),t[43]=A,t[44]=P,t[45]=O):O=t[45];let z;return t[46]!==O||t[47]!==R?(z=r.jsx(cs,{open:!0,onOpenChange:R,children:O}),t[46]=O,t[47]=R,t[48]=z):z=t[48],z}function Fv(t){return t.preventDefault()}function Hv(t){pe.error(`Top-up failed: ${t.message}`)}function Wv(t){const e=B.c(6),{balanceDollars:s}=t;let i;e[0]!==s?(i=s.toFixed(2),e[0]=s,e[1]=i):i=e[1];const n=i;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=Y("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=r.jsx(pl,{size:13,className:"text-emerald-600 dark:text-emerald-400"}),e[2]=o,e[3]=a):(o=e[2],a=e[3]);let l;return e[4]!==n?(l=r.jsxs("div",{className:o,children:[a,r.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",n," in credits to get started"]})]}),e[4]=n,e[5]=l):l=e[5],l}function Uv(){const t=B.c(8),{org:e}=be(),s=Ke();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 n,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=Y("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=r.jsx(ni,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=r.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=n,t[4]=o,t[5]=a):(n=t[3],o=t[4],a=t[5]);let l;return t[6]!==i?(l=r.jsxs("button",{type:"button",onClick:i,className:n,children:[o,a]}),t[6]=i,t[7]=l):l=t[7],l}function Kv(t){const e=B.c(11),{className:s}=t;let i;e[0]!==s?(i=Y("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=i):i=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=n):n=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs("div",{className:"flex items-center gap-3",children:[n,r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),r.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=r.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:r.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),r.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),e[4]=a):a=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[r.jsx(an,{align:"right",width:"w-3/4"}),r.jsx(an,{align:"left",width:"w-full",lines:3}),r.jsx(an,{align:"right",width:"w-2/3"}),r.jsx(an,{align:"left",width:"w-5/6",lines:2})]})}),e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:r.jsx("div",{className:"relative flex-1",children:r.jsxs("div",{className:"space-y-2 p-2",children:[r.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),r.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"px-4 py-4",children:r.jsx("div",{className:"mx-auto w-full max-w-2xl",children:r.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,r.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),r.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=u):u=e[8];let h;return e[9]!==i?(h=r.jsxs("div",{className:i,children:[a,l,u]}),e[9]=i,e[10]=h):h=e[10],h}function an(t){const e=B.c(22),{align:s,width:i,lines:n}=t,o=i===void 0?"w-full":i,a=n===void 0?1:n,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=Y("flex w-full gap-4 px-4 py-2",l),e[0]=l,e[1]=c):c=e[1];const d=s==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let u;e[2]!==d?(u=Y("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=u):u=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=h):h=e[4];const m=s==="right"?"bg-muted":"bg-transparent border border-border/40";let f;e[5]!==m||e[6]!==o?(f=Y("min-w-0 rounded-2xl p-4",m,o),e[5]=m,e[6]=o,e[7]=f):f=e[7];let p;e[8]!==a?(p=Array.from({length:a}),e[8]=a,e[9]=p):p=e[9];let g;e[10]!==a||e[11]!==p?(g=r.jsx("div",{className:"space-y-2",children:p.map((b,y)=>r.jsx("div",{className:Y("h-3 rounded bg-muted-foreground/20 animate-pulse",y===a-1?"w-3/4":"w-full"),style:{animationDelay:`${y*.1}s`}},y))}),e[10]=a,e[11]=p,e[12]=g):g=e[12];let _;e[13]!==g||e[14]!==f?(_=r.jsx("div",{className:f,children:g}),e[13]=g,e[14]=f,e[15]=_):_=e[15];let v;e[16]!==_||e[17]!==u?(v=r.jsxs("div",{className:u,children:[h,_]}),e[16]=_,e[17]=u,e[18]=v):v=e[18];let x;return e[19]!==v||e[20]!==c?(x=r.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=x):x=e[21],x}function qv(t){const e=B.c(5),{className:s,children:i}=t;let n;e[0]!==s?(n=Y("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=n):n=e[1];let o;return e[2]!==i||e[3]!==n?(o=r.jsx("div",{className:n,children:i}),e[2]=i,e[3]=n,e[4]=o):o=e[4],o}function Gv(t){const e=B.c(5),{children:s,className:i}=t;let n;e[0]!==i?(n=Y("flex-1 min-h-0 overflow-y-auto isolate",i),e[0]=i,e[1]=n):n=e[1];let o;return e[2]!==s||e[3]!==n?(o=r.jsx("div",{className:n,children:s}),e[2]=s,e[3]=n,e[4]=o):o=e[4],o}function Yv(t){const e=B.c(2),{children:s}=t;let i;return e[0]!==s?(i=r.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 Xv(){const t=B.c(16),{messages:e,status:s}=Ui(),i=zp(e);let n;t[0]!==i?(n=i.at(-1),t[0]=i,t[1]=n):n=t[1];const o=n,a=s==="submitted"||s==="streaming";let l;if(t[2]!==a||t[3]!==o||t[4]!==i||t[5]!==e||t[6]!==s){const c=e.at(-1),d=!a&&c?.role==="assistant"&&c.parts.filter(Zv).some(Qv),u=!a&&c?.role==="assistant"&&c.parts.some(Jv);let h;if(t[8]!==i||t[9]!==s){let f;t[11]!==i.length||t[12]!==s?(f=(p,g)=>r.jsx(hc,{pair:p,isLastPair:!1,status:g===i.length-1?s:void 0},`pair-${p.user.id}`),t[11]=i.length,t[12]=s,t[13]=f):f=t[13],h=i.slice(0,-1).map(f),t[8]=i,t[9]=s,t[10]=h}else h=t[10];let m;t[14]!==h?(m=r.jsx("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:h}),t[14]=h,t[15]=m):m=t[15],l=r.jsxs("div",{className:"w-full min-w-0 max-w-full overflow-y-auto h-full overflow-x-hidden",children:[m,o&&r.jsx("div",{className:Y("min-h-full min-w-0 max-w-2xl mx-auto w-full",(d||u)&&"pb-60"),children:r.jsx(hc,{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]=l}else l=t[7];return l}function Jv(t){return"state"in t&&t.state==="approval-requested"}function Qv(t){return t.state==="input-available"}function Zv(t){return t.type==="tool-user_ask"}function eb(t){const e=B.c(5),{children:s,className:i}=t;let n;e[0]!==i?(n=Y("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",i),e[0]=i,e[1]=n):n=e[1];let o;return e[2]!==s||e[3]!==n?(o=r.jsx("div",{className:n,children:s}),e[2]=s,e[3]=n,e[4]=o):o=e[4],o}const De=Object.assign(qv,{Main:Gv,Messages:Xv,EmptyState:Yv,Footer:eb,Input:Bv,Provider:Ep,ActiveTaskProvider:Ap,Skeleton:Kv,IceBreakers:ix,NoAiProviderEmptyState:Hg,CreditsEmptyState:zv,CreditsEyebrow:Wv,NoCreditsEyebrow:Uv,CreditsExhaustedBanner:Eu}),tb=`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
5
5
 
@@ -256,7 +256,7 @@ When given a research question or topic:
256
256
  - Identify sources, patterns, gaps, and contradictions
257
257
  - Deliver findings as clear, structured summaries with actionable insights
258
258
 
259
- Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,ob=["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 Uc(t){const e=B.c(7),{onRecruit:s,isRecruiting:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.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]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.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=r.jsxs("div",{className:"space-y-2",children:[o,r.jsx("ul",{className:"space-y-1.5",children:ob.map(ab)})]}),e[2]=a):a=e[2];const l=i?"Setting up...":"Add Web Researcher";let c;return e[3]!==i||e[4]!==s||e[5]!==l?(c=r.jsxs("div",{className:"flex flex-col gap-6",children:[n,a,r.jsx(oe,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:l})]}),e[3]=i,e[4]=s,e[5]=l,e[6]=c):c=e[6],c}function ab(t){return r.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[r.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function lb({open:t,onOpenChange:e,existingAgent:s}){const i=Ds(),n=co(),o=Sl(),[a,l]=S.useState(!1),c=Os.find(m=>m.id==="ai-research"),d=r.jsx(Ms,{icon:c.icon,name:c.title,size:"sm"}),u=async()=>{if(s){e(!1),n(s.id);return}l(!0);try{const m=await o.create.mutateAsync({title:c.title,description:"Systematic research and information synthesis assistant",icon:c.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:nb}});se("agent_recruit_confirmed",{template_id:"ai-research",agent_id:m.id}),e(!1),n(m.id)}catch(m){se("agent_recruit_failed",{template_id:"ai-research",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Researcher agent:",m)}finally{l(!1)}},h=`Add ${c.title}`;return i?r.jsx(Si,{open:t,onOpenChange:e,children:r.jsxs(yi,{className:"h-[70dvh]",children:[r.jsx(io,{className:"px-4 pt-4 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(bi,{className:"text-xl font-semibold",children:h})]})}),r.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:r.jsx(Uc,{onRecruit:u,isRecruiting:a})})]})}):r.jsx(cs,{open:t,onOpenChange:e,children:r.jsxs(ls,{className:"sm:max-w-[500px] p-8",children:[r.jsx(_s,{className:"mb-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(gs,{className:"text-xl font-semibold",children:h})]})}),r.jsx(Uc,{onRecruit:u,isRecruiting:a})]})})}function cb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function tr(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:n}=t,{org:o}=be(),a=Ke();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n.action||e[6]!==n.template_id||e[7]!==n.tile_kind?(l=()=>{if(se("home_agent_tile_clicked",{template_id:n.template_id,agent_id:s.id,agent_title:s.title,tile_kind:n.tile_kind,action:n.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=n.action,e[6]=n.template_id,e[7]=n.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(lo,{size:24}),e[10]=h):h=e[10];let m;e[11]!==s.icon||e[12]!==s.title?(m=r.jsx(Ms,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=m):m=e[13];let f;e[14]!==s.title?(f=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=f):f=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==m||e[19]!==f?(p=r.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[m,f]}),e[16]=c,e[17]=u,e[18]=m,e[19]=f,e[20]=p):p=e[20],p}function db(){const t=B.c(8),e=Ke(),{org:s}=be();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let n;t[1]!==e||t[2]!==s.slug?(n=()=>{se("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=n):n=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Cl,{size:20,className:"text-foreground"})}),a=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:n,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function hb(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=gu(e);let n;t[1]!==s?(n=()=>{se("home_create_agent_clicked"),s()},t[1]=s,t[2]=n):n=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==n?(c=r.jsxs("button",{type:"button",onClick:n,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=n,t[8]=c):c=t[8],c}function ub(){const t=B.c(95),e=ao(),{locator:s}=be(),[i,n]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),h=co();let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=Os.find(_b),t[0]=m):m=t[0];const f=m;let p;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=Os.find(gb),t[1]=p):p=t[1];const g=p;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=Os.find(pb),t[2]=_):_=t[2];const v=_;let x;t[3]===Symbol.for("react.memo_cache_sentinel")?(x=Os.find(mb),t[3]=x):x=t[3];const b=x;let y,C,j,w,V,k,R,T,E,N,A;if(t[4]!==s||t[5]!==h||t[6]!==e){const F=cb(s),G=e.filter(fb).sort((J,le)=>{const Se=F.indexOf(J.id),Ne=F.indexOf(le.id);return Se!==-1&&Ne!==-1?Se-Ne:Se!==-1?-1:Ne!==-1?1:new Date(le.updated_at).getTime()-new Date(J.updated_at).getTime()}).slice(0,4);let W;if(t[18]!==e){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=le=>le.id!==null&&(le.metadata?.type===g.id||le.title===g.title),t[20]=J):J=t[20],W=e.find(J),t[18]=e,t[19]=W}else W=t[19];j=W;let H;if(t[21]!==e){let J;t[23]===Symbol.for("react.memo_cache_sentinel")?(J=le=>le.id!==null&&(le.metadata?.type===v.id||le.title===v.title),t[23]=J):J=t[23],H=e.find(J),t[21]=e,t[22]=H}else H=t[22];y=H;let Z;if(t[24]!==e){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=le=>le.id!==null&&(le.metadata?.type===b.id||le.title===b.title),t[26]=J):J=t[26],Z=e.find(J),t[24]=e,t[25]=Z}else Z=t[25];C=Z,w=G.length>0,V="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",k="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[27]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(tr,{agent:f,onSpecialClick:()=>n(!0),tracking:{template_id:f.id,tile_kind:"template",action:"open_modal"}},f.id),t[27]=R):R=t[27];const q=j??g;let K;t[28]!==j||t[29]!==h?(K=j?()=>h(j.id):()=>a(!0),t[28]=j,t[29]=h,t[30]=K):K=t[30];const te=j?"existing":"template",ee=j?"navigate":"open_modal";let X;t[31]!==te||t[32]!==ee?(X={template_id:g.id,tile_kind:te,action:ee},t[31]=te,t[32]=ee,t[33]=X):X=t[33],t[34]!==q||t[35]!==K||t[36]!==X?(T=r.jsx(tr,{agent:q,onSpecialClick:K,tracking:X},g.id),t[34]=q,t[35]=K,t[36]=X,t[37]=T):T=t[37];const ie=y??v;let re;t[38]!==y||t[39]!==h?(re=y?()=>h(y.id):()=>c(!0),t[38]=y,t[39]=h,t[40]=re):re=t[40];const he=y?"existing":"template",xe=y?"navigate":"open_modal";let ae;t[41]!==he||t[42]!==xe?(ae={template_id:v.id,tile_kind:he,action:xe},t[41]=he,t[42]=xe,t[43]=ae):ae=t[43],t[44]!==ie||t[45]!==re||t[46]!==ae?(E=r.jsx(tr,{agent:ie,onSpecialClick:re,tracking:ae},v.id),t[44]=ie,t[45]=re,t[46]=ae,t[47]=E):E=t[47];const ue=C??b;let me;t[48]!==C||t[49]!==h?(me=C?()=>h(C.id):()=>u(!0),t[48]=C,t[49]=h,t[50]=me):me=t[50];const fe=C?"existing":"template",ce=C?"navigate":"open_modal";let ve;t[51]!==fe||t[52]!==ce?(ve={template_id:b.id,tile_kind:fe,action:ce},t[51]=fe,t[52]=ce,t[53]=ve):ve=t[53],t[54]!==ue||t[55]!==me||t[56]!==ve?(N=r.jsx(tr,{agent:ue,onSpecialClick:me,tracking:ve},b.id),t[54]=ue,t[55]=me,t[56]=ve,t[57]=N):N=t[57];let Ce;t[58]!==y?.id||t[59]!==C?.id||t[60]!==j?.id?(Ce=J=>J.id!==j?.id&&J.id!==y?.id&&J.id!==C?.id,t[58]=y?.id,t[59]=C?.id,t[60]=j?.id,t[61]=Ce):Ce=t[61];let Te;t[62]!==h?(Te=J=>r.jsx(tr,{agent:J,onSpecialClick:()=>h(J.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},J.id??"default"),t[62]=h,t[63]=Te):Te=t[63],A=G.filter(Ce).map(Te),t[4]=s,t[5]=h,t[6]=e,t[7]=y,t[8]=C,t[9]=j,t[10]=w,t[11]=V,t[12]=k,t[13]=R,t[14]=T,t[15]=E,t[16]=N,t[17]=A}else y=t[7],C=t[8],j=t[9],w=t[10],V=t[11],k=t[12],R=t[13],T=t[14],E=t[15],N=t[16],A=t[17];let I;t[64]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(hb,{}),t[64]=I):I=t[64];let M;t[65]!==w?(M=w&&r.jsx(db,{}),t[65]=w,t[66]=M):M=t[66];let L;t[67]!==M||t[68]!==k||t[69]!==R||t[70]!==T||t[71]!==E||t[72]!==N||t[73]!==A?(L=r.jsxs("div",{className:k,children:[R,T,E,N,A,I,M]}),t[67]=M,t[68]=k,t[69]=R,t[70]=T,t[71]=E,t[72]=N,t[73]=A,t[74]=L):L=t[74];let D;t[75]!==V||t[76]!==L?(D=r.jsx("div",{className:V,children:L}),t[75]=V,t[76]=L,t[77]=D):D=t[77];let P;t[78]!==i?(P=r.jsx(Bn,{open:i,onOpenChange:n}),t[78]=i,t[79]=P):P=t[79];let O;t[80]!==o||t[81]!==j?(O=r.jsx(fu,{open:o,onOpenChange:a,existingAgent:j}),t[80]=o,t[81]=j,t[82]=O):O=t[82];let z;t[83]!==l||t[84]!==y?(z=r.jsx(rb,{open:l,onOpenChange:c,existingAgent:y}),t[83]=l,t[84]=y,t[85]=z):z=t[85];let $;t[86]!==d||t[87]!==C?($=r.jsx(lb,{open:d,onOpenChange:u,existingAgent:C}),t[86]=d,t[87]=C,t[88]=$):$=t[88];let U;return t[89]!==D||t[90]!==P||t[91]!==O||t[92]!==z||t[93]!==$?(U=r.jsxs(r.Fragment,{children:[D,P,O,z,$]}),t[89]=D,t[90]=P,t[91]=O,t[92]=z,t[93]=$,t[94]=U):U=t[94],U}function fb(t){return t.id!==null&&!Mn(t.id)}function mb(t){return t.id==="ai-research"}function pb(t){return t.id==="ai-image"}function gb(t){return t.id==="site-diagnostics"}function _b(t){return t.id==="site-editor"}function xb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:r.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(vb)})}),t[0]=e):e=t[0],e}function vb(t,e){return r.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[r.jsx(Bi,{className:"size-12 rounded-xl shrink-0"}),r.jsx(Bi,{className:"h-3 sm:h-4 w-full"})]},e)}function Kc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(S.Suspense,{fallback:r.jsx(xb,{}),children:r.jsx(ub,{})}),t[0]=e):e=t[0],e}function sr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function qc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function bb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function yb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Sb),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=n):n=e[3],n}function Sb(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function wb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:n}=t,o=s+i+n,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?n/o*100:0;let d;e[0]!==a?(d=a>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==u||e[8]!==h?(m=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=m):m=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=f):f=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=r.jsxs("div",{className:"flex items-center gap-1.5",children:[f,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==n?(b=n>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=n,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==m?(C=r.jsxs("div",{className:"flex flex-col gap-2",children:[m,y]}),e[27]=y,e[28]=m,e[29]=C):C=e[29],C}function Vb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,n=ts(i),o=n?.title??"Subtask",a=n?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=r.jsx(Ms,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let m;e[3]!==h?(m=Y("shrink-0 font-medium",h),e[3]=h,e[4]=m):m=e[4];let f;e[5]!==o||e[6]!==m?(f=r.jsx("span",{className:m,children:o}),e[5]=o,e[6]=m,e[7]=f):f=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=r.jsx("span",{className:"ml-auto shrink-0",children:l?r.jsx(Ee,{size:12,className:"animate-spin text-muted-foreground"}):c?r.jsx(Og,{size:12,className:"text-destructive"}):d?r.jsx(ni,{size:12,className:"text-warning"}):r.jsx(x_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==f||e[16]!==p||e[17]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,f,p,g]}),e[14]=u,e[15]=f,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function Cb(t){const e=B.c(58),{onClose:s,back:i,className:n}=t,[o,a]=S.useState(null),{messages:l}=Ui(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=oi();let m,f,p,g,_,v,x,b;if(e[0]!==i||e[1]!==n||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let j;e[17]!==d?(j=X=>X.id===d,e[17]=d,e[18]=j):j=e[18];const w=c.find(j),V=Eh(l),k=[...l].reverse().find(Db),R=k?.metadata?.usage,T=k?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,E=R?.contextTokens??R?.totalTokens??0,N=T&&T>0?(E/T*100).toFixed(1):null,A=l;let I;e[19]!==A?(I=A.filter(Tb).reduce(Rb,0),e[19]=A,e[20]=I):I=e[20];const M=I,L=l;let D;e[21]!==L?(D=L.filter(Ib).reduce(Eb,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,V.totalTokens-M-P),z=l[0],$=l.at(-1),U=z?.metadata?.created_at??w?.created_at,F=$?.metadata?.created_at??w?.updated_at,G=l.filter(Ab),W=l.flatMap(kb),H=u?.modelId?bb(u.modelId):"—",Z=h?.title??"Decopilot",q=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:G.length},{label:"Agent",value:Z},{label:"Model",value:H},{label:"Context Limit",value:T?sr(T):"—"},{label:"Session Tokens (billed)",value:V.totalTokens>0?sr(V.totalTokens):"0"},{label:"Usage",value:N!==null?`${N}%`:"—"},{label:"Input Tokens",value:V.inputTokens>0?sr(V.inputTokens):"0"},{label:"Output Tokens",value:V.outputTokens>0?sr(V.outputTokens):"0"},{label:"Reasoning Tokens",value:V.reasoningTokens>0?sr(V.reasoningTokens):"0"},{label:"Cost",value:V.cost>0?`$${V.cost<.001?V.cost.toFixed(6):V.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:qc(U)},{label:"Last Activity",value:qc(F)}];if(!w&&G.length===0){let X;e[23]!==n?(X=Y("flex flex-col h-full w-full border-l border-border bg-background",n),e[23]=n,e[24]=X):X=e[24];let ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ie):ie=e[25];let re;e[26]!==i?(re=i?r.jsx(la,{size:14,className:"text-muted-foreground"}):r.jsx(ri,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=re):re=e[27];let he;e[28]!==s||e[29]!==re?(he=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:re})]}),e[28]=s,e[29]=re,e[30]=he):he=e[30];let xe;e[31]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=xe):xe=e[31];let ae;e[32]!==X||e[33]!==he?(ae=r.jsxs("div",{className:X,children:[he,xe]}),e[32]=X,e[33]=he,e[34]=ae):ae=e[34],b=ae;break e}e[35]!==n?(v=Y("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",n),e[35]=n,e[36]=v):v=e[36];let K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=K):K=e[37];let te;e[38]!==i?(te=i?r.jsx(la,{size:14}):r.jsx(ri,{size:14}),e[38]=i,e[39]=te):te=e[39],e[40]!==s||e[41]!==te?(x=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,r.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:te})]}),e[40]=s,e[41]=te,e[42]=x):x=e[42],m="flex flex-col gap-8 p-6",f=W.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),r.jsx("div",{className:"flex flex-col gap-1",children:W.map(jb)})]}),p=r.jsx(yb,{items:q});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[ee,r.jsx(wb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=G.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),r.jsx("div",{className:"flex flex-col gap-1",children:G.map(X=>{const ie=X.metadata?.created_at,re=o?.id===X.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(re?null:X),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:Y("shrink-0 font-medium",X.role==="user"?"text-chart-1":"text-chart-2"),children:X.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:X.id})]}),ie&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),re&&r.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(X,null,2)})]},X.id)})})]})}e[0]=i,e[1]=n,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=m,e[10]=f,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else m=e[9],f=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==m||e[49]!==f||e[50]!==p||e[51]!==g||e[52]!==_?(y=r.jsxs("div",{className:m,children:[f,p,g,_]}),e[48]=m,e[49]=f,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=r.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function jb(t,e){return r.jsx(Vb,{part:t},e)}function kb(t){return(t.parts??[]).filter(Nb)}function Nb(t){return t.type==="tool-subtask"}function Ab(t){return t.role!=="system"}function Eb(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Ib(t){return t.role==="assistant"}function Rb(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Tb(t){return t.role==="user"}function Db(t){return t.role==="assistant"&&t.metadata?.usage}function Mb(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Pb(t){const e=B.c(25),{orgId:s,userId:i,connectionId:n,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=n??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const m=Me(h);let f;e[3]!==a||e[4]!==l?(f={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=f):f=e[5];const p=d&&!!n&&!!a&&!!l;let g;e[6]!==m||e[7]!==f||e[8]!==p?(g={client:m,toolName:"list_branches",toolArguments:f,enabled:p,staleTime:3e4,select:$b},e[6]=m,e[7]=f,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=wi(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(Ob),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let j;if(e[14]!==_||e[15]!==y){const R=Array.isArray(_)?_:_?.branches??[];let T;e[17]!==y?(T=E=>!y.has(E.name),e[17]=y,e[18]=T):T=e[18],j=R.filter(Bb).filter(T).map(Lb),e[14]=_,e[15]=y,e[16]=j}else j=e[16];const w=j,V=Array.isArray(_)?null:_?.default_branch??null;let k;return e[19]!==V||e[20]!==x||e[21]!==v||e[22]!==w||e[23]!==C?(k={yours:C,others:w,defaultBase:V,isLoading:v,isError:x},e[19]=V,e[20]=x,e[21]=v,e[22]=w,e[23]=C,e[24]=k):k=e[24],k}function Lb(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Bb(t){return typeof t.name=="string"}function Ob(t){return{name:t,source:"yours"}}function $b(t){return Mb(t)}function zb(t){const e=B.c(36),{orgId:s,userId:i,connectionId:n,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let m;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(m={orgId:s,userId:i,connectionId:n,vmMap:l,owner:o,repo:a,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=m):m=e[7];const{yours:f,others:p,isLoading:g,isError:_}=Pb(m);let v;e[8]!==d?(v=N=>{d(N),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(gr,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=r.jsx(ai,{asChild:!0,children:r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,r.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(c_,{placeholder:"Search branches…"}),e[13]=j):j=e[13];let w;e[14]!==_?(w=_&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[14]=_,e[15]=w):w=e[15];let V;e[16]!==_||e[17]!==g||e[18]!==p.length||e[19]!==f.length?(V=!_&&!g&&f.length===0&&p.length===0&&r.jsx(a_,{children:"No branches found."}),e[16]=_,e[17]=g,e[18]=p.length,e[19]=f.length,e[20]=V):V=e[20];let k;e[21]!==x||e[22]!==f?(k=f.length>0&&r.jsx(Sc,{heading:"Your branches",children:f.map(N=>r.jsxs(wc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name})]},N.name))}),e[21]=x,e[22]=f,e[23]=k):k=e[23];let R;e[24]!==p||e[25]!==x?(R=p.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(l_,{}),r.jsx(Sc,{heading:"Other branches in repo",children:p.map(N=>r.jsxs(wc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name}),N.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",N.author]})]},N.name))})]}),e[24]=p,e[25]=x,e[26]=R):R=e[26];let T;e[27]!==w||e[28]!==V||e[29]!==k||e[30]!==R?(T=r.jsx(li,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(d_,{children:[j,r.jsxs(h_,{children:[w,V,k,R]})]})}),e[27]=w,e[28]=V,e[29]=k,e[30]=R,e[31]=T):T=e[31];let E;return e[32]!==u||e[33]!==T||e[34]!==C?(E=r.jsxs(ci,{open:u,onOpenChange:h,children:[C,T]}),e[32]=u,e[33]=T,e[34]=C,e[35]=E):E=e[35],E}const Fb=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),Hb="/decotexture.svg";function Gc(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:Fb},e[0]=i):i=e[0];let n,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:r.jsx(Ms,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=r.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("img",{src:Hb,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:r.jsx(no,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[n,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function Wb(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=lt.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let n;t[2]!==s||t[3]!==i?(n={queryKey:s,queryFn:Ub,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=n):n=t[4];const{data:o}=Fi(n);return o?.isDecoUser??!1}async function Ub(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function Kb(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[n,o]=S.useState(!1),a=Wb(),l=Ds(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:m}=ho();let f;e[0]!==i?.user?.name?(f=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=f):f=e[1];const p=f,g=c&&u&&h!=null,_=c&&d&&m;if(l){let N;e[2]!==h||e[3]!==g?(N=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=N):N=e[4];let A;e[5]!==_?(A=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[5]=_,e[6]=A):A=e[6];let I;e[7]!==p?(I=r.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=I):I=e[8];let M;e[9]!==N||e[10]!==A||e[11]!==I?(M=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[N,A,I]}),e[9]=N,e[10]=A,e[11]=I,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Kc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=r.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&r.jsx("div",{className:"w-full",children:r.jsx(Gc,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let z;e[22]!==n?(z=r.jsx(Bn,{open:n,onOpenChange:o}),e[22]=n,e[23]=z):z=e[23];let $;return e[24]!==z||e[25]!==O?($=r.jsxs(r.Fragment,{children:[O,z]}),e[24]=z,e[25]=O,e[26]=$):$=e[26],$}let v;e[27]!==h||e[28]!==g?(v=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=r.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=r.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=r.jsx("div",{className:"w-full",children:r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let j;e[40]!==y||e[41]!==C?(j=r.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=j):j=e[42];let w;e[43]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"w-full mt-10 mx-auto",children:r.jsx(Kc,{})}),e[43]=w):w=e[43];let V;e[44]!==j?(V=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[j,w]}),e[44]=j,e[45]=V):V=e[45];let k;e[46]!==a?(k=a&&r.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:r.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:r.jsx(Gc,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=k):k=e[47];let R;e[48]!==k||e[49]!==V?(R=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[V,k]}),e[48]=k,e[49]=V,e[50]=R):R=e[50];let T;e[51]!==n?(T=r.jsx(Bn,{open:n,onOpenChange:o}),e[51]=n,e[52]=T):T=e[52];let E;return e[53]!==R||e[54]!==T?(E=r.jsxs(r.Fragment,{children:[R,T]}),e[53]=R,e[54]=T,e[55]=E):E=e[55],E}function qb(){const t=B.c(26),{org:e}=be(),{selectedVirtualMcp:s}=oi(),{data:i}=St.useSession(),{currentBranch:n,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=ro(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=ts(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,m=!!h?.connectionId&&!!u;let f;t[2]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(lo,{size:32}),t[2]=f):f=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=r.jsx(Ms,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:f,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=r.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=r.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==n||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==m||t[16]!==u?(x=m&&r.jsx("div",{className:"mt-2",children:r.jsx(zb,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:n??void 0,onChange:o})}),t[10]=n,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=m,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"w-full max-w-3xl mx-auto",children:r.jsx(De.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=r.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function Gb(t){const e=B.c(27),{variant:s}=t,{org:i}=be(),n=yl(),{isChatEmpty:o}=Ui(),[a,l]=S.useState("chat"),c=ho();if(n.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(De,{className:"animate-in fade-in-0 duration-200",children:r.jsx(De.Main,{className:"flex flex-col items-center",children:r.jsx(De.EmptyState,{children:r.jsx(De.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!$v(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&r.jsx(De.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const m=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;e[10]!==m?(f=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),e[10]=m,e[11]=f):f=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?r.jsx(Kb,{onOpenContextPanel:()=>l("context")}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(qb,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(De.Messages,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==f||e[16]!==p?(g=r.jsx("div",{className:f,children:p}),e[15]=f,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Cb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=r.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=r.jsxs(De,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function Gu(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(De.Skeleton,{}),e[0]=i):i=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(De.Skeleton,{}),e[1]=n):n=e[1];let o;return e[2]!==s?(o=r.jsx(ks,{fallback:i,children:r.jsx(S.Suspense,{fallback:n,children:r.jsx(Gb,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function Yb(){const t=B.c(6),{org:e,locator:s}=be(),i=Mt();let n;t[0]!==s||t[1]!==i?(n=()=>{i.invalidateQueries({queryKey:lt.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=n):n=t[2];let o;t[3]!==e.id||t[4]!==n?(o={orgId:e.id,onTaskStatus:n},t[3]=e.id,t[4]=n,t[5]=o):o=t[5],b_(o)}function Xb(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:n}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?r.jsx(Jb,{virtualMcpId:s,size:o}):r.jsx(zs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n?(l=n&&r.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:r.jsx($i,{size:10,className:"text-white"})}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function Jb(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,n=ts(s);if(!n){let l;return e[0]!==i?(l=r.jsx(zs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=n.icon??null;let a;return e[2]!==n.title||e[3]!==i||e[4]!==o?(a=r.jsx(zs,{icon:o,name:n.title,size:i}),e[2]=n.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function Qb(t){const e=B.c(42),{task:s,isActive:i,onClick:n,onArchive:o,showAutomationBadge:a}=t,l=Fp(s.status),c=l.icon,d=ts(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,m="button",f=0;let p;e[2]!==n?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),n())},e[2]=n,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=Y("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=r.jsx(Xb,{virtualMcpId:s.virtual_mcp_id,size:"sm",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=r.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate font-mono",children:s.branch}),r.jsx("span",{className:"shrink-0",children:"·"})]}):h?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),r.jsx("span",{className:"shrink-0",children:"·"})]}):null,r.jsx("span",{className:"shrink-0",children:Hp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const j="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",w="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",V=l.label,k=14,R=Y(l.iconClassName,s.status==="in_progress"&&"animate-spin");let T;e[18]!==c||e[19]!==R?(T=r.jsx(c,{size:k,className:R}),e[18]=c,e[19]=R,e[20]=T):T=e[20];let E;e[21]!==l||e[22]!==T?(E=r.jsx("span",{className:w,"aria-label":V,children:T}),e[21]=l,e[22]=T,e[23]=E):E=e[23];let N;e[24]!==o?(N=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=N):N=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(_g,{size:14}),e[26]=A):A=e[26];let I;e[27]!==N?(I=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Archive task",onClick:N,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:A})}),e[27]=N,e[28]=I):I=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(st,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==I?(L=r.jsxs(it,{children:[I,M]}),e[30]=I,e[31]=L):L=e[31];let D;e[32]!==E||e[33]!==L?(D=r.jsxs("div",{className:j,children:[E,L]}),e[32]=E,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==n||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=r.jsxs("div",{role:m,tabIndex:f,onClick:n,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=n,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const Yu={all:"All tasks",manual:"Chats",automation:"Automation"},Xu={all:"All members",mine:"Mine only"};function Zb(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:n,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[m,f]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(G=>G.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==m||e[5]!==v?(x=m==="automation"?v.filter(i0):m==="manual"?v.filter(s0):v,e[4]=m,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=r.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=r.jsx(As,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?r.jsx(xg,{size:16}):r.jsx(lo,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let j;e[11]!==p?(j=G=>{const W=G;W!==p&&se("tasks_panel_member_filter_changed",{to_value:W}),g(W)},e[11]=p,e[12]=j):j=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=Object.keys(Xu),e[13]=w):w=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=w.map(t0),e[14]=V):V=e[14];let k;e[15]!==p||e[16]!==j?(k=r.jsx(Es,{align:"end",children:r.jsx(uc,{value:p,onValueChange:j,children:V})}),e[15]=p,e[16]=j,e[17]=k):k=e[17];let R;e[18]!==C||e[19]!==k?(R=r.jsxs(Ns,{children:[C,k]}),e[18]=C,e[19]=k,e[20]=R):R=e[20];const T=m!=="all"&&"text-purple-500";let E;e[21]!==T?(E=Y("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",T),e[21]=T,e[22]=E):E=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx($g,{size:16}),e[23]=N):N=e[23];let A;e[24]!==E?(A=r.jsx(As,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter tasks",className:E,children:N})}),e[24]=E,e[25]=A):A=e[25];let I;e[26]!==m?(I=G=>{const W=G;W!==m&&se("tasks_panel_filter_changed",{to_value:W}),f(W)},e[26]=m,e[27]=I):I=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(Yu),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(e0),e[29]=L):L=e[29];let D;e[30]!==m||e[31]!==I?(D=r.jsx(Es,{align:"end",children:r.jsx(uc,{value:m,onValueChange:I,children:L})}),e[30]=m,e[31]=I,e[32]=D):D=e[32];let P;e[33]!==A||e[34]!==D?(P=r.jsxs(Ns,{children:[A,D]}),e[33]=A,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&r.jsx("button",{type:"button",onClick:()=>{se("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:r.jsx(gl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let z;e[40]!==P||e[41]!==O||e[42]!==R?(z=r.jsxs("div",{className:"flex items-center gap-0.5",children:[R,P,O]}),e[40]=P,e[41]=O,e[42]=R,e[43]=z):z=e[43];let $;e[44]!==z||e[45]!==y?($=r.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,z]}),e[44]=z,e[45]=y,e[46]=$):$=e[46];let U;e[47]!==n||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(U=b.length===0&&u?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(G=>r.jsx(Qb,{task:G,isActive:n===G.id,onClick:()=>{n!==G.id&&se("tasks_panel_task_clicked",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null,from_automation:!!G.fromAutomation}),o(G)},onArchive:()=>{se("tasks_panel_task_archived",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null}),a(G)},showAutomationBadge:d||G.fromAutomation},G.id)),e[47]=n,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=U):U=e[53];let F;return e[54]!==$||e[55]!==U?(F=r.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[$,U]}),e[54]=$,e[55]=U,e[56]=F):F=e[56],F}function e0(t){return r.jsx(Oh,{value:t,children:Yu[t]},t)}function t0(t){return r.jsx(Oh,{value:t,children:Xu[t]},t)}function s0(t){return!t.fromAutomation}function i0(t){return t.fromAutomation}function r0(){const t=B.c(22);Yb();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:n}=ra(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=ra(o),{setTaskId:l,createNewTask:c}=zr();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=$r(d),{locator:h,org:m}=be(),f=Mt();let p;t[3]!==m.id?(p={connectionId:Wt,orgId:m.id},t[3]=m.id,t[4]=p):p=t[4];const g=Me(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==n?(v=[...n,...a.map(o0)].sort(n0),t[5]=a,t[6]=n,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==f?(b=async w=>{try{await Ip(g,w.id,{hidden:!0}),f.invalidateQueries({queryKey:lt.tasksPrefix(h)})}catch(V){const R=V;pe.error(`Failed to archive task: ${R.message}`)}},t[8]=g,t[9]=h,t[10]=f,t[11]=b):b=t[11];const y=b;if(x.length===0){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"h-full flex items-center justify-center p-4",children:r.jsx(Oi,{image:r.jsx(vg,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=w):w=t[12],w}let C;t[13]!==l?(C=w=>l(w.id,w.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let j;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(j=r.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:r.jsx(Zb,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=j):j=t[21],j}function n0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function o0(t){return{...t,fromAutomation:!0}}function a0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(l0)}),t[0]=e):e=t[0],e}function l0(t,e){return r.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function Ju(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(De.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ks,{fallback:e,children:r.jsx(S.Suspense,{fallback:r.jsx(a0,{}),children:r.jsx(r0,{})})}),t[1]=s):s=t[1],s}function Qu(){const t=B.c(77),{org:e}=be(),s=Ke(),i=Vh(),{setTasksOpen:n,openTab:o}=zr(),a=e.slug,l=be().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=$r(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=vi(u),m=i.location.pathname;let f;t[2]!==l.enabledPlugins?(f=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=f):f=t[3];const p=f;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let W;t[17]!==p?(W=ie=>p.includes(ie.pluginId),t[17]=p,t[18]=W):W=t[18];const H=tp.filter(W),Z=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const q=d.taskId??"",K=d.pluginId;let te;t[19]!==K?(te=ie=>K===ie,t[19]=K,t[20]=te):te=t[20],v=te;let ee;t[21]!==q||t[22]!==s||t[23]!==a||t[24]!==Z?(ee=ie=>{const re=q||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:re,pluginId:ie},search:he=>({...he,virtualmcpid:Z})})},t[21]=q,t[22]=s,t[23]=a,t[24]=Z,t[25]=ee):ee=t[25],b=ee;let X;t[26]!==v||t[27]!==b?(X=ie=>({key:ie.pluginId,label:ie.label,icon:ie.icon,isActive:v(ie.pluginId),onClick:()=>b(ie.pluginId)}),t[26]=v,t[27]=b,t[28]=X):X=t[28],y=H.map(X),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let j;if(t[29]!==p||t[30]!==v||t[31]!==b){let W;t[33]!==p?(W=q=>p.includes(q.pluginId),t[33]=p,t[34]=W):W=t[34];const H=sp.filter(W);let Z;t[35]!==v||t[36]!==b?(Z=q=>({type:"group",group:{id:`${q.pluginId}-${q.id}`,label:q.label,items:q.items.map((K,te)=>({key:`${q.pluginId}-${q.id}-${te}`,label:K.label,icon:K.icon,isActive:v(q.pluginId),onClick:()=>b(q.pluginId)})),defaultExpanded:q.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=Z):Z=t[37],j=H.map(Z),t[29]=p,t[30]=v,t[31]=b,t[32]=j}else j=t[32];const w=j;let V;if(t[38]!==o||t[39]!==_){let W;t[41]!==o?(W=H=>{const Z=Fr(H.icon),q=Z.type==="icon"?Hr(Z.name):null;return{key:`app-${H.connectionId}-${H.toolName}`,label:H.label||H.toolName,icon:q?r.jsx(q,{size:16,className:"text-muted-foreground"}):Z.type==="url"?r.jsx("img",{src:Z.url,alt:"",className:"size-4 rounded"}):r.jsx(_u,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(na(H.connectionId,H.toolName))}},t[41]=o,t[42]=W):W=t[42],V=_.map(W),t[38]=o,t[39]=_,t[40]=V}else V=t[40];const k=V;let R;t[43]!==k?(R=k.length>0?{type:"group",group:{id:"apps",label:"Apps",items:k,defaultExpanded:!0}}:null,t[43]=k,t[44]=R):R=t[44];const T=R;let E;t[45]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(bg,{className:"size-4!"}),t[45]=E):E=t[45];const N=m===`/${a}`||m===`/${a}/`;let A;t[46]!==s||t[47]!==a||t[48]!==n?(A=()=>{n(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=n,t[49]=A):A=t[49];let I;t[50]!==A||t[51]!==N?(I={key:"home",label:"Home",icon:E,isActive:N,onClick:A},t[50]=A,t[51]=N,t[52]=I):I=t[52];const M=I;let L;t[53]!==p?(L=p.includes(ip),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(rp,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==m?(O=m.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=m,t[58]=O):O=t[58];let z;t[59]!==s||t[60]!==a?(z=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=z):z=t[61];let $;t[62]!==O||t[63]!==z?($={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:z},t[62]=O,t[63]=z,t[64]=$):$=t[64];const U=$;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==U){const W=[M];x&&D&&W.push(U),F={type:"items",items:W},t[65]=M,t[66]=x,t[67]=D,t[68]=U,t[69]=F}else F=t[69];let G;if(t[70]!==T||t[71]!==w||t[72]!==C||t[73]!==F){if(G=[F],C.length>0){let W;t[75]!==C?(W={type:"items",items:C},t[75]=C,t[76]=W):W=t[76],G.push(W)}w.length>0&&G.push(...w),T&&G.push(T),t[70]=T,t[71]=w,t[72]=C,t[73]=F,t[74]=G}else G=t[74];return G}function Zu(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex h-6 items-center",children:r.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsxs(Ur,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,r.jsx(Kr,{children:r.jsx(xs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=n):n=e[2],n}function c0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(bu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function ef(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:n}=qr();let o;e[0]!==i||e[1]!==s||e[2]!==n?(o=()=>{se("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&n(!1)},e[0]=i,e[1]=s,e[2]=n,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=Y(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=r.jsx(ms,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=r.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function d0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(xu,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,n=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(u0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=r.jsx(Zu,{label:i,defaultExpanded:n,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(h0),e[8]=s.items,e[9]=i):i=e[9];let n;return e[10]!==i?(n=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(xs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=n):n=e[11],n}}}function h0(t){return r.jsx(ef,{item:t},t.key)}function u0(t){return r.jsx(ef,{item:t},t.key)}function f0(t){const e=B.c(14),{sections:s,header:i,footer:n,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(c0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=Y("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(m0),e[3]=s,e[4]=h):h=e[4];let m;e[5]!==o||e[6]!==u||e[7]!==h?(m=r.jsxs(vu,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=m):m=e[8];let f;return e[9]!==n||e[10]!==i||e[11]!==m||e[12]!==c?(f=r.jsxs(y_,{variant:c,children:[d,i,m,n]}),e[9]=n,e[10]=i,e[11]=m,e[12]=c,e[13]=f):f=e[13],f}function m0(t,e){return r.jsx(d0,{section:t},e)}function tf(t){const e=B.c(2);let s;return e[0]!==t?(s=r.jsx(f0,{...t}),e[0]=t,e[1]=s):s=e[1],s}tf.Skeleton=function(){return r.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>r.jsx("div",{className:"w-full h-8",children:r.jsx(Bi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function p0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(bu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function Yc(t){const e=B.c(15),{item:s,onClose:i}=t,n=s.isActive&&"z-10";let o;e[0]!==n?(o=Y(n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=r.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=r.jsx(ms,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=r.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function g0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(xu,{className:"my-2"}),e[0]=n):n=e[0],n}case"spacer":{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"flex-1"}),e[1]=n):n=e[1],n}case"group":{const n=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>r.jsx(Yc,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=r.jsx(Zu,{label:n,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let n;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>r.jsx(Yc,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],n=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=n}else n=e[13];let o;return e[16]!==n?(o=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(xs,{className:"gap-1.5",children:n})})}),e[16]=n,e[17]=o):o=e[17],o}}}function _0(t){const e=B.c(12),{sections:s,onClose:i,footer:n,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(p0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,m)=>r.jsx(g0,{section:h,onClose:i},m),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=r.jsxs(vu,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==n||e[10]!==c?(d=r.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,n]}),e[9]=n,e[10]=c,e[11]=d):d=e[11],d}function sf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const x0=js({name:Et().min(2,"Organization name is required")});function v0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={resolver:Or(x0),defaultValues:{name:""}},e[0]=n):n=e[0];const o=Hi(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:y0,onSuccess:b0},e[1]=a):a=e[1];const l=Br(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs(Nl,{children:[r.jsx(Al,{children:"Create a new organization"}),r.jsx(El,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let w;e[6]!==l?(w=V=>l.mutateAsync(V),e[6]=l,e[7]=w):w=e[7],u=o.handleSubmit(w),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=w=>{const{field:V}=w;return r.jsxs(Rt,{children:[r.jsx(rs,{children:"Organization Name"}),r.jsx(Tt,{children:r.jsx(bt,{...V,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),r.jsx(ug,{children:"The name of your company or organization"}),V.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",sf(V.value)]})]}),r.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let m;e[10]!==o.control||e[11]!==h?(m=r.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=m):m=e[12];let f;e[13]!==c?(f=c&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=f):f=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=r.jsx(jl,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=r.jsx(oe,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=r.jsxs(Il,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==m||e[32]!==f?(y=r.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[m,f,b]}),e[29]=b,e[30]=u,e[31]=m,e[32]=f,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=r.jsxs(kl,{children:[d,r.jsx(Pi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let j;return e[37]!==i||e[38]!==s||e[39]!==C?(j=r.jsx(Rl,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=j):j=e[40],j}function b0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function y0(t){const e=sf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function _a(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function S0(t){const e=B.c(13),{org:s,size:i}=t,n=i===void 0?"sm":i,o=n==="xs"?"size-5":"size-6",a=n==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=Y(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:_a(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?r.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:Y("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ln(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=r.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let m;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(m=r.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=m):m=e[10],m}let n;e[11]!==s||e[12]!==i?(n=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=n):n=e[13];let o;e[14]!==s.icon?(o=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=r.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==n||e[19]!==o||e[20]!==a?(l=r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=n,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function Xc(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:n,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,r.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==n||e[5]!==i||e[6]!==s){let m;e[8]!==n||e[9]!==i?(m=f=>r.jsxs("button",{type:"button",onClick:()=>n(f.slug),className:Y("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",f.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[r.jsx(S0,{org:f,size:"sm"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:f.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:f.slug})]}),f.slug===i&&r.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},f.id),e[8]=n,e[9]=i,e[10]=m):m=e[10],d=s.map(m),e[4]=n,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=r.jsxs(r.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function Jc(t){const e=B.c(142),{user:s,userImage:i,menuItems:n,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:m,close:f,isMobile:p}=t;if(p){const q=s?.name??"U";let K;e[0]!==q||e[1]!==i?(K=r.jsx(Cc,{url:i,fallback:q,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=q,e[1]=i,e[2]=K):K=e[2];const te=s?.name??"User";let ee;e[3]!==te?(ee=r.jsx("p",{className:"text-sm font-medium truncate",children:te}),e[3]=te,e[4]=ee):ee=e[4];const X=s?.email;let ie;e[5]!==X?(ie=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:X}),e[5]=X,e[6]=ie):ie=e[6];let re;e[7]!==ee||e[8]!==ie?(re=r.jsxs("div",{className:"flex-1 min-w-0",children:[ee,ie]}),e[7]=ee,e[8]=ie,e[9]=re):re=e[9];let he;e[10]!==s?(he=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(j0)},e[10]=s,e[11]=he):he=e[11];let xe;e[12]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(Li,{size:14}),e[12]=xe):xe=e[12];let ae;e[13]!==he?(ae=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:he,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:xe})}),e[13]=he,e[14]=ae):ae=e[14];let ue;e[15]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=ue):ue=e[15];let me;e[16]!==ae?(me=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[ae,ue]})}),e[16]=ae,e[17]=me):me=e[17];let fe;e[18]!==me||e[19]!==K||e[20]!==re?(fe=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[K,re,me]}),e[18]=me,e[19]=K,e[20]=re,e[21]=fe):fe=e[21];let ce;e[22]!==m||e[23]!==h||e[24]!==u||e[25]!==d?(ce=r.jsx("div",{className:"border-b border-border pb-2",children:r.jsx(Xc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:m})}),e[22]=m,e[23]=h,e[24]=u,e[25]=d,e[26]=ce):ce=e[26];let ve;if(e[27]!==f||e[28]!==n){let Pe;e[30]!==f?(Pe=Kt=>r.jsx(ln,{item:Kt,onClose:f},Kt.key),e[30]=f,e[31]=Pe):Pe=e[31],ve=n.map(Pe),e[27]=f,e[28]=n,e[29]=ve}else ve=e[29];let Ce;e[32]!==f||e[33]!==o?(Ce=r.jsx(ln,{item:o,onClose:f}),e[32]=f,e[33]=o,e[34]=Ce):Ce=e[34];let Te;e[35]!==ve||e[36]!==Ce?(Te=r.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ce]}),e[35]=ve,e[36]=Ce,e[37]=Te):Te=e[37];let J;e[38]!==ce||e[39]!==Te?(J=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[ce,Te]}),e[38]=ce,e[39]=Te,e[40]=J):J=e[40];let le;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let Pe;e[45]!==l.theme||e[46]!==c?(Pe=Kt=>{const{value:jt,icon:Ae,label:Ie}=Kt;return r.jsx("button",{type:"button","aria-label":Ie,onClick:()=>c(qe=>({...qe,theme:jt})),className:Y("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===jt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Ae},jt)},e[45]=l.theme,e[46]=c,e[47]=Pe):Pe=e[47],le=a.map(Pe),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=le}else le=e[44];let Se;e[48]!==le?(Se=r.jsx("div",{className:"flex items-center gap-0.5",children:le}),e[48]=le,e[49]=Se):Se=e[49];const Ne=l.enableSounds?"Disable sounds":"Enable sounds";let Be;e[50]!==c?(Be=()=>c(C0),e[50]=c,e[51]=Be):Be=e[51];const Oe=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let He;e[52]!==Oe?(He=Y("size-8 rounded-md flex items-center justify-center transition-colors",Oe),e[52]=Oe,e[53]=He):He=e[53];let Je;e[54]!==l.enableSounds?(Je=l.enableSounds?r.jsx(fc,{size:14}):r.jsx(mc,{size:14}),e[54]=l.enableSounds,e[55]=Je):Je=e[55];let dt;e[56]!==Ne||e[57]!==Be||e[58]!==He||e[59]!==Je?(dt=r.jsx("button",{type:"button","aria-label":Ne,onClick:Be,className:He,children:Je}),e[56]=Ne,e[57]=Be,e[58]=He,e[59]=Je,e[60]=dt):dt=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.279.0"]}),e[61]=ge):ge=e[61];let ke;e[62]!==dt?(ke=r.jsxs("div",{className:"flex items-center gap-2",children:[dt,ge]}),e[62]=dt,e[63]=ke):ke=e[63];let Qe;e[64]!==Se||e[65]!==ke?(Qe=r.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Se,ke]}),e[64]=Se,e[65]=ke,e[66]=Qe):Qe=e[66];let Ct;return e[67]!==fe||e[68]!==J||e[69]!==Qe?(Ct=r.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[fe,J,Qe]}),e[67]=fe,e[68]=J,e[69]=Qe,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=r.jsx(Cc,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=r.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let j;e[81]!==s?(j=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(V0)},e[81]=s,e[82]=j):j=e[82];let w;e[83]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Li,{size:14}),e[83]=w):w=e[83];let V;e[84]!==j?(V=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:j,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:w})}),e[84]=j,e[85]=V):V=e[85];let k;e[86]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=k):k=e[86];let R;e[87]!==V?(R=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[V,k]})}),e[87]=V,e[88]=R):R=e[88];let T;e[89]!==R||e[90]!==_||e[91]!==C?(T=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,R]}),e[89]=R,e[90]=_,e[91]=C,e[92]=T):T=e[92];let E;if(e[93]!==f||e[94]!==n){let q;e[96]!==f?(q=K=>r.jsx(ln,{item:K,onClose:f},K.key),e[96]=f,e[97]=q):q=e[97],E=n.map(q),e[93]=f,e[94]=n,e[95]=E}else E=e[95];let N;e[98]!==f||e[99]!==o?(N=r.jsx(ln,{item:o,onClose:f}),e[98]=f,e[99]=o,e[100]=N):N=e[100];let A;e[101]!==E||e[102]!==N?(A=r.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[E,N]}),e[101]=E,e[102]=N,e[103]=A):A=e[103];let I;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let q;e[108]!==l.theme||e[109]!==c?(q=K=>{const{value:te,icon:ee,label:X}=K;return r.jsx("button",{type:"button","aria-label":X,onClick:()=>c(ie=>({...ie,theme:te})),className:Y("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===te?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:ee},te)},e[108]=l.theme,e[109]=c,e[110]=q):q=e[110],I=a.map(q),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=I}else I=e[107];let M;e[111]!==I?(M=r.jsx("div",{className:"flex items-center gap-0.5",children:I}),e[111]=I,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(w0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=Y("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let z;e[117]!==l.enableSounds?(z=l.enableSounds?r.jsx(fc,{size:14}):r.jsx(mc,{size:14}),e[117]=l.enableSounds,e[118]=z):z=e[118];let $;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==z?($=r.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:z}),e[119]=L,e[120]=D,e[121]=O,e[122]=z,e[123]=$):$=e[123];let U;e[124]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.279.0"]}),e[124]=U):U=e[124];let F;e[125]!==$?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[$,U]}),e[125]=$,e[126]=F):F=e[126];let G;e[127]!==M||e[128]!==F?(G=r.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=G):G=e[129];let W;e[130]!==T||e[131]!==A||e[132]!==G?(W=r.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[T,A,G]}),e[130]=T,e[131]=A,e[132]=G,e[133]=W):W=e[133];let H;e[134]!==m||e[135]!==h||e[136]!==u||e[137]!==d?(H=r.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:r.jsx(Xc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:m})}),e[134]=m,e[135]=h,e[136]=u,e[137]=d,e[138]=H):H=e[138];let Z;return e[139]!==W||e[140]!==H?(Z=r.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[W,H]}),e[139]=W,e[140]=H,e[141]=Z):Z=e[141],Z}function w0(t){return{...t,enableSounds:!t.enableSounds}}function V0(){pe.success("User ID copied")}function C0(t){return{...t,enableSounds:!t.enableSounds}}function j0(){pe.success("User ID copied")}function rf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=Ke();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org",shouldThrow:!1},t[0]=n):n=t[0];const a=np(n)?.params.org,[l,c]=Wi(),d=Ds(),[u,h]=S.useState(!1),[m,f]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(Z=>Z.slug===a);let y;if(t[11]!==a||t[12]!==s){let Z;t[14]!==a?(Z=(q,K)=>q.slug===a?-1:K.slug===a?1:q.name.localeCompare(K.name),t[14]=a,t[15]=Z):Z=t[15],y=[...s??[]].sort(Z),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let j;t[16]!==i?(j=Z=>{h(!1),i({to:"/$org",params:{org:Z}})},t[16]=i,t[17]=j):j=t[17];const w=j;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>h(!1),t[18]=V):V=t[18];const k=V;let R;t[19]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Gr,{size:16}),t[19]=R):R=t[19];let T;t[20]!==i||t[21]!==a?(T={key:"preferences",label:"Preferences",icon:R,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=T):T=t[22];let E;t[23]===Symbol.for("react.memo_cache_sentinel")?(E={key:"terms",label:"Terms of Use",icon:r.jsx(yg,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=E):E=t[23];let N;t[24]===Symbol.for("react.memo_cache_sentinel")?(N={key:"privacy",label:"Privacy Policy",icon:r.jsx(Sg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=N):N=t[24];let A;t[25]===Symbol.for("react.memo_cache_sentinel")?(A={key:"github",label:"decocms/studio",icon:r.jsx(op,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=A):A=t[25];let I;t[26]===Symbol.for("react.memo_cache_sentinel")?(I={key:"community",label:"Community",icon:r.jsx(lo,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=I):I=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:r.jsx(eu,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==T?(L=[T,E,N,A,I,M],t[28]=T,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:r.jsx(Rg,{size:16}),onClick:N0},t[30]=P):P=t[30];const O=P;let z;t[31]===Symbol.for("react.memo_cache_sentinel")?(z={value:"light",icon:r.jsx(N_,{size:14}),label:"Light theme"},t[31]=z):z=t[31];let $;t[32]===Symbol.for("react.memo_cache_sentinel")?($={value:"dark",icon:r.jsx(A_,{size:14}),label:"Dark theme"},t[32]=$):$=t[32];let U;t[33]===Symbol.for("react.memo_cache_sentinel")?(U=[z,$,{value:"system",icon:r.jsx(E_,{size:14}),label:"System theme"}],t[33]=U):U=t[33];const F=U;let G;t[34]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{h(!1),f(!0)},t[34]=G):G=t[34];let W;t[35]!==w||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(W={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:w,onCreateOrg:G,close:k,isMobile:d},t[35]=w,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=W):W=t[44];const H=W;_=d?r.jsxs(Si,{open:u,onOpenChange:h,direction:"bottom",children:[r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[r.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:_a(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),r.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),r.jsxs(yi,{className:"h-[80dvh] p-0",children:[r.jsx(bi,{className:"sr-only",children:"Account"}),r.jsx(Jc,{...H})]})]}):r.jsxs(ci,{open:u,onOpenChange:h,children:[r.jsx(ai,{asChild:!0,children:r.jsx(ms,{tooltip:b?.name??"Account",className:"rounded-md",children:r.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:_a(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),r.jsx(li,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:k0,children:r.jsx(Jc,{...H})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==m?(v=r.jsx(v0,{open:m,onOpenChange:f}),t[45]=m,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=r.jsxs(r.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function k0(t){return t.preventDefault()}function N0(){se("signed_out",{source:"account_popover"}),St.signOut()}function A0({invitation:t}){const[e,s]=S.useState(!1),[i,n]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)pe.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});pe.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{pe.error("Failed to accept invitation"),s(!1)}},l=async()=>{n(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(pe.error(c.error.message),n(!1)):(pe.success("Invitation declined"),o.invalidateQueries())}catch{pe.error("Failed to decline invitation"),n(!1)}};return r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),r.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:r.jsx(Jt,{size:14})}),r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:r.jsx(ri,{size:14})})]})]})}function E0(){const t=S.useContext(ap),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class I0 extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function R0(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function T0(){const t=B.c(19),e=Ke(),{org:s}=be();let i;t[0]!==s.id?(i={connectionId:Wt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const n=Me(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==n?(a={client:n,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:D0},t[3]=n,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=wi(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const m=h;let f;t[9]!==u?(f=Y(u!=null&&R0(u)),t[9]=u,t[10]=f):f=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(pl,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==f||t[16]!==p||t[17]!==m?(_=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ms,{tooltip:m,className:f,onClick:p,children:g})})}),t[15]=f,t[16]=p,t[17]=m,t[18]=_):_=t[18],_}function D0(t){return t.structuredContent}function M0(){const t=B.c(1);if(!yl().some(P0))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(T0,{}),t[0]=i):i=t[0],i}function P0(t){return t.providerId==="deco"}function L0(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ms,{tooltip:"Connections",onClick:()=>{se("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:r.jsx(Tg,{size:24})})})}),t[0]=i):i=t[0];let n;return t[1]!==e?(n=r.jsxs(r.Fragment,{children:[i,r.jsx(Ll,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=n):n=t[2],n}function B0(){const t=B.c(11),e=E0();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(pc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&r.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let n;t[3]!==i?(n=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ai,{asChild:!0,children:r.jsxs(ms,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=n):n=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:r.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=r.jsxs(li,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(pc,{size:24,className:"text-muted-foreground/50"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):r.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(O0)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==n||t[9]!==a?(l=r.jsxs(ci,{children:[n,a]}),t[8]=n,t[9]=a,t[10]=l):l=t[10],l}function O0(t){return r.jsx(A0,{invitation:t},t.id)}function $0(){const t=B.c(6),e=Ke(),{org:s}=be();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Gr,{size:24}),t[3]=n):n=t[3];let o;return t[4]!==i?(o=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ms,{tooltip:"Settings",onClick:i,children:n})})}),t[4]=i,t[5]=o):o=t[5],o}function z0(){const t=B.c(5);let e,s,i,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(I0,{children:r.jsx(S.Suspense,{fallback:null,children:r.jsx(M0,{})})}),s=r.jsx(L0,{}),i=r.jsx(B0,{}),n=r.jsx($0,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=n):(e=t[0],s=t[1],i=t[2],n=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs(yu,{className:"px-2 pb-3 gap-1",children:[e,s,i,n,r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(rf,{})})})]}),t[4]=o):o=t[4],o}function F0(){const t=B.c(10),e=Ke(),{org:s}=be(),{setOpenMobile:i}=qr();let n;t[0]!==e||t[1]!==s.slug||t[2]!==i?(n=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=n):n=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Gr,{}),t[4]=o):o=t[4];let a;t[5]!==n?(a=r.jsx(Zt,{children:r.jsx(ms,{tooltip:"Settings",onClick:n,children:o})}),t[5]=n,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zt,{children:r.jsx(rf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=r.jsx(yu,{children:r.jsxs(xs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function H0(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(n=>n(i))},e)}const fo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ki(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Bl(t){return"nodeType"in t}function Ut(t){var e,s;return t?Ki(t)?t:Bl(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Ol(t){const{Document:e}=Ut(t);return t instanceof e}function Xr(t){return Ki(t)?!1:t instanceof Ut(t).HTMLElement}function nf(t){return t instanceof Ut(t).SVGElement}function qi(t){return t?Ki(t)?t.document:Bl(t)?Ol(t)?t:Xr(t)||nf(t)?t.ownerDocument:document:document:document}const Rs=fo?S.useLayoutEffect:S.useEffect;function $l(t){const e=S.useRef(t);return Rs(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}function W0(){const t=S.useRef(null),e=S.useCallback((i,n)=>{t.current=setInterval(i,n)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Er(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Rs(()=>{s.current!==t&&(s.current=t)},e),s}function Jr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Hn(t){const e=$l(t),s=S.useRef(null),i=S.useCallback(n=>{n!==s.current&&e?.(n,s.current),s.current=n},[]);return[s,i]}function xa(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let To={};function Qr(t,e){return S.useMemo(()=>{if(e)return e;const s=To[t]==null?0:To[t]+1;return To[t]=s,t+"-"+s},[t,e])}function of(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Di=of(1),Ir=of(-1);function U0(t){return"clientX"in t&&"clientY"in t}function zl(t){if(!t)return!1;const{KeyboardEvent:e}=Ut(t.target);return e&&t instanceof e}function K0(t){if(!t)return!1;const{TouchEvent:e}=Ut(t.target);return e&&t instanceof e}function va(t){if(K0(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return U0(t)?{x:t.clientX,y:t.clientY}:null}const Rr=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Rr.Translate.toString(t),Rr.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),Qc="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function q0(t){return t.matches(Qc)?t:t.querySelector(Qc)}const G0={display:"none"};function Y0(t){let{id:e,value:s}=t;return Ft.createElement("div",{id:e,style:G0},s)}function X0(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const n={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ft.createElement("div",{id:e,style:n,role:"status","aria-live":i,"aria-atomic":!0},s)}function J0(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const af=S.createContext(null);function Q0(t){const e=S.useContext(af);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Z0(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:n,event:o}=i;t.forEach(a=>{var l;return(l=a[n])==null?void 0:l.call(a,o)})},[t]),e]}const ey={draggable:`
259
+ Approach every request with rigor and intellectual honesty. Always surface what is uncertain or debated, not just what is known.`,ob=["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 Uc(t){const e=B.c(7),{onRecruit:s,isRecruiting:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.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]=n):n=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=r.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=r.jsxs("div",{className:"space-y-2",children:[o,r.jsx("ul",{className:"space-y-1.5",children:ob.map(ab)})]}),e[2]=a):a=e[2];const l=i?"Setting up...":"Add Web Researcher";let c;return e[3]!==i||e[4]!==s||e[5]!==l?(c=r.jsxs("div",{className:"flex flex-col gap-6",children:[n,a,r.jsx(oe,{onClick:s,disabled:i,className:"w-full cursor-pointer",children:l})]}),e[3]=i,e[4]=s,e[5]=l,e[6]=c):c=e[6],c}function ab(t){return r.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[r.jsx("span",{className:"text-amber-500 mt-0.5 shrink-0",children:"+"}),t]},t)}function lb({open:t,onOpenChange:e,existingAgent:s}){const i=Ds(),n=co(),o=Sl(),[a,l]=S.useState(!1),c=Os.find(m=>m.id==="ai-research"),d=r.jsx(Ms,{icon:c.icon,name:c.title,size:"sm"}),u=async()=>{if(s){e(!1),n(s.id);return}l(!0);try{const m=await o.create.mutateAsync({title:c.title,description:"Systematic research and information synthesis assistant",icon:c.icon,status:"active",connections:[],metadata:{type:"ai-research",instructions:nb}});se("agent_recruit_confirmed",{template_id:"ai-research",agent_id:m.id}),e(!1),n(m.id)}catch(m){se("agent_recruit_failed",{template_id:"ai-research",error:m instanceof Error?m.message:String(m)}),console.error("Failed to create Researcher agent:",m)}finally{l(!1)}},h=`Add ${c.title}`;return i?r.jsx(Si,{open:t,onOpenChange:e,children:r.jsxs(yi,{className:"h-[70dvh]",children:[r.jsx(io,{className:"px-4 pt-4 pb-4 shrink-0",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(bi,{className:"text-xl font-semibold",children:h})]})}),r.jsx("div",{className:"flex flex-col flex-1 min-h-0 px-4 pb-8",children:r.jsx(Uc,{onRecruit:u,isRecruiting:a})})]})}):r.jsx(cs,{open:t,onOpenChange:e,children:r.jsxs(ls,{className:"sm:max-w-[500px] p-8",children:[r.jsx(_s,{className:"mb-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[d,r.jsx(gs,{className:"text-xl font-semibold",children:h})]})}),r.jsx(Uc,{onRecruit:u,isRecruiting:a})]})})}function cb(t){try{const e=localStorage.getItem(`mesh:chat:recent-agents:${t}`);return e?JSON.parse(e):[]}catch{return[]}}function tr(t){const e=B.c(21),{agent:s,onSpecialClick:i,tracking:n}=t,{org:o}=be(),a=Ke();let l;e[0]!==s.id||e[1]!==s.title||e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n.action||e[6]!==n.template_id||e[7]!==n.tile_kind?(l=()=>{if(se("home_agent_tile_clicked",{template_id:n.template_id,agent_id:s.id,agent_title:s.title,tile_kind:n.tile_kind,action:n.action}),i)i();else{const g=crypto.randomUUID();a({to:"/$org/$taskId",params:{org:o.slug,taskId:g},search:{virtualmcpid:s.id}})}},e[0]=s.id,e[1]=s.title,e[2]=a,e[3]=i,e[4]=o,e[5]=n.action,e[6]=n.template_id,e[7]=n.tile_kind,e[8]=l):l=e[8];const c=l;let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),e[9]=d):d=e[9];const u=`Select agent ${s.title}`;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=r.jsx(lo,{size:24}),e[10]=h):h=e[10];let m;e[11]!==s.icon||e[12]!==s.title?(m=r.jsx(Ms,{icon:s.icon,name:s.title,size:"md",fallbackIcon:h,className:"transition-transform group-hover:scale-110"}),e[11]=s.icon,e[12]=s.title,e[13]=m):m=e[13];let f;e[14]!==s.title?(f=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight line-clamp-2 break-words w-full",children:s.title}),e[14]=s.title,e[15]=f):f=e[15];let p;return e[16]!==c||e[17]!==u||e[18]!==m||e[19]!==f?(p=r.jsxs("button",{type:"button",onClick:c,className:d,"aria-label":u,children:[m,f]}),e[16]=c,e[17]=u,e[18]=m,e[19]=f,e[20]=p):p=e[20],p}function db(){const t=B.c(8),e=Ke(),{org:s}=be();let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group"),t[0]=i):i=t[0];let n;t[1]!==e||t[2]!==s.slug?(n=()=>{se("home_see_all_agents_clicked"),e({to:"/$org/settings/agents",params:{org:s.slug}})},t[1]=e,t[2]=s.slug,t[3]=n):n=t[3];let o,a;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"size-12 rounded-xl bg-accent flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Cl,{size:20,className:"text-foreground"})}),a=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"See all"}),t[4]=o,t[5]=a):(o=t[4],a=t[5]);let l;return t[6]!==n?(l=r.jsxs("button",{type:"button",className:i,"aria-label":"See all agents",onClick:n,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function hb(){const t=B.c(9);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={navigateOnCreate:!0},t[0]=e):e=t[0];const{createVirtualMCP:s,isCreating:i}=gu(e);let n;t[1]!==s?(n=()=>{se("home_create_agent_clicked"),s()},t[1]=s,t[2]=n):n=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=Y("flex flex-col items-center gap-3 p-2 rounded-lg","transition-colors","cursor-pointer","w-[100px] shrink-0","group","disabled:opacity-50 disabled:cursor-not-allowed"),t[3]=o):o=t[3];let a,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"size-12 rounded-xl bg-background border-2 border-dashed border-border flex items-center justify-center shrink-0 transition-transform group-hover:scale-110",children:r.jsx(Qt,{size:20,className:"text-muted-foreground"})}),l=r.jsx("p",{className:"text-xs sm:text-sm text-foreground text-center leading-tight",children:"Create agent"}),t[4]=a,t[5]=l):(a=t[4],l=t[5]);let c;return t[6]!==i||t[7]!==n?(c=r.jsxs("button",{type:"button",onClick:n,disabled:i,className:o,"aria-label":"Create agent",children:[a,l]}),t[6]=i,t[7]=n,t[8]=c):c=t[8],c}function ub(){const t=B.c(95),e=ao(),{locator:s}=be(),[i,n]=S.useState(!1),[o,a]=S.useState(!1),[l,c]=S.useState(!1),[d,u]=S.useState(!1),h=co();let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=Os.find(_b),t[0]=m):m=t[0];const f=m;let p;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=Os.find(gb),t[1]=p):p=t[1];const g=p;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=Os.find(pb),t[2]=_):_=t[2];const v=_;let x;t[3]===Symbol.for("react.memo_cache_sentinel")?(x=Os.find(mb),t[3]=x):x=t[3];const b=x;let y,C,j,w,V,k,R,T,E,N,A;if(t[4]!==s||t[5]!==h||t[6]!==e){const F=cb(s),G=e.filter(fb).sort((J,le)=>{const Se=F.indexOf(J.id),Ne=F.indexOf(le.id);return Se!==-1&&Ne!==-1?Se-Ne:Se!==-1?-1:Ne!==-1?1:new Date(le.updated_at).getTime()-new Date(J.updated_at).getTime()}).slice(0,4);let W;if(t[18]!==e){let J;t[20]===Symbol.for("react.memo_cache_sentinel")?(J=le=>le.id!==null&&(le.metadata?.type===g.id||le.title===g.title),t[20]=J):J=t[20],W=e.find(J),t[18]=e,t[19]=W}else W=t[19];j=W;let H;if(t[21]!==e){let J;t[23]===Symbol.for("react.memo_cache_sentinel")?(J=le=>le.id!==null&&(le.metadata?.type===v.id||le.title===v.title),t[23]=J):J=t[23],H=e.find(J),t[21]=e,t[22]=H}else H=t[22];y=H;let Z;if(t[24]!==e){let J;t[26]===Symbol.for("react.memo_cache_sentinel")?(J=le=>le.id!==null&&(le.metadata?.type===b.id||le.title===b.title),t[26]=J):J=t[26],Z=e.find(J),t[24]=e,t[25]=Z}else Z=t[25];C=Z,w=G.length>0,V="w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",k="flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",t[27]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(tr,{agent:f,onSpecialClick:()=>n(!0),tracking:{template_id:f.id,tile_kind:"template",action:"open_modal"}},f.id),t[27]=R):R=t[27];const q=j??g;let K;t[28]!==j||t[29]!==h?(K=j?()=>h(j.id):()=>a(!0),t[28]=j,t[29]=h,t[30]=K):K=t[30];const te=j?"existing":"template",ee=j?"navigate":"open_modal";let X;t[31]!==te||t[32]!==ee?(X={template_id:g.id,tile_kind:te,action:ee},t[31]=te,t[32]=ee,t[33]=X):X=t[33],t[34]!==q||t[35]!==K||t[36]!==X?(T=r.jsx(tr,{agent:q,onSpecialClick:K,tracking:X},g.id),t[34]=q,t[35]=K,t[36]=X,t[37]=T):T=t[37];const ie=y??v;let re;t[38]!==y||t[39]!==h?(re=y?()=>h(y.id):()=>c(!0),t[38]=y,t[39]=h,t[40]=re):re=t[40];const he=y?"existing":"template",xe=y?"navigate":"open_modal";let ae;t[41]!==he||t[42]!==xe?(ae={template_id:v.id,tile_kind:he,action:xe},t[41]=he,t[42]=xe,t[43]=ae):ae=t[43],t[44]!==ie||t[45]!==re||t[46]!==ae?(E=r.jsx(tr,{agent:ie,onSpecialClick:re,tracking:ae},v.id),t[44]=ie,t[45]=re,t[46]=ae,t[47]=E):E=t[47];const ue=C??b;let me;t[48]!==C||t[49]!==h?(me=C?()=>h(C.id):()=>u(!0),t[48]=C,t[49]=h,t[50]=me):me=t[50];const fe=C?"existing":"template",ce=C?"navigate":"open_modal";let ve;t[51]!==fe||t[52]!==ce?(ve={template_id:b.id,tile_kind:fe,action:ce},t[51]=fe,t[52]=ce,t[53]=ve):ve=t[53],t[54]!==ue||t[55]!==me||t[56]!==ve?(N=r.jsx(tr,{agent:ue,onSpecialClick:me,tracking:ve},b.id),t[54]=ue,t[55]=me,t[56]=ve,t[57]=N):N=t[57];let Ce;t[58]!==y?.id||t[59]!==C?.id||t[60]!==j?.id?(Ce=J=>J.id!==j?.id&&J.id!==y?.id&&J.id!==C?.id,t[58]=y?.id,t[59]=C?.id,t[60]=j?.id,t[61]=Ce):Ce=t[61];let Te;t[62]!==h?(Te=J=>r.jsx(tr,{agent:J,onSpecialClick:()=>h(J.id),tracking:{template_id:null,tile_kind:"recent",action:"navigate"}},J.id??"default"),t[62]=h,t[63]=Te):Te=t[63],A=G.filter(Ce).map(Te),t[4]=s,t[5]=h,t[6]=e,t[7]=y,t[8]=C,t[9]=j,t[10]=w,t[11]=V,t[12]=k,t[13]=R,t[14]=T,t[15]=E,t[16]=N,t[17]=A}else y=t[7],C=t[8],j=t[9],w=t[10],V=t[11],k=t[12],R=t[13],T=t[14],E=t[15],N=t[16],A=t[17];let I;t[64]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(hb,{}),t[64]=I):I=t[64];let M;t[65]!==w?(M=w&&r.jsx(db,{}),t[65]=w,t[66]=M):M=t[66];let L;t[67]!==M||t[68]!==k||t[69]!==R||t[70]!==T||t[71]!==E||t[72]!==N||t[73]!==A?(L=r.jsxs("div",{className:k,children:[R,T,E,N,A,I,M]}),t[67]=M,t[68]=k,t[69]=R,t[70]=T,t[71]=E,t[72]=N,t[73]=A,t[74]=L):L=t[74];let D;t[75]!==V||t[76]!==L?(D=r.jsx("div",{className:V,children:L}),t[75]=V,t[76]=L,t[77]=D):D=t[77];let P;t[78]!==i?(P=r.jsx(Bn,{open:i,onOpenChange:n}),t[78]=i,t[79]=P):P=t[79];let O;t[80]!==o||t[81]!==j?(O=r.jsx(fu,{open:o,onOpenChange:a,existingAgent:j}),t[80]=o,t[81]=j,t[82]=O):O=t[82];let z;t[83]!==l||t[84]!==y?(z=r.jsx(rb,{open:l,onOpenChange:c,existingAgent:y}),t[83]=l,t[84]=y,t[85]=z):z=t[85];let $;t[86]!==d||t[87]!==C?($=r.jsx(lb,{open:d,onOpenChange:u,existingAgent:C}),t[86]=d,t[87]=C,t[88]=$):$=t[88];let U;return t[89]!==D||t[90]!==P||t[91]!==O||t[92]!==z||t[93]!==$?(U=r.jsxs(r.Fragment,{children:[D,P,O,z,$]}),t[89]=D,t[90]=P,t[91]=O,t[92]=z,t[93]=$,t[94]=U):U=t[94],U}function fb(t){return t.id!==null&&!Mn(t.id)}function mb(t){return t.id==="ai-research"}function pb(t){return t.id==="ai-image"}function gb(t){return t.id==="site-diagnostics"}function _b(t){return t.id==="site-editor"}function xb(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"w-full max-md:overflow-x-auto max-md:[scrollbar-width:none] max-md:[&::-webkit-scrollbar]:hidden",children:r.jsx("div",{className:"flex flex-wrap justify-center gap-1.5 max-md:flex-nowrap max-md:justify-start md:max-h-52 md:overflow-hidden",children:Array.from({length:7}).map(vb)})}),t[0]=e):e=t[0],e}function vb(t,e){return r.jsxs("div",{className:"flex flex-col items-center gap-3 p-2 w-[100px] shrink-0",children:[r.jsx(Bi,{className:"size-12 rounded-xl shrink-0"}),r.jsx(Bi,{className:"h-3 sm:h-4 w-full"})]},e)}function Kc(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(S.Suspense,{fallback:r.jsx(xb,{}),children:r.jsx(ub,{})}),t[0]=e):e=t[0],e}function sr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function qc(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function bb(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function yb(t){const e=B.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Sb),e[0]=s,e[1]=i):i=e[1];let n;return e[2]!==i?(n=r.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=n):n=e[3],n}function Sb(t){return r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),r.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function wb(t){const e=B.c(30),{userTokens:s,assistantTokens:i,otherTokens:n}=t,o=s+i+n,a=o>0?s/o*100:0,l=o>0?i/o*100:0,c=o>0?n/o*100:0;let d;e[0]!==a?(d=a>0&&r.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==l?(u=l>0&&r.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let h;e[4]!==c?(h=c>0&&r.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=h):h=e[5];let m;e[6]!==d||e[7]!==u||e[8]!==h?(m=r.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,u,h]}),e[6]=d,e[7]=u,e[8]=h,e[9]=m):m=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=f):f=e[10];let p;e[11]!==a?(p=a.toFixed(1),e[11]=a,e[12]=p):p=e[12];let g;e[13]!==p?(g=r.jsxs("div",{className:"flex items-center gap-1.5",children:[f,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let _;e[15]===Symbol.for("react.memo_cache_sentinel")?(_=r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=_):_=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let x;e[18]!==v?(x=r.jsxs("div",{className:"flex items-center gap-1.5",children:[_,r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=x):x=e[19];let b;e[20]!==c||e[21]!==n?(b=n>0&&r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=n,e[22]=b):b=e[22];let y;e[23]!==x||e[24]!==b||e[25]!==g?(y=r.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,x,b]}),e[23]=x,e[24]=b,e[25]=g,e[26]=y):y=e[26];let C;return e[27]!==y||e[28]!==m?(C=r.jsxs("div",{className:"flex flex-col gap-2",children:[m,y]}),e[27]=y,e[28]=m,e[29]=C):C=e[29],C}function Vb(t){const e=B.c(19),{part:s}=t,i=s.input?.agent_id,n=ts(i),o=n?.title??"Subtask",a=n?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,c=s.state==="output-error",d=s.state==="approval-requested";let u;e[0]!==a||e[1]!==o?(u=r.jsx(Ms,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=u):u=e[2];const h=c?"text-destructive":"text-foreground";let m;e[3]!==h?(m=Y("shrink-0 font-medium",h),e[3]=h,e[4]=m):m=e[4];let f;e[5]!==o||e[6]!==m?(f=r.jsx("span",{className:m,children:o}),e[5]=o,e[6]=m,e[7]=f):f=e[7];let p;e[8]!==s.input?(p=s.input?.prompt&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-muted-foreground/50",children:"·"}),r.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=p):p=e[9];let g;e[10]!==d||e[11]!==c||e[12]!==l?(g=r.jsx("span",{className:"ml-auto shrink-0",children:l?r.jsx(Ee,{size:12,className:"animate-spin text-muted-foreground"}):c?r.jsx(Og,{size:12,className:"text-destructive"}):d?r.jsx(ni,{size:12,className:"text-warning"}):r.jsx(x_,{size:12,className:"text-emerald-500"})}),e[10]=d,e[11]=c,e[12]=l,e[13]=g):g=e[13];let _;return e[14]!==u||e[15]!==f||e[16]!==p||e[17]!==g?(_=r.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,f,p,g]}),e[14]=u,e[15]=f,e[16]=p,e[17]=g,e[18]=_):_=e[18],_}function Cb(t){const e=B.c(58),{onClose:s,back:i,className:n}=t,[o,a]=S.useState(null),{messages:l}=Ui(),{tasks:c,taskId:d}=es(),{selectedModel:u,selectedVirtualMcp:h}=oi();let m,f,p,g,_,v,x,b;if(e[0]!==i||e[1]!==n||e[2]!==l||e[3]!==s||e[4]!==o?.id||e[5]!==u||e[6]!==h?.title||e[7]!==d||e[8]!==c){b=Symbol.for("react.early_return_sentinel");e:{let j;e[17]!==d?(j=X=>X.id===d,e[17]=d,e[18]=j):j=e[18];const w=c.find(j),V=Eh(l),k=[...l].reverse().find(Db),R=k?.metadata?.usage,T=k?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,E=R?.contextTokens??R?.totalTokens??0,N=T&&T>0?(E/T*100).toFixed(1):null,A=l;let I;e[19]!==A?(I=A.filter(Tb).reduce(Rb,0),e[19]=A,e[20]=I):I=e[20];const M=I,L=l;let D;e[21]!==L?(D=L.filter(Ib).reduce(Eb,0),e[21]=L,e[22]=D):D=e[22];const P=D,O=Math.max(0,V.totalTokens-M-P),z=l[0],$=l.at(-1),U=z?.metadata?.created_at??w?.created_at,F=$?.metadata?.created_at??w?.updated_at,G=l.filter(Ab),W=l.flatMap(kb),H=u?.modelId?bb(u.modelId):"—",Z=h?.title??"Decopilot",q=[{label:"Session",value:w?.title??"New chat"},{label:"Messages",value:G.length},{label:"Agent",value:Z},{label:"Model",value:H},{label:"Context Limit",value:T?sr(T):"—"},{label:"Session Tokens (billed)",value:V.totalTokens>0?sr(V.totalTokens):"0"},{label:"Usage",value:N!==null?`${N}%`:"—"},{label:"Input Tokens",value:V.inputTokens>0?sr(V.inputTokens):"0"},{label:"Output Tokens",value:V.outputTokens>0?sr(V.outputTokens):"0"},{label:"Reasoning Tokens",value:V.reasoningTokens>0?sr(V.reasoningTokens):"0"},{label:"Cost",value:V.cost>0?`$${V.cost<.001?V.cost.toFixed(6):V.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:qc(U)},{label:"Last Activity",value:qc(F)}];if(!w&&G.length===0){let X;e[23]!==n?(X=Y("flex flex-col h-full w-full border-l border-border bg-background",n),e[23]=n,e[24]=X):X=e[24];let ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(ie=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=ie):ie=e[25];let re;e[26]!==i?(re=i?r.jsx(la,{size:14,className:"text-muted-foreground"}):r.jsx(ri,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=re):re=e[27];let he;e[28]!==s||e[29]!==re?(he=r.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[ie,r.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:re})]}),e[28]=s,e[29]=re,e[30]=he):he=e[30];let xe;e[31]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=xe):xe=e[31];let ae;e[32]!==X||e[33]!==he?(ae=r.jsxs("div",{className:X,children:[he,xe]}),e[32]=X,e[33]=he,e[34]=ae):ae=e[34],b=ae;break e}e[35]!==n?(v=Y("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",n),e[35]=n,e[36]=v):v=e[36];let K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K=r.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=K):K=e[37];let te;e[38]!==i?(te=i?r.jsx(la,{size:14}):r.jsx(ri,{size:14}),e[38]=i,e[39]=te):te=e[39],e[40]!==s||e[41]!==te?(x=r.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[K,r.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:te})]}),e[40]=s,e[41]=te,e[42]=x):x=e[42],m="flex flex-col gap-8 p-6",f=W.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),r.jsx("div",{className:"flex flex-col gap-1",children:W.map(jb)})]}),p=r.jsx(yb,{items:q});let ee;e[43]===Symbol.for("react.memo_cache_sentinel")?(ee=r.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=ee):ee=e[43],e[44]!==P||e[45]!==O||e[46]!==M?(g=r.jsxs("div",{className:"flex flex-col gap-3",children:[ee,r.jsx(wb,{userTokens:M,assistantTokens:P,otherTokens:O})]}),e[44]=P,e[45]=O,e[46]=M,e[47]=g):g=e[47],_=G.length>0&&r.jsxs("div",{className:"flex flex-col gap-3",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),r.jsx("div",{className:"flex flex-col gap-1",children:G.map(X=>{const ie=X.metadata?.created_at,re=o?.id===X.id;return r.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(re?null:X),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:Y("shrink-0 font-medium",X.role==="user"?"text-chart-1":"text-chart-2"),children:X.role}),r.jsx("span",{className:"text-muted-foreground",children:"•"}),r.jsx("span",{className:"truncate text-muted-foreground font-mono",children:X.id})]}),ie&&r.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(ie).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),re&&r.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(X,null,2)})]},X.id)})})]})}e[0]=i,e[1]=n,e[2]=l,e[3]=s,e[4]=o?.id,e[5]=u,e[6]=h?.title,e[7]=d,e[8]=c,e[9]=m,e[10]=f,e[11]=p,e[12]=g,e[13]=_,e[14]=v,e[15]=x,e[16]=b}else m=e[9],f=e[10],p=e[11],g=e[12],_=e[13],v=e[14],x=e[15],b=e[16];if(b!==Symbol.for("react.early_return_sentinel"))return b;let y;e[48]!==m||e[49]!==f||e[50]!==p||e[51]!==g||e[52]!==_?(y=r.jsxs("div",{className:m,children:[f,p,g,_]}),e[48]=m,e[49]=f,e[50]=p,e[51]=g,e[52]=_,e[53]=y):y=e[53];let C;return e[54]!==v||e[55]!==x||e[56]!==y?(C=r.jsxs("div",{className:v,children:[x,y]}),e[54]=v,e[55]=x,e[56]=y,e[57]=C):C=e[57],C}function jb(t,e){return r.jsx(Vb,{part:t},e)}function kb(t){return(t.parts??[]).filter(Nb)}function Nb(t){return t.type==="tool-subtask"}function Ab(t){return t.role!=="system"}function Eb(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Ib(t){return t.role==="assistant"}function Rb(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Tb(t){return t.role==="user"}function Db(t){return t.role==="assistant"&&t.metadata?.usage}function Mb(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Pb(t){const e=B.c(25),{orgId:s,userId:i,connectionId:n,vmMap:o,owner:a,repo:l,enabled:c}=t,d=c===void 0?!0:c,u=n??null;let h;e[0]!==s||e[1]!==u?(h={connectionId:u,orgId:s},e[0]=s,e[1]=u,e[2]=h):h=e[2];const m=Me(h);let f;e[3]!==a||e[4]!==l?(f={owner:a,repo:l},e[3]=a,e[4]=l,e[5]=f):f=e[5];const p=d&&!!n&&!!a&&!!l;let g;e[6]!==m||e[7]!==f||e[8]!==p?(g={client:m,toolName:"list_branches",toolArguments:f,enabled:p,staleTime:3e4,select:$b},e[6]=m,e[7]=f,e[8]=p,e[9]=g):g=e[9];const{data:_,isLoading:v,isError:x}=wi(g);let b,y;e[10]!==i||e[11]!==o?(y=new Set(Object.keys(o?.[i]??{})),b=[...y].sort().map(Ob),e[10]=i,e[11]=o,e[12]=b,e[13]=y):(b=e[12],y=e[13]);const C=b;let j;if(e[14]!==_||e[15]!==y){const R=Array.isArray(_)?_:_?.branches??[];let T;e[17]!==y?(T=E=>!y.has(E.name),e[17]=y,e[18]=T):T=e[18],j=R.filter(Bb).filter(T).map(Lb),e[14]=_,e[15]=y,e[16]=j}else j=e[16];const w=j,V=Array.isArray(_)?null:_?.default_branch??null;let k;return e[19]!==V||e[20]!==x||e[21]!==v||e[22]!==w||e[23]!==C?(k={yours:C,others:w,defaultBase:V,isLoading:v,isError:x},e[19]=V,e[20]=x,e[21]=v,e[22]=w,e[23]=C,e[24]=k):k=e[24],k}function Lb(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function Bb(t){return typeof t.name=="string"}function Ob(t){return{name:t,source:"yours"}}function $b(t){return Mb(t)}function zb(t){const e=B.c(36),{orgId:s,userId:i,connectionId:n,owner:o,repo:a,vmMap:l,value:c,onChange:d}=t,[u,h]=S.useState(!1);let m;e[0]!==n||e[1]!==u||e[2]!==s||e[3]!==o||e[4]!==a||e[5]!==i||e[6]!==l?(m={orgId:s,userId:i,connectionId:n,vmMap:l,owner:o,repo:a,enabled:u},e[0]=n,e[1]=u,e[2]=s,e[3]=o,e[4]=a,e[5]=i,e[6]=l,e[7]=m):m=e[7];const{yours:f,others:p,isLoading:g,isError:_}=Pb(m);let v;e[8]!==d?(v=N=>{d(N),h(!1)},e[8]=d,e[9]=v):v=e[9];const x=v,b=c??"Select branch…";let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(gr,{className:"h-3.5 w-3.5"}),e[10]=y):y=e[10];let C;e[11]!==b?(C=r.jsx(ai,{asChild:!0,children:r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,r.jsx("span",{className:"max-w-[200px] truncate",children:b})]})}),e[11]=b,e[12]=C):C=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=r.jsx(c_,{placeholder:"Search branches…"}),e[13]=j):j=e[13];let w;e[14]!==_?(w=_&&r.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[14]=_,e[15]=w):w=e[15];let V;e[16]!==_||e[17]!==g||e[18]!==p.length||e[19]!==f.length?(V=!_&&!g&&f.length===0&&p.length===0&&r.jsx(a_,{children:"No branches found."}),e[16]=_,e[17]=g,e[18]=p.length,e[19]=f.length,e[20]=V):V=e[20];let k;e[21]!==x||e[22]!==f?(k=f.length>0&&r.jsx(Sc,{heading:"Your branches",children:f.map(N=>r.jsxs(wc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name})]},N.name))}),e[21]=x,e[22]=f,e[23]=k):k=e[23];let R;e[24]!==p||e[25]!==x?(R=p.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(l_,{}),r.jsx(Sc,{heading:"Other branches in repo",children:p.map(N=>r.jsxs(wc,{value:N.name,onSelect:()=>x(N.name),children:[r.jsx(gr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 truncate",children:N.name}),N.author&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",N.author]})]},N.name))})]}),e[24]=p,e[25]=x,e[26]=R):R=e[26];let T;e[27]!==w||e[28]!==V||e[29]!==k||e[30]!==R?(T=r.jsx(li,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:r.jsxs(d_,{children:[j,r.jsxs(h_,{children:[w,V,k,R]})]})}),e[27]=w,e[28]=V,e[29]=k,e[30]=R,e[31]=T):T=e[31];let E;return e[32]!==u||e[33]!==T||e[34]!==C?(E=r.jsxs(ci,{open:u,onOpenChange:h,children:[C,T]}),e[32]=u,e[33]=T,e[34]=C,e[35]=E):E=e[35],E}const Fb=["radial-gradient(ellipse 25% 220% at -5% 120%, rgba(165,149,255,0.35) 0%, transparent 100%)","radial-gradient(ellipse 25% 220% at 105% -20%, rgba(208,236,26,0.32) 0%, transparent 100%)"].join(", "),Hb="/decotexture.svg";function Gc(t){const e=B.c(7),{onClick:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundImage:Fb},e[0]=i):i=e[0];let n,o;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"relative shrink-0 p-1.5 bg-[var(--brand-green-light)] rounded-lg border border-border",children:r.jsx(Ms,{icon:"/logos/deco%20logo.svg",name:"deco.cx",size:"xs",className:"border-0 rounded-none bg-transparent"})}),o=r.jsx("p",{className:"flex-1 relative text-sm font-medium text-foreground leading-none whitespace-nowrap",children:"Import your deco.cx site"}),e[1]=n,e[2]=o):(n=e[1],o=e[2]);let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("img",{src:Hb,alt:"","aria-hidden":!0,className:"absolute pointer-events-none",style:{width:"274.5px",height:"272.25px",left:"calc(50% + 145.5px)",top:"calc(50% + 40px)",transform:"translate(-50%, -50%)"}}),e[3]=a):a=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("div",{className:"relative bg-background flex items-center justify-center size-8 rounded-md shrink-0",children:r.jsx(no,{size:16,className:"text-foreground transition-transform group-hover:translate-x-0.5"})}),e[4]=l):l=e[4];let c;return e[5]!==s?(c=r.jsxs("button",{type:"button",onClick:s,className:"w-full relative flex items-center gap-4 px-4 py-4 rounded-lg border border-border bg-background overflow-hidden transition-colors text-left cursor-pointer group",style:i,children:[n,o,a,l]}),e[5]=s,e[6]=c):c=e[6],c}function Wb(){const t=B.c(5),{data:e}=St.useSession();let s;t[0]!==e?.user?.email?(s=lt.decoProfile(e?.user?.email),t[0]=e?.user?.email,t[1]=s):s=t[1];const i=!!e?.user?.email;let n;t[2]!==s||t[3]!==i?(n={queryKey:s,queryFn:Ub,enabled:i,staleTime:3e5},t[2]=s,t[3]=i,t[4]=n):n=t[4];const{data:o}=Fi(n);return o?.isDecoUser??!1}async function Ub(){const t=await fetch("/api/deco-sites/profile");return t.ok?t.json():{isDecoUser:!1}}function Kb(t){const e=B.c(56),{onOpenContextPanel:s}=t,{data:i}=St.useSession(),[n,o]=S.useState(!1),a=Wb(),l=Ds(),{hasDecoKey:c,isZeroBalance:d,isInitialFreeCredit:u,balanceDollars:h,hasOnlyDecoProvider:m}=ho();let f;e[0]!==i?.user?.name?(f=i?.user?.name?.split(" ")[0]||"there",e[0]=i?.user?.name,e[1]=f):f=e[1];const p=f,g=c&&u&&h!=null,_=c&&d&&m;if(l){let N;e[2]!==h||e[3]!==g?(N=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[2]=h,e[3]=g,e[4]=N):N=e[4];let A;e[5]!==_?(A=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[5]=_,e[6]=A):A=e[6];let I;e[7]!==p?(I=r.jsxs("p",{className:"text-3xl font-medium text-foreground text-center max-w-[280px]",children:["What's on your mind, ",p,"?"]}),e[7]=p,e[8]=I):I=e[8];let M;e[9]!==N||e[10]!==A||e[11]!==I?(M=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[N,A,I]}),e[9]=N,e[10]=A,e[11]=I,e[12]=M):M=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx(Kc,{}),e[13]=L):L=e[13];let D;e[14]!==s?(D=r.jsxs("div",{className:"w-full flex flex-col gap-4 pb-4",children:[L,r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})]}),e[14]=s,e[15]=D):D=e[15];let P;e[16]!==a?(P=a&&r.jsx("div",{className:"w-full",children:r.jsx(Gc,{onClick:()=>o(!0)})}),e[16]=a,e[17]=P):P=e[17];let O;e[18]!==M||e[19]!==D||e[20]!==P?(O=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-4",children:[M,D,P]}),e[18]=M,e[19]=D,e[20]=P,e[21]=O):O=e[21];let z;e[22]!==n?(z=r.jsx(Bn,{open:n,onOpenChange:o}),e[22]=n,e[23]=z):z=e[23];let $;return e[24]!==z||e[25]!==O?($=r.jsxs(r.Fragment,{children:[O,z]}),e[24]=z,e[25]=O,e[26]=$):$=e[26],$}let v;e[27]!==h||e[28]!==g?(v=g&&r.jsx("div",{className:"mb-4",children:r.jsx(De.CreditsEyebrow,{balanceDollars:h})}),e[27]=h,e[28]=g,e[29]=v):v=e[29];let x;e[30]!==_?(x=_&&r.jsx("div",{className:"mb-4",children:r.jsx(De.NoCreditsEyebrow,{})}),e[30]=_,e[31]=x):x=e[31];let b;e[32]!==p?(b=r.jsxs("p",{className:"text-3xl font-medium text-foreground",children:["What's on your mind, ",p,"?"]}),e[32]=p,e[33]=b):b=e[33];let y;e[34]!==v||e[35]!==x||e[36]!==b?(y=r.jsxs("div",{className:"text-center mb-10",children:[v,x,b]}),e[34]=v,e[35]=x,e[36]=b,e[37]=y):y=e[37];let C;e[38]!==s?(C=r.jsx("div",{className:"w-full",children:r.jsx(De.Input,{onOpenContextPanel:s,showConnectionsBanner:!0})}),e[38]=s,e[39]=C):C=e[39];let j;e[40]!==y||e[41]!==C?(j=r.jsxs("div",{className:"flex flex-col items-center w-full max-w-[672px]",children:[y,C]}),e[40]=y,e[41]=C,e[42]=j):j=e[42];let w;e[43]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"w-full mt-10 mx-auto",children:r.jsx(Kc,{})}),e[43]=w):w=e[43];let V;e[44]!==j?(V=r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center w-full",children:[j,w]}),e[44]=j,e[45]=V):V=e[45];let k;e[46]!==a?(k=a&&r.jsx("div",{className:"absolute bottom-6 left-0 right-0 px-10",children:r.jsx("div",{className:"w-full max-w-[500px] mx-auto",children:r.jsx(Gc,{onClick:()=>o(!0)})})}),e[46]=a,e[47]=k):k=e[47];let R;e[48]!==k||e[49]!==V?(R=r.jsxs("div",{className:"flex-1 relative flex flex-col items-center px-10",children:[V,k]}),e[48]=k,e[49]=V,e[50]=R):R=e[50];let T;e[51]!==n?(T=r.jsx(Bn,{open:n,onOpenChange:o}),e[51]=n,e[52]=T):T=e[52];let E;return e[53]!==R||e[54]!==T?(E=r.jsxs(r.Fragment,{children:[R,T]}),e[53]=R,e[54]=T,e[55]=E):E=e[55],E}function qb(){const t=B.c(26),{org:e}=be(),{selectedVirtualMcp:s}=oi(),{data:i}=St.useSession(),{currentBranch:n,setCurrentTaskBranch:o}=es();let a;t[0]!==e.id?(a=ro(e.id),t[0]=e.id,t[1]=a):a=t[1];const c=s??a,d=ts(c.id),u=i?.user?.id??"",h=d?.metadata?.githubRepo??null,m=!!h?.connectionId&&!!u;let f;t[2]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(lo,{size:32}),t[2]=f):f=t[2];let p;t[3]!==c.icon||t[4]!==c.title?(p=r.jsx(Ms,{icon:c.icon,name:c.title,size:"lg",fallbackIcon:f,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=c.icon,t[4]=c.title,t[5]=p):p=t[5];let g;t[6]!==c.title?(g=r.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:c.title}),t[6]=c.title,t[7]=g):g=t[7];const _=c.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==_?(v=r.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:_}),t[8]=_,t[9]=v):v=t[9];let x;t[10]!==n||t[11]!==d?.metadata?.vmMap||t[12]!==h||t[13]!==e.id||t[14]!==o||t[15]!==m||t[16]!==u?(x=m&&r.jsx("div",{className:"mt-2",children:r.jsx(zb,{orgId:e.id,userId:u,connectionId:h.connectionId,owner:h.owner,repo:h.name,vmMap:d?.metadata?.vmMap,value:n??void 0,onChange:o})}),t[10]=n,t[11]=d?.metadata?.vmMap,t[12]=h,t[13]=e.id,t[14]=o,t[15]=m,t[16]=u,t[17]=x):x=t[17];let b;t[18]!==p||t[19]!==g||t[20]!==v||t[21]!==x?(b=r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[p,g,v,x]}),t[18]=p,t[19]=g,t[20]=v,t[21]=x,t[22]=b):b=t[22];let y;t[23]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx("div",{className:"w-full max-w-3xl mx-auto",children:r.jsx(De.IceBreakers,{})}),t[23]=y):y=t[23];let C;return t[24]!==b?(C=r.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[b,y]}),t[24]=b,t[25]=C):C=t[25],C}function Gb(t){const e=B.c(27),{variant:s}=t,{org:i}=be(),n=yl(),{isChatEmpty:o}=Ui(),[a,l]=S.useState("chat"),c=ho();if(n.length===0){let C;return e[0]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx(De,{className:"animate-in fade-in-0 duration-200",children:r.jsx(De.Main,{className:"flex flex-col items-center",children:r.jsx(De.EmptyState,{children:r.jsx(De.NoAiProviderEmptyState,{})})})}),e[0]=C):C=e[0],C}let d;e[1]!==c.hasDecoKey||e[2]!==c.hasOnlyDecoProvider||e[3]!==c.isLoading||e[4]!==c.isZeroBalance||e[5]!==o||e[6]!==i?(d=c.hasDecoKey&&c.isZeroBalance&&c.hasOnlyDecoProvider&&!c.isLoading&&o&&!$v(i.id),e[1]=c.hasDecoKey,e[2]=c.hasOnlyDecoProvider,e[3]=c.isLoading,e[4]=c.isZeroBalance,e[5]=o,e[6]=i,e[7]=d):d=e[7];const u=d;let h;e[8]!==u?(h=u&&r.jsx(De.CreditsEmptyState,{}),e[8]=u,e[9]=h):h=e[9];const m=a!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;e[10]!==m?(f=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),e[10]=m,e[11]=f):f=e[11];let p;e[12]!==o||e[13]!==s?(p=o?s==="home"?r.jsx(Kb,{onOpenContextPanel:()=>l("context")}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(qb,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}):r.jsxs(r.Fragment,{children:[r.jsx(De.Main,{children:r.jsx(De.Messages,{})}),r.jsx(De.Footer,{children:r.jsx(De.Input,{onOpenContextPanel:()=>l("context")})})]}),e[12]=o,e[13]=s,e[14]=p):p=e[14];let g;e[15]!==f||e[16]!==p?(g=r.jsx("div",{className:f,children:p}),e[15]=f,e[16]=p,e[17]=g):g=e[17];const _=a==="context"?"opacity-100":"opacity-0 pointer-events-none";let v;e[18]!==_?(v=Y("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",_),e[18]=_,e[19]=v):v=e[19];let x;e[20]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(Cb,{back:!0,onClose:()=>l("chat")}),e[20]=x):x=e[20];let b;e[21]!==v?(b=r.jsx("div",{className:v,children:x}),e[21]=v,e[22]=b):b=e[22];let y;return e[23]!==b||e[24]!==h||e[25]!==g?(y=r.jsxs(De,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,g,b]}),e[23]=b,e[24]=h,e[25]=g,e[26]=y):y=e[26],y}function Gu(t){const e=B.c(4),{variant:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(De.Skeleton,{}),e[0]=i):i=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(De.Skeleton,{}),e[1]=n):n=e[1];let o;return e[2]!==s?(o=r.jsx(ks,{fallback:i,children:r.jsx(S.Suspense,{fallback:n,children:r.jsx(Gb,{variant:s})})}),e[2]=s,e[3]=o):o=e[3],o}function Yb(){const t=B.c(6),{org:e,locator:s}=be(),i=Mt();let n;t[0]!==s||t[1]!==i?(n=()=>{i.invalidateQueries({queryKey:lt.tasksPrefix(s)})},t[0]=s,t[1]=i,t[2]=n):n=t[2];let o;t[3]!==e.id||t[4]!==n?(o={orgId:e.id,onTaskStatus:n},t[3]=e.id,t[4]=n,t[5]=o):o=t[5],b_(o)}function Xb(t){const e=B.c(8),{virtualMcpId:s,size:i,showAutomationBadge:n}=t,o=i===void 0?"sm":i;let a;e[0]!==o||e[1]!==s?(a=s?r.jsx(Jb,{virtualMcpId:s,size:o}):r.jsx(zs,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=a):a=e[2];let l;e[3]!==n?(l=n&&r.jsx("span",{"aria-label":"Automation-triggered",className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:r.jsx($i,{size:10,className:"text-white"})}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=r.jsxs("div",{className:"relative shrink-0",children:[a,l]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function Jb(t){const e=B.c(6),{virtualMcpId:s,size:i}=t,n=ts(s);if(!n){let l;return e[0]!==i?(l=r.jsx(zs,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=n.icon??null;let a;return e[2]!==n.title||e[3]!==i||e[4]!==o?(a=r.jsx(zs,{icon:o,name:n.title,size:i}),e[2]=n.title,e[3]=i,e[4]=o,e[5]=a):a=e[5],a}function Fs(t){const e=t?.metadata?.githubRepo;return e?.connectionId&&t?.connections?.some(i=>i.connection_id===e.connectionId)?e:null}function Qb(t){const e=B.c(42),{task:s,isActive:i,onClick:n,onArchive:o,showAutomationBadge:a}=t,l=Fp(s.status),c=l.icon,d=ts(s.virtual_mcp_id);let u;e[0]!==d?(u=Fs(d),e[0]=d,e[1]=u):u=e[1];const h=u,m="button",f=0;let p;e[2]!==n?(p=O=>{O.target===O.currentTarget&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),n())},e[2]=n,e[3]=p):p=e[3];const g=i?"bg-accent":"hover:bg-accent/60";let _;e[4]!==g?(_=Y("group/row flex items-center gap-3 px-2 py-1.5 rounded-md cursor-pointer transition-colors",g),e[4]=g,e[5]=_):_=e[5];let v;e[6]!==a||e[7]!==s.virtual_mcp_id?(v=r.jsx(Xb,{virtualMcpId:s.virtual_mcp_id,size:"xs",showAutomationBadge:a}),e[6]=a,e[7]=s.virtual_mcp_id,e[8]=v):v=e[8];const x=s.title||"Untitled task";let b;e[9]!==x?(b=r.jsx("div",{className:"text-sm text-foreground truncate",children:x}),e[9]=x,e[10]=b):b=e[10];let y;e[11]!==h||e[12]!==s.branch||e[13]!==s.updated_at?(y=s.updated_at&&r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[s.branch?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"truncate font-mono",children:s.branch}),r.jsx("span",{className:"shrink-0",children:"·"})]}):h?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"truncate",children:[h.owner,"/",h.name]}),r.jsx("span",{className:"shrink-0",children:"·"})]}):null,r.jsx("span",{className:"shrink-0",children:Hp(new Date(s.updated_at))})]}),e[11]=h,e[12]=s.branch,e[13]=s.updated_at,e[14]=y):y=e[14];let C;e[15]!==y||e[16]!==b?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[b,y]}),e[15]=y,e[16]=b,e[17]=C):C=e[17];const j="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",w="[grid-area:slot] flex size-7 items-center justify-center group-hover/row:invisible",V=l.label,k=14,R=Y(l.iconClassName,s.status==="in_progress"&&"animate-spin");let T;e[18]!==c||e[19]!==R?(T=r.jsx(c,{size:k,className:R}),e[18]=c,e[19]=R,e[20]=T):T=e[20];let E;e[21]!==l||e[22]!==T?(E=r.jsx("span",{className:w,"aria-label":V,children:T}),e[21]=l,e[22]=T,e[23]=E):E=e[23];let N;e[24]!==o?(N=O=>{O.stopPropagation(),o()},e[24]=o,e[25]=N):N=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(_g,{size:14}),e[26]=A):A=e[26];let I;e[27]!==N?(I=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Archive task",onClick:N,className:"[grid-area:slot] invisible group-hover/row:visible flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted",children:A})}),e[27]=N,e[28]=I):I=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(st,{side:"right",children:"Archive"}),e[29]=M):M=e[29];let L;e[30]!==I?(L=r.jsxs(it,{children:[I,M]}),e[30]=I,e[31]=L):L=e[31];let D;e[32]!==E||e[33]!==L?(D=r.jsxs("div",{className:j,children:[E,L]}),e[32]=E,e[33]=L,e[34]=D):D=e[34];let P;return e[35]!==n||e[36]!==C||e[37]!==D||e[38]!==p||e[39]!==_||e[40]!==v?(P=r.jsxs("div",{role:m,tabIndex:f,onClick:n,onKeyDown:p,className:_,children:[v,C,D]}),e[35]=n,e[36]=C,e[37]=D,e[38]=p,e[39]=_,e[40]=v,e[41]=P):P=e[41],P}const Yu={all:"All tasks",manual:"Chats",automation:"Automation"},Xu={all:"All members",mine:"Mine only"};function Zb(t){const e=B.c(57),{title:s,tasks:i,activeTaskId:n,onSelect:o,onArchive:a,onNew:l,showNewButton:c,showAutomationBadge:d,emptyLabel:u,currentUserId:h}=t,[m,f]=S.useState("all"),[p,g]=S.useState("mine");let _;e[0]!==h||e[1]!==p||e[2]!==i?(_=p==="mine"&&h?i.filter(G=>G.created_by===h):i,e[0]=h,e[1]=p,e[2]=i,e[3]=_):_=e[3];const v=_;let x;e[4]!==m||e[5]!==v?(x=m==="automation"?v.filter(i0):m==="manual"?v.filter(s0):v,e[4]=m,e[5]=v,e[6]=x):x=e[6];const b=x;let y;e[7]!==s?(y=r.jsx("span",{children:s}),e[7]=s,e[8]=y):y=e[8];let C;e[9]!==p?(C=r.jsx(As,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter by member",className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:p==="mine"?r.jsx(xg,{size:16}):r.jsx(lo,{size:16})})}),e[9]=p,e[10]=C):C=e[10];let j;e[11]!==p?(j=G=>{const W=G;W!==p&&se("tasks_panel_member_filter_changed",{to_value:W}),g(W)},e[11]=p,e[12]=j):j=e[12];let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=Object.keys(Xu),e[13]=w):w=e[13];let V;e[14]===Symbol.for("react.memo_cache_sentinel")?(V=w.map(t0),e[14]=V):V=e[14];let k;e[15]!==p||e[16]!==j?(k=r.jsx(Es,{align:"end",children:r.jsx(uc,{value:p,onValueChange:j,children:V})}),e[15]=p,e[16]=j,e[17]=k):k=e[17];let R;e[18]!==C||e[19]!==k?(R=r.jsxs(Ns,{children:[C,k]}),e[18]=C,e[19]=k,e[20]=R):R=e[20];const T=m!=="all"&&"text-purple-500";let E;e[21]!==T?(E=Y("flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",T),e[21]=T,e[22]=E):E=e[22];let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx($g,{size:16}),e[23]=N):N=e[23];let A;e[24]!==E?(A=r.jsx(As,{asChild:!0,children:r.jsx("button",{type:"button","aria-label":"Filter tasks",className:E,children:N})}),e[24]=E,e[25]=A):A=e[25];let I;e[26]!==m?(I=G=>{const W=G;W!==m&&se("tasks_panel_filter_changed",{to_value:W}),f(W)},e[26]=m,e[27]=I):I=e[27];let M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(Yu),e[28]=M):M=e[28];let L;e[29]===Symbol.for("react.memo_cache_sentinel")?(L=M.map(e0),e[29]=L):L=e[29];let D;e[30]!==m||e[31]!==I?(D=r.jsx(Es,{align:"end",children:r.jsx(uc,{value:m,onValueChange:I,children:L})}),e[30]=m,e[31]=I,e[32]=D):D=e[32];let P;e[33]!==A||e[34]!==D?(P=r.jsxs(Ns,{children:[A,D]}),e[33]=A,e[34]=D,e[35]=P):P=e[35];let O;e[36]!==l||e[37]!==c||e[38]!==s?(O=c&&l&&r.jsx("button",{type:"button",onClick:()=>{se("tasks_panel_new_clicked"),l()},"aria-label":`New ${s.toLowerCase()}`,className:"flex size-8 items-center justify-center rounded-md hover:bg-muted hover:text-foreground",children:r.jsx(gl,{size:16})}),e[36]=l,e[37]=c,e[38]=s,e[39]=O):O=e[39];let z;e[40]!==P||e[41]!==O||e[42]!==R?(z=r.jsxs("div",{className:"flex items-center gap-0.5",children:[R,P,O]}),e[40]=P,e[41]=O,e[42]=R,e[43]=z):z=e[43];let $;e[44]!==z||e[45]!==y?($=r.jsxs("div",{className:"pl-2 pr-1.5 h-7 flex items-center justify-between text-xs font-medium text-muted-foreground mb-1",children:[y,z]}),e[44]=z,e[45]=y,e[46]=$):$=e[46];let U;e[47]!==n||e[48]!==u||e[49]!==a||e[50]!==o||e[51]!==d||e[52]!==b?(U=b.length===0&&u?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground/70",children:u}):b.map(G=>r.jsx(Qb,{task:G,isActive:n===G.id,onClick:()=>{n!==G.id&&se("tasks_panel_task_clicked",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null,from_automation:!!G.fromAutomation}),o(G)},onArchive:()=>{se("tasks_panel_task_archived",{thread_id:G.id,virtual_mcp_id:G.virtual_mcp_id??null}),a(G)},showAutomationBadge:d||G.fromAutomation},G.id)),e[47]=n,e[48]=u,e[49]=a,e[50]=o,e[51]=d,e[52]=b,e[53]=U):U=e[53];let F;return e[54]!==$||e[55]!==U?(F=r.jsxs("div",{className:"flex flex-col gap-0.5 mt-1",children:[$,U]}),e[54]=$,e[55]=U,e[56]=F):F=e[56],F}function e0(t){return r.jsx(Oh,{value:t,children:Yu[t]},t)}function t0(t){return r.jsx(Oh,{value:t,children:Xu[t]},t)}function s0(t){return!t.fromAutomation}function i0(t){return t.fromAutomation}function r0(){const t=B.c(22);Yb();const{data:e}=St.useSession(),s=e?.user?.id;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={owner:"me",status:"open",hasTrigger:!1},t[0]=i):i=t[0];const{tasks:n}=ra(i);let o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o={owner:"all",status:"open",hasTrigger:!0},t[1]=o):o=t[1];const{tasks:a}=ra(o),{setTaskId:l,createNewTask:c}=zr();let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d={strict:!1},t[2]=d):d=t[2];const u=$r(d),{locator:h,org:m}=be(),f=Mt();let p;t[3]!==m.id?(p={connectionId:Wt,orgId:m.id},t[3]=m.id,t[4]=p):p=t[4];const g=Me(p),_=u.taskId??null;let v;t[5]!==a||t[6]!==n?(v=[...n,...a.map(o0)].sort(n0),t[5]=a,t[6]=n,t[7]=v):v=t[7];const x=v;let b;t[8]!==g||t[9]!==h||t[10]!==f?(b=async w=>{try{await Ip(g,w.id,{hidden:!0}),f.invalidateQueries({queryKey:lt.tasksPrefix(h)})}catch(V){const R=V;pe.error(`Failed to archive task: ${R.message}`)}},t[8]=g,t[9]=h,t[10]=f,t[11]=b):b=t[11];const y=b;if(x.length===0){let w;return t[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx("div",{className:"h-full flex items-center justify-center p-4",children:r.jsx(Oi,{image:r.jsx(vg,{size:48,className:"text-muted-foreground"}),title:"No tasks yet",description:"Start a conversation to create your first task."})}),t[12]=w):w=t[12],w}let C;t[13]!==l?(C=w=>l(w.id,w.virtual_mcp_id),t[13]=l,t[14]=C):C=t[14];let j;return t[15]!==_||t[16]!==x||t[17]!==c||t[18]!==s||t[19]!==y||t[20]!==C?(j=r.jsx("div",{className:"flex flex-col h-full min-h-0 overflow-y-auto p-2 gap-3",children:r.jsx(Zb,{title:"Tasks",tasks:x,activeTaskId:_,onSelect:C,onArchive:y,onNew:c,showNewButton:!0,currentUserId:s})}),t[15]=_,t[16]=x,t[17]=c,t[18]=s,t[19]=y,t[20]=C,t[21]=j):j=t[21],j}function n0(t,e){return(e.updated_at??"").localeCompare(t.updated_at??"")}function o0(t){return{...t,fromAutomation:!0}}function a0(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{className:"flex flex-col h-full p-2 gap-1.5",children:Array.from({length:6}).map(l0)}),t[0]=e):e=t[0],e}function l0(t,e){return r.jsx("div",{className:"h-10 rounded-md bg-muted/60 animate-pulse"},e)}function Ju(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(De.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(ks,{fallback:e,children:r.jsx(S.Suspense,{fallback:r.jsx(a0,{}),children:r.jsx(r0,{})})}),t[1]=s):s=t[1],s}function Qu(){const t=B.c(77),{org:e}=be(),s=Ke(),i=Vh(),{setTasksOpen:n,openTab:o}=zr(),a=e.slug,l=be().project;let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[0]=c):c=t[0];const d=$r(c);let u;t[1]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[1]=u):u=t[1];const h=vi(u),m=i.location.pathname;let f;t[2]!==l.enabledPlugins?(f=l.enabledPlugins??[],t[2]=l.enabledPlugins,t[3]=f):f=t[3];const p=f;let g;t[4]!==l.ui?(g=l.ui?.pinnedViews??[],t[4]=l.ui,t[5]=g):g=t[5];const _=g;let v,x,b,y;if(t[6]!==l.id||t[7]!==p||t[8]!==s||t[9]!==a||t[10]!==d.pluginId||t[11]!==d.taskId||t[12]!==h.virtualmcpid){let W;t[17]!==p?(W=ie=>p.includes(ie.pluginId),t[17]=p,t[18]=W):W=t[18];const H=tp.filter(W),Z=h.virtualmcpid??l.id;x=!!h.virtualmcpid;const q=d.taskId??"",K=d.pluginId;let te;t[19]!==K?(te=ie=>K===ie,t[19]=K,t[20]=te):te=t[20],v=te;let ee;t[21]!==q||t[22]!==s||t[23]!==a||t[24]!==Z?(ee=ie=>{const re=q||crypto.randomUUID();s({to:"/$org/$taskId/$pluginId",params:{org:a,taskId:re,pluginId:ie},search:he=>({...he,virtualmcpid:Z})})},t[21]=q,t[22]=s,t[23]=a,t[24]=Z,t[25]=ee):ee=t[25],b=ee;let X;t[26]!==v||t[27]!==b?(X=ie=>({key:ie.pluginId,label:ie.label,icon:ie.icon,isActive:v(ie.pluginId),onClick:()=>b(ie.pluginId)}),t[26]=v,t[27]=b,t[28]=X):X=t[28],y=H.map(X),t[6]=l.id,t[7]=p,t[8]=s,t[9]=a,t[10]=d.pluginId,t[11]=d.taskId,t[12]=h.virtualmcpid,t[13]=v,t[14]=x,t[15]=b,t[16]=y}else v=t[13],x=t[14],b=t[15],y=t[16];const C=y;let j;if(t[29]!==p||t[30]!==v||t[31]!==b){let W;t[33]!==p?(W=q=>p.includes(q.pluginId),t[33]=p,t[34]=W):W=t[34];const H=sp.filter(W);let Z;t[35]!==v||t[36]!==b?(Z=q=>({type:"group",group:{id:`${q.pluginId}-${q.id}`,label:q.label,items:q.items.map((K,te)=>({key:`${q.pluginId}-${q.id}-${te}`,label:K.label,icon:K.icon,isActive:v(q.pluginId),onClick:()=>b(q.pluginId)})),defaultExpanded:q.defaultExpanded??!0}}),t[35]=v,t[36]=b,t[37]=Z):Z=t[37],j=H.map(Z),t[29]=p,t[30]=v,t[31]=b,t[32]=j}else j=t[32];const w=j;let V;if(t[38]!==o||t[39]!==_){let W;t[41]!==o?(W=H=>{const Z=Fr(H.icon),q=Z.type==="icon"?Hr(Z.name):null;return{key:`app-${H.connectionId}-${H.toolName}`,label:H.label||H.toolName,icon:q?r.jsx(q,{size:16,className:"text-muted-foreground"}):Z.type==="url"?r.jsx("img",{src:Z.url,alt:"",className:"size-4 rounded"}):r.jsx(_u,{size:16,className:"text-muted-foreground"}),isActive:!1,onClick:()=>o(na(H.connectionId,H.toolName))}},t[41]=o,t[42]=W):W=t[42],V=_.map(W),t[38]=o,t[39]=_,t[40]=V}else V=t[40];const k=V;let R;t[43]!==k?(R=k.length>0?{type:"group",group:{id:"apps",label:"Apps",items:k,defaultExpanded:!0}}:null,t[43]=k,t[44]=R):R=t[44];const T=R;let E;t[45]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(bg,{className:"size-4!"}),t[45]=E):E=t[45];const N=m===`/${a}`||m===`/${a}/`;let A;t[46]!==s||t[47]!==a||t[48]!==n?(A=()=>{n(!1),s({to:"/$org",params:{org:a}})},t[46]=s,t[47]=a,t[48]=n,t[49]=A):A=t[49];let I;t[50]!==A||t[51]!==N?(I={key:"home",label:"Home",icon:E,isActive:N,onClick:A},t[50]=A,t[51]=N,t[52]=I):I=t[52];const M=I;let L;t[53]!==p?(L=p.includes(ip),t[53]=p,t[54]=L):L=t[54];const D=L;let P;t[55]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(rp,{className:"size-4!"}),t[55]=P):P=t[55];let O;t[56]!==a||t[57]!==m?(O=m.startsWith(`/${a}/settings/workflows`),t[56]=a,t[57]=m,t[58]=O):O=t[58];let z;t[59]!==s||t[60]!==a?(z=()=>s({to:"/$org/settings/workflows",params:{org:a}}),t[59]=s,t[60]=a,t[61]=z):z=t[61];let $;t[62]!==O||t[63]!==z?($={key:"workflows",label:"Workflows",icon:P,isActive:O,onClick:z},t[62]=O,t[63]=z,t[64]=$):$=t[64];const U=$;let F;if(t[65]!==M||t[66]!==x||t[67]!==D||t[68]!==U){const W=[M];x&&D&&W.push(U),F={type:"items",items:W},t[65]=M,t[66]=x,t[67]=D,t[68]=U,t[69]=F}else F=t[69];let G;if(t[70]!==T||t[71]!==w||t[72]!==C||t[73]!==F){if(G=[F],C.length>0){let W;t[75]!==C?(W={type:"items",items:C},t[75]=C,t[76]=W):W=t[76],G.push(W)}w.length>0&&G.push(...w),T&&G.push(T),t[70]=T,t[71]=w,t[72]=C,t[73]=F,t[74]=G}else G=t[74];return G}function Zu(t){const e=B.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex h-6 items-center",children:r.jsx("div",{className:"h-0.5 w-16 rounded-full bg-sidebar-foreground/15"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsxs(Ur,{className:"pt-0 pr-0 pb-2 pl-0 mt-2",children:[i,r.jsx(Kr,{children:r.jsx(xs,{className:"gap-0.5",children:s})})]}),e[1]=s,e[2]=n):n=e[2],n}function c0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(bu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function ef(t){const e=B.c(15),{item:s}=t,{isMobile:i,setOpenMobile:n}=qr();let o;e[0]!==i||e[1]!==s||e[2]!==n?(o=()=>{se("nav_item_clicked",{nav_key:s.key,nav_label:s.label,is_active:!!s.isActive,is_mobile:i}),s.onClick?.(),i&&n(!1)},e[0]=i,e[1]=s,e[2]=n,e[3]=o):o=e[3];const a=o,l=s.key,c=s.isActive&&"z-10";let d;e[4]!==c?(d=Y(c),e[4]=c,e[5]=d):d=e[5];let u;e[6]!==a||e[7]!==s.icon||e[8]!==s.isActive||e[9]!==s.label?(u=r.jsx(ms,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:s.icon}),e[6]=a,e[7]=s.icon,e[8]=s.isActive,e[9]=s.label,e[10]=u):u=e[10];let h;return e[11]!==s.key||e[12]!==d||e[13]!==u?(h=r.jsx(Zt,{className:d,children:u},l),e[11]=s.key,e[12]=d,e[13]=u,e[14]=h):h=e[14],h}function d0(t){const e=B.c(12),{section:s}=t;switch(s.type){case"divider":{let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(xu,{className:"my-2"}),e[0]=i):i=e[0],i}case"spacer":{let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1"}),e[1]=i):i=e[1],i}case"group":{const i=s.group.label,n=s.group.defaultExpanded;let o;e[2]!==s.group.items?(o=s.group.items.map(u0),e[2]=s.group.items,e[3]=o):o=e[3];let a;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==o?(a=r.jsx(Zu,{label:i,defaultExpanded:n,children:o}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=o,e[7]=a):a=e[7],a}case"items":{let i;e[8]!==s.items?(i=s.items.map(h0),e[8]=s.items,e[9]=i):i=e[9];let n;return e[10]!==i?(n=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(xs,{className:"gap-1.5",children:i})})}),e[10]=i,e[11]=n):n=e[11],n}}}function h0(t){return r.jsx(ef,{item:t},t.key)}function u0(t){return r.jsx(ef,{item:t},t.key)}function f0(t){const e=B.c(14),{sections:s,header:i,footer:n,additionalContent:o,variant:a,contentClassName:l}=t,c=a===void 0?"sidebar":a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(c0,{})}),e[0]=d):d=e[0];let u;e[1]!==l?(u=Y("flex flex-col flex-1 px-2 py-2 gap-0",l),e[1]=l,e[2]=u):u=e[2];let h;e[3]!==s?(h=s.map(m0),e[3]=s,e[4]=h):h=e[4];let m;e[5]!==o||e[6]!==u||e[7]!==h?(m=r.jsxs(vu,{className:u,children:[h,o]}),e[5]=o,e[6]=u,e[7]=h,e[8]=m):m=e[8];let f;return e[9]!==n||e[10]!==i||e[11]!==m||e[12]!==c?(f=r.jsxs(y_,{variant:c,children:[d,i,m,n]}),e[9]=n,e[10]=i,e[11]=m,e[12]=c,e[13]=f):f=e[13],f}function m0(t,e){return r.jsx(d0,{section:t},e)}function tf(t){const e=B.c(2);let s;return e[0]!==t?(s=r.jsx(f0,{...t}),e[0]=t,e[1]=s):s=e[1],s}tf.Skeleton=function(){return r.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>r.jsx("div",{className:"w-full h-8",children:r.jsx(Bi,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};function p0(){const t=B.c(7),s=Ch().logo??jh,i=typeof s=="string"?s:s.light,n=typeof s=="string"?s:s.dark;let o;t[0]!==i?(o=r.jsx("img",{src:i,alt:"Logo",className:"size-6 object-contain dark:hidden"}),t[0]=i,t[1]=o):o=t[1];let a;t[2]!==n?(a=r.jsx("img",{src:n,alt:"Logo",className:"size-6 object-contain hidden dark:block"}),t[2]=n,t[3]=a):a=t[3];let l;return t[4]!==o||t[5]!==a?(l=r.jsx(bu,{className:"flex items-center justify-center shrink-0 px-2 pb-0",children:r.jsxs("div",{className:"flex w-full aspect-square items-center justify-center",children:[o,a]})}),t[4]=o,t[5]=a,t[6]=l):l=t[6],l}function Yc(t){const e=B.c(15),{item:s,onClose:i}=t,n=s.isActive&&"z-10";let o;e[0]!==n?(o=Y(n),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==s||e[3]!==i?(a=()=>{s.onClick?.(),i()},e[2]=s,e[3]=i,e[4]=a):a=e[4];let l;e[5]!==s.icon?(l=r.jsx("span",{className:"[&>svg]:size-8",children:s.icon}),e[5]=s.icon,e[6]=l):l=e[6];let c;e[7]!==s.isActive||e[8]!==s.label||e[9]!==a||e[10]!==l?(c=r.jsx(ms,{onClick:a,isActive:s.isActive,tooltip:s.label,className:"bg-muted/75",children:l}),e[7]=s.isActive,e[8]=s.label,e[9]=a,e[10]=l,e[11]=c):c=e[11];let d;return e[12]!==o||e[13]!==c?(d=r.jsx(Zt,{className:o,children:c}),e[12]=o,e[13]=c,e[14]=d):d=e[14],d}function g0(t){const e=B.c(18),{section:s,onClose:i}=t;switch(s.type){case"divider":{let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(xu,{className:"my-2"}),e[0]=n):n=e[0],n}case"spacer":{let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx("div",{className:"flex-1"}),e[1]=n):n=e[1],n}case"group":{const n=s.group.label,o=s.group.defaultExpanded;let a;if(e[2]!==i||e[3]!==s.group.items){let c;e[5]!==i?(c=d=>r.jsx(Yc,{item:d,onClose:i},d.key),e[5]=i,e[6]=c):c=e[6],a=s.group.items.map(c),e[2]=i,e[3]=s.group.items,e[4]=a}else a=e[4];let l;return e[7]!==s.group.defaultExpanded||e[8]!==s.group.label||e[9]!==a?(l=r.jsx(Zu,{label:n,defaultExpanded:o,children:a}),e[7]=s.group.defaultExpanded,e[8]=s.group.label,e[9]=a,e[10]=l):l=e[10],l}case"items":{let n;if(e[11]!==i||e[12]!==s.items){let a;e[14]!==i?(a=l=>r.jsx(Yc,{item:l,onClose:i},l.key),e[14]=i,e[15]=a):a=e[15],n=s.items.map(a),e[11]=i,e[12]=s.items,e[13]=n}else n=e[13];let o;return e[16]!==n?(o=r.jsx(Ur,{className:"pt-0 pr-0 pb-0 pl-0",children:r.jsx(Kr,{children:r.jsx(xs,{className:"gap-1.5",children:n})})}),e[16]=n,e[17]=o):o=e[17],o}}}function _0(t){const e=B.c(12),{sections:s,onClose:i,footer:n,additionalContent:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"h-10 shrink-0"}),children:r.jsx(p0,{})}),e[0]=a):a=e[0];let l;if(e[1]!==i||e[2]!==s){let u;e[4]!==i?(u=(h,m)=>r.jsx(g0,{section:h,onClose:i},m),e[4]=i,e[5]=u):u=e[5],l=s.map(u),e[1]=i,e[2]=s,e[3]=l}else l=e[3];let c;e[6]!==o||e[7]!==l?(c=r.jsxs(vu,{className:"flex flex-col flex-1 px-2 py-2 gap-0",children:[l,o]}),e[6]=o,e[7]=l,e[8]=c):c=e[8];let d;return e[9]!==n||e[10]!==c?(d=r.jsxs("div",{className:"bg-sidebar flex h-full w-full flex-col","data-sidebar":"sidebar",children:[a,c,n]}),e[9]=n,e[10]=c,e[11]=d):d=e[11],d}function sf(t){return t.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const x0=js({name:Et().min(2,"Organization name is required")});function v0(t){const e=B.c(41),{open:s,onOpenChange:i}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={resolver:Or(x0),defaultValues:{name:""}},e[0]=n):n=e[0];const o=Hi(n);let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={mutationFn:y0,onSuccess:b0},e[1]=a):a=e[1];const l=Br(a),c=l.error instanceof Error?l.error.message:l.error?"Failed to create organization.":null;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=r.jsxs(Nl,{children:[r.jsx(Al,{children:"Create a new organization"}),r.jsx(El,{children:"Set up a new organization to collaborate with others."})]}),e[2]=d):d=e[2];let u;if(e[3]!==l||e[4]!==o){let w;e[6]!==l?(w=V=>l.mutateAsync(V),e[6]=l,e[7]=w):w=e[7],u=o.handleSubmit(w),e[3]=l,e[4]=o,e[5]=u}else u=e[5];let h;e[8]!==o.formState.isSubmitting?(h=w=>{const{field:V}=w;return r.jsxs(Rt,{children:[r.jsx(rs,{children:"Organization Name"}),r.jsx(Tt,{children:r.jsx(bt,{...V,placeholder:"Acme Inc.",disabled:o.formState.isSubmitting})}),r.jsx(ug,{children:"The name of your company or organization"}),V.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",sf(V.value)]})]}),r.jsx(Dt,{})]})},e[8]=o.formState.isSubmitting,e[9]=h):h=e[9];let m;e[10]!==o.control||e[11]!==h?(m=r.jsx(It,{control:o.control,name:"name",render:h}),e[10]=o.control,e[11]=h,e[12]=m):m=e[12];let f;e[13]!==c?(f=c&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:c}),e[13]=c,e[14]=f):f=e[14];let p;e[15]!==l||e[16]!==o?(p=()=>{l.reset(),o.reset()},e[15]=l,e[16]=o,e[17]=p):p=e[17];let g;e[18]!==o.formState.isSubmitting||e[19]!==p?(g=r.jsx(jl,{disabled:o.formState.isSubmitting,onClick:p,children:"Cancel"}),e[18]=o.formState.isSubmitting,e[19]=p,e[20]=g):g=e[20];const _=!o.formState.isValid||o.formState.isSubmitting;let v;e[21]!==o.formState.isSubmitting?(v=o.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(jr,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=o.formState.isSubmitting,e[22]=v):v=e[22];let x;e[23]!==_||e[24]!==v?(x=r.jsx(oe,{type:"submit",variant:"default",disabled:_,children:v}),e[23]=_,e[24]=v,e[25]=x):x=e[25];let b;e[26]!==x||e[27]!==g?(b=r.jsxs(Il,{children:[g,x]}),e[26]=x,e[27]=g,e[28]=b):b=e[28];let y;e[29]!==b||e[30]!==u||e[31]!==m||e[32]!==f?(y=r.jsxs("form",{className:"space-y-6",onSubmit:u,autoComplete:"off",children:[m,f,b]}),e[29]=b,e[30]=u,e[31]=m,e[32]=f,e[33]=y):y=e[33];let C;e[34]!==o||e[35]!==y?(C=r.jsxs(kl,{children:[d,r.jsx(Pi,{...o,children:y})]}),e[34]=o,e[35]=y,e[36]=C):C=e[36];let j;return e[37]!==i||e[38]!==s||e[39]!==C?(j=r.jsx(Rl,{open:s,onOpenChange:i,children:C}),e[37]=i,e[38]=s,e[39]=C,e[40]=j):j=e[40],j}function b0(t){const{orgSlug:e}=t;window.location.href=`/${e}`}async function y0(t){const e=sf(t.name);if(!e)throw new Error("Organization slug is invalid");const s=await St.organization.create({name:t.name,slug:e});if(s?.error)throw new Error(s.error.message||"Failed to create organization");const i=s?.data?.slug??e;if(!i)throw new Error("Failed to create organization");return{orgSlug:i}}function _a(t){let e=0;for(let i=0;i<t.length;i++)e=t.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function S0(t){const e=B.c(13),{org:s,size:i}=t,n=i===void 0?"sm":i,o=n==="xs"?"size-5":"size-6",a=n==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=Y(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:_a(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==a?(d=s.logo?r.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:Y("font-semibold leading-none",a),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=a,e[8]=d):d=e[8];let u;return e[9]!==l||e[10]!==c||e[11]!==d?(u=r.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=u):u=e[12],u}function ln(t){const e=B.c(22),{item:s,onClose:i}=t;if(s.href){const c=s.external?"_blank":void 0,d=s.external?"noopener noreferrer":void 0;let u;e[0]!==s.icon?(u=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[0]=s.icon,e[1]=u):u=e[1];let h;e[2]!==s.label?(h=r.jsx("span",{className:"flex-1",children:s.label}),e[2]=s.label,e[3]=h):h=e[3];let m;return e[4]!==s.href||e[5]!==i||e[6]!==c||e[7]!==d||e[8]!==u||e[9]!==h?(m=r.jsxs("a",{href:s.href,target:c,rel:d,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",onClick:i,children:[u,h]}),e[4]=s.href,e[5]=i,e[6]=c,e[7]=d,e[8]=u,e[9]=h,e[10]=m):m=e[10],m}let n;e[11]!==s||e[12]!==i?(n=()=>{s.onClick?.(),i()},e[11]=s,e[12]=i,e[13]=n):n=e[13];let o;e[14]!==s.icon?(o=r.jsx("span",{className:"shrink-0 text-muted-foreground",children:s.icon}),e[14]=s.icon,e[15]=o):o=e[15];let a;e[16]!==s.label?(a=r.jsx("span",{className:"flex-1",children:s.label}),e[16]=s.label,e[17]=a):a=e[17];let l;return e[18]!==n||e[19]!==o||e[20]!==a?(l=r.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-2.5 px-3 py-2 rounded-md text-sm text-left w-full transition-colors text-foreground/80 hover:bg-sidebar-accent hover:text-foreground",children:[o,a]}),e[18]=n,e[19]=o,e[20]=a,e[21]=l):l=e[21],l}function Xc(t){const e=B.c(16),{sortedOrgs:s,orgParam:i,onSelectOrg:n,onCreateOrg:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("span",{className:"text-sm font-medium text-muted-foreground/60",children:"Your Organizations"}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Qt,{size:16}),e[1]=l):l=e[1];let c;e[2]!==o?(c=r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a,r.jsx("button",{type:"button",onClick:o,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:l})]}),e[2]=o,e[3]=c):c=e[3];let d;if(e[4]!==n||e[5]!==i||e[6]!==s){let m;e[8]!==n||e[9]!==i?(m=f=>r.jsxs("button",{type:"button",onClick:()=>n(f.slug),className:Y("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",f.slug===i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[r.jsx(S0,{org:f,size:"sm"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:f.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:f.slug})]}),f.slug===i&&r.jsx(Jt,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},f.id),e[8]=n,e[9]=i,e[10]=m):m=e[10],d=s.map(m),e[4]=n,e[5]=i,e[6]=s,e[7]=d}else d=e[7];let u;e[11]!==d?(u=r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1",children:d}),e[11]=d,e[12]=u):u=e[12];let h;return e[13]!==c||e[14]!==u?(h=r.jsxs(r.Fragment,{children:[c,u]}),e[13]=c,e[14]=u,e[15]=h):h=e[15],h}function Jc(t){const e=B.c(142),{user:s,userImage:i,menuItems:n,signOutItem:o,themeOptions:a,preferences:l,setPreferences:c,sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:m,close:f,isMobile:p}=t;if(p){const q=s?.name??"U";let K;e[0]!==q||e[1]!==i?(K=r.jsx(Cc,{url:i,fallback:q,shape:"circle",size:"sm",className:"shrink-0"}),e[0]=q,e[1]=i,e[2]=K):K=e[2];const te=s?.name??"User";let ee;e[3]!==te?(ee=r.jsx("p",{className:"text-sm font-medium truncate",children:te}),e[3]=te,e[4]=ee):ee=e[4];const X=s?.email;let ie;e[5]!==X?(ie=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:X}),e[5]=X,e[6]=ie):ie=e[6];let re;e[7]!==ee||e[8]!==ie?(re=r.jsxs("div",{className:"flex-1 min-w-0",children:[ee,ie]}),e[7]=ee,e[8]=ie,e[9]=re):re=e[9];let he;e[10]!==s?(he=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(j0)},e[10]=s,e[11]=he):he=e[11];let xe;e[12]===Symbol.for("react.memo_cache_sentinel")?(xe=r.jsx(Li,{size:14}),e[12]=xe):xe=e[12];let ae;e[13]!==he?(ae=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:he,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:xe})}),e[13]=he,e[14]=ae):ae=e[14];let ue;e[15]===Symbol.for("react.memo_cache_sentinel")?(ue=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[15]=ue):ue=e[15];let me;e[16]!==ae?(me=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[ae,ue]})}),e[16]=ae,e[17]=me):me=e[17];let fe;e[18]!==me||e[19]!==K||e[20]!==re?(fe=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-4 border-b border-border",children:[K,re,me]}),e[18]=me,e[19]=K,e[20]=re,e[21]=fe):fe=e[21];let ce;e[22]!==m||e[23]!==h||e[24]!==u||e[25]!==d?(ce=r.jsx("div",{className:"border-b border-border pb-2",children:r.jsx(Xc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:m})}),e[22]=m,e[23]=h,e[24]=u,e[25]=d,e[26]=ce):ce=e[26];let ve;if(e[27]!==f||e[28]!==n){let Pe;e[30]!==f?(Pe=Kt=>r.jsx(ln,{item:Kt,onClose:f},Kt.key),e[30]=f,e[31]=Pe):Pe=e[31],ve=n.map(Pe),e[27]=f,e[28]=n,e[29]=ve}else ve=e[29];let Ce;e[32]!==f||e[33]!==o?(Ce=r.jsx(ln,{item:o,onClose:f}),e[32]=f,e[33]=o,e[34]=Ce):Ce=e[34];let Te;e[35]!==ve||e[36]!==Ce?(Te=r.jsxs("nav",{className:"flex flex-col px-2 pt-2 pb-2 gap-0.5",children:[ve,Ce]}),e[35]=ve,e[36]=Ce,e[37]=Te):Te=e[37];let J;e[38]!==ce||e[39]!==Te?(J=r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[ce,Te]}),e[38]=ce,e[39]=Te,e[40]=J):J=e[40];let le;if(e[41]!==l.theme||e[42]!==c||e[43]!==a){let Pe;e[45]!==l.theme||e[46]!==c?(Pe=Kt=>{const{value:jt,icon:Ae,label:Ie}=Kt;return r.jsx("button",{type:"button","aria-label":Ie,onClick:()=>c(qe=>({...qe,theme:jt})),className:Y("size-8 rounded-md flex items-center justify-center transition-colors",l.theme===jt?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:Ae},jt)},e[45]=l.theme,e[46]=c,e[47]=Pe):Pe=e[47],le=a.map(Pe),e[41]=l.theme,e[42]=c,e[43]=a,e[44]=le}else le=e[44];let Se;e[48]!==le?(Se=r.jsx("div",{className:"flex items-center gap-0.5",children:le}),e[48]=le,e[49]=Se):Se=e[49];const Ne=l.enableSounds?"Disable sounds":"Enable sounds";let Be;e[50]!==c?(Be=()=>c(C0),e[50]=c,e[51]=Be):Be=e[51];const Oe=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let He;e[52]!==Oe?(He=Y("size-8 rounded-md flex items-center justify-center transition-colors",Oe),e[52]=Oe,e[53]=He):He=e[53];let Je;e[54]!==l.enableSounds?(Je=l.enableSounds?r.jsx(fc,{size:14}):r.jsx(mc,{size:14}),e[54]=l.enableSounds,e[55]=Je):Je=e[55];let dt;e[56]!==Ne||e[57]!==Be||e[58]!==He||e[59]!==Je?(dt=r.jsx("button",{type:"button","aria-label":Ne,onClick:Be,className:He,children:Je}),e[56]=Ne,e[57]=Be,e[58]=He,e[59]=Je,e[60]=dt):dt=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.279.2"]}),e[61]=ge):ge=e[61];let ke;e[62]!==dt?(ke=r.jsxs("div",{className:"flex items-center gap-2",children:[dt,ge]}),e[62]=dt,e[63]=ke):ke=e[63];let Qe;e[64]!==Se||e[65]!==ke?(Qe=r.jsxs("div",{className:"flex items-center justify-between px-3 py-3 border-t border-border/50",children:[Se,ke]}),e[64]=Se,e[65]=ke,e[66]=Qe):Qe=e[66];let Ct;return e[67]!==fe||e[68]!==J||e[69]!==Qe?(Ct=r.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[fe,J,Qe]}),e[67]=fe,e[68]=J,e[69]=Qe,e[70]=Ct):Ct=e[70],Ct}const g=s?.name??"U";let _;e[71]!==g||e[72]!==i?(_=r.jsx(Cc,{url:i,fallback:g,shape:"circle",size:"sm",className:"shrink-0"}),e[71]=g,e[72]=i,e[73]=_):_=e[73];const v=s?.name??"User";let x;e[74]!==v?(x=r.jsx("p",{className:"text-sm font-medium truncate",children:v}),e[74]=v,e[75]=x):x=e[75];const b=s?.email;let y;e[76]!==b?(y=r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b}),e[76]=b,e[77]=y):y=e[77];let C;e[78]!==x||e[79]!==y?(C=r.jsxs("div",{className:"flex-1 min-w-0",children:[x,y]}),e[78]=x,e[79]=y,e[80]=C):C=e[80];let j;e[81]!==s?(j=()=>{s?.id&&navigator.clipboard.writeText(s.id).then(V0)},e[81]=s,e[82]=j):j=e[82];let w;e[83]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(Li,{size:14}),e[83]=w):w=e[83];let V;e[84]!==j?(V=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",tabIndex:-1,onClick:j,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors",children:w})}),e[84]=j,e[85]=V):V=e[85];let k;e[86]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(st,{side:"right",children:r.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[86]=k):k=e[86];let R;e[87]!==V?(R=r.jsx(Mi,{delayDuration:300,children:r.jsxs(it,{children:[V,k]})}),e[87]=V,e[88]=R):R=e[88];let T;e[89]!==R||e[90]!==_||e[91]!==C?(T=r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 mx-1 mt-1",children:[_,C,R]}),e[89]=R,e[90]=_,e[91]=C,e[92]=T):T=e[92];let E;if(e[93]!==f||e[94]!==n){let q;e[96]!==f?(q=K=>r.jsx(ln,{item:K,onClose:f},K.key),e[96]=f,e[97]=q):q=e[97],E=n.map(q),e[93]=f,e[94]=n,e[95]=E}else E=e[95];let N;e[98]!==f||e[99]!==o?(N=r.jsx(ln,{item:o,onClose:f}),e[98]=f,e[99]=o,e[100]=N):N=e[100];let A;e[101]!==E||e[102]!==N?(A=r.jsxs("nav",{className:"flex-1 flex flex-col px-2 pt-1 overflow-y-auto",children:[E,N]}),e[101]=E,e[102]=N,e[103]=A):A=e[103];let I;if(e[104]!==l.theme||e[105]!==c||e[106]!==a){let q;e[108]!==l.theme||e[109]!==c?(q=K=>{const{value:te,icon:ee,label:X}=K;return r.jsx("button",{type:"button","aria-label":X,onClick:()=>c(ie=>({...ie,theme:te})),className:Y("size-7 rounded-md flex items-center justify-center transition-colors",l.theme===te?"bg-sidebar-accent text-foreground":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground"),children:ee},te)},e[108]=l.theme,e[109]=c,e[110]=q):q=e[110],I=a.map(q),e[104]=l.theme,e[105]=c,e[106]=a,e[107]=I}else I=e[107];let M;e[111]!==I?(M=r.jsx("div",{className:"flex items-center gap-0.5",children:I}),e[111]=I,e[112]=M):M=e[112];const L=l.enableSounds?"Disable sounds":"Enable sounds";let D;e[113]!==c?(D=()=>c(w0),e[113]=c,e[114]=D):D=e[114];const P=l.enableSounds?"text-foreground hover:bg-sidebar-accent/50":"text-muted-foreground hover:bg-sidebar-accent/50 hover:text-foreground";let O;e[115]!==P?(O=Y("size-7 rounded-md flex items-center justify-center transition-colors",P),e[115]=P,e[116]=O):O=e[116];let z;e[117]!==l.enableSounds?(z=l.enableSounds?r.jsx(fc,{size:14}):r.jsx(mc,{size:14}),e[117]=l.enableSounds,e[118]=z):z=e[118];let $;e[119]!==L||e[120]!==D||e[121]!==O||e[122]!==z?($=r.jsx("button",{type:"button","aria-label":L,onClick:D,className:O,children:z}),e[119]=L,e[120]=D,e[121]=O,e[122]=z,e[123]=$):$=e[123];let U;e[124]===Symbol.for("react.memo_cache_sentinel")?(U=r.jsxs("span",{className:"text-xs text-muted-foreground/60",children:["v","2.279.2"]}),e[124]=U):U=e[124];let F;e[125]!==$?(F=r.jsxs("div",{className:"flex items-center gap-2",children:[$,U]}),e[125]=$,e[126]=F):F=e[126];let G;e[127]!==M||e[128]!==F?(G=r.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 border-t border-border/50",children:[M,F]}),e[127]=M,e[128]=F,e[129]=G):G=e[129];let W;e[130]!==T||e[131]!==A||e[132]!==G?(W=r.jsxs("div",{className:"w-60 shrink-0 flex flex-col border-r border-border bg-sidebar/75",children:[T,A,G]}),e[130]=T,e[131]=A,e[132]=G,e[133]=W):W=e[133];let H;e[134]!==m||e[135]!==h||e[136]!==u||e[137]!==d?(H=r.jsx("div",{className:"flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden",children:r.jsx(Xc,{sortedOrgs:d,orgParam:u,onSelectOrg:h,onCreateOrg:m})}),e[134]=m,e[135]=h,e[136]=u,e[137]=d,e[138]=H):H=e[138];let Z;return e[139]!==W||e[140]!==H?(Z=r.jsxs("div",{className:"flex min-h-[380px] w-full overflow-hidden",children:[W,H]}),e[139]=W,e[140]=H,e[141]=Z):Z=e[141],Z}function w0(t){return{...t,enableSounds:!t.enableSounds}}function V0(){pe.success("User ID copied")}function C0(t){return{...t,enableSounds:!t.enableSounds}}function j0(){pe.success("User ID copied")}function rf(){const t=B.c(50),{data:e}=St.useSession(),{data:s}=St.useListOrganizations(),i=Ke();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org",shouldThrow:!1},t[0]=n):n=t[0];const a=np(n)?.params.org,[l,c]=Wi(),d=Ds(),[u,h]=S.useState(!1),[m,f]=S.useState(!1),p=e?.user,g=p?.image;let _;if(t[1]!==d||t[2]!==i||t[3]!==u||t[4]!==a||t[5]!==s||t[6]!==l||t[7]!==c||t[8]!==p||t[9]!==g){const b=s?.find(Z=>Z.slug===a);let y;if(t[11]!==a||t[12]!==s){let Z;t[14]!==a?(Z=(q,K)=>q.slug===a?-1:K.slug===a?1:q.name.localeCompare(K.name),t[14]=a,t[15]=Z):Z=t[15],y=[...s??[]].sort(Z),t[11]=a,t[12]=s,t[13]=y}else y=t[13];const C=y;let j;t[16]!==i?(j=Z=>{h(!1),i({to:"/$org",params:{org:Z}})},t[16]=i,t[17]=j):j=t[17];const w=j;let V;t[18]===Symbol.for("react.memo_cache_sentinel")?(V=()=>h(!1),t[18]=V):V=t[18];const k=V;let R;t[19]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(Gr,{size:16}),t[19]=R):R=t[19];let T;t[20]!==i||t[21]!==a?(T={key:"preferences",label:"Preferences",icon:R,onClick:()=>{i({to:"/$org/settings/profile",params:{org:a??""}})}},t[20]=i,t[21]=a,t[22]=T):T=t[22];let E;t[23]===Symbol.for("react.memo_cache_sentinel")?(E={key:"terms",label:"Terms of Use",icon:r.jsx(yg,{size:16}),href:"https://www.decocms.com/terms-of-use",external:!0},t[23]=E):E=t[23];let N;t[24]===Symbol.for("react.memo_cache_sentinel")?(N={key:"privacy",label:"Privacy Policy",icon:r.jsx(Sg,{size:16}),href:"https://www.decocms.com/privacy-policy",external:!0},t[24]=N):N=t[24];let A;t[25]===Symbol.for("react.memo_cache_sentinel")?(A={key:"github",label:"decocms/studio",icon:r.jsx(op,{className:"w-4 h-4"}),href:"https://github.com/decocms/studio",external:!0},t[25]=A):A=t[25];let I;t[26]===Symbol.for("react.memo_cache_sentinel")?(I={key:"community",label:"Community",icon:r.jsx(lo,{size:16}),href:"https://decocms.com/discord",external:!0},t[26]=I):I=t[26];let M;t[27]===Symbol.for("react.memo_cache_sentinel")?(M={key:"homepage",label:"Homepage",icon:r.jsx(eu,{size:16}),href:"https://decocms.com",external:!0},t[27]=M):M=t[27];let L;t[28]!==T?(L=[T,E,N,A,I,M],t[28]=T,t[29]=L):L=t[29];const D=L;let P;t[30]===Symbol.for("react.memo_cache_sentinel")?(P={key:"logout",label:"Sign out",icon:r.jsx(Rg,{size:16}),onClick:N0},t[30]=P):P=t[30];const O=P;let z;t[31]===Symbol.for("react.memo_cache_sentinel")?(z={value:"light",icon:r.jsx(N_,{size:14}),label:"Light theme"},t[31]=z):z=t[31];let $;t[32]===Symbol.for("react.memo_cache_sentinel")?($={value:"dark",icon:r.jsx(A_,{size:14}),label:"Dark theme"},t[32]=$):$=t[32];let U;t[33]===Symbol.for("react.memo_cache_sentinel")?(U=[z,$,{value:"system",icon:r.jsx(E_,{size:14}),label:"System theme"}],t[33]=U):U=t[33];const F=U;let G;t[34]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{h(!1),f(!0)},t[34]=G):G=t[34];let W;t[35]!==w||t[36]!==d||t[37]!==D||t[38]!==a||t[39]!==l||t[40]!==c||t[41]!==C||t[42]!==p||t[43]!==g?(W={user:p,userImage:g,menuItems:D,signOutItem:O,themeOptions:F,preferences:l,setPreferences:c,sortedOrgs:C,orgParam:a,onSelectOrg:w,onCreateOrg:G,close:k,isMobile:d},t[35]=w,t[36]=d,t[37]=D,t[38]=a,t[39]=l,t[40]=c,t[41]=C,t[42]=p,t[43]=g,t[44]=W):W=t[44];const H=W;_=d?r.jsxs(Si,{open:u,onOpenChange:h,direction:"bottom",children:[r.jsxs("button",{type:"button",onClick:()=>h(!0),className:"flex items-center gap-3 w-full px-3 py-2.5 rounded-lg transition-colors text-sm text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-foreground",children:[r.jsx("div",{className:"shrink-0 size-5 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:_a(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[8px]",children:(b?.name??"?").slice(0,2).toUpperCase()})}),r.jsx("span",{className:"truncate",children:b?.name??"Account"})]}),r.jsxs(yi,{className:"h-[80dvh] p-0",children:[r.jsx(bi,{className:"sr-only",children:"Account"}),r.jsx(Jc,{...H})]})]}):r.jsxs(ci,{open:u,onOpenChange:h,children:[r.jsx(ai,{asChild:!0,children:r.jsx(ms,{tooltip:b?.name??"Account",className:"rounded-md",children:r.jsx("div",{className:"shrink-0 size-6 rounded-md flex items-center justify-center border border-border/50 overflow-hidden",style:b?.logo?void 0:_a(b?.name??""),children:b?.logo?r.jsx("img",{src:b.logo,alt:"",className:"size-full object-cover"}):r.jsx("span",{className:"font-semibold leading-none text-[9px]",children:(b?.name??"?").slice(0,2).toUpperCase()})})})}),r.jsx(li,{side:"right",align:"end",sideOffset:18,collisionPadding:16,className:"w-[520px] p-0 flex max-h-[520px]",onCloseAutoFocus:k0,children:r.jsx(Jc,{...H})})]}),t[1]=d,t[2]=i,t[3]=u,t[4]=a,t[5]=s,t[6]=l,t[7]=c,t[8]=p,t[9]=g,t[10]=_}else _=t[10];let v;t[45]!==m?(v=r.jsx(v0,{open:m,onOpenChange:f}),t[45]=m,t[46]=v):v=t[46];let x;return t[47]!==_||t[48]!==v?(x=r.jsxs(r.Fragment,{children:[_,v]}),t[47]=_,t[48]=v,t[49]=x):x=t[49],x}function k0(t){return t.preventDefault()}function N0(){se("signed_out",{source:"account_popover"}),St.signOut()}function A0({invitation:t}){const[e,s]=S.useState(!1),[i,n]=S.useState(!1),o=Mt(),a=async()=>{s(!0);try{const c=await St.organization.acceptInvitation({invitationId:t.id});if(c.error)pe.error(c.error.message),s(!1);else{const d=await St.organization.setActive({organizationId:t.organizationId});pe.success("Invitation accepted!");const u=d?.data?.slug;window.location.href=u?`/${u}`:"/"}}catch{pe.error("Failed to accept invitation"),s(!1)}},l=async()=>{n(!0);try{const c=await St.organization.rejectInvitation({invitationId:t.id});c.error?(pe.error(c.error.message),n(!1)):(pe.success("Invitation declined"),o.invalidateQueries())}catch{pe.error("Failed to decline invitation"),n(!1)}};return r.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border last:border-0 hover:bg-muted/25 transition-colors",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"You've been invited to join"}),r.jsx("p",{className:"text-sm font-medium truncate",children:t.organizationName??"Unknown organization"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950",onClick:a,disabled:e||i,"aria-label":"Accept invitation",children:r.jsx(Jt,{size:14})}),r.jsx(oe,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground hover:text-destructive hover:bg-destructive/10",onClick:l,disabled:e||i,"aria-label":"Decline invitation",children:r.jsx(ri,{size:14})})]})]})}function E0(){const t=S.useContext(ap),{data:e}=t.hooks.useListUserInvitations();return(e??[]).filter(i=>i.status==="pending"&&new Date(i.expiresAt)>new Date)}class I0 extends S.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,s){}render(){return this.state.hasError?null:this.props.children}}function R0(t){return t<=1?"text-destructive":t<=5?"text-amber-500 dark:text-amber-400":"text-foreground/70"}function T0(){const t=B.c(19),e=Ke(),{org:s}=be();let i;t[0]!==s.id?(i={connectionId:Wt,orgId:s.id},t[0]=s.id,t[1]=i):i=t[1];const n=Me(i);let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={providerId:"deco"},t[2]=o):o=t[2];let a;t[3]!==n?(a={client:n,toolName:"AI_PROVIDER_CREDITS",toolArguments:o,staleTime:6e4,select:D0},t[3]=n,t[4]=a):a=t[4];const{data:l,isPending:c,isError:d}=wi(a),u=l?.balanceCents!=null?l.balanceCents/100:null;let h;t[5]!==u||t[6]!==d||t[7]!==c?(h=c||d||u==null?"Credits":`Credits: $${u.toFixed(2)}`,t[5]=u,t[6]=d,t[7]=c,t[8]=h):h=t[8];const m=h;let f;t[9]!==u?(f=Y(u!=null&&R0(u)),t[9]=u,t[10]=f):f=t[10];let p;t[11]!==e||t[12]!==s.slug?(p=()=>e({to:"/$org/settings/ai-providers",params:{org:s.slug}}),t[11]=e,t[12]=s.slug,t[13]=p):p=t[13];let g;t[14]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(pl,{size:24}),t[14]=g):g=t[14];let _;return t[15]!==f||t[16]!==p||t[17]!==m?(_=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ms,{tooltip:m,className:f,onClick:p,children:g})})}),t[15]=f,t[16]=p,t[17]=m,t[18]=_):_=t[18],_}function D0(t){return t.structuredContent}function M0(){const t=B.c(1);if(!yl().some(P0))return null;let i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(T0,{}),t[0]=i):i=t[0],i}function P0(t){return t.providerId==="deco"}function L0(){const t=B.c(3),[e,s]=S.useState(!1);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ms,{tooltip:"Connections",onClick:()=>{se("connections_dialog_opened",{source:"sidebar_footer",mode:"browse"}),s(!0)},children:r.jsx(Tg,{size:24})})})}),t[0]=i):i=t[0];let n;return t[1]!==e?(n=r.jsxs(r.Fragment,{children:[i,r.jsx(Ll,{mode:"browse",open:e,onOpenChange:s,defaultTab:"all"})]}),t[1]=e,t[2]=n):n=t[2],n}function B0(){const t=B.c(11),e=E0();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(pc,{size:24}),t[0]=s):s=t[0];let i;t[1]!==e.length?(i=e.length>0&&r.jsx("span",{className:"absolute top-1 right-1 size-2 rounded-full bg-red-500 pointer-events-none"}),t[1]=e.length,t[2]=i):i=t[2];let n;t[3]!==i?(n=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ai,{asChild:!0,children:r.jsxs(ms,{tooltip:"Inbox",className:"relative",children:[s,i]})})})}),t[3]=i,t[4]=n):n=t[4];let o;t[5]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"px-4 py-3 border-b border-border shrink-0",children:r.jsx("h3",{className:"text-sm font-medium",children:"Inbox"})}),t[5]=o):o=t[5];let a;t[6]!==e?(a=r.jsxs(li,{side:"right",align:"start",sideOffset:16,collisionPadding:16,className:"w-[min(400px,calc(100vw-2rem))] p-0 h-[min(650px,calc(100dvh-4rem))] flex flex-col",children:[o,e.length===0?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx(pc,{size:24,className:"text-muted-foreground/50"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"No invites pending"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Organization invitations will appear here"})]}):r.jsx("div",{className:"overflow-y-auto flex-1",children:e.map(O0)})]}),t[6]=e,t[7]=a):a=t[7];let l;return t[8]!==n||t[9]!==a?(l=r.jsxs(ci,{children:[n,a]}),t[8]=n,t[9]=a,t[10]=l):l=t[10],l}function O0(t){return r.jsx(A0,{invitation:t},t.id)}function $0(){const t=B.c(6),e=Ke(),{org:s}=be();let i;t[0]!==e||t[1]!==s.slug?(i=()=>e({to:"/$org/settings",params:{org:s.slug}}),t[0]=e,t[1]=s.slug,t[2]=i):i=t[2];let n;t[3]===Symbol.for("react.memo_cache_sentinel")?(n=r.jsx(Gr,{size:24}),t[3]=n):n=t[3];let o;return t[4]!==i?(o=r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(ms,{tooltip:"Settings",onClick:i,children:n})})}),t[4]=i,t[5]=o):o=t[5],o}function z0(){const t=B.c(5);let e,s,i,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(I0,{children:r.jsx(S.Suspense,{fallback:null,children:r.jsx(M0,{})})}),s=r.jsx(L0,{}),i=r.jsx(B0,{}),n=r.jsx($0,{}),t[0]=e,t[1]=s,t[2]=i,t[3]=n):(e=t[0],s=t[1],i=t[2],n=t[3]);let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsxs(yu,{className:"px-2 pb-3 gap-1",children:[e,s,i,n,r.jsx(xs,{children:r.jsx(Zt,{children:r.jsx(rf,{})})})]}),t[4]=o):o=t[4],o}function F0(){const t=B.c(10),e=Ke(),{org:s}=be(),{setOpenMobile:i}=qr();let n;t[0]!==e||t[1]!==s.slug||t[2]!==i?(n=()=>{e({to:"/$org/settings",params:{org:s.slug}}),i(!1)},t[0]=e,t[1]=s.slug,t[2]=i,t[3]=n):n=t[3];let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(Gr,{}),t[4]=o):o=t[4];let a;t[5]!==n?(a=r.jsx(Zt,{children:r.jsx(ms,{tooltip:"Settings",onClick:n,children:o})}),t[5]=n,t[6]=a):a=t[6];let l;t[7]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(Zt,{children:r.jsx(rf,{})}),t[7]=l):l=t[7];let c;return t[8]!==a?(c=r.jsx(yu,{children:r.jsxs(xs,{children:[a,l]})}),t[8]=a,t[9]=c):c=t[9],c}function H0(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return S.useMemo(()=>i=>{e.forEach(n=>n(i))},e)}const fo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ki(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Bl(t){return"nodeType"in t}function Ut(t){var e,s;return t?Ki(t)?t:Bl(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function Ol(t){const{Document:e}=Ut(t);return t instanceof e}function Xr(t){return Ki(t)?!1:t instanceof Ut(t).HTMLElement}function nf(t){return t instanceof Ut(t).SVGElement}function qi(t){return t?Ki(t)?t.document:Bl(t)?Ol(t)?t:Xr(t)||nf(t)?t.ownerDocument:document:document:document}const Rs=fo?S.useLayoutEffect:S.useEffect;function $l(t){const e=S.useRef(t);return Rs(()=>{e.current=t}),S.useCallback(function(){for(var s=arguments.length,i=new Array(s),n=0;n<s;n++)i[n]=arguments[n];return e.current==null?void 0:e.current(...i)},[])}function W0(){const t=S.useRef(null),e=S.useCallback((i,n)=>{t.current=setInterval(i,n)},[]),s=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function Er(t,e){e===void 0&&(e=[t]);const s=S.useRef(t);return Rs(()=>{s.current!==t&&(s.current=t)},e),s}function Jr(t,e){const s=S.useRef();return S.useMemo(()=>{const i=t(s.current);return s.current=i,i},[...e])}function Hn(t){const e=$l(t),s=S.useRef(null),i=S.useCallback(n=>{n!==s.current&&e?.(n,s.current),s.current=n},[]);return[s,i]}function xa(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let To={};function Qr(t,e){return S.useMemo(()=>{if(e)return e;const s=To[t]==null?0:To[t]+1;return To[t]=s,t+"-"+s},[t,e])}function of(t){return function(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),n=1;n<s;n++)i[n-1]=arguments[n];return i.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const Di=of(1),Ir=of(-1);function U0(t){return"clientX"in t&&"clientY"in t}function zl(t){if(!t)return!1;const{KeyboardEvent:e}=Ut(t.target);return e&&t instanceof e}function K0(t){if(!t)return!1;const{TouchEvent:e}=Ut(t.target);return e&&t instanceof e}function va(t){if(K0(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:s}=t.touches[0];return{x:e,y:s}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:s}=t.changedTouches[0];return{x:e,y:s}}}return U0(t)?{x:t.clientX,y:t.clientY}:null}const Rr=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:s}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:s}=t;return"scaleX("+e+") scaleY("+s+")"}},Transform:{toString(t){if(t)return[Rr.Translate.toString(t),Rr.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:i}=t;return e+" "+s+"ms "+i}}}),Qc="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function q0(t){return t.matches(Qc)?t:t.querySelector(Qc)}const G0={display:"none"};function Y0(t){let{id:e,value:s}=t;return Ft.createElement("div",{id:e,style:G0},s)}function X0(t){let{id:e,announcement:s,ariaLiveType:i="assertive"}=t;const n={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ft.createElement("div",{id:e,style:n,role:"status","aria-live":i,"aria-atomic":!0},s)}function J0(){const[t,e]=S.useState("");return{announce:S.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const af=S.createContext(null);function Q0(t){const e=S.useContext(af);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Z0(){const[t]=S.useState(()=>new Set),e=S.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[S.useCallback(i=>{let{type:n,event:o}=i;t.forEach(a=>{var l;return(l=a[n])==null?void 0:l.call(a,o)})},[t]),e]}const ey={draggable:`
260
260
  To pick up a draggable item, press the space bar.
261
261
  While dragging, use the arrow keys to move the item.
262
262
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -447,4 +447,4 @@ ${J}
447
447
 
448
448
  <message>
449
449
  ${ue}
450
- </message>`}]}}))},L=e.models?.credentialId||f||"",D=e.models?.thinking?.id||p?.modelId||"",P=Hi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),z=P.watch("credential_id"),$=P.watch("model_id"),{models:U,isLoading:F}=su(z||void 0),G=U.find(ae=>ae.modelId===$)??null,W=S.useRef(null),H=S.useRef(new Set),Z=S.useRef(0),q=S.useRef(null),K=3e4,te=()=>{q.current&&(clearTimeout(q.current),q.current=null),W.current!==null&&(se("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(H.current),save_count:Z.current,edit_duration_ms:Date.now()-W.current}),W.current=null,H.current=new Set,Z.current=0)},ee=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!I.current)return!0;const ue=Object.keys(P.formState.dirtyFields),me=I.current;I.current=!1;const fe=P.getValues();try{const ce=fe.credential_id&&fe.model_id?fe.credential_id:"",ve=fe.credential_id&&fe.model_id?fe.model_id:"",Ce={id:t,name:fe.name,active:fe.active,agent:{id:o},models:{credentialId:ce,thinking:{id:ve}},messages:Rp(b),temperature:0};await l.mutateAsync(Ce),W.current===null&&(W.current=Date.now());for(const Te of ue)H.current.add(Te);return me&&H.current.add("messages"),Z.current+=1,q.current&&clearTimeout(q.current),q.current=setTimeout(te,K),P.reset({...fe,credential_id:ce,model_id:ve}),!0}catch{return I.current=!0,!1}},X=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{ee()},1e3)},ie=async()=>(A.current&&clearTimeout(A.current),ee()),re=ae=>{if(y(ae),!N.current){N.current=!0;return}I.current=!0,X()},he=S.useRef(!1);he.current||(he.current=!0,P.watch(()=>{X()}));const xe=async()=>{se("automation_test_clicked",{automation_id:t,agent_id:o});const ae=await ie();if(te(),!ae)return;if(!b){pe.error("No instructions configured for this automation");return}G&&z&&m({...G,keyId:z}),v({..._,toolApprovalLevel:"auto"});const ue=dc(b);h({message:{tiptapDoc:b,parts:ue},virtualMcpId:o||void 0})};return r.jsxs(r.Fragment,{children:[i&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(oe,{variant:"ghost",size:"sm",onClick:i,children:[r.jsx(vl,{size:14}),"Back to list"]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(bt,{...P.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),n&&r.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(ua,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ai,{control:P.control,name:"active",render:({field:ae})=>r.jsx(ha,{checked:ae.value,onCheckedChange:ue=>{ae.onChange(ue),setTimeout(()=>ie(),0)},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(P_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),r.jsx(S5,{automationId:t,open:C,onOpenChange:j,onCustomSelect:()=>{V(!0),E(!1),R("")},onEventSelect:()=>{E(!0),V(!1)}})]}),e.triggers.length===0&&!w?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>j(!0),children:"Add a starter"})," ","to get going."]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ae=>r.jsx(w5,{trigger:ae,automationId:t,connectionName:ae.connection_id?u.get(ae.connection_id):void 0},ae.id))}),w&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(_r,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:k,onChange:ae=>R(ae.target.value),onBlur:async()=>{const ae=k.trim();if(!(!ae||!Vr(ae)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:ae}),se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),V(!1),R("")}catch{pe.error("Failed to add starter")}},onKeyDown:async ae=>{const ue=k.trim();ae.key==="Enter"&&ue&&Vr(ue)&&ae.target.blur(),ae.key==="Escape"&&(V(!1),R(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!Vr(k)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{V(!1),R("")},children:r.jsx(ri,{size:13})})]}),T&&r.jsx(S.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:r.jsx(C5,{automationId:t,onDone:()=>E(!1)})})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[r.jsx(xl,{size:13}),"Improve"]})]}),r.jsx(Uu,{tiptapDoc:b,setTiptapDoc:re,placeholder:"What should this automation do?",children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Ku,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[r.jsx(ru,{model:G,isLoading:F,credentialId:z||null,onCredentialChange:ae=>{P.setValue("credential_id",ae??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:ae=>P.setValue("model_id",ae.modelId,{shouldDirty:!0}),placeholder:"Model"}),r.jsxs(it,{children:[r.jsx(tt,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:xe,disabled:!o,children:[r.jsx(Hh,{size:16}),"Test"]})}),r.jsx(st,{children:"Test Automation"})]})]})]})})]})]})]})}function E5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let n;e[0]!==s?(n=Ih(s),e[0]=s,e[1]=n):n=e[1];const o=n;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=r.jsx(fs,{children:r.jsx(fs.Content,{children:r.jsx(fs.Body,{children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(I5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function I5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,n=Ke(),{data:o,isLoading:a}=B_(s);let l;e[0]!==n?(l=()=>n({to:".",search:R5,replace:!0}),e[0]=n,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=r.jsx(A5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function R5(t){return{...t,main:"automations"}}function T5(t){const e=B.c(19),{virtualMcpId:s}=t,i=Ke(),{data:n}=O_(s),o=n===void 0?[]:n,{create:a}=Yr(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(k=>k.name.toLowerCase().includes(d));let h;e[0]!==i?(h=k=>i({to:".",search:R=>({...R,main:"automation:"+k}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const m=h,f=async()=>{if(a.isPending)return;se("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const k=await a.mutateAsync(z_(s));m(k.id)},p=fs,g=fs,_=fs;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==f?(x=r.jsx(fs.Title,{actions:r.jsxs(oe,{size:"sm",onClick:f,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=f,e[5]=x):x=e[5];const b=o.length>0&&r.jsx(F_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:r.jsxs(oe,{size:"sm",onClick:f,disabled:a.isPending,children:[r.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(k=>r.jsx($_,{automation:k,onClick:()=>m(k.id)},k.id))});let j;e[9]!==_.Body||e[10]!==y||e[11]!==C?(j=r.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=j):j=e[12];let w;e[13]!==j||e[14]!==g.Content?(w=r.jsx(g.Content,{children:j}),e[13]=j,e[14]=g.Content,e[15]=w):w=e[15];let V;return e[16]!==p||e[17]!==w?(V=r.jsx(p,{children:w}),e[16]=p,e[17]=w,e[18]=V):V=e[18],V}function D5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(S.Suspense,{fallback:i,children:r.jsx(T5,{virtualMcpId:s})}),e[1]=s,e[2]=n):n=e[2],n}const ph=S.lazy(()=>kp(()=>import("./project-app-view-DQAduvBB.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])).then(t=>({default:t.AppViewContent})));function M5(t){const e=B.c(35),{taskId:s,virtualMcpId:i}=t;let n;e[0]!==s||e[1]!==i?(n={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=n):n=e[2];const{activeTab:o,layoutTabs:a,automationTabParsed:l}=Ff(n);if(Xp(o)){let f;return e[3]!==i?(f=r.jsx(xd,{virtualMcpId:i}),e[3]=i,e[4]=f):f=e[4],f}if(o==="git"){let f;return e[5]!==i?(f=r.jsx(yV,{virtualMcpId:i}),e[5]=i,e[6]=f):f=e[6],f}if(o==="automations"){let f;return e[7]!==i?(f=r.jsx(D5,{virtualMcpId:i}),e[7]=i,e[8]=f):f=e[8],f}if(o==="env"){let f;return e[9]!==i?(f=r.jsx(g5,{virtualMcpId:i}),e[9]=i,e[10]=f):f=e[10],f}if(o==="preview"){let f;return e[11]!==i?(f=r.jsx(QV,{virtualMcpId:i}),e[11]=i,e[12]=f):f=e[12],f}if(l){let f;return e[13]!==o||e[14]!==i?(f=r.jsx(E5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=f):f=e[15],f}let c;e[16]!==o?(c=Jp(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let f;e[18]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=f):f=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=r.jsx(S.Suspense,{fallback:f,children:r.jsx(ph,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let f;e[26]!==o?(f=p=>p.id===o,e[26]=o,e[27]=f):f=e[27],u=a.find(f),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let f;e[28]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=f):f=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=r.jsx(S.Suspense,{fallback:f,children:r.jsx(ph,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let m;return e[33]!==i?(m=r.jsx(xd,{virtualMcpId:i}),e[33]=i,e[34]=m):m=e[34],m}function P5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,n]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ll.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=al(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=m=>n(()=>{m>0&&m<100&&l(m)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=r.jsx(nu,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=c,e[5]=u,e[6]=h):h=e[6],h}function L5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:n,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==n||e[1]!==o?(c=fd(n,o),e[0]=n,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=ll.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=al(u,45),m=S.useRef(null);let f,p;e[4]!==n||e[5]!==o||e[6]!==h?(f=()=>{const T=m.current;if(!T)return;const E=fd(n,o),N=E.chat>0&&E.chat<100?h:E.chat,A=E.chat>0&&E.chat<100?100-h:E.main;T.setLayout([N,A])},p=[n,o,h],e[4]=n,e[5]=o,e[6]=h,e[7]=f,e[8]=p):(f=e[7],p=e[8]),S.useEffect(f,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??r.jsx(Gu,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=r.jsx(P5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Yg,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j={overflow:"visible"},e[19]=j):j=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=Y("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[20]=w):w=e[20];let V;e[21]!==i||e[22]!==s?(V=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:w,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(M5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=V):V=e[23];let k;e[24]!==d.main||e[25]!==V?(k=r.jsx(nu,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:j,collapsible:!0,collapsedSize:0,minSize:20,children:V}),e[24]=d.main,e[25]=V,e[26]=k):k=e[26];let R;return e[27]!==k||e[28]!==g||e[29]!==b?(R=r.jsxs(Xg,{ref:m,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,k]},g),e[27]=k,e[28]=g,e[29]=b,e[30]=R):R=e[30],R}const sa="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",gh="bg-sidebar-accent text-sidebar-foreground",ia="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function B5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:n,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=$f(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{se("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?gh:ia;let h;e[3]!==u?(h=Y(sa,u),e[3]=u,e[4]=h):h=e[4];let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ig,{size:16}),e[5]=m):m=e[5];let f;e[6]!==d||e[7]!==h||e[8]!==a?(f=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:m})}),e[6]=d,e[7]=h,e[8]=a,e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(st,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==f?(g=r.jsxs(it,{delayDuration:300,children:[f,p]}),e[11]=f,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==n?(_=!s&&r.jsxs(it,{delayDuration:300,children:[r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{se("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),n()},"aria-pressed":i,className:Y(sa,i?gh:ia),children:r.jsx(Eg,{size:16})})}),r.jsx(st,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=n,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=Y("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,j=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let w;e[19]!==j?(w=Y(sa,ia,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",j),e[19]=j,e[20]=w):w=e[20];let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(gl,{size:16}),e[21]=V):V=e[21];let k;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==w?(k=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:w,children:V})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=w,e[27]=k):k=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(st,{side:"bottom",children:"New task"}),e[28]=R):R=e[28];let T;e[29]!==k?(T=r.jsx("div",{className:"overflow-hidden",children:r.jsxs(it,{delayDuration:300,children:[k,R]})}),e[29]=k,e[30]=T):T=e[30];let E;e[31]!==x||e[32]!==T?(E=r.jsx("div",{className:x,children:T}),e[31]=x,e[32]=T,e[33]=E):E=e[33];let N;return e[34]!==E||e[35]!==g||e[36]!==_?(N=r.jsxs(r.Fragment,{children:[g,_,E]}),e[34]=E,e[35]=g,e[36]=_,e[37]=N):N=e[37],N}function O5(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),n=t.slice(s);if(e==null)return{visible:i,overflow:n};if(i.some(h=>h.id===e))return{visible:i,overflow:n};const a=n.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:n};const l=i[i.length-1],c=n[a],d=[...i.slice(0,-1),c],u=[l,...n.slice(0,a),...n.slice(a+1)];return{visible:d,overflow:u}}function $5(t){const e=B.c(13),{title:s,icon:i,active:n,onClick:o}=t,a=n?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=Y("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i?(c=r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(z5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==n||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=r.jsxs("button",{type:"button",onClick:o,"aria-pressed":n,"aria-label":s,className:l,children:[c,d]}),e[6]=n,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function z5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Xh,{className:"size-4"}),e[4]=i):i=e[4],i}function F5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[n,o]=S.useState(!1);let a;e[0]!==i?(a=m=>{o(!1),i(m)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ai,{asChild:!0,children:r.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:r.jsx(qh,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let m;e[6]!==l?(m=f=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l(f.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(H5,{icon:f.icon})}),r.jsx("span",{className:"truncate",children:f.title})]})},f.id),e[6]=l,e[7]=m):m=e[7],d=s.map(m),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=r.jsx(li,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==u?(h=r.jsxs(ci,{open:n,onOpenChange:o,children:[c,u]}),e[10]=n,e[11]=u,e[12]=h):h=e[12],h}function H5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Xh,{className:"size-4"}),e[4]=i):i=e[4],i}const W5=6;function U5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,n=Ke();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Ff(o);let u,h,m,f;if(e[3]!==l||e[4]!==c||e[5]!==n||e[6]!==d||e[7]!==a||e[8]!==s){const _=Qp({activeTab:l,mainOpen:c}),v=j=>j.id==="automations"?_:c&&j.id===l,b=a.find(j=>v(j))?.id??null,{visible:y,overflow:C}=O5(a,b,W5);h=C,u=j=>{const w=a.find(k=>k.id===j),V=b===j&&c;if(se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:w?.kind??null,was_active:V}),j==="automations"){const k=Zp({activeTab:l,mainOpen:c});n({to:".",search:R=>({...R,main:k}),replace:!0});return}d(j)},m="flex items-center min-w-0 ml-auto gap-0.5",f=y.map(j=>r.jsx($5,{title:j.title,icon:j.icon,active:v(j),onClick:()=>u(j.id)},j.id)),e[3]=l,e[4]=c,e[5]=n,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=m,e[12]=f}else u=e[9],h=e[10],m=e[11],f=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&r.jsx(F5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==m||e[17]!==f||e[18]!==p?(g=r.jsxs("div",{className:m,children:[f,p]}),e[16]=m,e[17]=f,e[18]=p,e[19]=g):g=e[19],g}function K5(t){const e=B.c(12);let s,i,n,o;e[0]!==t?({className:s,orientation:n,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=n===void 0?"horizontal":n,l=o===void 0?!0:o;let c;e[5]!==s?(c=Y("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=r.jsx(Np,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function q5(t){const e=B.c(20),{prNumber:s,disabled:i,send:n}=t;let o;e[0]!==s||e[1]!==n?(o=()=>n(dV({prNumber:s})),e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==n?(l=()=>n(cV({prNumber:s})),e[3]=s,e[4]=n,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=r.jsx(oe,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=r.jsx(As,{asChild:!0,children:r.jsx(oe,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let m;e[12]!==c?(m=r.jsx(Es,{align:"end",children:r.jsx(ot,{onClick:c,children:"Review"})}),e[12]=c,e[13]=m):m=e[13];let f;e[14]!==h||e[15]!==m?(f=r.jsxs(Ns,{children:[h,m]}),e[14]=h,e[15]=m,e[16]=f):f=e[16];let p;return e[17]!==d||e[18]!==f?(p=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,f]}),e[17]=d,e[18]=f,e[19]=p):p=e[19],p}const G5=new Set(["failure","timed_out","cancelled","action_required"]);function Y5(t){return t.status==="completed"&&G5.has(t.conclusion)}function X5(t){return t.status==="queued"||t.status==="in_progress"}function J5(t){const{branchStatus:e,pr:s,checks:i,reviews:n}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((n?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(Y5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(X5)?{label:"Running tests…",disabled:!0}:n?.draft?{label:"Mark ready",action:"mark-ready"}:(n?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:n?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function Q5(){return Yi().branchStatus}const Z5=6e4,ek=3e4;function tk(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Me(s),n=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==n?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:n},e[3]=t.owner,e[4]=t.repo,e[5]=n,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Z5,refetchIntervalInBackground:!1,staleTime:ek,select:sk},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],wi(l)}function sk(t){const e=Zr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),n=Number(e.review_comments??0),o=s==="blocked"&&n>0?n:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function ik(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=be(),n=ts(s),{currentBranch:o}=es(),a=Zn(),l=n?.metadata?.githubRepo??null,c=Q5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",m=o??null;let f;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==m?(f={orgId:i.id,connectionId:d,owner:u,repo:h,branch:m},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=m,e[5]=f):f=e[5];const g=Wf(f).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=Kf(y),j=l?.connectionId??"",w=l?.owner??"",V=l?.name??"",k=g&&g.state==="open"?g.number:null;let R;e[12]!==i.id||e[13]!==j||e[14]!==w||e[15]!==V||e[16]!==k?(R={orgId:i.id,connectionId:j,owner:w,repo:V,prNumber:k},e[12]=i.id,e[13]=j,e[14]=w,e[15]=V,e[16]=k,e[17]=R):R=e[17];const T=tk(R);if(!l?.connectionId||!o)return null;let E;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==T.data?(E=J5({branchStatus:c,pr:g,checks:C.data??[],reviews:T.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=T.data,e[22]=E):E=e[22];const N=E;if(!N)return null;let A;e[23]!==a?(A=$=>a.sendMessage({parts:[{type:"text",text:$}]}),e[23]=a,e[24]=A):A=e[24];const I=A,M=a.isStreaming;let L;e[25]!==o||e[26]!==N||e[27]!==M||e[28]!==g||e[29]!==I?(L=$=>{if(!M)switch($){case"commit-and-push":{I(tV({branch:o}));return}case"create-pr":{I(sV({branch:o}));return}case"reopen":{g&&I(iV({prNumber:g.number}));return}case"rebase":{I(rV({branch:o}));return}case"fix-checks":{g&&I(oV({prNumber:g.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{g&&I(aV({prNumber:g.number}));return}case"resolve-comments":{g&&I(lV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=N,e[27]=M,e[28]=g,e[29]=I,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(K5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let z;return e[32]!==N||e[33]!==M||e[34]!==D||e[35]!==I||e[36]!==O?(z=r.jsxs(r.Fragment,{children:[P,r.jsx(rk,{button:N,isStreaming:M,onActivate:D,prNumber:O,send:I})]}),e[32]=N,e[33]=M,e[34]=D,e[35]=I,e[36]=O,e[37]=z):z=e[37],z}function rk(t){const e=B.c(18),{button:s,isStreaming:i}=t,n=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==n||e[1]!==t.prNumber||e[2]!==t.send?(u=r.jsx(q5,{prNumber:t.prNumber,disabled:n,send:t.send}),e[0]=n,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let h;return e[4]!==u||e[5]!==o?(h=r.jsx(_h,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==n||e[12]!==a||e[13]!==l?(c=r.jsx(oe,{size:"sm",variant:a,disabled:n,onClick:l,children:s.label}),e[10]=s.label,e[11]=n,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=r.jsx(_h,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function _h(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=r.jsx(r.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let n;e[2]!==i?(n=r.jsx(tt,{asChild:!0,children:r.jsx("span",{children:i})}),e[2]=i,e[3]=n):n=e[3];let o;e[4]!==s?(o=r.jsx(st,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==o?(a=r.jsx(Mi,{children:r.jsxs(it,{children:[n,o]})}),e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function nk(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=r.jsx(ze.Right,{children:r.jsx(ik,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Ii=S.createContext(null);function lc(){return S.use(Ii)}function xh(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:n}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(De.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??r.jsx(Gu,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==n?(c=r.jsx(ks,{fallback:o,children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(De.ActiveTaskProvider,{taskId:n,children:l})})}),e[5]=l,e[6]=n,e[7]=c):c=e[7],c}function vh(t){const e=B.c(3),{onNewTaskRef:s,createNewTask:i}=t;let n;return e[0]!==i||e[1]!==s?(n=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=n):n=e[2],S.useLayoutEffect(n),null}function ok(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Dg,{size:20}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:r.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=n):n=e[2],n}function bh(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:n,children:o}=t,{org:a}=be(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?n?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const m=h;let f;e[2]!==a.id?(f={connectionId:Wt,orgId:a.id},e[2]=a.id,e[3]=f):f=e[3];const p=Me(f),{mutate:g}=Gl(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==n?(x=()=>{i&&d&&l&&(n?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:ak})))},b=[i,d,l,n,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=n,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==m?(y=r.jsx(PV,{daemonBaseUrl:m,children:o}),e[13]=o,e[14]=m,e[15]=y):y=e[15],y}function ak(t){console.error("[auto-start-vm] failed:",t)}function yh(){const t=B.c(106),e=Ds(),s=Ke(),{org:i}=be(),n=LS()?.tasksOpen??!1;I_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=$r(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=vi(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??ro(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let m;t[5]!==i.id?(m=ul(i.id),t[5]=i.id,t[6]=m):m=t[6];const f=h===m,p=!f,g=U_(a.taskId??"",h),_=ts(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let j;t[11]!==p||t[12]!==l||t[13]!==h?(j={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=j):j=t[14];const w=DS(b,j),{setOpenMobile:V,openMobile:k}=qr(),R=V,T=S.useRef(null);let E,N;t[15]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const q=K=>{Ph(K)&&K.shiftKey&&K.code==="KeyS"&&!K.repeat&&(K.preventDefault(),T.current?.())};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},N=[],t[15]=E,t[16]=N):(E=t[15],N=t[16]),S.useEffect(E,N);const A=h;let I;t[17]!==_||t[18]!==h?(I={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=I):I=t[19];const M=I;if(g.status==="creating"||g.status==="loading"){let q;t[20]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[r.jsx(Ee,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=q):q=t[20];let K;return t[21]!==M?(K=r.jsx(Ii,{value:M,children:q}),t[21]=M,t[22]=K):K=t[22],K}if(g.status==="error"){let q;t[23]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=q):q=t[23];let K;t[24]!==g.error.message?(K=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[q,r.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=K):K=t[25];let te;return t[26]!==M||t[27]!==K?(te=r.jsx(Ii,{value:M,children:K}),t[26]=M,t[27]=K,t[28]=te):te=t[28],te}if(!_){let q;t[29]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(ni,{size:48,className:"text-muted-foreground"}),t[29]=q):q=t[29];const K=`The agent "${h}" does not exist in this organization.`;let te;t[30]!==s||t[31]!==l?(te=r.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=te):te=t[32];let ee;t[33]!==K||t[34]!==te?(ee=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Oi,{image:q,title:"Agent not found",description:K,actions:te})})}),t[33]=K,t[34]=te,t[35]=ee):ee=t[35];let X;return t[36]!==M||t[37]!==ee?(X=r.jsx(Ii,{value:M,children:ee}),t[36]=M,t[37]=ee,t[38]=X):X=t[38],X}if(e){let q;t[39]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(C_,{className:"sr-only",children:"Navigation"}),t[39]=q):q=t[39];let K;t[40]!==R?(K=r.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:r.jsx(kS,{onClose:()=>R(!1)})}),t[40]=R,t[41]=K):K=t[41];let te;t[42]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:r.jsx(Ju,{})}),t[42]=te):te=t[42];let ee;t[43]!==K?(ee=r.jsxs(j_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[q,r.jsxs("div",{className:"flex h-full",children:[K,te]})]}),t[43]=K,t[44]=ee):ee=t[44];let X;t[45]!==k||t[46]!==R||t[47]!==ee?(X=r.jsx(k_,{open:k,onOpenChange:R,children:ee}),t[45]=k,t[46]=R,t[47]=ee,t[48]=X):X=t[48];const ie=X,re=_?.metadata?.vmMap;let he;t[49]!==w.createNewTask?(he=r.jsx(vh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[49]=w.createNewTask,t[50]=he):he=t[50];let xe;t[51]!==R?(xe=r.jsx(ok,{onOpenSidebar:()=>R(!0)}),t[51]=R,t[52]=xe):xe=t[52];const ae=f?"home":void 0;let ue;t[53]!==ae?(ue=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(xh,{variant:ae})}),t[53]=ae,t[54]=ue):ue=t[54];let me;t[55]!==C||t[56]!==ie||t[57]!==re||t[58]!==he||t[59]!==xe||t[60]!==ue||t[61]!==h?(me=r.jsxs(bh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:re,children:[he,xe,ue,ie]}),t[55]=C,t[56]=ie,t[57]=re,t[58]=he,t[59]=xe,t[60]=ue,t[61]=h,t[62]=me):me=t[62];let fe;t[63]!==A||t[64]!==me?(fe=r.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:r.jsx(De.Provider,{virtualMcpId:A,children:me},A)}),t[63]=A,t[64]=me,t[65]=fe):fe=t[65];let ce;return t[66]!==M||t[67]!==fe?(ce=r.jsx(Ii,{value:M,children:fe}),t[66]=M,t[67]=fe,t[68]=ce):ce=t[68],ce}const L=n?void 0:w.createNewTask;let D;t[69]!==f||t[70]!==w.chatOpen||t[71]!==w.toggleChat||t[72]!==L?(D=r.jsx(ze.Toggles,{children:r.jsx(B5,{isDecopilot:f,chatOpen:w.chatOpen,toggleChat:w.toggleChat,onNewTask:L})}),t[69]=f,t[70]=w.chatOpen,t[71]=w.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==f||t[75]!==w.taskId||t[76]!==h?(P=!f&&r.jsx(ze.Tabs,{children:r.jsx(U5,{virtualMcpId:h,taskId:w.taskId})}),t[74]=f,t[75]=w.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let z;t[78]!==_||t[79]!==f?(z=!f&&r.jsx(nk,{virtualMcp:_}),t[78]=_,t[79]=f,t[80]=z):z=t[80];let $;t[81]!==w.createNewTask?($=r.jsx(vh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[81]=w.createNewTask,t[82]=$):$=t[82];const U=f?"home":void 0;let F;t[83]!==U?(F=r.jsx(xh,{variant:U}),t[83]=U,t[84]=F):F=t[84];let G;t[85]!==w.chatOpen||t[86]!==w.mainOpen||t[87]!==w.taskId||t[88]!==F||t[89]!==h?(G=r.jsx(L5,{virtualMcpId:h,taskId:w.taskId,chatOpen:w.chatOpen,mainOpen:w.mainOpen,chatContent:F}),t[85]=w.chatOpen,t[86]=w.mainOpen,t[87]=w.taskId,t[88]=F,t[89]=h,t[90]=G):G=t[90];let W;t[91]!==C||t[92]!==O||t[93]!==z||t[94]!==$||t[95]!==G||t[96]!==h?(W=r.jsxs(bh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[z,$,G]}),t[91]=C,t[92]=O,t[93]=z,t[94]=$,t[95]=G,t[96]=h,t[97]=W):W=t[97];let H;t[98]!==A||t[99]!==P||t[100]!==W?(H=r.jsxs(De.Provider,{virtualMcpId:A,children:[P,W]},A),t[98]=A,t[99]=P,t[100]=W,t[101]=H):H=t[101];let Z;return t[102]!==M||t[103]!==D||t[104]!==H?(Z=r.jsxs(Ii,{value:M,children:[D,H]}),t[102]=M,t[103]=D,t[104]=H,t[105]=Z):Z=t[105],Z}function tN(){const t=B.c(5),e=Ds();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(jS,{}),t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={background:"transparent",containerType:"inline-size"},t[2]=n):n=t[2];let o;return t[3]!==e?(o=r.jsx(S_,{defaultOpen:!1,children:r.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:r.jsxs(w_,{className:"flex-1 bg-sidebar",style:s,children:[i,r.jsx(V_,{className:"flex flex-col",style:n,children:e?r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(yh,{})}):r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(MS,{children:r.jsxs(ze,{children:[r.jsxs(ze.Header,{children:[r.jsxs(ze.LeftColumn,{children:[r.jsx(ze.Nav,{}),r.jsx(ze.TogglesSlot,{})]}),r.jsx(ze.CenterSlot,{}),r.jsxs(ze.RightColumn,{children:[r.jsx(ze.TabsSlot,{}),r.jsx(ze.RightSlot,{})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[r.jsx(ew,{}),r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(yh,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{tN as default,lc as useInsetContext};
450
+ </message>`}]}}))},L=e.models?.credentialId||f||"",D=e.models?.thinking?.id||p?.modelId||"",P=Hi({defaultValues:{name:e.name,active:e.active,credential_id:L,model_id:D}}),O=P.watch("active"),z=P.watch("credential_id"),$=P.watch("model_id"),{models:U,isLoading:F}=su(z||void 0),G=U.find(ae=>ae.modelId===$)??null,W=S.useRef(null),H=S.useRef(new Set),Z=S.useRef(0),q=S.useRef(null),K=3e4,te=()=>{q.current&&(clearTimeout(q.current),q.current=null),W.current!==null&&(se("automation_updated",{automation_id:t,agent_id:o,fields:Array.from(H.current),save_count:Z.current,edit_duration_ms:Date.now()-W.current}),W.current=null,H.current=new Set,Z.current=0)},ee=async()=>{if(!(Object.keys(P.formState.dirtyFields).length>0)&&!I.current)return!0;const ue=Object.keys(P.formState.dirtyFields),me=I.current;I.current=!1;const fe=P.getValues();try{const ce=fe.credential_id&&fe.model_id?fe.credential_id:"",ve=fe.credential_id&&fe.model_id?fe.model_id:"",Ce={id:t,name:fe.name,active:fe.active,agent:{id:o},models:{credentialId:ce,thinking:{id:ve}},messages:Rp(b),temperature:0};await l.mutateAsync(Ce),W.current===null&&(W.current=Date.now());for(const Te of ue)H.current.add(Te);return me&&H.current.add("messages"),Z.current+=1,q.current&&clearTimeout(q.current),q.current=setTimeout(te,K),P.reset({...fe,credential_id:ce,model_id:ve}),!0}catch{return I.current=!0,!1}},X=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{ee()},1e3)},ie=async()=>(A.current&&clearTimeout(A.current),ee()),re=ae=>{if(y(ae),!N.current){N.current=!0;return}I.current=!0,X()},he=S.useRef(!1);he.current||(he.current=!0,P.watch(()=>{X()}));const xe=async()=>{se("automation_test_clicked",{automation_id:t,agent_id:o});const ae=await ie();if(te(),!ae)return;if(!b){pe.error("No instructions configured for this automation");return}G&&z&&m({...G,keyId:z}),v({..._,toolApprovalLevel:"auto"});const ue=dc(b);h({message:{tiptapDoc:b,parts:ue},virtualMcpId:o||void 0})};return r.jsxs(r.Fragment,{children:[i&&r.jsx("div",{className:"flex items-center pb-4 shrink-0",children:r.jsxs(oe,{variant:"ghost",size:"sm",onClick:i,children:[r.jsx(vl,{size:14}),"Back to list"]})}),r.jsxs("div",{className:"flex flex-col gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(bt,{...P.register("name"),placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}}),n&&r.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:r.jsx(ua,{size:14})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ai,{control:P.control,name:"active",render:({field:ae})=>r.jsx(ha,{checked:ae.value,onCheckedChange:ue=>{ae.onChange(ue),setTimeout(()=>ie(),0)},className:"cursor-pointer"})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:O?"Active":"Inactive"}),r.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),r.jsx(P_,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),r.jsx(S5,{automationId:t,open:C,onOpenChange:j,onCustomSelect:()=>{V(!0),E(!1),R("")},onEventSelect:()=>{E(!0),V(!1)}})]}),e.triggers.length===0&&!w?r.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",r.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>j(!0),children:"Add a starter"})," ","to get going."]})}):r.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ae=>r.jsx(w5,{trigger:ae,automationId:t,connectionName:ae.connection_id?u.get(ae.connection_id):void 0},ae.id))}),w&&r.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[r.jsx(_r,{size:14,className:"text-muted-foreground shrink-0"}),r.jsx("input",{type:"text",value:k,onChange:ae=>R(ae.target.value),onBlur:async()=>{const ae=k.trim();if(!(!ae||!Vr(ae)))try{await c.mutateAsync({automation_id:t,type:"cron",cron_expression:ae}),se("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),V(!1),R("")}catch{pe.error("Failed to add starter")}},onKeyDown:async ae=>{const ue=k.trim();ae.key==="Enter"&&ue&&Vr(ue)&&ae.target.blur(),ae.key==="Escape"&&(V(!1),R(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),k&&!Vr(k)&&r.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),c.isPending&&r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),r.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{V(!1),R("")},children:r.jsx(ri,{size:13})})]}),T&&r.jsx(S.Suspense,{fallback:r.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[r.jsx(Ee,{size:13,className:"animate-spin text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:r.jsx(C5,{automationId:t,onDone:()=>E(!1)})})]}),r.jsxs("div",{className:"flex flex-col gap-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),r.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:!b,onClick:M,children:[r.jsx(xl,{size:13}),"Improve"]})]}),r.jsx(Uu,{tiptapDoc:b,setTiptapDoc:re,placeholder:"What should this automation do?",children:r.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[r.jsx(Ku,{virtualMcpId:o||null,className:"max-h-[45vh]"}),r.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[r.jsx(ru,{model:G,isLoading:F,credentialId:z||null,onCredentialChange:ae=>{P.setValue("credential_id",ae??"",{shouldDirty:!0}),P.setValue("model_id","",{shouldDirty:!0})},onModelChange:ae=>P.setValue("model_id",ae.modelId,{shouldDirty:!0}),placeholder:"Model"}),r.jsxs(it,{children:[r.jsx(tt,{asChild:!0,children:r.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:xe,disabled:!o,children:[r.jsx(Hh,{size:16}),"Test"]})}),r.jsx(st,{children:"Test Automation"})]})]})]})})]})]})]})}function E5(t){const e=B.c(6),{tabId:s,virtualMcpId:i}=t;let n;e[0]!==s?(n=Ih(s),e[0]=s,e[1]=n):n=e[1];const o=n;if(!o)return null;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=a):a=e[2];let l;return e[3]!==o.id||e[4]!==i?(l=r.jsx(fs,{children:r.jsx(fs.Content,{children:r.jsx(fs.Body,{children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(I5,{id:o.id,virtualMcpId:i})})})})}),e[3]=o.id,e[4]=i,e[5]=l):l=e[5],l}function I5(t){const e=B.c(9),{id:s,virtualMcpId:i}=t,n=Ke(),{data:o,isLoading:a}=B_(s);let l;e[0]!==n?(l=()=>n({to:".",search:R5,replace:!0}),e[0]=n,e[1]=l):l=e[1];const c=l;if(a){let u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=u):u=e[2],u}if(!o){let u;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=u):u=e[3],u}let d;return e[4]!==o||e[5]!==s||e[6]!==c||e[7]!==i?(d=r.jsx(A5,{automationId:s,automation:o,virtualMcpId:i,onBack:c}),e[4]=o,e[5]=s,e[6]=c,e[7]=i,e[8]=d):d=e[8],d}function R5(t){return{...t,main:"automations"}}function T5(t){const e=B.c(19),{virtualMcpId:s}=t,i=Ke(),{data:n}=O_(s),o=n===void 0?[]:n,{create:a}=Yr(),[l,c]=S.useState(""),d=l.toLowerCase(),u=o.filter(k=>k.name.toLowerCase().includes(d));let h;e[0]!==i?(h=k=>i({to:".",search:R=>({...R,main:"automation:"+k}),replace:!0}),e[0]=i,e[1]=h):h=e[1];const m=h,f=async()=>{if(a.isPending)return;se("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const k=await a.mutateAsync(z_(s));m(k.id)},p=fs,g=fs,_=fs;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(Qt,{size:14}),e[2]=v):v=e[2];let x;e[3]!==a.isPending||e[4]!==f?(x=r.jsx(fs.Title,{actions:r.jsxs(oe,{size:"sm",onClick:f,disabled:a.isPending,children:[v,"New automation"]}),children:"Automations"}),e[3]=a.isPending,e[4]=f,e[5]=x):x=e[5];const b=o.length>0&&r.jsx(F_,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let y;e[6]!==x||e[7]!==b?(y=r.jsxs("div",{className:"flex flex-col gap-6",children:[x,b]}),e[6]=x,e[7]=b,e[8]=y):y=e[8];const C=o.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:r.jsxs(oe,{size:"sm",onClick:f,disabled:a.isPending,children:[r.jsx(Qt,{size:14}),"New automation"]})})}):u.length===0?r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx(Oi,{image:r.jsx($i,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):r.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(k=>r.jsx($_,{automation:k,onClick:()=>m(k.id)},k.id))});let j;e[9]!==_.Body||e[10]!==y||e[11]!==C?(j=r.jsxs(_.Body,{children:[y,C]}),e[9]=_.Body,e[10]=y,e[11]=C,e[12]=j):j=e[12];let w;e[13]!==j||e[14]!==g.Content?(w=r.jsx(g.Content,{children:j}),e[13]=j,e[14]=g.Content,e[15]=w):w=e[15];let V;return e[16]!==p||e[17]!==w?(V=r.jsx(p,{children:w}),e[16]=p,e[17]=w,e[18]=V):V=e[18],V}function D5(t){const e=B.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx(S.Suspense,{fallback:i,children:r.jsx(T5,{virtualMcpId:s})}),e[1]=s,e[2]=n):n=e[2],n}const ph=S.lazy(()=>kp(()=>import("./project-app-view-DA-h2zTN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])).then(t=>({default:t.AppViewContent})));function M5(t){const e=B.c(35),{taskId:s,virtualMcpId:i}=t;let n;e[0]!==s||e[1]!==i?(n={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=n):n=e[2];const{activeTab:o,layoutTabs:a,automationTabParsed:l}=Ff(n);if(Xp(o)){let f;return e[3]!==i?(f=r.jsx(xd,{virtualMcpId:i}),e[3]=i,e[4]=f):f=e[4],f}if(o==="git"){let f;return e[5]!==i?(f=r.jsx(yV,{virtualMcpId:i}),e[5]=i,e[6]=f):f=e[6],f}if(o==="automations"){let f;return e[7]!==i?(f=r.jsx(D5,{virtualMcpId:i}),e[7]=i,e[8]=f):f=e[8],f}if(o==="env"){let f;return e[9]!==i?(f=r.jsx(g5,{virtualMcpId:i}),e[9]=i,e[10]=f):f=e[10],f}if(o==="preview"){let f;return e[11]!==i?(f=r.jsx(QV,{virtualMcpId:i}),e[11]=i,e[12]=f):f=e[12],f}if(l){let f;return e[13]!==o||e[14]!==i?(f=r.jsx(E5,{tabId:o,virtualMcpId:i}),e[13]=o,e[14]=i,e[15]=f):f=e[15],f}let c;e[16]!==o?(c=Jp(o),e[16]=o,e[17]=c):c=e[17];const d=c;if(d){let f;e[18]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[18]=f):f=e[18];let p;return e[19]!==o||e[20]!==d.connectionId||e[21]!==d.toolName?(p=r.jsx(S.Suspense,{fallback:f,children:r.jsx(ph,{connectionId:d.connectionId,toolName:d.toolName},o)}),e[19]=o,e[20]=d.connectionId,e[21]=d.toolName,e[22]=p):p=e[22],p}let u;if(e[23]!==o||e[24]!==a){let f;e[26]!==o?(f=p=>p.id===o,e[26]=o,e[27]=f):f=e[27],u=a.find(f),e[23]=o,e[24]=a,e[25]=u}else u=e[25];const h=u;if(h){let f;e[28]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx("div",{className:"h-full w-full flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),e[28]=f):f=e[28];let p;return e[29]!==o||e[30]!==h.id||e[31]!==h.view.appId?(p=r.jsx(S.Suspense,{fallback:f,children:r.jsx(ph,{connectionId:h.view.appId,toolName:h.id},o)}),e[29]=o,e[30]=h.id,e[31]=h.view.appId,e[32]=p):p=e[32],p}let m;return e[33]!==i?(m=r.jsx(xd,{virtualMcpId:i}),e[33]=i,e[34]=m):m=e[34],m}function P5(t){const e=B.c(7),{children:s,defaultSize:i}=t,[,n]=S.useTransition();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ll.decoChatPanelWidth(),e[0]=o):o=e[0];const[a,l]=al(o,45),c=i>0&&i<100?a:i;let d;e[1]!==l?(d=m=>n(()=>{m>0&&m<100&&l(m)}),e[1]=l,e[2]=d):d=e[2];const u=d;let h;return e[3]!==s||e[4]!==c||e[5]!==u?(h=r.jsx(nu,{defaultSize:c,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=c,e[5]=u,e[6]=h):h=e[6],h}function L5(t){const e=B.c(31),{virtualMcpId:s,taskId:i,chatOpen:n,mainOpen:o,variant:a,chatContent:l}=t;let c;e[0]!==n||e[1]!==o?(c=fd(n,o),e[0]=n,e[1]=o,e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=ll.decoChatPanelWidth(),e[3]=u):u=e[3];const[h]=al(u,45),m=S.useRef(null);let f,p;e[4]!==n||e[5]!==o||e[6]!==h?(f=()=>{const T=m.current;if(!T)return;const E=fd(n,o),N=E.chat>0&&E.chat<100?h:E.chat,A=E.chat>0&&E.chat<100?100-h:E.main;T.setLayout([N,A])},p=[n,o,h],e[4]=n,e[5]=o,e[6]=h,e[7]=f,e[8]=p):(f=e[7],p=e[8]),S.useEffect(f,p);const g=`${s}-${i}`;let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_={overflow:"visible"},e[9]=_):_=e[9];let v;e[10]!==l||e[11]!==a?(v=l??r.jsx(Gu,{variant:a}),e[10]=l,e[11]=a,e[12]=v):v=e[12];let x;e[13]!==v?(x=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:v})}),e[13]=v,e[14]=x):x=e[14];let b;e[15]!==d.chat||e[16]!==x?(b=r.jsx(P5,{defaultSize:d.chat,children:x}),e[15]=d.chat,e[16]=x,e[17]=b):b=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=r.jsx(Yg,{className:"bg-sidebar"}),e[18]=y):y=e[18];const C=d.main;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j={overflow:"visible"},e[19]=j):j=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=Y("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[20]=w):w=e[20];let V;e[21]!==i||e[22]!==s?(V=r.jsx("div",{className:"h-full p-0.5 pt-0.25",children:r.jsx("div",{className:w,children:r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(M5,{taskId:i,virtualMcpId:s})})})}),e[21]=i,e[22]=s,e[23]=V):V=e[23];let k;e[24]!==d.main||e[25]!==V?(k=r.jsx(nu,{className:"min-w-0 flex flex-col",order:2,defaultSize:C,style:j,collapsible:!0,collapsedSize:0,minSize:20,children:V}),e[24]=d.main,e[25]=V,e[26]=k):k=e[26];let R;return e[27]!==k||e[28]!==g||e[29]!==b?(R=r.jsxs(Xg,{ref:m,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:_,children:[b,y,k]},g),e[27]=k,e[28]=g,e[29]=b,e[30]=R):R=e[30],R}const sa="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",gh="bg-sidebar-accent text-sidebar-foreground",ia="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function B5(t){const e=B.c(38),{isDecopilot:s,chatOpen:i,toggleChat:n,onNewTask:o}=t,{tasksOpen:a,toggleTasks:l}=$f(),c=!!o;let d;e[0]!==a||e[1]!==l?(d=()=>{se("agent_toolbar_toggled",{button:"tasks",next_state:a?"closed":"open"}),l()},e[0]=a,e[1]=l,e[2]=d):d=e[2];const u=a?gh:ia;let h;e[3]!==u?(h=Y(sa,u),e[3]=u,e[4]=h):h=e[4];let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(Ig,{size:16}),e[5]=m):m=e[5];let f;e[6]!==d||e[7]!==h||e[8]!==a?(f=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:d,"aria-pressed":a,className:h,children:m})}),e[6]=d,e[7]=h,e[8]=a,e[9]=f):f=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(st,{side:"bottom",children:"Tasks"}),e[10]=p):p=e[10];let g;e[11]!==f?(g=r.jsxs(it,{delayDuration:300,children:[f,p]}),e[11]=f,e[12]=g):g=e[12];let _;e[13]!==i||e[14]!==s||e[15]!==n?(_=!s&&r.jsxs(it,{delayDuration:300,children:[r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:()=>{se("agent_toolbar_toggled",{button:"chat",next_state:i?"closed":"open"}),n()},"aria-pressed":i,className:Y(sa,i?gh:ia),children:r.jsx(Eg,{size:16})})}),r.jsx(st,{side:"bottom",children:"Chat"})]}),e[13]=i,e[14]=s,e[15]=n,e[16]=_):_=e[16];const v=c?"grid-cols-[1fr]":"grid-cols-[0fr]";let x;e[17]!==v?(x=Y("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",v),e[17]=v,e[18]=x):x=e[18];const b=!c,y=c?0:-1,C=!c,j=c?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let w;e[19]!==j?(w=Y(sa,ia,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",j),e[19]=j,e[20]=w):w=e[20];let V;e[21]===Symbol.for("react.memo_cache_sentinel")?(V=r.jsx(gl,{size:16}),e[21]=V):V=e[21];let k;e[22]!==o||e[23]!==b||e[24]!==y||e[25]!==C||e[26]!==w?(k=r.jsx(tt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:o,disabled:b,tabIndex:y,"aria-hidden":C,className:w,children:V})}),e[22]=o,e[23]=b,e[24]=y,e[25]=C,e[26]=w,e[27]=k):k=e[27];let R;e[28]===Symbol.for("react.memo_cache_sentinel")?(R=r.jsx(st,{side:"bottom",children:"New task"}),e[28]=R):R=e[28];let T;e[29]!==k?(T=r.jsx("div",{className:"overflow-hidden",children:r.jsxs(it,{delayDuration:300,children:[k,R]})}),e[29]=k,e[30]=T):T=e[30];let E;e[31]!==x||e[32]!==T?(E=r.jsx("div",{className:x,children:T}),e[31]=x,e[32]=T,e[33]=E):E=e[33];let N;return e[34]!==E||e[35]!==g||e[36]!==_?(N=r.jsxs(r.Fragment,{children:[g,_,E]}),e[34]=E,e[35]=g,e[36]=_,e[37]=N):N=e[37],N}function O5(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),n=t.slice(s);if(e==null)return{visible:i,overflow:n};if(i.some(h=>h.id===e))return{visible:i,overflow:n};const a=n.findIndex(h=>h.id===e);if(a===-1)return{visible:i,overflow:n};const l=i[i.length-1],c=n[a],d=[...i.slice(0,-1),c],u=[l,...n.slice(0,a),...n.slice(a+1)];return{visible:d,overflow:u}}function $5(t){const e=B.c(13),{title:s,icon:i,active:n,onClick:o}=t,a=n?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=Y("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let c;e[2]!==i?(c=r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(z5,{icon:i})}),e[2]=i,e[3]=c):c=e[3];let d;e[4]!==s?(d=r.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=d):d=e[5];let u;return e[6]!==n||e[7]!==o||e[8]!==l||e[9]!==c||e[10]!==d||e[11]!==s?(u=r.jsxs("button",{type:"button",onClick:o,"aria-pressed":n,"aria-label":s,className:l,children:[c,d]}),e[6]=n,e[7]=o,e[8]=l,e[9]=c,e[10]=d,e[11]=s,e[12]=u):u=e[12],u}function z5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Xh,{className:"size-4"}),e[4]=i):i=e[4],i}function F5(t){const e=B.c(13),{overflow:s,onSelect:i}=t,[n,o]=S.useState(!1);let a;e[0]!==i?(a=m=>{o(!1),i(m)},e[0]=i,e[1]=a):a=e[1];const l=a;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=r.jsx(ai,{asChild:!0,children:r.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:r.jsx(qh,{className:"size-4"})})}),e[2]=c):c=e[2];let d;if(e[3]!==l||e[4]!==s){let m;e[6]!==l?(m=f=>r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>l(f.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[r.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:r.jsx(H5,{icon:f.icon})}),r.jsx("span",{className:"truncate",children:f.title})]})},f.id),e[6]=l,e[7]=m):m=e[7],d=s.map(m),e[3]=l,e[4]=s,e[5]=d}else d=e[5];let u;e[8]!==d?(u=r.jsx(li,{align:"end",className:"w-56 p-1",children:r.jsx("ul",{className:"flex flex-col",children:d})}),e[8]=d,e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==u?(h=r.jsxs(ci,{open:n,onOpenChange:o,children:[c,u]}),e[10]=n,e[11]=u,e[12]=h):h=e[12],h}function H5(t){const e=B.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:n}=s;let o;return e[0]!==n?(o=r.jsx(n,{className:"size-4"}),e[0]=n,e[1]=o):o=e[1],o}if(s.kind==="url"){let n;return e[2]!==s.src?(n=r.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=n):n=e[3],n}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Xh,{className:"size-4"}),e[4]=i):i=e[4],i}const W5=6;function U5(t){const e=B.c(20),{virtualMcpId:s,taskId:i}=t,n=Ke();let o;e[0]!==i||e[1]!==s?(o={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=o):o=e[2];const{tabs:a,activeTab:l,mainOpen:c,setActiveTab:d}=Ff(o);let u,h,m,f;if(e[3]!==l||e[4]!==c||e[5]!==n||e[6]!==d||e[7]!==a||e[8]!==s){const _=Qp({activeTab:l,mainOpen:c}),v=j=>j.id==="automations"?_:c&&j.id===l,b=a.find(j=>v(j))?.id??null,{visible:y,overflow:C}=O5(a,b,W5);h=C,u=j=>{const w=a.find(k=>k.id===j),V=b===j&&c;if(se("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:j,tab_kind:w?.kind??null,was_active:V}),j==="automations"){const k=Zp({activeTab:l,mainOpen:c});n({to:".",search:R=>({...R,main:k}),replace:!0});return}d(j)},m="flex items-center min-w-0 ml-auto gap-0.5",f=y.map(j=>r.jsx($5,{title:j.title,icon:j.icon,active:v(j),onClick:()=>u(j.id)},j.id)),e[3]=l,e[4]=c,e[5]=n,e[6]=d,e[7]=a,e[8]=s,e[9]=u,e[10]=h,e[11]=m,e[12]=f}else u=e[9],h=e[10],m=e[11],f=e[12];let p;e[13]!==u||e[14]!==h?(p=h.length>0&&r.jsx(F5,{overflow:h,onSelect:u}),e[13]=u,e[14]=h,e[15]=p):p=e[15];let g;return e[16]!==m||e[17]!==f||e[18]!==p?(g=r.jsxs("div",{className:m,children:[f,p]}),e[16]=m,e[17]=f,e[18]=p,e[19]=g):g=e[19],g}function K5(t){const e=B.c(12);let s,i,n,o;e[0]!==t?({className:s,orientation:n,decorative:o,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=n,e[4]=o):(s=e[1],i=e[2],n=e[3],o=e[4]);const a=n===void 0?"horizontal":n,l=o===void 0?!0:o;let c;e[5]!==s?(c=Y("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==c?(d=r.jsx(Np,{"data-slot":"separator-root",decorative:l,orientation:a,className:c,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=c,e[11]=d):d=e[11],d}function q5(t){const e=B.c(20),{prNumber:s,disabled:i,send:n}=t;let o;e[0]!==s||e[1]!==n?(o=()=>n(dV({prNumber:s})),e[0]=s,e[1]=n,e[2]=o):o=e[2];const a=o;let l;e[3]!==s||e[4]!==n?(l=()=>n(cV({prNumber:s})),e[3]=s,e[4]=n,e[5]=l):l=e[5];const c=l;let d;e[6]!==i||e[7]!==a?(d=r.jsx(oe,{size:"sm",className:"rounded-r-none border-r border-primary-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(kr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let h;e[10]!==i?(h=r.jsx(As,{asChild:!0,children:r.jsx(oe,{size:"sm",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=h):h=e[11];let m;e[12]!==c?(m=r.jsx(Es,{align:"end",children:r.jsx(ot,{onClick:c,children:"Review"})}),e[12]=c,e[13]=m):m=e[13];let f;e[14]!==h||e[15]!==m?(f=r.jsxs(Ns,{children:[h,m]}),e[14]=h,e[15]=m,e[16]=f):f=e[16];let p;return e[17]!==d||e[18]!==f?(p=r.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[d,f]}),e[17]=d,e[18]=f,e[19]=p):p=e[19],p}const G5=new Set(["failure","timed_out","cancelled","action_required"]);function Y5(t){return t.status==="completed"&&G5.has(t.conclusion)}function X5(t){return t.status==="queued"||t.status==="in_progress"}function J5(t){const{branchStatus:e,pr:s,checks:i,reviews:n}=t;if(!e)return null;if(e.workingTreeDirty||e.unpushed>0)return{label:"Save changes",action:"commit-and-push"};if(s?.merged)return!!e.headSha&&!!s.headSha&&e.headSha!==s.headSha?{label:"Submit for review",action:"create-pr"}:null;if(e.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen"};if(!s)return{label:"Submit for review",action:"create-pr"};if((n?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase"};const l=i.filter(Y5).map(c=>c.name);return l.length>0?{label:"Fix tests",action:"fix-checks",meta:{failingChecks:l}}:i.some(X5)?{label:"Running tests…",disabled:!0}:n?.draft?{label:"Mark ready",action:"mark-ready"}:(n?.unresolvedConversations??0)>0?{label:"Address feedback",action:"resolve-comments"}:n?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0}:{label:"Publish",action:"merge-split"}}return null}function Q5(){return Yi().branchStatus}const Z5=6e4,ek=3e4;function tk(t){const e=B.c(11);let s;e[0]!==t.connectionId||e[1]!==t.orgId?(s={connectionId:t.connectionId,orgId:t.orgId},e[0]=t.connectionId,e[1]=t.orgId,e[2]=s):s=e[2];const i=Me(s),n=t.prNumber??0;let o;e[3]!==t.owner||e[4]!==t.repo||e[5]!==n?(o={method:"get",owner:t.owner,repo:t.repo,pullNumber:n},e[3]=t.owner,e[4]=t.repo,e[5]=n,e[6]=o):o=e[6];const a=!!t.prNumber;let l;return e[7]!==i||e[8]!==o||e[9]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:o,enabled:a,refetchInterval:Z5,refetchIntervalInBackground:!1,staleTime:ek,select:sk},e[7]=i,e[8]=o,e[9]=a,e[10]=l):l=e[10],wi(l)}function sk(t){const e=Zr(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),n=Number(e.review_comments??0),o=s==="blocked"&&n>0?n:0;return{draft:i,mergeableState:s,unresolvedConversations:o,missingRequiredApprovals:s==="blocked"&&o===0}}function ik(t){const e=B.c(38),{virtualMcpId:s}=t,{org:i}=be(),n=ts(s),{currentBranch:o}=es(),a=Zn(),l=n?.metadata?.githubRepo??null,c=Q5(),d=l?.connectionId??"",u=l?.owner??"",h=l?.name??"",m=o??null;let f;e[0]!==i.id||e[1]!==d||e[2]!==u||e[3]!==h||e[4]!==m?(f={orgId:i.id,connectionId:d,owner:u,repo:h,branch:m},e[0]=i.id,e[1]=d,e[2]=u,e[3]=h,e[4]=m,e[5]=f):f=e[5];const g=Wf(f).data??null,_=l?.connectionId??"",v=l?.owner??"",x=l?.name??"",b=g&&g.state==="open"?g.number:null;let y;e[6]!==i.id||e[7]!==_||e[8]!==v||e[9]!==x||e[10]!==b?(y={orgId:i.id,connectionId:_,owner:v,repo:x,prNumber:b},e[6]=i.id,e[7]=_,e[8]=v,e[9]=x,e[10]=b,e[11]=y):y=e[11];const C=Kf(y),j=l?.connectionId??"",w=l?.owner??"",V=l?.name??"",k=g&&g.state==="open"?g.number:null;let R;e[12]!==i.id||e[13]!==j||e[14]!==w||e[15]!==V||e[16]!==k?(R={orgId:i.id,connectionId:j,owner:w,repo:V,prNumber:k},e[12]=i.id,e[13]=j,e[14]=w,e[15]=V,e[16]=k,e[17]=R):R=e[17];const T=tk(R);if(!l?.connectionId||!o)return null;let E;e[18]!==c||e[19]!==C.data||e[20]!==g||e[21]!==T.data?(E=J5({branchStatus:c,pr:g,checks:C.data??[],reviews:T.data??null}),e[18]=c,e[19]=C.data,e[20]=g,e[21]=T.data,e[22]=E):E=e[22];const N=E;if(!N)return null;let A;e[23]!==a?(A=$=>a.sendMessage({parts:[{type:"text",text:$}]}),e[23]=a,e[24]=A):A=e[24];const I=A,M=a.isStreaming;let L;e[25]!==o||e[26]!==N||e[27]!==M||e[28]!==g||e[29]!==I?(L=$=>{if(!M)switch($){case"commit-and-push":{I(tV({branch:o}));return}case"create-pr":{I(sV({branch:o}));return}case"reopen":{g&&I(iV({prNumber:g.number}));return}case"rebase":{I(rV({branch:o}));return}case"fix-checks":{g&&I(oV({prNumber:g.number,failingChecks:N.meta?.failingChecks??[]}));return}case"mark-ready":{g&&I(aV({prNumber:g.number}));return}case"resolve-comments":{g&&I(lV({prNumber:g.number}));return}case"merge-split":return}},e[25]=o,e[26]=N,e[27]=M,e[28]=g,e[29]=I,e[30]=L):L=e[30];const D=L;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(K5,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[31]=P):P=e[31];const O=g?.number;let z;return e[32]!==N||e[33]!==M||e[34]!==D||e[35]!==I||e[36]!==O?(z=r.jsxs(r.Fragment,{children:[P,r.jsx(rk,{button:N,isStreaming:M,onActivate:D,prNumber:O,send:I})]}),e[32]=N,e[33]=M,e[34]=D,e[35]=I,e[36]=O,e[37]=z):z=e[37],z}function rk(t){const e=B.c(18),{button:s,isStreaming:i}=t,n=!!s.disabled||i,o=i?"Chat is running":null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==n||e[1]!==t.prNumber||e[2]!==t.send?(u=r.jsx(q5,{prNumber:t.prNumber,disabled:n,send:t.send}),e[0]=n,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let h;return e[4]!==u||e[5]!==o?(h=r.jsx(_h,{label:o,children:u}),e[4]=u,e[5]=o,e[6]=h):h=e[6],h}const a=s.disabled?"outline":"default";let l;e[7]!==s.action||e[8]!==t?(l=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=l):l=e[9];let c;e[10]!==s.label||e[11]!==n||e[12]!==a||e[13]!==l?(c=r.jsx(oe,{size:"sm",variant:a,disabled:n,onClick:l,children:s.label}),e[10]=s.label,e[11]=n,e[12]=a,e[13]=l,e[14]=c):c=e[14];let d;return e[15]!==c||e[16]!==o?(d=r.jsx(_h,{label:o,children:c}),e[15]=c,e[16]=o,e[17]=d):d=e[17],d}function _h(t){const e=B.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=r.jsx(r.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let n;e[2]!==i?(n=r.jsx(tt,{asChild:!0,children:r.jsx("span",{children:i})}),e[2]=i,e[3]=n):n=e[3];let o;e[4]!==s?(o=r.jsx(st,{children:s}),e[4]=s,e[5]=o):o=e[5];let a;return e[6]!==n||e[7]!==o?(a=r.jsx(Mi,{children:r.jsxs(it,{children:[n,o]})}),e[6]=n,e[7]=o,e[8]=a):a=e[8],a}function nk(t){const e=B.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let o;return e[0]!==s.id?(o=r.jsx(ze.Right,{children:r.jsx(ik,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=o):o=e[1],o}const Ii=S.createContext(null);function lc(){return S.use(Ii)}function xh(t){const e=B.c(8),{children:s,variant:i}=t,{taskId:n}=es();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=o):o=e[0];let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(De.Skeleton,{}),e[1]=a):a=e[1];let l;e[2]!==s||e[3]!==i?(l=s??r.jsx(Gu,{variant:i}),e[2]=s,e[3]=i,e[4]=l):l=e[4];let c;return e[5]!==l||e[6]!==n?(c=r.jsx(ks,{fallback:o,children:r.jsx(S.Suspense,{fallback:a,children:r.jsx(De.ActiveTaskProvider,{taskId:n,children:l})})}),e[5]=l,e[6]=n,e[7]=c):c=e[7],c}function vh(t){const e=B.c(3),{onNewTaskRef:s,createNewTask:i}=t;let n;return e[0]!==i||e[1]!==s?(n=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=n):n=e[2],S.useLayoutEffect(n),null}function ok(t){const e=B.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(Dg,{size:20}),e[0]=i):i=e[0];let n;return e[1]!==s?(n=r.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:r.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=n):n=e[2],n}function bh(t){const e=B.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:n,children:o}=t,{org:a}=be(),{currentBranch:l}=es(),{data:c}=St.useSession(),d=c?.user?.id,u=d&&l?n?.[d]?.[l]??null:null;let h;e[0]!==u?(h=u?.previewUrl?u.previewUrl.replace(/\/$/,""):null,e[0]=u,e[1]=h):h=e[1];const m=h;let f;e[2]!==a.id?(f={connectionId:Wt,orgId:a.id},e[2]=a.id,e[3]=f):f=e[3];const p=Me(f),{mutate:g}=Gl(p);let _;e[4]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[4]=_):_=e[4];const v=S.useRef(_);let x,b;e[5]!==l||e[6]!==i||e[7]!==g||e[8]!==d||e[9]!==s||e[10]!==n?(x=()=>{i&&d&&l&&(n?.[d]?.[l]||v.current.has(l)||(v.current.add(l),g({virtualMcpId:s,branch:l},{onError:ak})))},b=[i,d,l,n,s,g],e[5]=l,e[6]=i,e[7]=g,e[8]=d,e[9]=s,e[10]=n,e[11]=x,e[12]=b):(x=e[11],b=e[12]),S.useEffect(x,b);let y;return e[13]!==o||e[14]!==m?(y=r.jsx(PV,{daemonBaseUrl:m,children:o}),e[13]=o,e[14]=m,e[15]=y):y=e[15],y}function ak(t){console.error("[auto-start-vm] failed:",t)}function yh(){const t=B.c(106),e=Ds(),s=Ke(),{org:i}=be(),n=LS()?.tasksOpen??!1;I_(i.id);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},t[0]=o):o=t[0];const a=$r(o),l=a.org??"";let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},t[1]=c):c=t[1];const d=vi(c);let u;t[2]!==i.id||t[3]!==d.virtualmcpid?(u=d.virtualmcpid??ro(i.id).id,t[2]=i.id,t[3]=d.virtualmcpid,t[4]=u):u=t[4];const h=u;let m;t[5]!==i.id?(m=ul(i.id),t[5]=i.id,t[6]=m):m=t[6];const f=h===m,p=!f,g=U_(a.taskId??"",h),_=ts(h),v=_?.metadata?.ui?.layout??null;let x;t[7]!==v?(x=v?{defaultMainView:v.defaultMainView??null,chatDefaultOpen:v.chatDefaultOpen??null}:null,t[7]=v,t[8]=x):x=t[8];const b=x;let y;t[9]!==_?(y=_&&Fs(_),t[9]=_,t[10]=y):y=t[10];const C=!!y;let j;t[11]!==p||t[12]!==l||t[13]!==h?(j={virtualMcpId:h,orgSlug:l,isAgentRoute:p},t[11]=p,t[12]=l,t[13]=h,t[14]=j):j=t[14];const w=DS(b,j),{setOpenMobile:V,openMobile:k}=qr(),R=V,T=S.useRef(null);let E,N;t[15]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const q=K=>{Ph(K)&&K.shiftKey&&K.code==="KeyS"&&!K.repeat&&(K.preventDefault(),T.current?.())};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},N=[],t[15]=E,t[16]=N):(E=t[15],N=t[16]),S.useEffect(E,N);const A=h;let I;t[17]!==_||t[18]!==h?(I={virtualMcpId:h,entity:_},t[17]=_,t[18]=h,t[19]=I):I=t[19];const M=I;if(g.status==="creating"||g.status==="loading"){let q;t[20]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[r.jsx(Ee,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[20]=q):q=t[20];let K;return t[21]!==M?(K=r.jsx(Ii,{value:M,children:q}),t[21]=M,t[22]=K):K=t[22],K}if(g.status==="error"){let q;t[23]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[23]=q):q=t[23];let K;t[24]!==g.error.message?(K=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[q,r.jsx("div",{className:"text-muted-foreground",children:g.error.message})]})}),t[24]=g.error.message,t[25]=K):K=t[25];let te;return t[26]!==M||t[27]!==K?(te=r.jsx(Ii,{value:M,children:K}),t[26]=M,t[27]=K,t[28]=te):te=t[28],te}if(!_){let q;t[29]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(ni,{size:48,className:"text-muted-foreground"}),t[29]=q):q=t[29];const K=`The agent "${h}" does not exist in this organization.`;let te;t[30]!==s||t[31]!==l?(te=r.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[30]=s,t[31]=l,t[32]=te):te=t[32];let ee;t[33]!==K||t[34]!==te?(ee=r.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:r.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:r.jsx(Oi,{image:q,title:"Agent not found",description:K,actions:te})})}),t[33]=K,t[34]=te,t[35]=ee):ee=t[35];let X;return t[36]!==M||t[37]!==ee?(X=r.jsx(Ii,{value:M,children:ee}),t[36]=M,t[37]=ee,t[38]=X):X=t[38],X}if(e){let q;t[39]===Symbol.for("react.memo_cache_sentinel")?(q=r.jsx(C_,{className:"sr-only",children:"Navigation"}),t[39]=q):q=t[39];let K;t[40]!==R?(K=r.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:r.jsx(kS,{onClose:()=>R(!1)})}),t[40]=R,t[41]=K):K=t[41];let te;t[42]===Symbol.for("react.memo_cache_sentinel")?(te=r.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:r.jsx(Ju,{})}),t[42]=te):te=t[42];let ee;t[43]!==K?(ee=r.jsxs(j_,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[q,r.jsxs("div",{className:"flex h-full",children:[K,te]})]}),t[43]=K,t[44]=ee):ee=t[44];let X;t[45]!==k||t[46]!==R||t[47]!==ee?(X=r.jsx(k_,{open:k,onOpenChange:R,children:ee}),t[45]=k,t[46]=R,t[47]=ee,t[48]=X):X=t[48];const ie=X,re=_?.metadata?.vmMap;let he;t[49]!==w.createNewTask?(he=r.jsx(vh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[49]=w.createNewTask,t[50]=he):he=t[50];let xe;t[51]!==R?(xe=r.jsx(ok,{onOpenSidebar:()=>R(!0)}),t[51]=R,t[52]=xe):xe=t[52];const ae=f?"home":void 0;let ue;t[53]!==ae?(ue=r.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:r.jsx(xh,{variant:ae})}),t[53]=ae,t[54]=ue):ue=t[54];let me;t[55]!==C||t[56]!==ie||t[57]!==re||t[58]!==he||t[59]!==xe||t[60]!==ue||t[61]!==h?(me=r.jsxs(bh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:re,children:[he,xe,ue,ie]}),t[55]=C,t[56]=ie,t[57]=re,t[58]=he,t[59]=xe,t[60]=ue,t[61]=h,t[62]=me):me=t[62];let fe;t[63]!==A||t[64]!==me?(fe=r.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:r.jsx(De.Provider,{virtualMcpId:A,children:me},A)}),t[63]=A,t[64]=me,t[65]=fe):fe=t[65];let ce;return t[66]!==M||t[67]!==fe?(ce=r.jsx(Ii,{value:M,children:fe}),t[66]=M,t[67]=fe,t[68]=ce):ce=t[68],ce}const L=n?void 0:w.createNewTask;let D;t[69]!==f||t[70]!==w.chatOpen||t[71]!==w.toggleChat||t[72]!==L?(D=r.jsx(ze.Toggles,{children:r.jsx(B5,{isDecopilot:f,chatOpen:w.chatOpen,toggleChat:w.toggleChat,onNewTask:L})}),t[69]=f,t[70]=w.chatOpen,t[71]=w.toggleChat,t[72]=L,t[73]=D):D=t[73];let P;t[74]!==f||t[75]!==w.taskId||t[76]!==h?(P=!f&&r.jsx(ze.Tabs,{children:r.jsx(U5,{virtualMcpId:h,taskId:w.taskId})}),t[74]=f,t[75]=w.taskId,t[76]=h,t[77]=P):P=t[77];const O=_?.metadata?.vmMap;let z;t[78]!==_||t[79]!==f?(z=!f&&r.jsx(nk,{virtualMcp:_}),t[78]=_,t[79]=f,t[80]=z):z=t[80];let $;t[81]!==w.createNewTask?($=r.jsx(vh,{onNewTaskRef:T,createNewTask:w.createNewTask}),t[81]=w.createNewTask,t[82]=$):$=t[82];const U=f?"home":void 0;let F;t[83]!==U?(F=r.jsx(xh,{variant:U}),t[83]=U,t[84]=F):F=t[84];let G;t[85]!==w.chatOpen||t[86]!==w.mainOpen||t[87]!==w.taskId||t[88]!==F||t[89]!==h?(G=r.jsx(L5,{virtualMcpId:h,taskId:w.taskId,chatOpen:w.chatOpen,mainOpen:w.mainOpen,chatContent:F}),t[85]=w.chatOpen,t[86]=w.mainOpen,t[87]=w.taskId,t[88]=F,t[89]=h,t[90]=G):G=t[90];let W;t[91]!==C||t[92]!==O||t[93]!==z||t[94]!==$||t[95]!==G||t[96]!==h?(W=r.jsxs(bh,{virtualMcpId:h,hasActiveGithubRepo:C,vmMap:O,children:[z,$,G]}),t[91]=C,t[92]=O,t[93]=z,t[94]=$,t[95]=G,t[96]=h,t[97]=W):W=t[97];let H;t[98]!==A||t[99]!==P||t[100]!==W?(H=r.jsxs(De.Provider,{virtualMcpId:A,children:[P,W]},A),t[98]=A,t[99]=P,t[100]=W,t[101]=H):H=t[101];let Z;return t[102]!==M||t[103]!==D||t[104]!==H?(Z=r.jsxs(Ii,{value:M,children:[D,H]}),t[102]=M,t[103]=D,t[104]=H,t[105]=Z):Z=t[105],Z}function tN(){const t=B.c(5),e=Ds();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={"--sidebar-width-icon":"3.5rem"},t[0]=s):s=t[0];let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx(jS,{}),t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n={background:"transparent",containerType:"inline-size"},t[2]=n):n=t[2];let o;return t[3]!==e?(o=r.jsx(S_,{defaultOpen:!1,children:r.jsx("div",{className:"flex flex-col h-dvh overflow-hidden",children:r.jsxs(w_,{className:"flex-1 bg-sidebar",style:s,children:[i,r.jsx(V_,{className:"flex flex-col",style:n,children:e?r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(yh,{})}):r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(MS,{children:r.jsxs(ze,{children:[r.jsxs(ze.Header,{children:[r.jsxs(ze.LeftColumn,{children:[r.jsx(ze.Nav,{}),r.jsx(ze.TogglesSlot,{})]}),r.jsx(ze.CenterSlot,{}),r.jsxs(ze.RightColumn,{children:[r.jsx(ze.TabsSlot,{}),r.jsx(ze.RightSlot,{})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-row",children:[r.jsx(ew,{}),r.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:r.jsx(S.Suspense,{fallback:r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx(Ee,{size:20,className:"animate-spin text-muted-foreground"})}),children:r.jsx(yh,{})})})]})]})})})})]})})}),t[3]=e,t[4]=o):o=t[4],o}export{tN as default,lc as useInsetContext};