decocms 4.36.1 → 4.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/client/assets/{AlertCircle-C2zx73v1.js → AlertCircle-B2MTFPS8.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-OGhitWLh.js → ArrowUpRight-3C0ovRNT.js} +1 -1
  3. package/dist/client/assets/{Check-D6HvgI2g.js → Check-hTX0g2g6.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-CYZdwL-J.js → CheckCircle-BjY-L4wY.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-ByETU86_.js → ChevronDown-CtbNgJjS.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-7KvMU2vd.js → ChevronRight-COyMMtrn.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-CYrCj8X7.js → ChevronUp-DrQLdS-5.js} +1 -1
  8. package/dist/client/assets/{Circle-DOOA9v6c.js → Circle-CbNg9WkJ.js} +1 -1
  9. package/dist/client/assets/{Copy01-D-BRa4K0.js → Copy01-nNlbPBfs.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CLtGCuZK.js → DotsVertical-Rhpmgb2O.js} +1 -1
  11. package/dist/client/assets/{Eye-D6qP6V4S.js → Eye-tz4NoIL3.js} +1 -1
  12. package/dist/client/assets/{FilterLines-D7dDw7wL.js → FilterLines-CGeWpTTu.js} +1 -1
  13. package/dist/client/assets/{Globe01-CuYb5M-c.js → Globe01-DAnAnRWA.js} +1 -1
  14. package/dist/client/assets/{Globe04-B__PKdCg.js → Globe04-GxqrJxZR.js} +1 -1
  15. package/dist/client/assets/{HardDrive-DRzRwjaA.js → HardDrive-DyDObBdu.js} +1 -1
  16. package/dist/client/assets/{Key01-D-qRXFHh.js → Key01-CYWVoXbx.js} +1 -1
  17. package/dist/client/assets/{LayoutLeft-C3EmIjeK.js → LayoutLeft-MTYFfG6g.js} +1 -1
  18. package/dist/client/assets/{LinkExternal01-VTHhLEjU.js → LinkExternal01-CStBYLEA.js} +1 -1
  19. package/dist/client/assets/{List-iDbaSfVT.js → List-DX8nYhDN.js} +1 -1
  20. package/dist/client/assets/{Loading02-67soz7DG.js → Loading02-O--MdSmG.js} +1 -1
  21. package/dist/client/assets/{Monitor01-Fie3xtLO.js → Monitor01-DKsaSo1z.js} +1 -1
  22. package/dist/client/assets/{Palette-M1ORiolb.js → Palette-COnagfGv.js} +1 -1
  23. package/dist/client/assets/{Play-BA8f3fnM.js → Play-ZxstDp2T.js} +1 -1
  24. package/dist/client/assets/{Plus-ByOZ9gpl.js → Plus-BGYMpw9I.js} +1 -1
  25. package/dist/client/assets/{SearchLg-CrTBzGwT.js → SearchLg-D9ukiV6Z.js} +1 -1
  26. package/dist/client/assets/{SearchMd-DV92b2Zw.js → SearchMd-BBEv0nJn.js} +1 -1
  27. package/dist/client/assets/{Settings02-OEOBFgTP.js → Settings02-DiK4Zfdk.js} +1 -1
  28. package/dist/client/assets/{Shield01-Cdi1yUP9.js → Shield01-BUQ-CBWY.js} +1 -1
  29. package/dist/client/assets/{Star01-0p5PUoqR.js → Star01-DL3N0SSB.js} +1 -1
  30. package/dist/client/assets/{Stars01-r7l5BwMj.js → Stars01-snzEz7AB.js} +1 -1
  31. package/dist/client/assets/{Stars02-DsvP56BL.js → Stars02-CS7iRFAY.js} +1 -1
  32. package/dist/client/assets/{Sun-D5XAhhyB.js → Sun-BJJc3pjv.js} +1 -1
  33. package/dist/client/assets/{SwitchHorizontal01-D-dAE6RW.js → SwitchHorizontal01-Cv0gqoMg.js} +1 -1
  34. package/dist/client/assets/{Tool01-DTzBlqba.js → Tool01-C2uuW4sH.js} +1 -1
  35. package/dist/client/assets/{Trash01-CaBABzO2.js → Trash01-CMz4JKhN.js} +1 -1
  36. package/dist/client/assets/{Upload01-sOqK5QXu.js → Upload01-Cp-_RjRZ.js} +1 -1
  37. package/dist/client/assets/{User01-BIkzGI_P.js → User01-DknnnxgR.js} +1 -1
  38. package/dist/client/assets/{Users01-DW9NksVW.js → Users01-DX1dVpzy.js} +1 -1
  39. package/dist/client/assets/{Users03-CEq8hIuH.js → Users03-CTDBVnnv.js} +1 -1
  40. package/dist/client/assets/{X-BsurtT-j.js → X-BfuzWudS.js} +1 -1
  41. package/dist/client/assets/{XCircle-DSjVZp8y.js → XCircle-E2sSpnug.js} +1 -1
  42. package/dist/client/assets/{XClose-BlRyle85.js → XClose-DFQ360gy.js} +1 -1
  43. package/dist/client/assets/{Zap-yMgLq3tY.js → Zap-utKfCp3-.js} +1 -1
  44. package/dist/client/assets/{ZapSquare-Bd5s_Rdz.js → ZapSquare-BH5fJb6A.js} +1 -1
  45. package/dist/client/assets/{ZoomOut-CKTNxroC.js → ZoomOut-CT0X_7Jz.js} +1 -1
  46. package/dist/client/assets/{access-gate-Dc3gPUBu.js → access-gate-Dx6MkDA5.js} +1 -1
  47. package/dist/client/assets/{add-section-modal-D1oVmoDv.js → add-section-modal-Dn9Nqw9B.js} +1 -1
  48. package/dist/client/assets/{agent-capabilities-Bf0tk_gW.js → agent-capabilities-D9YyIGdF.js} +1 -1
  49. package/dist/client/assets/{agent-icon-BorkCYJw.js → agent-icon-DbNqfZc_.js} +1 -1
  50. package/dist/client/assets/{agents-list-CfKG18-o.js → agents-list-Djv5YvSe.js} +1 -1
  51. package/dist/client/assets/{ai-providers-BClpMP1p.js → ai-providers-DJI1U_jp.js} +1 -1
  52. package/dist/client/assets/{alert-BmsHPPxC.js → alert-Bfmv8FC7.js} +1 -1
  53. package/dist/client/assets/{alert-dialog-CuyxrrrS.js → alert-dialog-BlTyvb5S.js} +1 -1
  54. package/dist/client/assets/{app-editor-CQyzSGAt.js → app-editor-CETJj2AM.js} +1 -1
  55. package/dist/client/assets/{auth-BzmdwOhT.js → auth-CaTmxkVI.js} +1 -1
  56. package/dist/client/assets/{auth-catchall-D82Rjmex.js → auth-catchall-BEzlchjB.js} +1 -1
  57. package/dist/client/assets/{auth-entry-aCnf-2wA.js → auth-entry-4PMsoHu8.js} +1 -1
  58. package/dist/client/assets/{auth-split-layout-DfBbLOlx.js → auth-split-layout-0k_6qDlQ.js} +1 -1
  59. package/dist/client/assets/{authenticate-and-persist-oauth-D3fnngdw.js → authenticate-and-persist-oauth-CiUVcPTS.js} +1 -1
  60. package/dist/client/assets/{automation-list-row-6_cQV5lO.js → automation-list-row-DsN97P8i.js} +1 -1
  61. package/dist/client/assets/{automation-runs-B5a4VZox.js → automation-runs-TZuhdUpi.js} +1 -1
  62. package/dist/client/assets/{automations-BUz4OA2X.js → automations-BbKkAM2W.js} +1 -1
  63. package/dist/client/assets/{autosend-BM-B1IAA.js → autosend-D4dPIA2Q.js} +1 -1
  64. package/dist/client/assets/{avatar-B1wJc9_9.js → avatar-CvuiT91G.js} +1 -1
  65. package/dist/client/assets/{badge-DqqUCIT0.js → badge-DOfBOYyl.js} +1 -1
  66. package/dist/client/assets/{block-document-C3RSKn5K.js → block-document-BLd6tzam.js} +1 -1
  67. package/dist/client/assets/{brand-context-Cv-WGYWl.js → brand-context-Ca6q9Tqj.js} +1 -1
  68. package/dist/client/assets/{breadcrumb-jPCxMGe_.js → breadcrumb-D5us0V-m.js} +1 -1
  69. package/dist/client/assets/{buckets-BIJdDXhq.js → buckets-Dls2XDL-.js} +1 -1
  70. package/dist/client/assets/{bulk-category-panel-CzfCRQM_.js → bulk-category-panel-C4Bw4AHl.js} +1 -1
  71. package/dist/client/assets/{calendar-DHJhad1j.js → calendar-B-i9ZRLn.js} +1 -1
  72. package/dist/client/assets/{capability-load-error-oLKDTbs2.js → capability-load-error-D7nD2P6s.js} +1 -1
  73. package/dist/client/assets/{card-XoGkEmyY.js → card-lN93fE4x.js} +1 -1
  74. package/dist/client/assets/{category-editor-BXQcvflh.js → category-editor-C-bPIYYJ.js} +1 -1
  75. package/dist/client/assets/{chat-context-BcZe3D5x.js → chat-context-BjfvKTYg.js} +1 -1
  76. package/dist/client/assets/{checkbox-BaOOKY6q.js → checkbox-D_SvHOnD.js} +1 -1
  77. package/dist/client/assets/{cli-auth-success-CNlUcm0U.js → cli-auth-success-B7yXUnSd.js} +1 -1
  78. package/dist/client/assets/{collection-detail-CbifGYVm.js → collection-detail-Chy6MzYE.js} +1 -1
  79. package/dist/client/assets/{collection-display-button-DwBGtrEM.js → collection-display-button-fVbJP6MV.js} +1 -1
  80. package/dist/client/assets/{collection-search-BiSwH17E.js → collection-search-DlG-P_hI.js} +1 -1
  81. package/dist/client/assets/{collection-table-wrapper-1I0mDH2w.js → collection-table-wrapper-CLeEt78c.js} +1 -1
  82. package/dist/client/assets/{collection-tabs-BKiPDgUq.js → collection-tabs-CGV57TWU.js} +1 -1
  83. package/dist/client/assets/{command-BaISYNTo.js → command-CwCzyhKv.js} +1 -1
  84. package/dist/client/assets/{commerce-onboarding-BPAQB53K.js → commerce-onboarding-CJDsD41v.js} +1 -1
  85. package/dist/client/assets/{connect-desktop-dialog-CCKz7Z_e.js → connect-desktop-dialog-BjxQ9REX.js} +1 -1
  86. package/dist/client/assets/{connection-card-CN6kBoX7.js → connection-card-BvJ7ni9e.js} +1 -1
  87. package/dist/client/assets/{connection-detail-g66H9HxG.js → connection-detail-DOPJPQxf.js} +1 -1
  88. package/dist/client/assets/{connection-form-helpers-Dd-rb-tx.js → connection-form-helpers-CEr3ghMm.js} +1 -1
  89. package/dist/client/assets/{connections-Co6McEqm.js → connections-B_-RgGOG.js} +1 -1
  90. package/dist/client/assets/{decopilot-sse-pool-Dvi7BTFV.js → decopilot-sse-pool-ZwquLkpw.js} +1 -1
  91. package/dist/client/assets/{dialog-Cqozb2z_.js → dialog-CecKqyMD.js} +1 -1
  92. package/dist/client/assets/{domain-settings-BFmfTjQ4.js → domain-settings-CBSHzxhR.js} +1 -1
  93. package/dist/client/assets/{drawer-CJJAGKvo.js → drawer-CYdd2dRg.js} +1 -1
  94. package/dist/client/assets/{dropdown-menu-BkaIZk4g.js → dropdown-menu-DgOUTi08.js} +1 -1
  95. package/dist/client/assets/{empty-state-m5P2rnUP.js → empty-state-A08rgKQW.js} +1 -1
  96. package/dist/client/assets/{extract-connection-data-Bh73dMWr.js → extract-connection-data-JlVrtTOq.js} +1 -1
  97. package/dist/client/assets/{file-explorer-B1c6Fj3p.js → file-explorer-C0HkCv56.js} +1 -1
  98. package/dist/client/assets/{file-type-icon-D-15TrXD.js → file-type-icon-hNB12mM-.js} +1 -1
  99. package/dist/client/assets/{files-CeqnLcq9.js → files-BD5hM59O.js} +1 -1
  100. package/dist/client/assets/{form-DUMjAMVd.js → form-DScNzOXD.js} +1 -1
  101. package/dist/client/assets/{general-Bpja7KX9.js → general-C6AsH2oC.js} +1 -1
  102. package/dist/client/assets/{github-repo-picker-B-pHTDyi.js → github-repo-picker-LXQPUBg-.js} +1 -1
  103. package/dist/client/assets/{hooks-DfKlo-cr.js → hooks-BDC3xAqI.js} +1 -1
  104. package/dist/client/assets/{index-jtjapMhV.js → index-6boH-yNr.js} +1 -1
  105. package/dist/client/assets/{index-Bk3RzB-u.js → index-9QwACmFE.js} +1 -1
  106. package/dist/client/assets/{index-Dk8vPBPa.js → index-B5zfNCUb.js} +1 -1
  107. package/dist/client/assets/{index-D6R0O2P2.js → index-BDb5jgty.js} +1 -1
  108. package/dist/client/assets/{index-B_EBz91i.js → index-Ba1nrFdh.js} +1 -1
  109. package/dist/client/assets/{index-CvwG42UF.js → index-BbQHVX85.js} +1 -1
  110. package/dist/client/assets/{index-DbeHUDZJ.js → index-Br7hFXfd.js} +1 -1
  111. package/dist/client/assets/{index-Ct45J5ta.js → index-C1EaTR0J.js} +1 -1
  112. package/dist/client/assets/{index-CBvAxu0B.js → index-CBrpJgay.js} +5 -5
  113. package/dist/client/assets/{index-BkZkf0_g.js → index-D0vcYjWr.js} +1 -1
  114. package/dist/client/assets/{index-DmzFFBrg.js → index-D5AMb38_.js} +3 -3
  115. package/dist/client/assets/{index-DwtTkR4L.js → index-DBLJJ5hc.js} +1 -1
  116. package/dist/client/assets/{index-xjClfdVW.js → index-DXhlgdhI.js} +1 -1
  117. package/dist/client/assets/{index-1YmBxrx_.js → index-Wojdijed.js} +1 -1
  118. package/dist/client/assets/{index-redirect-ky12OAiK.js → index-redirect-BY0_EL5a.js} +1 -1
  119. package/dist/client/assets/{input-Bb_xVFER.js → input-CLXnGmJ0.js} +1 -1
  120. package/dist/client/assets/{integration-icon-DATPgjQE.js → integration-icon-BQOBM6zg.js} +1 -1
  121. package/dist/client/assets/{invite-member-dialog-WIQ70Hpp.js → invite-member-dialog-DGgUEy2i.js} +1 -1
  122. package/dist/client/assets/{label-B94P9vB0.js → label-aX83GfeD.js} +1 -1
  123. package/dist/client/assets/{login-BeVs55ND.js → login-BbfrNJpm.js} +1 -1
  124. package/dist/client/assets/{mcp-oauth-CnV7j05R.js → mcp-oauth-C2pIfPax.js} +1 -1
  125. package/dist/client/assets/{members-BoPCU0hW.js → members-BOOOGHcj.js} +1 -1
  126. package/dist/client/assets/{monaco-editor-QbvzQOeC.js → monaco-editor-D8cnNfve.js} +1 -1
  127. package/dist/client/assets/{monitoring-stats-row-CYANVK3F.js → monitoring-stats-row-Q8mnJjzS.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-CKOmkiBS.js → oauth-callback-LUg6IDQ-.js} +1 -1
  129. package/dist/client/assets/{oauth-callback-ai-provider-Z6CGvF8D.js → oauth-callback-ai-provider-BZ0Wn0-b.js} +1 -1
  130. package/dist/client/assets/{onboarding-CVUKdr0o.js → onboarding-C2tFYRj7.js} +1 -1
  131. package/dist/client/assets/{org-install-CKs2rVPE.js → org-install-DYa-yF2T.js} +1 -1
  132. package/dist/client/assets/{org-layout-9wcUruxI.js → org-layout-DayR0jNU.js} +1 -1
  133. package/dist/client/assets/{organization-choice-DFK_Kv4M.js → organization-choice-D8AfDrAX.js} +1 -1
  134. package/dist/client/assets/{page-seo-form-dWcC9hVa.js → page-seo-form-DfniKL1Q.js} +1 -1
  135. package/dist/client/assets/page-seo-sheet-BcKckI0p.js +1 -0
  136. package/dist/client/assets/{popover-C1d3wzxG.js → popover-Cvj77i8A.js} +1 -1
  137. package/dist/client/assets/{post-editor-By-N3zg4.js → post-editor-DDgBqLC0.js} +1 -1
  138. package/dist/client/assets/{primitives-BEfzkBce.js → primitives-8L17F8DB.js} +1 -1
  139. package/dist/client/assets/{profile-BQFPvVJu.js → profile-BC9L7S10.js} +1 -1
  140. package/dist/client/assets/project-app-view-BBJU6aKw.js +1 -0
  141. package/dist/client/assets/record-editor-C_mvNdEN.js +1 -0
  142. package/dist/client/assets/registry-BXel79t9.js +2 -0
  143. package/dist/client/assets/{registry-layout-CA-A2I6k.js → registry-layout-BosYUQqx.js} +1 -1
  144. package/dist/client/assets/{require-capability-Ck3fCEXa.js → require-capability-CfXY--Wr.js} +1 -1
  145. package/dist/client/assets/{required-auth-layout-DObUM9AX.js → required-auth-layout-ChcaTQMo.js} +1 -1
  146. package/dist/client/assets/{reset-password-D4sTfrXf.js → reset-password-8kj4qfwl.js} +1 -1
  147. package/dist/client/assets/{roles-DKEkKccf.js → roles-CtqJqIZL.js} +1 -1
  148. package/dist/client/assets/{search-input-DC05-0AW.js → search-input-Bd4t9JDl.js} +1 -1
  149. package/dist/client/assets/{secrets-3Ttgg7nt.js → secrets-C4mVZQcY.js} +1 -1
  150. package/dist/client/assets/{sections-editor-CXVf5rkb.js → sections-editor-Cv3sWswm.js} +1 -1
  151. package/dist/client/assets/{select-D_B0V35l.js → select-CNCjpX2V.js} +1 -1
  152. package/dist/client/assets/{select-model-B-KRGkdz.js → select-model-DyWLV5uO.js} +1 -1
  153. package/dist/client/assets/{seo-editor-Mkk341P4.js → seo-editor-wF02jWH-.js} +1 -1
  154. package/dist/client/assets/{settings-layout-Cn1bN8fY.js → settings-layout-DgqHTu0l.js} +1 -1
  155. package/dist/client/assets/{settings-section-QF1vBoo3.js → settings-section-BB3V0eaP.js} +1 -1
  156. package/dist/client/assets/{shell-controls-DRn3nSzu.js → shell-controls-DsldefAT.js} +1 -1
  157. package/dist/client/assets/{shell-layout-CMAjkxmj.js → shell-layout-CABvaYX6.js} +1 -1
  158. package/dist/client/assets/{sidebar-DJME9dof.js → sidebar-3VY89Rtk.js} +1 -1
  159. package/dist/client/assets/{skeleton-qRwR75F8.js → skeleton-ChVmi2IX.js} +1 -1
  160. package/dist/client/assets/{sso-DxQar4SB.js → sso-Be8rG7x5.js} +1 -1
  161. package/dist/client/assets/{store--t1A6DkC.js → store-DnI2J89T.js} +1 -1
  162. package/dist/client/assets/store-registry-WJQ75VV4.js +2 -0
  163. package/dist/client/assets/{studio-tools-UX6N7d2r.js → studio-tools-BW2lcaoN.js} +1 -1
  164. package/dist/client/assets/{switch-BmqpzRFs.js → switch-CAtXVnK8.js} +1 -1
  165. package/dist/client/assets/{table-CfFZGkWK.js → table-Db7D5N3o.js} +1 -1
  166. package/dist/client/assets/{tabs-DlcklrI5.js → tabs-NehxmzGs.js} +1 -1
  167. package/dist/client/assets/{textarea-BzTKr_HK.js → textarea-BN37l3pG.js} +1 -1
  168. package/dist/client/assets/{toggle-group-CsB4TsD2.js → toggle-group-CDVwU9BE.js} +1 -1
  169. package/dist/client/assets/{toolbar-CgrpKNru.js → toolbar-C6s1lQVM.js} +1 -1
  170. package/dist/client/assets/{toolbar-icon-button-C1S8AU-f.js → toolbar-icon-button-ueskcjGk.js} +1 -1
  171. package/dist/client/assets/{tools-list-Dfvu_B7V.js → tools-list-CQ95anOh.js} +1 -1
  172. package/dist/client/assets/{tooltip-aM-b_FMT.js → tooltip-CPDCuZHp.js} +1 -1
  173. package/dist/client/assets/{types-7dsZP07A.js → types-Ck5ZRVig.js} +1 -1
  174. package/dist/client/assets/{use-ai-providers-BlkTdF0X.js → use-ai-providers-BM0N7Zmt.js} +1 -1
  175. package/dist/client/assets/{use-automations-C_CtojUg.js → use-automations-DP9-Stjg.js} +1 -1
  176. package/dist/client/assets/{use-capability-Bw6gzO5q.js → use-capability-B_XurTSq.js} +1 -1
  177. package/dist/client/assets/{use-clock-tick-Ba1Zlu1M.js → use-clock-tick-F7Pzvzfn.js} +1 -1
  178. package/dist/client/assets/{use-collections-Dxn-jOSX.js → use-collections-Dh7qGqEQ.js} +1 -1
  179. package/dist/client/assets/{use-connection-B0zCG1-a.js → use-connection-585bR3ni.js} +1 -1
  180. package/dist/client/assets/{use-copy-B5fZpUTA.js → use-copy-YIt7_Dc0.js} +1 -1
  181. package/dist/client/assets/{use-create-virtual-mcp-DSzgTT68.js → use-create-virtual-mcp-C3v7rFVk.js} +1 -1
  182. package/dist/client/assets/{use-debounced-autosave-DW1h5ZuH.js → use-debounced-autosave-DfYRmvlO.js} +1 -1
  183. package/dist/client/assets/{use-debounced-value-D7rnUNVd.js → use-debounced-value-DZDuT6Tu.js} +1 -1
  184. package/dist/client/assets/{use-decopilot-events-CIVxjDP4.js → use-decopilot-events-B6cy-C6Y.js} +1 -1
  185. package/dist/client/assets/{use-delete-connection-B8apYeWw.js → use-delete-connection-j8Sa-QjW.js} +1 -1
  186. package/dist/client/assets/{use-file-configs-BQfx7XnG.js → use-file-configs-C7VbGe23.js} +1 -1
  187. package/dist/client/assets/{use-infinite-scroll-DvBX031h.js → use-infinite-scroll-CpCcr_3o.js} +1 -1
  188. package/dist/client/assets/{use-join-requests-B07vT8hJ.js → use-join-requests-1FlLmGNJ.js} +1 -1
  189. package/dist/client/assets/{use-mcp-client-Dw4U5H-f.js → use-mcp-client-BWHiesE0.js} +1 -1
  190. package/dist/client/assets/{use-mcp-prompts-l-z3sSL5.js → use-mcp-prompts-C2U11Ngq.js} +1 -1
  191. package/dist/client/assets/{use-mcp-tools-4kMo0jGf.js → use-mcp-tools-CasywNR6.js} +1 -1
  192. package/dist/client/assets/{use-members-CBMMwgoE.js → use-members-D_ltbzOt.js} +1 -1
  193. package/dist/client/assets/{use-mobile-BNuGCh6O.js → use-mobile-Dsc-qXvn.js} +1 -1
  194. package/dist/client/assets/{use-navigate-to-agent-C763L22g.js → use-navigate-to-agent-v796T5h7.js} +1 -1
  195. package/dist/client/assets/{use-org-auth-client-DJX5VyDz.js → use-org-auth-client-Ch-UL4AR.js} +1 -1
  196. package/dist/client/assets/{use-org-sso-CVk_tjj-.js → use-org-sso-B7a42d9W.js} +1 -1
  197. package/dist/client/assets/{use-organization-roles-I8ipNHLV.js → use-organization-roles-CK698yw9.js} +1 -1
  198. package/dist/client/assets/{use-organization-settings-uVjrDo-p.js → use-organization-settings-BmvkeAEv.js} +1 -1
  199. package/dist/client/assets/{use-registry-connections-DQ3PMJAS.js → use-registry-connections-BOqLT8mU.js} +1 -1
  200. package/dist/client/assets/{use-secrets-CpEeyJSa.js → use-secrets-stp1JXmp.js} +1 -1
  201. package/dist/client/assets/{use-status-sounds-BhpMlu6B.js → use-status-sounds-PXTvpsbK.js} +1 -1
  202. package/dist/client/assets/{use-view-mode-Chm_GM7D.js → use-view-mode-B5Z6-7vx.js} +1 -1
  203. package/dist/client/assets/{use-virtual-mcp-CsU1NWTG.js → use-virtual-mcp-7yP2xMZ8.js} +1 -1
  204. package/dist/client/assets/useInfiniteQuery-Cyv_Biwf.js +1 -0
  205. package/dist/client/assets/useSuspenseInfiniteQuery-fXsNWzj4.js +1 -0
  206. package/dist/client/assets/{variant-calendar-BmacLARX.js → variant-calendar-BiFKt806.js} +1 -1
  207. package/dist/client/assets/{view-mode-toggle-D_CmTAzA.js → view-mode-toggle-CeyQhEOw.js} +1 -1
  208. package/dist/client/index.html +1 -1
  209. package/dist/server/cli.js +463 -463
  210. package/dist/server/migrate.js +48 -48
  211. package/dist/server/server.js +312 -312
  212. package/package.json +1 -1
  213. package/dist/client/assets/page-seo-sheet-BeK7IuoW.js +0 -1
  214. package/dist/client/assets/project-app-view-mdWvAUSo.js +0 -1
  215. package/dist/client/assets/record-editor-BPDdom2o.js +0 -1
  216. package/dist/client/assets/registry-BAt5xyrM.js +0 -2
  217. package/dist/client/assets/store-registry-Dlyk5UCT.js +0 -2
  218. package/dist/client/assets/useInfiniteQuery-CNq1SO52.js +0 -1
  219. package/dist/client/assets/useSuspenseInfiniteQuery-DwWoW1jy.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-editor-CQyzSGAt.js","assets/index-DmzFFBrg.js","assets/index-DhHJ9QL9.css","assets/ChevronRight-7KvMU2vd.js","assets/automation-runs-B5a4VZox.js","assets/select-D_B0V35l.js","assets/tooltip-aM-b_FMT.js","assets/Check-D6HvgI2g.js","assets/ChevronDown-ByETU86_.js","assets/ChevronUp-CYrCj8X7.js","assets/useInfiniteQuery-CNq1SO52.js","assets/use-infinite-scroll-DvBX031h.js","assets/use-connection-B0zCG1-a.js","assets/use-collections-Dxn-jOSX.js","assets/use-mcp-client-Dw4U5H-f.js","assets/constants-B72Xmt_K.js","assets/auth-BzmdwOhT.js","assets/use-virtual-mcp-CsU1NWTG.js","assets/card-XoGkEmyY.js","assets/sidebar-DJME9dof.js","assets/LayoutLeft-C3EmIjeK.js","assets/use-mobile-BNuGCh6O.js","assets/X-BsurtT-j.js","assets/table-CfFZGkWK.js","assets/empty-state-m5P2rnUP.js","assets/use-members-CBMMwgoE.js","assets/use-org-auth-client-DJX5VyDz.js","assets/use-clock-tick-Ba1Zlu1M.js","assets/AlertCircle-C2zx73v1.js","assets/CheckCircle-CYZdwL-J.js","assets/Circle-DOOA9v6c.js","assets/agent-icon-BorkCYJw.js","assets/Tool01-DTzBlqba.js","assets/SwitchHorizontal01-D-dAE6RW.js","assets/Settings02-OEOBFgTP.js","assets/XCircle-DSjVZp8y.js","assets/ArrowUpRight-OGhitWLh.js","assets/ZapSquare-Bd5s_Rdz.js","assets/Users03-CEq8hIuH.js","assets/Loading02-67soz7DG.js","assets/Stars02-DsvP56BL.js","assets/Copy01-D-BRa4K0.js","assets/ZoomOut-CKTNxroC.js","assets/DotsVertical-CLtGCuZK.js","assets/Globe01-CuYb5M-c.js","assets/Eye-D6qP6V4S.js","assets/FilterLines-D7dDw7wL.js","assets/Star01-0p5PUoqR.js","assets/Globe04-B__PKdCg.js","assets/HardDrive-DRzRwjaA.js","assets/Key01-D-qRXFHh.js","assets/LinkExternal01-VTHhLEjU.js","assets/List-iDbaSfVT.js","assets/Monitor01-Fie3xtLO.js","assets/Sun-D5XAhhyB.js","assets/Palette-M1ORiolb.js","assets/Play-BA8f3fnM.js","assets/Plus-ByOZ9gpl.js","assets/SearchLg-CrTBzGwT.js","assets/SearchMd-DV92b2Zw.js","assets/Shield01-Cdi1yUP9.js","assets/Stars01-r7l5BwMj.js","assets/Trash01-CaBABzO2.js","assets/Upload01-sOqK5QXu.js","assets/User01-BIkzGI_P.js","assets/Users01-DW9NksVW.js","assets/XClose-BlRyle85.js","assets/Zap-yMgLq3tY.js","assets/use-automations-C_CtojUg.js","assets/studio-tools-UX6N7d2r.js","assets/useSuspenseInfiniteQuery-DwWoW1jy.js","assets/badge-DqqUCIT0.js","assets/checkbox-BaOOKY6q.js","assets/command-BaISYNTo.js","assets/index-D6R0O2P2.js","assets/dialog-Cqozb2z_.js","assets/popover-C1d3wzxG.js","assets/avatar-B1wJc9_9.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-B5fZpUTA.js","assets/file-type-icon-D-15TrXD.js","assets/tab-id-DAJ8K7VA.js","assets/monaco-editor-QbvzQOeC.js","assets/index-jtjapMhV.js","assets/chat-context-BcZe3D5x.js","assets/autosend-BM-B1IAA.js","assets/hooks-DfKlo-cr.js","assets/decopilot-sse-pool-Dvi7BTFV.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/use-ai-providers-BlkTdF0X.js","assets/use-decopilot-events-CIVxjDP4.js","assets/use-organization-settings-uVjrDo-p.js","assets/types-7dsZP07A.js","assets/shell-layout-CMAjkxmj.js","assets/alert-dialog-CuyxrrrS.js","assets/required-auth-layout-DObUM9AX.js","assets/use-org-sso-CVk_tjj-.js","assets/integration-icon-DATPgjQE.js","assets/use-navigate-to-agent-C763L22g.js","assets/reusable-new-chat-qqWu133U.js","assets/use-mcp-prompts-l-z3sSL5.js","assets/form-DUMjAMVd.js","assets/label-B94P9vB0.js","assets/input-Bb_xVFER.js","assets/add-section-modal-D1oVmoDv.js","assets/drawer-CJJAGKvo.js","assets/collection-search-BiSwH17E.js","assets/tabs-DlcklrI5.js","assets/toggle-group-CsB4TsD2.js","assets/agent-capabilities-Bf0tk_gW.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-CN6kBoX7.js","assets/use-registry-connections-DQ3PMJAS.js","assets/extract-connection-data-Bh73dMWr.js","assets/collection-tabs-BKiPDgUq.js","assets/textarea-BzTKr_HK.js","assets/connection-form-helpers-Dd-rb-tx.js","assets/authenticate-and-persist-oauth-D3fnngdw.js","assets/mcp-oauth-CnV7j05R.js","assets/connect-desktop-dialog-CCKz7Z_e.js","assets/select-model-B-KRGkdz.js","assets/skeleton-qRwR75F8.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-QF1vBoo3.js","assets/dropdown-menu-BkaIZk4g.js","assets/index-Ct45J5ta.js","assets/toolbar-CgrpKNru.js","assets/use-debounced-value-D7rnUNVd.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-BhpMlu6B.js","assets/use-mcp-tools-4kMo0jGf.js","assets/use-capability-Bw6gzO5q.js","assets/tools-list-Dfvu_B7V.js","assets/switch-BmqpzRFs.js","assets/use-debounced-autosave-DW1h5ZuH.js","assets/index-CvwG42UF.js","assets/search-input-DC05-0AW.js","assets/github-repo-picker-B-pHTDyi.js","assets/github-installations-DzN1UQ4x.js","assets/use-secrets-CpEeyJSa.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/index-DbeHUDZJ.js","assets/get-initials-D-f_fDFw.js","assets/calendar-DHJhad1j.js","assets/toolbar-icon-button-C1S8AU-f.js","assets/automation-list-row-6_cQV5lO.js","assets/use-file-configs-BQfx7XnG.js","assets/post-editor-By-N3zg4.js","assets/block-document-C3RSKn5K.js","assets/primitives-BEfzkBce.js","assets/record-editor-BPDdom2o.js","assets/category-editor-BXQcvflh.js","assets/bulk-category-panel-CzfCRQM_.js","assets/index-B_EBz91i.js","assets/sections-editor-CXVf5rkb.js","assets/page-seo-form-dWcC9hVa.js","assets/seo-editor-Mkk341P4.js","assets/variant-calendar-BmacLARX.js","assets/view-mode-toggle-D_CmTAzA.js","assets/page-seo-sheet-BeK7IuoW.js","assets/file-explorer-B1c6Fj3p.js","assets/project-app-view-mdWvAUSo.js"])))=>i.map(i=>d[i]);
2
- import{p as os,r as C,o as V4,n as N4,c as B,$ as Ae,l as ne,j as i,P as ps,t as ce,G as nn,a8 as A4,H as Qt,a9 as x9,V as v9,B as re,J as _9,I as S1,aa as T4,ab as E4,a1 as sr,ac as fs,ad as Pr,ae as vu,b as St,d as Ds,M as Ce,af as R4,ag as nr,ah as P4,Z as w1,ai as j1,K as Qe,aj as Cl,a as vi,ak as I4,al as C1,am as D4,an as Zs,ao as fc,ap as Ri,aq as M4,ar as mc,as as O4,at as $4,au as B4,av as z4,L as b9,aw as F4,ax as U4,ay as H4,az as K4,aA as k1,aB as Kr,k as gs,i as qe,aC as y9,u as jo,e as L9,aD as Ge,a6 as V1,aE as zi,aF as Ws,Y as N1,aG as W4,aH as q4,aI as A1,aJ as G4,aK as kl,aL as Fi,aM as T1,aN as Y4,aO as J4,aP as E1,aQ as X4,aR as Q4,aS as Z4,aT as e5,aU as Qo,a7 as t5}from"./index-DmzFFBrg.js";import{i as S9,n as s5,c as R1}from"./SwitchHorizontal01-D-dAE6RW.js";import{u as xs,a as js,S as Ui,b as ir,c as as,d as P1,s as n5,e as i5,f as r5,p as I1,g as D1,A as o5,h as a5,i as l5,t as c5,j as d5,k as u5}from"./chat-context-BcZe3D5x.js";import{c as w9,s as rr,g as rn,P as io,d as j9,t as di,a as h5,M as f5,i as m5,b as Ba,e as M1,f as p5,D as g5,h as x5,j as v5,k as Hi,l as _5,u as O1,E as b5,m as C9,n as y5,F as L5,o as $1,p as B1,q as z1,S as S5,r as w5,v as j5,w as C5,x as _u,y as k5,z as F1,O as V5,A as N5,B as Sn,G as A5,T as T5,C as U1,R as E5,H as R5,I as P5,J as I5,K as D5,L as M5}from"./automation-runs-B5a4VZox.js";import{c as ro,a as Re,b as Pe,T as Ie}from"./tooltip-aM-b_FMT.js";import{c as ns,a as is,d as Ft,e as Ut,b as qn,D as _i}from"./dialog-Cqozb2z_.js";import{c as O5,b as H1,a as K1,D as W1}from"./drawer-CJJAGKvo.js";import{C as $5}from"./collection-search-BiSwH17E.js";import{u as Co}from"./use-mobile-BNuGCh6O.js";import{u as pt,a as B5,m as z5}from"./use-mcp-client-Dw4U5H-f.js";import{a as ko,S as k9,i as za,c as F5,d as q1,b as bu}from"./constants-B72Xmt_K.js";import{u as G1,g as Vo,l as a0}from"./use-mcp-prompts-l-z3sSL5.js";import{t as Ht}from"./ChevronDown-ByETU86_.js";import{i as ms}from"./X-BsurtT-j.js";import{t as U5,z as H5,b as Vl,u as Y1}from"./hooks-DfKlo-cr.js";import{K as K5,i as J1,u as No,r as W5,a as X1}from"./shell-layout-CMAjkxmj.js";import{a as Ao,u as qs,b as V9,c as q5}from"./use-virtual-mcp-CsU1NWTG.js";import{w as Q1,A as G5}from"./autosend-BM-B1IAA.js";import{n as Ki,b as Z1}from"./ZapSquare-Bd5s_Rdz.js";import{i as Tt}from"./Check-D6HvgI2g.js";import{s as on}from"./Star01-0p5PUoqR.js";import{a as _n,i as Y5,b as N9,c as A9,d as T9}from"./Tool01-DTzBlqba.js";import{g as Nl,h as em,j as E9,k as an,l as R9,m as P9,n as tm,o as J5,A as Hn,p as sm,q as nm,r as X5,u as Q5,c as im,v as Z5,w as ex,x as tx,y as sx,z as nx,B as ix,C as rx,D as ox,E as ax,F as Gn,G as Dn,H as Wi,I as yu,J as bi,K as I9,L as To,M as lx,N as cx,O as rm,P as Fa,Q as D9,R as dx,S as om,t as am,T as Ua,U as ux,V as hx,W as fx,e as lm,X as mx,Y as cm,Z as px,_ as Al,$ as M9,a0 as dm,a1 as l0,a2 as pc,a3 as Lu,a4 as gx,a5 as xx,a6 as vx,a7 as _x,a8 as bx,a9 as yx,aa as O9,i as c0,ab as um,ac as Su,ad as Lx,ae as Sx,af as wx,ag as jx,ah as Cx,ai as kx,aj as Vx,ak as Nx,al as hm,am as Ax,an as Tx}from"./agent-icon-BorkCYJw.js";import{i as or}from"./Upload01-sOqK5QXu.js";import{i as fn}from"./AlertCircle-C2zx73v1.js";import{a as Ss}from"./Copy01-D-BRa4K0.js";import{a as d0,b as $9,d as B9,e as z9,F as fm}from"./form-DUMjAMVd.js";import{S as $t,a as Bt,b as nt,c as zt,d as Gt}from"./select-D_B0V35l.js";import{b as Tl,i as Ex,a as Rx}from"./Settings02-OEOBFgTP.js";import{i as Eo,t as u0,a as mm,b as Px}from"./XCircle-DSjVZp8y.js";import{T as ri,a as Ro,b as $n,c as El}from"./tabs-DlcklrI5.js";import{a as pm,T as Ha}from"./toggle-group-CsB4TsD2.js";import{I as Ye}from"./input-Bb_xVFER.js";import{u as F9,g as Po,a as U9,A as gm,c as xm,b as bn,r as Ix,f as Dx,d as Mx}from"./agent-capabilities-Bf0tk_gW.js";import{u as Ms}from"./studio-tools-UX6N7d2r.js";import{i as ar}from"./Monitor01-Fie3xtLO.js";import{u as vm,C as Ox,a as $x,b as Bx,l as zx}from"./connect-desktop-dialog-CCKz7Z_e.js";import{s as yn}from"./XClose-BlRyle85.js";import{m as Rl,i as Fx,g as _m,a as Ux,N as bm,M as Hx}from"./select-model-B-KRGkdz.js";import{e as Fs,a as Ps,f as Kx,b as yi,C as Li,c as Si,d as lr,g as Wx}from"./command-BaISYNTo.js";import{a as Cs,b as ks,P as Vs}from"./popover-C1d3wzxG.js";import{u as ym}from"./useInfiniteQuery-CNq1SO52.js";import{D as Zt,a as es,b as Ir,c as ts,d as He,e as oo,f as ao,g as lo,h as h0,i as Io,j as Di}from"./dropdown-menu-BkaIZk4g.js";import{t as Bn}from"./Stars01-r7l5BwMj.js";import{f as qx,a as Gx,d as Lm,b as Yx,u as Jx,c as Xx,e as Qx,g as Zx,h as ev,i as tv,F as sv,j as nv,k as iv,l as rv,m as ov,n as av,o as lv,H as cv,L as dv,p as uv,S as hv,B as fv,R as Zo,q as wu,r as ju,s as co,T as H9,t as mv}from"./index-Ct45J5ta.js";import{s as Lt}from"./Plus-ByOZ9gpl.js";import{p as pv,q as gv}from"./question-004-sINsf4GQ.js";import{i as cn}from"./ChevronRight-7KvMU2vd.js";import{u as Sm}from"./use-ai-providers-BlkTdF0X.js";import{i as Pl}from"./CheckCircle-CYZdwL-J.js";import{n as Cu,a as wm,s as jm,b as xv}from"./Loading02-67soz7DG.js";import{I as Gs}from"./integration-icon-DATPgjQE.js";import{u as vv}from"./use-status-sounds-BhpMlu6B.js";import{E as qi}from"./empty-state-m5P2rnUP.js";import{r as Ka,a as _v,p as Cm,f as f0,b as km,c as Vm,d as Nm,e as bv,F as yv,g as Lv,h as Sv,i as wv,j as jv,k as Cv,l as Am,m as kv}from"./tab-id-DAJ8K7VA.js";import{T as uo}from"./toolbar-CgrpKNru.js";import{i as K9}from"./SearchLg-CrTBzGwT.js";import{s as ws}from"./Trash01-CaBABzO2.js";import{t as W9}from"./Users01-DW9NksVW.js";import{i as ui}from"./Zap-yMgLq3tY.js";import{f as Wa,a as qa,b as Ga,c as Ya,d as Ja,e as Xa,A as Qa,g as Za}from"./alert-dialog-CuyxrrrS.js";import{C as cr}from"./checkbox-BaOOKY6q.js";import{a as Do,b as Vv,c as Nv,d as hi,i as Tm}from"./ZoomOut-CKTNxroC.js";import{u as Em,a as Rm,b as Av}from"./use-organization-settings-uVjrDo-p.js";import{i as Yn,n as Tv}from"./Globe01-CuYb5M-c.js";import{u as Mo,a as q9,b as Pm}from"./use-connection-B0zCG1-a.js";import{u as Il,a as G9,b as Im}from"./use-mcp-tools-4kMo0jGf.js";import{g as Dl,M as Ev}from"./types-7dsZP07A.js";import{e as Dm}from"./backoff-CrEUbyZT.js";import{u as Rv}from"./use-capability-Bw6gzO5q.js";import{F as Gi,M as Y9,O as Pv}from"./file-type-icon-D-15TrXD.js";import{a as Iv}from"./extract-connection-data-Bh73dMWr.js";import{A as ja}from"./avatar-B1wJc9_9.js";import{T as Mm,u as Om}from"./tools-list-Dfvu_B7V.js";import{a as Dv,i as ku}from"./mcp-oauth-CnV7j05R.js";import{s as $m,g as Mv}from"./connection-slug-eyAPH6o3.js";import{C as J9,a as el}from"./card-XoGkEmyY.js";import{L as Xe}from"./label-B94P9vB0.js";import{S as ho}from"./switch-BmqpzRFs.js";import{T as Yi}from"./textarea-BzTKr_HK.js";import{i as fi}from"./Play-BA8f3fnM.js";import{u as tl}from"./use-debounced-autosave-DW1h5ZuH.js";import{i as fo}from"./SearchMd-DV92b2Zw.js";import{i as Ov}from"./LayoutLeft-C3EmIjeK.js";import{P as zs}from"./index-CvwG42UF.js";import{S as X9}from"./search-input-DC05-0AW.js";import{C as Bm}from"./collection-tabs-BKiPDgUq.js";import{i as Q9}from"./Key01-D-qRXFHh.js";import{a as Z9,G as $v}from"./github-repo-picker-B-pHTDyi.js";import{S as yt}from"./skeleton-qRwR75F8.js";import{s as Bv}from"./User01-BIkzGI_P.js";import{u as zv,a as Fv}from"./use-secrets-CpEeyJSa.js";import{f as zm}from"./formatDistanceToNow-Cb2QZZJn.js";import{u as Uv}from"./use-members-CBMMwgoE.js";import{u as Hv,S as Kv,T as Wv}from"./index-DbeHUDZJ.js";import{m as qv,n as Gv,o as Yv,p as Jv,q as Xv}from"./sidebar-DJME9dof.js";import{n as wn}from"./LinkExternal01-VTHhLEjU.js";import{l as Qv,w as Zv}from"./index-jtjapMhV.js";import{T as Vu}from"./toolbar-icon-button-C1S8AU-f.js";import{d as e6}from"./delay-CnY5UFtP.js";import{B as t6}from"./badge-DqqUCIT0.js";import{u as Oo,a as s6,b as n6,c as i6,d as r6}from"./use-automations-C_CtojUg.js";import{s as Wr}from"./Stars02-DsvP56BL.js";import{M as Ml}from"./monaco-editor-QbvzQOeC.js";import{A as o6}from"./automation-list-row-6_cQV5lO.js";import{s as Fm}from"./Eye-D6qP6V4S.js";import{C as a6}from"./calendar-DHJhad1j.js";import{i as l6}from"./List-iDbaSfVT.js";import{i as c6}from"./DotsVertical-CLtGCuZK.js";import{u as d6}from"./use-debounced-value-D7rnUNVd.js";import{u as u6,a as Um}from"./use-file-configs-BQfx7XnG.js";import{i as h6}from"./FilterLines-D7dDw7wL.js";function f6(t,e){const s=os(e);return m6({filters:{...t,status:"pending"}},s).length}function Nu(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function m6(t={},e){const s=os(e).getMutationCache(),n=C.useRef(t),r=C.useRef(null);return r.current===null&&(r.current=Nu(s,t)),C.useEffect(()=>{n.current=t}),C.useSyncExternalStore(C.useCallback(o=>s.subscribe(()=>{const a=V4(r.current,Nu(s,n.current));r.current!==a&&(r.current=a,N4.schedule(o))}),[s]),()=>r.current,()=>r.current)}const Au=3,Hm="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",p6="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Km(t){const e=B.c(46),{item:s,onSelect:n,isLoading:r,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 S=rn(c._meta);d=c.title??j9(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let S;e[4]!==n||e[5]!==c?(S=()=>n(c),e[4]=n,e[5]=c,e[6]=S):S=e[6];const j=o||r,k=r&&"bg-accent/40",V=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==k||e[8]!==V?(T=ne(p6,"hover:bg-accent/60 text-foreground",k,V),e[7]=k,e[8]=V,e[9]=T):T=e[9];let A;e[10]!==h?(A=i.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=A):A=e[11];let N;e[12]!==r?(N=r&&i.jsx(Ui,{size:"xs"}),e[12]=r,e[13]=N):N=e[13];let E;e[14]!==A||e[15]!==N?(E=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,N]}),e[14]=A,e[15]=N,e[16]=E):E=e[16];let I;e[17]!==u?(I=u&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=I):I=e[18];let P;return e[19]!==E||e[20]!==I||e[21]!==S||e[22]!==j||e[23]!==T?(P=i.jsxs("button",{type:"button",onClick:S,disabled:j,className:T,children:[E,I]}),e[19]=E,e[20]=I,e[21]=S,e[22]=j,e[23]=T,e[24]=P):P=e[24],P}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ne(Hm,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=i.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let _;e[33]!==r?(_=r&&i.jsx(Ui,{size:"xs"}),e[33]=r,e[34]=_):_=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==_?(b=i.jsx(Re,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,_]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=_,e[40]=b):b=e[40];const y=u??h;let L;e[41]!==y?(L=i.jsx(Pe,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==b||e[44]!==L?(w=i.jsxs(Ie,{delayDuration:400,children:[b,L]}),e[43]=b,e[44]=L,e[45]=w):w=e[45],w}function g6(t){const e=B.c(41),{items:s,open:n,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=C.useState(""),d=!!a;let h;e[0]!==s||e[1]!==l?(h=l.trim()?s.filter(j=>{const k=l.toLowerCase();return j.prompt.name.toLowerCase().includes(k)||(j.prompt.title??"").toLowerCase().includes(k)||(j.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=h):h=e[2];const u=h,f=Co();let m;e[3]!==u.length||e[4]!==l?(m=u.length===0&&i.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=u.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==u||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let j;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(j=k=>i.jsx(Km,{item:k,variant:"card",onSelect:V=>{r(!1),o(V)},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]=r,e[15]=o,e[16]=j):j=e[16],p=u.map(j),e[6]=u,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=i.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const x=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{j.key==="Escape"&&c("")},e[20]=v):v=e[20];let _;e[21]!==l?(_=i.jsx($5,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=_):_=e[22];const b=_;if(f){let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(O5,{className:"sr-only",children:i.jsx(H1,{children:"All prompts"})}),e[23]=j):j=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let V;e[25]!==x||e[26]!==b?(V=i.jsxs(K1,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[j,k,b,x]}),e[25]=x,e[26]=b,e[27]=V):V=e[27];let T;return e[28]!==r||e[29]!==n||e[30]!==V?(T=i.jsx(ro,{delayDuration:400,children:i.jsx(W1,{open:n,onOpenChange:r,children:V})}),e[28]=r,e[29]=n,e[30]=V,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ns,{className:"sr-only",children:i.jsx(is,{children:"All prompts"})}),e[32]=y):y=e[32];let L;e[33]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=L):L=e[33];let w;e[34]!==x||e[35]!==b?(w=i.jsxs(Ft,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,L,b,x]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let S;return e[37]!==r||e[38]!==n||e[39]!==w?(S=i.jsx(ro,{delayDuration:400,children:i.jsx(Ut,{open:n,onOpenChange:r,children:w})}),e[37]=r,e[38]=n,e[39]=w,e[40]=S):S=e[40],S}function x6(t){const e=B.c(29),{items:s,onSelect:n,loadingPrompt:r,className:o}=t,[a,l]=C.useState(!1);if(s.length===0)return null;let c,d,h;if(e[0]!==s||e[1]!==r||e[2]!==n){const v=s.slice(0,Au);let _;e[6]!==s?(_=s.slice(Au),e[6]=s,e[7]=_):_=e[7],c=_,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==n?(b=y=>i.jsx(Km,{item:y,onSelect:n,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=n,e[11]=b):b=e[11],h=v.map(b),e[0]=s,e[1]=r,e[2]=n,e[3]=c,e[4]=d,e[5]=h}else c=e[3],d=e[4],h=e[5];const u=h;let f;e[12]!==o?(f=ne("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&i.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:ne(Hm,"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]=m):m=e[16];let p;e[17]!==u||e[18]!==f||e[19]!==m?(p=i.jsxs("div",{className:f,children:[u,m]}),e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==n?(g=i.jsx(g6,{items:s,open:a,onOpenChange:l,onSelect:n,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=n,e[25]=g):g=e[25];let x;return e[26]!==p||e[27]!==g?(x=i.jsxs(ro,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=x):x=e[28],x}function v6(){return null}function _6(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 b6(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:n}=js(),{org:r}=Ae();let o;e[0]!==s||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:s,orgId:r.id,orgSlug:r.slug},e[0]=s,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const a=pt(o);let l;e[4]!==a?(l={client:a,staleTime:6e4},e[4]=a,e[5]=l):l=e[5];const{data:c}=G1(l);let d;e[6]!==c?.prompts?(d=c?.prompts??[],e[6]=c?.prompts,e[7]=d):d=e[7];const h=d;let u;e[8]!==h?(u=h.map(y6),e[8]=h,e[9]=u):u=e[9];const f=u;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[p,g]=C.useReducer(_6,m),[x,v]=C.useState(null);let _;e[11]!==a||e[12]!==n?(_=async(N,E)=>{if(!a){ce.error("MCP client not available"),g({type:"RESET"});return}try{const I=await Vo(a,N.name,E);g({type:"RESET"});const P={type:"doc",content:[{type:"paragraph",content:[w9({id:N.name,name:rr(N.name,rn(N._meta)),metadata:I.messages,char:"/",kind:"prompt",args:E}),{type:"text",text:" "}]}]};await n(P)}catch(I){console.error("[ice-breakers] Failed to fetch prompt:",I),ce.error("Failed to load prompt. Please try again."),g({type:"RESET"})}},e[11]=a,e[12]=n,e[13]=_):_=e[13];const b=_;let y;e[14]!==b?(y=async N=>{if(N.arguments&&N.arguments.length>0){g({type:"SELECT_PROMPT",prompt:N}),v(N);return}g({type:"START_LOADING",prompt:N}),await b(N)},e[14]=b,e[15]=y):y=e[15];const L=y;let w;e[16]!==x||e[17]!==b?(w=async N=>{x&&(g({type:"START_LOADING",prompt:x,arguments:N}),v(null),await b(x,N))},e[16]=x,e[17]=b,e[18]=w):w=e[18];const S=w;if(f.length===0)return null;const j=p.stage==="loading"?p.prompt:null;let k;e[19]!==L||e[20]!==f||e[21]!==j?(k=i.jsx(x6,{items:f,onSelect:L,loadingPrompt:j}),e[19]=L,e[20]=f,e[21]=j,e[22]=k):k=e[22];let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{v(null),g({type:"RESET"})},e[23]=V):V=e[23];let T;e[24]!==x||e[25]!==S?(T=i.jsx(io,{prompt:x,setPrompt:V,onSubmit:S}),e[24]=x,e[25]=S,e[26]=T):T=e[26];let A;return e[27]!==k||e[28]!==T?(A=i.jsxs(i.Fragment,{children:[k,T]}),e[27]=k,e[28]=T,e[29]=A):A=e[29],A}function y6(t){return{prompt:t}}function L6(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:n}=xs(),{org:r}=Ae();let o;e[0]!==r.id?(o=ko(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ne("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(v6,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=i.jsx(b6,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=i.jsx(ps,{fallback:null,children:i.jsx(C.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=i.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const gc="cubic-bezier(0.645, 0.045, 0.355, 1)",S6=44,w6={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-amber-500/5 after:pointer-events-none after:-z-10"},j6={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},C6={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function Kn(t){const e=B.c(61),{icon:s,label:n,count:r,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,[m,p]=C.useState(d),[g,x]=C.useState(!1);let v;e[0]!==u?(v=()=>{x(!0),u?.()},e[0]=u,e[1]=v):v=e[1];const _=v;if(g)return null;const b=j6[f],y=w6[f];let L;e[2]!==b||e[3]!==y?(L=ne("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",b,y),e[2]=b,e[3]=y,e[4]=L):L=e[4];let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(k6),e[5]=w):w=e[5];const S=m&&"rounded-b-none",j=!m&&"rounded-b-xl";let k;e[6]!==S||e[7]!==j?(k=ne("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,j),e[6]=S,e[7]=j,e[8]=k):k=e[8];const V=C6[f];let T;e[9]!==V?(T=ne("shrink-0",V),e[9]=V,e[10]=T):T=e[10];let A;e[11]!==s||e[12]!==T?(A=i.jsx("span",{className:T,children:s}),e[11]=s,e[12]=T,e[13]=A):A=e[13];let N;e[14]!==n?(N=i.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=N):N=e[15];let E;e[16]!==r?(E=r?i.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=E):E=e[17];const I=m?"rotate(180deg)":"rotate(0deg)";let P;e[18]!==I?(P=i.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:i.jsx(Ht,{size:16,style:{transform:I,transition:`transform 180ms ${gc}`}})}),e[18]=I,e[19]=P):P=e[19];let R,D;e[20]!==_?(R=Z=>{Z.stopPropagation(),_()},D=Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),Z.stopPropagation(),_())},e[20]=_,e[21]=R,e[22]=D):(R=e[21],D=e[22]);let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(ms,{size:16}),e[23]=M):M=e[23];let F;e[24]!==R||e[25]!==D?(F=i.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:R,onKeyDown:D,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:M}),e[24]=R,e[25]=D,e[26]=F):F=e[26];let $;e[27]!==m||e[28]!==A||e[29]!==N||e[30]!==E||e[31]!==P||e[32]!==F||e[33]!==k?($=i.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:w,className:k,children:[A,N,E,P,F]}),e[27]=m,e[28]=A,e[29]=N,e[30]=E,e[31]=P,e[32]=F,e[33]=k,e[34]=$):$=e[34];const O=m?"1fr":"0fr";let U;e[35]!==O?(U={display:"grid",gridTemplateRows:O,transition:`grid-template-rows 180ms ${gc}`},e[35]=O,e[36]=U):U=e[36];let K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K={overflow:"hidden",minHeight:0},e[37]=K):K=e[37];const H=m?1:0;let q;e[38]!==H?(q={opacity:H,transition:`opacity 120ms ${gc}`},e[38]=H,e[39]=q):q=e[39];let J;e[40]!==o?(J=o?i.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:i.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):i.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=J):J=e[41];let G;e[42]!==c||e[43]!==o?(G=c?i.jsx("div",{className:ne("overflow-clip pb-4",!o&&"pt-4"),children:c}):null,e[42]=c,e[43]=o,e[44]=G):G=e[44];let W;e[45]!==a||e[46]!==l?(W=a||l?i.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=a,e[46]=l,e[47]=W):W=e[47];let z;e[48]!==q||e[49]!==J||e[50]!==G||e[51]!==W?(z=i.jsx("div",{style:K,children:i.jsxs("div",{style:q,children:[J,G,W]})}),e[48]=q,e[49]=J,e[50]=G,e[51]=W,e[52]=z):z=e[52];let X;e[53]!==U||e[54]!==z?(X=i.jsx("div",{"data-testid":"collapsible-highlight-body",style:U,children:z}),e[53]=U,e[54]=z,e[55]=X):X=e[55];let Q;return e[56]!==$||e[57]!==X||e[58]!==L||e[59]!==f?(Q=i.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:L,children:[$,X]}),e[56]=$,e[57]=X,e[58]=L,e[59]=f,e[60]=Q):Q=e[60],Q}function k6(t){return!t}const V6=nn({content:Qt().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:x9(["pending","in_progress","completed"]),activeForm:Qt().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Wm=nn({todos:A4(V6)}),N6="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";U5({description:N6,inputSchema:H5(Wm),execute:async({todos:t})=>({ok:!0,count:t.length})});const A6="tool-todo_write",T6=new Set(["input-available","output-available"]);function qm(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type!==A6||typeof o.state!="string"||!T6.has(o.state))continue;const a=Wm.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function Gm(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 n="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:n,friendlyName:di(h5(n)),input:s.input})}return e}function Ym(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 n=s.input;e.push({toolCallId:s.toolCallId,plan:n.plan,state:s.state})}return e}function E6(t){return t?t.message.startsWith("[CREDITS]"):!1}const R6={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function P6(t){const{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&s&&E6(s))return{...R6,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(b=>b.type==="tool-user_ask").filter(b=>b.state!=="output-available").length,u=Ym(l),f=Gm(c),m=qm(e),p=!r&&!!s,g=f.length>0||r&&o,x=u.length>0,_=!r&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:_,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h}}function Jm(){const t=B.c(6),{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=js(),a=s??null,l=n??null;let c;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=P6({messages:e,error:a,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function I6(){const t=Jm();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Xm(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)}const D6="__home__";function ed(t,e){return v9.chatDraft(t,e)}function M6(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const s=e.tiptapDoc;return!s||typeof s!="object"||s.type!=="doc"||!Array.isArray(s.content)?null:s}function O6(t,e,s,n,r){const o=ed(e,s);if(Xm(n)){t.removeItem(o);return}const a={tiptapDoc:n,updatedAt:Date.now()},l=JSON.stringify(a);try{t.setItem(o,l)}catch(c){if(B6(c)){const d=new TextEncoder().encode(l).byteLength;r?.onQuotaExceeded?.({docSizeBytes:d});return}throw c}}function Tu(t,e,s){const n=ed(e,s),r=t.getItem(n),o=M6(r);return r!==null&&o===null&&t.removeItem(n),o}function $6(t,e,s){t.removeItem(ed(e,s))}function B6(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function z6(t){const e=B.c(21),{current:s,total:n,onPrev:r,onNext:o}=t;if(n<=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=ne("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=i.jsx(Tl,{size:14}),e[2]=d):d=e[2];let h;e[3]!==r||e[4]!==a||e[5]!==c?(h=i.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=h):h=e[6];const u=s+1;let f;e[7]!==u||e[8]!==n?(f=i.jsxs("span",{className:"tabular-nums text-xs",children:[u," of ",n]}),e[7]=u,e[8]=n,e[9]=f):f=e[9];const m=s===n-1,p=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=ne("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Eo,{size:14}),e[12]=x):x=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=i.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:x}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let _;return e[17]!==v||e[18]!==h||e[19]!==f?(_=i.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[h,f,v]}),e[17]=v,e[18]=h,e[19]=f,e[20]=_):_=e[20],_}function Qm(t){const e=B.c(8),{currentIndex:s,total:n,onPrev:r,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(l=i.jsx(z6,{current:s,total:n,onPrev:r,onNext:o}),e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function F6(t){const e=B.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!r,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=ne("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=i.jsx(re,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let _;e[10]!==v?(_=i.jsx(Re,{asChild:!0,children:v}),e[10]=v,e[11]=_):_=e[11];let b;e[12]!==f?(b=i.jsx(Pe,{children:f}),e[12]=f,e[13]=b):b=e[13];let y;return e[14]!==_||e[15]!==b?(y=i.jsxs(Ie,{children:[_,b]}),e[14]=_,e[15]=b,e[16]=y):y=e[16],y}function Zm(t,e,s){return t.findIndex(n=>e(n)===s)}function Eu(t,e,s,n){return t.length===0?!1:t.every(r=>n(s[e(r)]))}function Ru(t,e,s,n,r){if(t.length===0)return null;const o=Zm(t,e,r);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==r&&!n(s[c]))return c}return null}function U6(t){return!t.isStreaming&&t.allAnswered}function e2(t){const{parts:e,partKey:s,schema:n,defaultValues:r,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=C.useState(c),[u,f]=C.useState(!1),m=_9({resolver:S1(n),defaultValues:r}),p=m.watch(),g=Zm(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),_=Eu(e,s,p,a),b=U6({isStreaming:o,allAnswered:_}),y=()=>{if(g>0){const T=e[g-1];T&&h(s(T))}},L=()=>{if(g>=0&&g<e.length-1){const T=e[g+1];T&&h(s(T))}},w=()=>{const T=m.getValues(),A=Ru(e,s,T,a,d);A&&h(A)},S=()=>{m.handleSubmit(T=>{const A=T;for(const N of e)l(N,A[s(N)])})()},j=C.useRef(S);j.current=S;const k=()=>{b&&(f(!1),j.current())},V=()=>{const T=m.getValues();if(Eu(e,s,T,a)){if(o){f(!0);return}f(!1),j.current()}else{const A=Ru(e,s,T,a,d);A&&h(A)}};return C.useEffect(()=>{if(u&&!o){if(!_){f(!1);return}f(!1),j.current()}},[u,o,_]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:_,canSubmit:b,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:k,submitOrAdvance:V}}const t2="User denied this tool call, give other alternatives.";function s2(t){const e=B.c(9),{onYolo:s}=t,[n,r]=sr();let o;e[0]!==s||e[1]!==n||e[2]!==r?(o=h=>{const u=h,f=n.toolApprovalLevel??"readonly";r({...n,toolApprovalLevel:u}),u==="auto"&&s(f)},e[0]=s,e[1]=n,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(zt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:K6,children:i.jsx(Gt,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx($t,{children:Pr.map(H6)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==n.toolApprovalLevel?(d=i.jsxs(Bt,{value:n.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=n.toolApprovalLevel,e[8]=d):d=e[8],d}function H6(t){return i.jsx(nt,{value:t.value,children:t.label},t.value)}function K6(t){return t.stopPropagation()}function n2(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let n;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],n=o}catch{n=String(s)}let r;return e[3]!==n?(r=i.jsx("div",{className:"px-4",children:i.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:n})}),e[3]=n,e[4]=r):r=e[4],r}function W6(t){const e=B.c(28),{approval:s,onRespond:n}=t,[r]=sr(),o=r.toolApprovalLevel??"readonly";let a;e[0]!==s.approvalId||e[1]!==o||e[2]!==n?(a=()=>n(s.approvalId,!1,t2,o),e[0]=s.approvalId,e[1]=o,e[2]=n,e[3]=a):a=e[3];const l=a;let c;e[4]!==s.approvalId||e[5]!==o||e[6]!==n?(c=()=>n(s.approvalId,!0,void 0,o),e[4]=s.approvalId,e[5]=o,e[6]=n,e[7]=c):c=e[7];const d=c;let h;e[8]!==s.approvalId||e[9]!==n?(h=L=>n(s.approvalId,!0,void 0,L),e[8]=s.approvalId,e[9]=n,e[10]=h):h=e[10];const u=h;let f;e[11]!==u?(f=i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(s2,{onYolo:u})}),e[11]=u,e[12]=f):f=e[12];const m=f;let p;e[13]!==l?(p=i.jsx(re,{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:l,children:"Deny"}),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==d?(g=i.jsx(re,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=i.jsxs(i.Fragment,{children:[p,g]}),e[17]=p,e[18]=g,e[19]=x):x=e[19];const v=x;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(Nl,{size:14}),e[20]=_):_=e[20];let b;e[21]!==s.input?(b=i.jsx(n2,{input:s.input}),e[21]=s.input,e[22]=b):b=e[22];let y;return e[23]!==s.friendlyName||e[24]!==m||e[25]!==v||e[26]!==b?(y=i.jsx(Kn,{icon:_,label:"Approval needed",title:s.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:v,children:b}),e[23]=s.friendlyName,e[24]=m,e[25]=v,e[26]=b,e[27]=y):y=e[27],y}const q6=T4(Qt(),nn({approved:E4().optional(),levelOverride:x9(["auto","readonly"]).optional()}));function G6(t){const e=B.c(42),{approvals:s,isStreaming:n,onRespond:r}=t,[o]=sr(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s?(l=Object.fromEntries(s.map(X6)),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==a||e[3]!==r?(d=(V,T)=>{const A=T;typeof A?.approved=="boolean"&&r(V.approvalId,A.approved,A.approved===!1?t2:void 0,A.levelOverride??a)},e[2]=a,e[3]=r,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==c||e[7]!==n||e[8]!==d?(h={parts:s,partKey:J6,schema:q6,defaultValues:c,isStreaming:n,hasAnswer:Y6,onSubmit:d},e[5]=s,e[6]=c,e[7]=n,e[8]=d,e[9]=h):h=e[9];const u=e2(h);let f;e[10]!==s||e[11]!==u?(f=V=>{u.form.reset(Object.fromEntries(s.map(T=>[T.approvalId,{approved:!0,levelOverride:V}]))),u.submitOrAdvance()},e[10]=s,e[11]=u,e[12]=f):f=e[12];const m=f,p=u.currentPart;let g;e[13]!==u?(g=V=>{V.preventDefault(),u.submit()},e[13]=u,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Nl,{size:14}),e[15]=x):x=e[15];const v=`${s.length} approvals pending`,_=p?.friendlyName??"";let b;e[16]!==m?(b=i.jsx(s2,{onYolo:m}),e[16]=m,e[17]=b):b=e[17];let y;e[18]!==s.length||e[19]!==u.currentIndex||e[20]!==u.goNext||e[21]!==u.goPrev||e[22]!==b?(y=i.jsx(Qm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext,extraLeft:b}),e[18]=s.length,e[19]=u.currentIndex,e[20]=u.goNext,e[21]=u.goPrev,e[22]=b,e[23]=y):y=e[23];let L;e[24]!==p||e[25]!==u.form.control||e[26]!==u.submitOrAdvance?(L=p?i.jsx(Q6,{approvalId:p.approvalId,control:u.form.control,onChange:u.submitOrAdvance}):null,e[24]=p,e[25]=u.form.control,e[26]=u.submitOrAdvance,e[27]=L):L=e[27];let w;e[28]!==p?(w=p?i.jsx(n2,{input:p.input}):null,e[28]=p,e[29]=w):w=e[29];let S;e[30]!==y||e[31]!==L||e[32]!==w||e[33]!==v||e[34]!==_?(S=i.jsx(Kn,{icon:x,label:v,title:_,defaultExpanded:!0,footerLeft:y,footerRight:L,children:w}),e[30]=y,e[31]=L,e[32]=w,e[33]=v,e[34]=_,e[35]=S):S=e[35];let j;e[36]!==S||e[37]!==g?(j=i.jsx("form",{onSubmit:g,children:S}),e[36]=S,e[37]=g,e[38]=j):j=e[38];let k;return e[39]!==u.form||e[40]!==j?(k=i.jsx(d0,{...u.form,children:j}),e[39]=u.form,e[40]=j,e[41]=k):k=e[41],k}function Y6(t){return typeof t?.approved=="boolean"}function J6(t){return t.approvalId}function X6(t){return[t.approvalId,{approved:void 0}]}function Q6(t){const e=B.c(6),{approvalId:s,control:n,onChange:r}=t,o=`${s}.approved`;let a;e[0]!==r?(a=c=>{const{field:d}=c,h=d.value===!0,u=d.value===!1;return i.jsxs(i.Fragment,{children:[i.jsx(re,{type:"button",variant:u?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":u,children:"Deny"}),i.jsx(re,{type:"button",variant:h?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":h,children:"Accept"})]})},e[0]=r,e[1]=a):a=e[1];let l;return e[2]!==n||e[3]!==o||e[4]!==a?(l=i.jsx(fs,{control:n,name:o,render:a}),e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function Z6(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(Nl,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function e_(t){const e=B.c(8),{approvals:s,isStreaming:n,onRespond:r}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Z6,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==r||e[2]!==a?(l=i.jsx(W6,{approval:a,onRespond:r}),e[1]=r,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==r?(o=i.jsx(G6,{approvals:s,isStreaming:n,onRespond:r}),e[4]=s,e[5]=n,e[6]=r,e[7]=o):o=e[7],o}function t_(t){const e=B.c(16),{plan:s,onApprove:n,onDismiss:r}=t;let o;e[0]!==n||e[1]!==s.plan?(o=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=i.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=i.jsx(re,{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=i.jsxs(i.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const h=d;let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(em,{size:14}),e[10]=u):u=e[10];let f;e[11]!==s.plan?(f=i.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:i.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:i.jsx(f5,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[11]=s.plan,e[12]=f):f=e[12];let m;return e[13]!==h||e[14]!==f?(m=i.jsx(Kn,{icon:u,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:h,children:f}),e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function s_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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-[640px] mx-auto mb-2",children:[i.jsx(Tt,{className:"size-5 text-purple-500 shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function n_(t){const e=B.c(7),{plans:s,isStreaming:n,onApprove:r,onDismiss:o}=t;if(n&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(s_,{}),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]!==r||e[5]!==o?(c=i.jsx(t_,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function i2(t){return t?"response"in t?t.response:t.option??t.draft:""}const Pu=nn({response:Qt().min(1,"Response is required")}),i_=nn({option:Qt().nullable(),draft:Qt()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),r_=nn({response:x9(["yes","no"])});function o_(t){switch(t.type){case"text":return Pu;case"choice":return i_;case"confirm":return r_;default:return Pu}}function a_(t){const e={};for(const s of t)e[s.toolCallId]=o_(s.input);return nn(e)}function l_(t){const e=B.c(6),{control:s,name:n,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l,d=c.value??"";return i.jsxs($9,{children:[i.jsx(B9,{children:i.jsx("div",{className:"px-2",children:i.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(E9,{size:16,className:"text-muted-foreground"})}),i.jsx("input",{...c,value:d,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),i.jsx(z9,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==n||e[4]!==o?(a=i.jsx(fm,{control:s,name:n,render:o}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5],a}function r2(t,e){const s=B.c(4);let n,r;s[0]!==t||s[1]!==e?(n=()=>{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)},r=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=r):(n=s[2],r=s[3]),C.useEffect(n,r)}function c_(t){const e=B.c(40),{control:s,name:n,options:r}=t,o=`${n}.option`;let a;e[0]!==s||e[1]!==o?(a={control:s,name:o,defaultValue:null},e[0]=s,e[1]=o,e[2]=a):a=e[2];const{field:l}=vu(a),c=`${n}.draft`;let d;e[3]!==s||e[4]!==c?(d={control:s,name:c,defaultValue:""},e[3]=s,e[4]=c,e[5]=d):d=e[5];const{field:h}=vu(d),u=l.value,f=h.value??"";let m;if(e[6]!==l||e[7]!==r?(m=A=>{const N=r[A];N!=null&&l.onChange(N)},e[6]=l,e[7]=r,e[8]=m):m=e[8],r2(r.length,m),r.length===0)return null;const p=u===null;let g;if(e[9]!==l||e[10]!==u||e[11]!==r){let A;e[13]!==l||e[14]!==u?(A=(N,E)=>{const I=u===N;return i.jsxs("button",{type:"button",onClick:()=>l.onChange(N),className:ne("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",I&&"bg-accent/50",!I&&"hover:bg-accent/30"),"aria-label":`Select ${N}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",I?"bg-chart-1 text-white":"bg-muted text-foreground"),children:E+1}),i.jsx("span",{className:"text-sm text-foreground truncate",children:N})]},`${E}-${N}`)},e[13]=l,e[14]=u,e[15]=A):A=e[15],g=r.map(A),e[9]=l,e[10]=u,e[11]=r,e[12]=g}else g=e[12];const x=p&&"bg-accent/50",v=!p&&"hover:bg-accent/30";let _;e[16]!==x||e[17]!==v?(_=ne("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x,v),e[16]=x,e[17]=v,e[18]=_):_=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(E9,{size:16,className:"text-muted-foreground"})}),e[19]=b):b=e[19];const y=p?f:"";let L;e[20]!==h||e[21]!==l||e[22]!==u?(L=A=>{h.onChange(A.target.value),u!==null&&l.onChange(null)},e[20]=h,e[21]=l,e[22]=u,e[23]=L):L=e[23];let w;e[24]!==l||e[25]!==u?(w=()=>{u!==null&&l.onChange(null)},e[24]=l,e[25]=u,e[26]=w):w=e[26];let S;e[27]!==y||e[28]!==L||e[29]!==w?(S=i.jsx("input",{type:"text",value:y,onChange:L,onFocus:w,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=y,e[28]=L,e[29]=w,e[30]=S):S=e[30];let j;e[31]!==S||e[32]!==_?(j=i.jsxs("label",{className:_,children:[b,S]}),e[31]=S,e[32]=_,e[33]=j):j=e[33];let k;e[34]!==j||e[35]!==g?(k=i.jsx(B9,{children:i.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[g,j]})}),e[34]=j,e[35]=g,e[36]=k):k=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(z9,{}),e[37]=V):V=e[37];let T;return e[38]!==k?(T=i.jsxs($9,{children:[k,V]}),e[38]=k,e[39]=T):T=e[39],T}function d_(t){const e=B.c(6),{control:s,name:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=C.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=h=>{a.current?.onChange(o[h]??"")},e[1]=l):l=e[1],r2(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=h=>{const{field:u}=h;return a.current=u,i.jsxs($9,{children:[i.jsx(B9,{children:i.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=u.value===f;return i.jsxs("button",{type:"button",onClick:()=>u.onChange(f),className:ne("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),i.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),i.jsx(z9,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==n?(d=i.jsx(fm,{control:s,name:n,render:c}),e[3]=s,e[4]=n,e[5]=d):d=e[5],d}function Iu(t){const e=B.c(13),{input:s,control:n,toolCallId:r}=t;switch(s.type){case"text":{const o=`${r}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=i.jsx(l_,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}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]!==n||e[7]!==a||e[8]!==r?(l=i.jsx(c_,{control:n,name:r,options:a}),e[6]=n,e[7]=a,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let a;return e[10]!==n||e[11]!==o?(a=i.jsx(d_,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function u_(t){const e=B.c(71),{parts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=a_(s.map(p_)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(m_)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==r?(d=(R,D)=>{const M=i2(D);M&&r(R,M)},e[4]=r,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:f_,schema:a,defaultValues:c,isStreaming:n,hasAnswer:h_,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=e2(h),f=u.currentPart;let m;e[12]!==f||e[13]!==u?(m=()=>{const R=f;if(!R)return;const D=R.toolCallId;R.input?.type==="choice"?(u.form.setValue(`${D}.option`,null),u.form.setValue(`${D}.draft`,"user has skip this question")):u.form.setValue(`${D}.response`,"user has skip this question"),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=m;let g;e[15]!==u.currentIndex||e[16]!==u.goNext||e[17]!==u.goPrev||e[18]!==s.length?(g=i.jsx(Qm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[15]=u.currentIndex,e[16]=u.goNext,e[17]=u.goPrev,e[18]=s.length,e[19]=g):g=e[19];const x=g;let v;e[20]!==p?(v=i.jsx(re,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),e[20]=p,e[21]=v):v=e[21];let _;e[22]!==u.isAllAnswered||e[23]!==u.isCurrentAnswered||e[24]!==u.submitOrAdvance||e[25]!==n?(_=i.jsx(F6,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[22]=u.isAllAnswered,e[23]=u.isCurrentAnswered,e[24]=u.submitOrAdvance,e[25]=n,e[26]=_):_=e[26];let b;e[27]!==v||e[28]!==_?(b=i.jsxs(i.Fragment,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=b):b=e[29];const y=b;if(s.length===1){const R=s[0];if(!R?.input)return null;let D;e[30]!==u?(D=q=>{q.preventDefault(),u.submit()},e[30]=u,e[31]=D):D=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(u0,{size:14}),e[32]=M):M=e[32];const F=R.input?.prompt??"Question",$=R.input;let O;e[33]!==u.form.control||e[34]!==R.toolCallId||e[35]!==$?(O=i.jsx(Iu,{input:$,control:u.form.control,toolCallId:R.toolCallId}),e[33]=u.form.control,e[34]=R.toolCallId,e[35]=$,e[36]=O):O=e[36];let U;e[37]!==y||e[38]!==F||e[39]!==O?(U=i.jsx(Kn,{icon:M,label:"Question pending",title:F,defaultExpanded:!0,footerRight:y,children:O}),e[37]=y,e[38]=F,e[39]=O,e[40]=U):U=e[40];let K;e[41]!==D||e[42]!==U?(K=i.jsx("form",{onSubmit:D,autoComplete:"off",children:U}),e[41]=D,e[42]=U,e[43]=K):K=e[43];let H;return e[44]!==u.form||e[45]!==K?(H=i.jsx(d0,{...u.form,children:K}),e[44]=u.form,e[45]=K,e[46]=H):H=e[46],H}const L=u.form;let w;e[47]!==u?(w=R=>{R.preventDefault(),u.submit()},e[47]=u,e[48]=w):w=e[48];let S;e[49]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(u0,{size:14}),e[49]=S):S=e[49];const j=`${u.currentIndex+1} of ${s.length}`,k=f?.input?.prompt??"Question",V=u.activeKey,T=u.setActiveKey;let A;if(e[50]!==u.form||e[51]!==s){let R;e[53]!==u.form?(R=D=>i.jsx(ri,{value:D.toolCallId,className:"mt-0",children:i.jsx(Iu,{input:D.input,control:u.form.control,toolCallId:D.toolCallId})},D.toolCallId),e[53]=u.form,e[54]=R):R=e[54],A=s.map(R),e[50]=u.form,e[51]=s,e[52]=A}else A=e[52];let N;e[55]!==u.activeKey||e[56]!==u.setActiveKey||e[57]!==A?(N=i.jsx(Ro,{value:V,onValueChange:T,children:A}),e[55]=u.activeKey,e[56]=u.setActiveKey,e[57]=A,e[58]=N):N=e[58];let E;e[59]!==x||e[60]!==y||e[61]!==j||e[62]!==k||e[63]!==N?(E=i.jsx(Kn,{icon:S,label:"Question pending",count:j,title:k,defaultExpanded:!0,footerLeft:x,footerRight:y,children:N}),e[59]=x,e[60]=y,e[61]=j,e[62]=k,e[63]=N,e[64]=E):E=e[64];let I;e[65]!==w||e[66]!==E?(I=i.jsx("form",{onSubmit:w,autoComplete:"off",children:E}),e[65]=w,e[66]=E,e[67]=I):I=e[67];let P;return e[68]!==u.form||e[69]!==I?(P=i.jsx(d0,{...L,children:I}),e[68]=u.form,e[69]=I,e[70]=P):P=e[70],P}function h_(t){return!!i2(t)}function f_(t){return t.toolCallId}function m_(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function p_(t){return{toolCallId:t.toolCallId,input:t.input}}function g_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(u0,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function o2(t){const e=B.c(7),{userAskParts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(x_),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(g_,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==r||e[5]!==a?(l=i.jsx(u_,{parts:a,isStreaming:n,onSubmit:r}),e[3]=n,e[4]=r,e[5]=a,e[6]=l):l=e[6],l}function x_(t){return t.state==="input-available"}function v_(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function __(){const t=B.c(21),{messages:e}=js();let s,n,r,o,a,l,c,d,h;if(t[0]!==e){h=Symbol.for("react.early_return_sentinel");e:{const m=qm(e);if(m.length===0){h=null;break e}const p=v_(m);s=Kn,a=i.jsx(S_,{status:p.icon}),l=p.activity,c=p.progress,d=!1,n="todos-list",r="flex flex-col px-2 max-h-[40vh] overflow-y-auto",o=m.map(b_)}t[0]=e,t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a,t[6]=l,t[7]=c,t[8]=d,t[9]=h}else s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],d=t[8],h=t[9];if(h!==Symbol.for("react.early_return_sentinel"))return h;let u;t[10]!==n||t[11]!==r||t[12]!==o?(u=i.jsx("ul",{"data-testid":n,className:r,children:o}),t[10]=n,t[11]=r,t[12]=o,t[13]=u):u=t[13];let f;return t[14]!==s||t[15]!==a||t[16]!==l||t[17]!==c||t[18]!==d||t[19]!==u?(f=i.jsx(s,{icon:a,label:l,count:c,defaultExpanded:d,children:u}),t[14]=s,t[15]=a,t[16]=l,t[17]=c,t[18]=d,t[19]=u,t[20]=f):f=t[20],f}function b_(t,e){return i.jsx(y_,{todo:t},e)}function y_(t){const e=B.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=i.jsx(L_,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=ne("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=i.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=i.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function L_(t){const e=B.c(4),{status:s}=t,n=s==="completed"?"true":void 0,r=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("svg",{viewBox:"0 0 21 21",children:i.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let a;return e[1]!==n||e[2]!==r?(a=i.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function S_(t){const e=B.c(3),{status:s}=t;if(s==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:i.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:i.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(s==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=n):n=e[2],n}const w_={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"}]},j_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function a2(t){const e=B.c(41),{onDismiss:s}=t,{org:n}=Ae(),r=St(),{decoKeyId:o}=F9(),a=Ms(),[l,c]=C.useState(""),[d,h]=C.useState(!1),[u,f]=C.useState("usd"),m=u==="brl"?"R$":"$";let p,g;e[0]!==n.id?(p=()=>{Ce("credits_exhausted_shown",{organization_id:n.id})},g=[n.id],e[0]=n.id,e[1]=p,e[2]=g):(p=e[1],g=e[2]),C.useEffect(p,g);let x;e[3]!==u||e[4]!==a?(x=async R=>{const{url:D}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:R,currency:u});return D},e[3]=u,e[4]=a,e[5]=x):x=e[5];let v;e[6]!==s?(v=R=>{R&&window.open(R,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=v):v=e[7];let _;e[8]!==x||e[9]!==v?(_={mutationFn:x,onSuccess:v,onError:V_},e[8]=x,e[9]=v,e[10]=_):_=e[10];const{mutate:b,isPending:y}=Ds(_),L=parseFloat(l),w=!isNaN(L)&&L>=1;let S;e[11]!==s?(S=R=>!R&&s?.(),e[11]=s,e[12]=S):S=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=k):k=e[14];let V;e[15]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[k,i.jsxs(ns,{className:"relative gap-4",children:[i.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"}),i.jsxs("div",{children:[i.jsx(is,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),i.jsx(qn,{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[15]=V):V=e[15];let T;e[16]!==u||e[17]!==m||e[18]!==l||e[19]!==L||e[20]!==o||e[21]!==w||e[22]!==y||e[23]!==d||e[24]!==b?(T=o&&i.jsxs("div",{className:"px-8 pt-5 pb-6",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(pm,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:R=>{R&&f(R)},children:[i.jsx(Ha,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(Ha,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsxs("div",{className:"rounded-xl border border-border p-5",children:[i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:w_[u].map(R=>{const{dollars:D,label:M}=R;return i.jsxs("button",{type:"button",disabled:y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:D*100,currency:u,tier_label:M,source:"exhausted_banner"}),b(D*100)},className:ne("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:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,D]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:M})]},D)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(Ye,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:R=>c(R.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(re,{className:"h-10",disabled:!w||y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:Math.round(L*100),currency:u,tier_label:"custom",source:"exhausted_banner"}),b(Math.round(L*100))},children:y?"Opening...":"Add"})]}):i.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"})]}),i.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:j_.map(C_)})]}),e[16]=u,e[17]=m,e[18]=l,e[19]=L,e[20]=o,e[21]=w,e[22]=y,e[23]=d,e[24]=b,e[25]=T):T=e[25];let A;e[26]!==s?(A=i.jsx(re,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[26]=s,e[27]=A):A=e[27];let N;e[28]!==r||e[29]!==s||e[30]!==n.slug?(N=i.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},children:"Manage providers"}),e[28]=r,e[29]=s,e[30]=n.slug,e[31]=N):N=e[31];let E;e[32]!==A||e[33]!==N?(E=i.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[A,N]}),e[32]=A,e[33]=N,e[34]=E):E=e[34];let I;e[35]!==T||e[36]!==E?(I=i.jsxs(Ft,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:k_,children:[V,T,E]}),e[35]=T,e[36]=E,e[37]=I):I=e[37];let P;return e[38]!==I||e[39]!==S?(P=i.jsx(Ut,{open:!0,onOpenChange:S,children:I}),e[38]=I,e[39]=S,e[40]=P):P=e[40],P}function C_(t){return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:i.jsx(Tt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),i.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function k_(t){return t.preventDefault()}function V_(t){ce.error(`Top-up failed: ${t.message}`)}function N_(){const t=B.c(5),e=ir(),s=vm(),[n,r]=C.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!s.ready||s.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(ar,{size:14}),t[0]=a):a=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(re,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Kn,{icon:a,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:l,children:i.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",i.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=c):c=t[2];let d;return t[3]!==n?(d=i.jsxs(i.Fragment,{children:[c,i.jsx(Ox,{open:n,onOpenChange:r})]}),t[3]=n,t[4]=d):d=t[4],d}function A_(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const T_={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 sl(t){const e=B.c(19),{variant:s,onDismiss:n}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?fn:nr,l=r?t.error.message:T_[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let c;e[0]!==r||e[1]!==l?(c=r?A_(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=c):c=e[2];const{summary:d,rawDetails:h}=c;let u;e[3]!==a?(u=i.jsx(a,{size:14}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(f=r?i.jsx(re,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):i.jsx(re,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=f):f=e[8];let m;e[9]!==h?(m=h?i.jsxs("details",{className:"group mx-4",children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"m4.5 3 3 3-3 3"})}),i.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),i.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),i.jsxs("div",{className:"relative mt-2",children:[i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(h).then(R_).catch(E_)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:i.jsx(Ss,{className:"size-3.5"})}),i.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:h})]})]}):null,e[9]=h,e[10]=m):m=e[10];let p;return e[11]!==o||e[12]!==n||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m||e[17]!==s?(p=i.jsx(Kn,{icon:u,label:o,title:d,defaultExpanded:!0,variant:s,onClose:n,footerRight:f,children:m}),e[11]=o,e[12]=n,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=s,e[18]=p):p=e[18],p}function E_(){return ce.error("Could not copy")}function R_(){return ce.success("Copied to clipboard")}function Ol(){const t=B.c(62),{error:e,clearError:s,finishReason:n,clearFinishReason:r,messages:o,isStreaming:a,submit:l,sendMessage:c}=js(),[d,h]=sr(),{virtualMcpId:u,createTaskWithMessage:f}=as(),{chatMode:m,simpleModeTier:p}=xs();let g;t[0]!==m||t[1]!==p||t[2]!==u?(g=Y=>({tier:p,mode:m,toolApprovalLevel:Y,agent:u?{id:u}:void 0}),t[0]=m,t[1]=p,t[2]=u,t[3]=g):g=t[3];const x=g;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??R4(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const _=v,b=o.at(-1),y=b?.role==="assistant"?b.parts:[],L=y.filter(M_),w=Ym(y),S=Gm(y);let j;t[6]!==e||t[7]!==c?(j=()=>{if(e){const ee={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};c(ee)}},t[6]=e,t[7]=c,t[8]=j):j=t[8];const k=j;let V;t[9]!==c?(V=()=>{c({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=c,t[10]=V):V=t[10];const T=V;let A;t[11]!==x||t[12]!==_||t[13]!==l?(A=(Y,ee)=>{l({kind:"toolOutput",toolCallId:Y.toolCallId,output:{response:ee}},x(_))},t[11]=x,t[12]=_,t[13]=l,t[14]=A):A=t[14];const N=A;let E;t[15]!==f||t[16]!==d||t[17]!==h||t[18]!==u?(E=Y=>{h({...d,toolApprovalLevel:"auto"}),f({virtualMcpId:u,message:{parts:[{type:"text",text:`Implement this plan:
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/app-editor-CETJj2AM.js","assets/index-D5AMb38_.js","assets/index-DhHJ9QL9.css","assets/ChevronRight-COyMMtrn.js","assets/automation-runs-TZuhdUpi.js","assets/select-CNCjpX2V.js","assets/tooltip-CPDCuZHp.js","assets/Check-hTX0g2g6.js","assets/ChevronDown-CtbNgJjS.js","assets/ChevronUp-DrQLdS-5.js","assets/useInfiniteQuery-Cyv_Biwf.js","assets/use-infinite-scroll-CpCcr_3o.js","assets/use-connection-585bR3ni.js","assets/use-collections-Dh7qGqEQ.js","assets/use-mcp-client-BWHiesE0.js","assets/constants-B72Xmt_K.js","assets/auth-CaTmxkVI.js","assets/use-virtual-mcp-7yP2xMZ8.js","assets/card-lN93fE4x.js","assets/sidebar-3VY89Rtk.js","assets/LayoutLeft-MTYFfG6g.js","assets/use-mobile-Dsc-qXvn.js","assets/X-BfuzWudS.js","assets/table-Db7D5N3o.js","assets/empty-state-A08rgKQW.js","assets/use-members-D_ltbzOt.js","assets/use-org-auth-client-Ch-UL4AR.js","assets/use-clock-tick-F7Pzvzfn.js","assets/AlertCircle-B2MTFPS8.js","assets/CheckCircle-BjY-L4wY.js","assets/Circle-CbNg9WkJ.js","assets/agent-icon-DbNqfZc_.js","assets/Tool01-C2uuW4sH.js","assets/SwitchHorizontal01-Cv0gqoMg.js","assets/Settings02-DiK4Zfdk.js","assets/XCircle-E2sSpnug.js","assets/ArrowUpRight-3C0ovRNT.js","assets/ZapSquare-BH5fJb6A.js","assets/Users03-CTDBVnnv.js","assets/Loading02-O--MdSmG.js","assets/Stars02-CS7iRFAY.js","assets/Copy01-nNlbPBfs.js","assets/ZoomOut-CT0X_7Jz.js","assets/DotsVertical-Rhpmgb2O.js","assets/Globe01-DAnAnRWA.js","assets/Eye-tz4NoIL3.js","assets/FilterLines-CGeWpTTu.js","assets/Star01-DL3N0SSB.js","assets/Globe04-GxqrJxZR.js","assets/HardDrive-DyDObBdu.js","assets/Key01-CYWVoXbx.js","assets/LinkExternal01-CStBYLEA.js","assets/List-DX8nYhDN.js","assets/Monitor01-DKsaSo1z.js","assets/Sun-BJJc3pjv.js","assets/Palette-COnagfGv.js","assets/Play-ZxstDp2T.js","assets/Plus-BGYMpw9I.js","assets/SearchLg-D9ukiV6Z.js","assets/SearchMd-BBEv0nJn.js","assets/Shield01-BUQ-CBWY.js","assets/Stars01-snzEz7AB.js","assets/Trash01-CMz4JKhN.js","assets/Upload01-Cp-_RjRZ.js","assets/User01-DknnnxgR.js","assets/Users01-DX1dVpzy.js","assets/XClose-DFQ360gy.js","assets/Zap-utKfCp3-.js","assets/use-automations-DP9-Stjg.js","assets/studio-tools-BW2lcaoN.js","assets/useSuspenseInfiniteQuery-fXsNWzj4.js","assets/badge-DOfBOYyl.js","assets/checkbox-D_SvHOnD.js","assets/command-CwCzyhKv.js","assets/index-BDb5jgty.js","assets/dialog-CecKqyMD.js","assets/popover-Cvj77i8A.js","assets/avatar-CvuiT91G.js","assets/format-time-Cy7tTmZp.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/use-copy-YIt7_Dc0.js","assets/file-type-icon-hNB12mM-.js","assets/tab-id-DAJ8K7VA.js","assets/monaco-editor-D8cnNfve.js","assets/index-6boH-yNr.js","assets/chat-context-BjfvKTYg.js","assets/autosend-D4dPIA2Q.js","assets/hooks-BDC3xAqI.js","assets/decopilot-sse-pool-ZwquLkpw.js","assets/backoff-CrEUbyZT.js","assets/delay-CnY5UFtP.js","assets/use-ai-providers-BM0N7Zmt.js","assets/use-decopilot-events-B6cy-C6Y.js","assets/use-organization-settings-BmvkeAEv.js","assets/types-Ck5ZRVig.js","assets/shell-layout-CABvaYX6.js","assets/alert-dialog-BlTyvb5S.js","assets/required-auth-layout-ChcaTQMo.js","assets/use-org-sso-B7a42d9W.js","assets/integration-icon-BQOBM6zg.js","assets/use-navigate-to-agent-v796T5h7.js","assets/reusable-new-chat-qqWu133U.js","assets/use-mcp-prompts-C2U11Ngq.js","assets/form-DScNzOXD.js","assets/label-aX83GfeD.js","assets/input-CLXnGmJ0.js","assets/add-section-modal-Dn9Nqw9B.js","assets/drawer-CYdd2dRg.js","assets/collection-search-DlG-P_hI.js","assets/tabs-NehxmzGs.js","assets/toggle-group-CDVwU9BE.js","assets/agent-capabilities-D9YyIGdF.js","assets/connection-slug-eyAPH6o3.js","assets/connection-card-BvJ7ni9e.js","assets/use-registry-connections-BOqLT8mU.js","assets/extract-connection-data-JlVrtTOq.js","assets/collection-tabs-CGV57TWU.js","assets/textarea-BN37l3pG.js","assets/connection-form-helpers-CEr3ghMm.js","assets/authenticate-and-persist-oauth-CiUVcPTS.js","assets/mcp-oauth-C2pIfPax.js","assets/connect-desktop-dialog-BjxQ9REX.js","assets/select-model-DyWLV5uO.js","assets/skeleton-ChVmi2IX.js","assets/ai-providers-logos-DD3qZ33J.js","assets/settings-section-BB3V0eaP.js","assets/dropdown-menu-DgOUTi08.js","assets/index-C1EaTR0J.js","assets/toolbar-C6s1lQVM.js","assets/use-debounced-value-DZDuT6Tu.js","assets/question-004-sINsf4GQ.js","assets/use-status-sounds-PXTvpsbK.js","assets/use-mcp-tools-CasywNR6.js","assets/use-capability-B_XurTSq.js","assets/tools-list-CQ95anOh.js","assets/switch-CAtXVnK8.js","assets/use-debounced-autosave-DfYRmvlO.js","assets/index-BbQHVX85.js","assets/search-input-Bd4t9JDl.js","assets/github-repo-picker-LXQPUBg-.js","assets/github-installations-DzN1UQ4x.js","assets/use-secrets-stp1JXmp.js","assets/formatDistanceToNow-Cb2QZZJn.js","assets/index-Br7hFXfd.js","assets/get-initials-D-f_fDFw.js","assets/calendar-B-i9ZRLn.js","assets/toolbar-icon-button-ueskcjGk.js","assets/automation-list-row-DsN97P8i.js","assets/use-file-configs-C7VbGe23.js","assets/post-editor-DDgBqLC0.js","assets/block-document-BLd6tzam.js","assets/primitives-8L17F8DB.js","assets/record-editor-C_mvNdEN.js","assets/category-editor-C-bPIYYJ.js","assets/bulk-category-panel-C4Bw4AHl.js","assets/index-Ba1nrFdh.js","assets/sections-editor-Cv3sWswm.js","assets/page-seo-form-DfniKL1Q.js","assets/seo-editor-wF02jWH-.js","assets/variant-calendar-BiFKt806.js","assets/view-mode-toggle-CeyQhEOw.js","assets/page-seo-sheet-BcKckI0p.js","assets/file-explorer-C0HkCv56.js","assets/project-app-view-BBJU6aKw.js"])))=>i.map(i=>d[i]);
2
+ import{p as os,r as C,o as V4,n as N4,c as B,$ as Ae,l as ne,j as i,P as ps,t as ce,G as nn,a8 as A4,H as Qt,a9 as x9,V as v9,B as re,J as _9,I as S1,aa as T4,ab as E4,a1 as sr,ac as fs,ad as Pr,ae as vu,b as St,d as Ds,M as Ce,af as R4,ag as nr,ah as P4,Z as w1,ai as j1,K as Qe,aj as Cl,a as vi,ak as I4,al as C1,am as D4,an as Zs,ao as fc,ap as Ri,aq as M4,ar as mc,as as O4,at as $4,au as B4,av as z4,L as b9,aw as F4,ax as U4,ay as H4,az as K4,aA as k1,aB as Kr,k as gs,i as qe,aC as y9,u as jo,e as L9,aD as Ge,a6 as V1,aE as zi,aF as Ws,Y as N1,aG as W4,aH as q4,aI as A1,aJ as G4,aK as kl,aL as Fi,aM as T1,aN as Y4,aO as J4,aP as E1,aQ as X4,aR as Q4,aS as Z4,aT as e5,aU as Qo,a7 as t5}from"./index-D5AMb38_.js";import{i as S9,n as s5,c as R1}from"./SwitchHorizontal01-Cv0gqoMg.js";import{u as xs,a as js,S as Ui,b as ir,c as as,d as P1,s as n5,e as i5,f as r5,p as I1,g as D1,A as o5,h as a5,i as l5,t as c5,j as d5,k as u5}from"./chat-context-BjfvKTYg.js";import{c as w9,s as rr,g as rn,P as io,d as j9,t as di,a as h5,M as f5,i as m5,b as Ba,e as M1,f as p5,D as g5,h as x5,j as v5,k as Hi,l as _5,u as O1,E as b5,m as C9,n as y5,F as L5,o as $1,p as B1,q as z1,S as S5,r as w5,v as j5,w as C5,x as _u,y as k5,z as F1,O as V5,A as N5,B as Sn,G as A5,T as T5,C as U1,R as E5,H as R5,I as P5,J as I5,K as D5,L as M5}from"./automation-runs-TZuhdUpi.js";import{c as ro,a as Re,b as Pe,T as Ie}from"./tooltip-CPDCuZHp.js";import{c as ns,a as is,d as Ft,e as Ut,b as qn,D as _i}from"./dialog-CecKqyMD.js";import{c as O5,b as H1,a as K1,D as W1}from"./drawer-CYdd2dRg.js";import{C as $5}from"./collection-search-DlG-P_hI.js";import{u as Co}from"./use-mobile-Dsc-qXvn.js";import{u as pt,a as B5,m as z5}from"./use-mcp-client-BWHiesE0.js";import{a as ko,S as k9,i as za,c as F5,d as q1,b as bu}from"./constants-B72Xmt_K.js";import{u as G1,g as Vo,l as a0}from"./use-mcp-prompts-C2U11Ngq.js";import{t as Ht}from"./ChevronDown-CtbNgJjS.js";import{i as ms}from"./X-BfuzWudS.js";import{t as U5,z as H5,b as Vl,u as Y1}from"./hooks-BDC3xAqI.js";import{K as K5,i as J1,u as No,r as W5,a as X1}from"./shell-layout-CABvaYX6.js";import{a as Ao,u as qs,b as V9,c as q5}from"./use-virtual-mcp-7yP2xMZ8.js";import{w as Q1,A as G5}from"./autosend-D4dPIA2Q.js";import{n as Ki,b as Z1}from"./ZapSquare-BH5fJb6A.js";import{i as Tt}from"./Check-hTX0g2g6.js";import{s as on}from"./Star01-DL3N0SSB.js";import{a as _n,i as Y5,b as N9,c as A9,d as T9}from"./Tool01-C2uuW4sH.js";import{g as Nl,h as em,j as E9,k as an,l as R9,m as P9,n as tm,o as J5,A as Hn,p as sm,q as nm,r as X5,u as Q5,c as im,v as Z5,w as ex,x as tx,y as sx,z as nx,B as ix,C as rx,D as ox,E as ax,F as Gn,G as Dn,H as Wi,I as yu,J as bi,K as I9,L as To,M as lx,N as cx,O as rm,P as Fa,Q as D9,R as dx,S as om,t as am,T as Ua,U as ux,V as hx,W as fx,e as lm,X as mx,Y as cm,Z as px,_ as Al,$ as M9,a0 as dm,a1 as l0,a2 as pc,a3 as Lu,a4 as gx,a5 as xx,a6 as vx,a7 as _x,a8 as bx,a9 as yx,aa as O9,i as c0,ab as um,ac as Su,ad as Lx,ae as Sx,af as wx,ag as jx,ah as Cx,ai as kx,aj as Vx,ak as Nx,al as hm,am as Ax,an as Tx}from"./agent-icon-DbNqfZc_.js";import{i as or}from"./Upload01-Cp-_RjRZ.js";import{i as fn}from"./AlertCircle-B2MTFPS8.js";import{a as Ss}from"./Copy01-nNlbPBfs.js";import{a as d0,b as $9,d as B9,e as z9,F as fm}from"./form-DScNzOXD.js";import{S as $t,a as Bt,b as nt,c as zt,d as Gt}from"./select-CNCjpX2V.js";import{b as Tl,i as Ex,a as Rx}from"./Settings02-DiK4Zfdk.js";import{i as Eo,t as u0,a as mm,b as Px}from"./XCircle-E2sSpnug.js";import{T as ri,a as Ro,b as $n,c as El}from"./tabs-NehxmzGs.js";import{a as pm,T as Ha}from"./toggle-group-CDVwU9BE.js";import{I as Ye}from"./input-CLXnGmJ0.js";import{u as F9,g as Po,a as U9,A as gm,c as xm,b as bn,r as Ix,f as Dx,d as Mx}from"./agent-capabilities-D9YyIGdF.js";import{u as Ms}from"./studio-tools-BW2lcaoN.js";import{i as ar}from"./Monitor01-DKsaSo1z.js";import{u as vm,C as Ox,a as $x,b as Bx,l as zx}from"./connect-desktop-dialog-BjxQ9REX.js";import{s as yn}from"./XClose-DFQ360gy.js";import{m as Rl,i as Fx,g as _m,a as Ux,N as bm,M as Hx}from"./select-model-DyWLV5uO.js";import{e as Fs,a as Ps,f as Kx,b as yi,C as Li,c as Si,d as lr,g as Wx}from"./command-CwCzyhKv.js";import{a as Cs,b as ks,P as Vs}from"./popover-Cvj77i8A.js";import{u as ym}from"./useInfiniteQuery-Cyv_Biwf.js";import{D as Zt,a as es,b as Ir,c as ts,d as He,e as oo,f as ao,g as lo,h as h0,i as Io,j as Di}from"./dropdown-menu-DgOUTi08.js";import{t as Bn}from"./Stars01-snzEz7AB.js";import{f as qx,a as Gx,d as Lm,b as Yx,u as Jx,c as Xx,e as Qx,g as Zx,h as ev,i as tv,F as sv,j as nv,k as iv,l as rv,m as ov,n as av,o as lv,H as cv,L as dv,p as uv,S as hv,B as fv,R as Zo,q as wu,r as ju,s as co,T as H9,t as mv}from"./index-C1EaTR0J.js";import{s as Lt}from"./Plus-BGYMpw9I.js";import{p as pv,q as gv}from"./question-004-sINsf4GQ.js";import{i as cn}from"./ChevronRight-COyMMtrn.js";import{u as Sm}from"./use-ai-providers-BM0N7Zmt.js";import{i as Pl}from"./CheckCircle-BjY-L4wY.js";import{n as Cu,a as wm,s as jm,b as xv}from"./Loading02-O--MdSmG.js";import{I as Gs}from"./integration-icon-BQOBM6zg.js";import{u as vv}from"./use-status-sounds-PXTvpsbK.js";import{E as qi}from"./empty-state-A08rgKQW.js";import{r as Ka,a as _v,p as Cm,f as f0,b as km,c as Vm,d as Nm,e as bv,F as yv,g as Lv,h as Sv,i as wv,j as jv,k as Cv,l as Am,m as kv}from"./tab-id-DAJ8K7VA.js";import{T as uo}from"./toolbar-C6s1lQVM.js";import{i as K9}from"./SearchLg-D9ukiV6Z.js";import{s as ws}from"./Trash01-CMz4JKhN.js";import{t as W9}from"./Users01-DX1dVpzy.js";import{i as ui}from"./Zap-utKfCp3-.js";import{f as Wa,a as qa,b as Ga,c as Ya,d as Ja,e as Xa,A as Qa,g as Za}from"./alert-dialog-BlTyvb5S.js";import{C as cr}from"./checkbox-D_SvHOnD.js";import{a as Do,b as Vv,c as Nv,d as hi,i as Tm}from"./ZoomOut-CT0X_7Jz.js";import{u as Em,a as Rm,b as Av}from"./use-organization-settings-BmvkeAEv.js";import{i as Yn,n as Tv}from"./Globe01-DAnAnRWA.js";import{u as Mo,a as q9,b as Pm}from"./use-connection-585bR3ni.js";import{u as Il,a as G9,b as Im}from"./use-mcp-tools-CasywNR6.js";import{g as Dl,M as Ev}from"./types-Ck5ZRVig.js";import{e as Dm}from"./backoff-CrEUbyZT.js";import{u as Rv}from"./use-capability-B_XurTSq.js";import{F as Gi,M as Y9,O as Pv}from"./file-type-icon-hNB12mM-.js";import{a as Iv}from"./extract-connection-data-JlVrtTOq.js";import{A as ja}from"./avatar-CvuiT91G.js";import{T as Mm,u as Om}from"./tools-list-CQ95anOh.js";import{a as Dv,i as ku}from"./mcp-oauth-C2pIfPax.js";import{s as $m,g as Mv}from"./connection-slug-eyAPH6o3.js";import{C as J9,a as el}from"./card-lN93fE4x.js";import{L as Xe}from"./label-aX83GfeD.js";import{S as ho}from"./switch-CAtXVnK8.js";import{T as Yi}from"./textarea-BN37l3pG.js";import{i as fi}from"./Play-ZxstDp2T.js";import{u as tl}from"./use-debounced-autosave-DfYRmvlO.js";import{i as fo}from"./SearchMd-BBEv0nJn.js";import{i as Ov}from"./LayoutLeft-MTYFfG6g.js";import{P as zs}from"./index-BbQHVX85.js";import{S as X9}from"./search-input-Bd4t9JDl.js";import{C as Bm}from"./collection-tabs-CGV57TWU.js";import{i as Q9}from"./Key01-CYWVoXbx.js";import{a as Z9,G as $v}from"./github-repo-picker-LXQPUBg-.js";import{S as yt}from"./skeleton-ChVmi2IX.js";import{s as Bv}from"./User01-DknnnxgR.js";import{u as zv,a as Fv}from"./use-secrets-stp1JXmp.js";import{f as zm}from"./formatDistanceToNow-Cb2QZZJn.js";import{u as Uv}from"./use-members-D_ltbzOt.js";import{u as Hv,S as Kv,T as Wv}from"./index-Br7hFXfd.js";import{m as qv,n as Gv,o as Yv,p as Jv,q as Xv}from"./sidebar-3VY89Rtk.js";import{n as wn}from"./LinkExternal01-CStBYLEA.js";import{l as Qv,w as Zv}from"./index-6boH-yNr.js";import{T as Vu}from"./toolbar-icon-button-ueskcjGk.js";import{d as e6}from"./delay-CnY5UFtP.js";import{B as t6}from"./badge-DOfBOYyl.js";import{u as Oo,a as s6,b as n6,c as i6,d as r6}from"./use-automations-DP9-Stjg.js";import{s as Wr}from"./Stars02-CS7iRFAY.js";import{M as Ml}from"./monaco-editor-D8cnNfve.js";import{A as o6}from"./automation-list-row-DsN97P8i.js";import{s as Fm}from"./Eye-tz4NoIL3.js";import{C as a6}from"./calendar-B-i9ZRLn.js";import{i as l6}from"./List-DX8nYhDN.js";import{i as c6}from"./DotsVertical-Rhpmgb2O.js";import{u as d6}from"./use-debounced-value-DZDuT6Tu.js";import{u as u6,a as Um}from"./use-file-configs-C7VbGe23.js";import{i as h6}from"./FilterLines-CGeWpTTu.js";function f6(t,e){const s=os(e);return m6({filters:{...t,status:"pending"}},s).length}function Nu(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function m6(t={},e){const s=os(e).getMutationCache(),n=C.useRef(t),r=C.useRef(null);return r.current===null&&(r.current=Nu(s,t)),C.useEffect(()=>{n.current=t}),C.useSyncExternalStore(C.useCallback(o=>s.subscribe(()=>{const a=V4(r.current,Nu(s,n.current));r.current!==a&&(r.current=a,N4.schedule(o))}),[s]),()=>r.current,()=>r.current)}const Au=3,Hm="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",p6="flex flex-col gap-1.5 p-4 rounded-xl bg-accent/40 text-sm leading-snug transition-colors cursor-pointer text-left";function Km(t){const e=B.c(46),{item:s,onSelect:n,isLoading:r,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 S=rn(c._meta);d=c.title??j9(c.name,S),e[0]=c._meta,e[1]=c.name,e[2]=c.title,e[3]=d}else d=e[3];const h=d,u=c.description||null;if(l==="card"){let S;e[4]!==n||e[5]!==c?(S=()=>n(c),e[4]=n,e[5]=c,e[6]=S):S=e[6];const j=o||r,k=r&&"bg-accent/40",V=(o||r)&&"cursor-not-allowed opacity-50";let T;e[7]!==k||e[8]!==V?(T=ne(p6,"hover:bg-accent/60 text-foreground",k,V),e[7]=k,e[8]=V,e[9]=T):T=e[9];let A;e[10]!==h?(A=i.jsx("span",{className:"font-medium truncate capitalize",children:h}),e[10]=h,e[11]=A):A=e[11];let N;e[12]!==r?(N=r&&i.jsx(Ui,{size:"xs"}),e[12]=r,e[13]=N):N=e[13];let E;e[14]!==A||e[15]!==N?(E=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,N]}),e[14]=A,e[15]=N,e[16]=E):E=e[16];let I;e[17]!==u?(I=u&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:u}),e[17]=u,e[18]=I):I=e[18];let P;return e[19]!==E||e[20]!==I||e[21]!==S||e[22]!==j||e[23]!==T?(P=i.jsxs("button",{type:"button",onClick:S,disabled:j,className:T,children:[E,I]}),e[19]=E,e[20]=I,e[21]=S,e[22]=j,e[23]=T,e[24]=P):P=e[24],P}let f;e[25]!==n||e[26]!==c?(f=()=>n(c),e[25]=n,e[26]=c,e[27]=f):f=e[27];const m=o||r,p=r&&"bg-muted/50",g=(o||r)&&"cursor-not-allowed opacity-50";let x;e[28]!==p||e[29]!==g?(x=ne(Hm,"hover:bg-muted/70 hover:text-foreground",p,g),e[28]=p,e[29]=g,e[30]=x):x=e[30];let v;e[31]!==h?(v=i.jsx("span",{className:"capitalize",children:h}),e[31]=h,e[32]=v):v=e[32];let _;e[33]!==r?(_=r&&i.jsx(Ui,{size:"xs"}),e[33]=r,e[34]=_):_=e[34];let b;e[35]!==f||e[36]!==m||e[37]!==x||e[38]!==v||e[39]!==_?(b=i.jsx(Re,{asChild:!0,children:i.jsxs("button",{type:"button",onClick:f,disabled:m,className:x,children:[v,_]})}),e[35]=f,e[36]=m,e[37]=x,e[38]=v,e[39]=_,e[40]=b):b=e[40];const y=u??h;let L;e[41]!==y?(L=i.jsx(Pe,{side:"top",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:y})}),e[41]=y,e[42]=L):L=e[42];let w;return e[43]!==b||e[44]!==L?(w=i.jsxs(Ie,{delayDuration:400,children:[b,L]}),e[43]=b,e[44]=L,e[45]=w):w=e[45],w}function g6(t){const e=B.c(41),{items:s,open:n,onOpenChange:r,onSelect:o,loadingPrompt:a}=t,[l,c]=C.useState(""),d=!!a;let h;e[0]!==s||e[1]!==l?(h=l.trim()?s.filter(j=>{const k=l.toLowerCase();return j.prompt.name.toLowerCase().includes(k)||(j.prompt.title??"").toLowerCase().includes(k)||(j.prompt.description??"").toLowerCase().includes(k)}):s,e[0]=s,e[1]=l,e[2]=h):h=e[2];const u=h,f=Co();let m;e[3]!==u.length||e[4]!==l?(m=u.length===0&&i.jsxs("p",{className:"col-span-4 text-sm text-muted-foreground text-center py-8",children:["No prompts match “",l,"”"]}),e[3]=u.length,e[4]=l,e[5]=m):m=e[5];let p;if(e[6]!==u||e[7]!==d||e[8]!==a?.name||e[9]!==r||e[10]!==o){let j;e[12]!==d||e[13]!==a?.name||e[14]!==r||e[15]!==o?(j=k=>i.jsx(Km,{item:k,variant:"card",onSelect:V=>{r(!1),o(V)},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]=r,e[15]=o,e[16]=j):j=e[16],p=u.map(j),e[6]=u,e[7]=d,e[8]=a?.name,e[9]=r,e[10]=o,e[11]=p}else p=e[11];let g;e[17]!==m||e[18]!==p?(g=i.jsx("div",{className:"flex-1 overflow-y-auto [scrollbar-gutter:stable]",children:i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 p-5",children:[m,p]})}),e[17]=m,e[18]=p,e[19]=g):g=e[19];const x=g;let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=j=>{j.key==="Escape"&&c("")},e[20]=v):v=e[20];let _;e[21]!==l?(_=i.jsx($5,{value:l,onChange:c,placeholder:"Search prompts...",onKeyDown:v}),e[21]=l,e[22]=_):_=e[22];const b=_;if(f){let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(O5,{className:"sr-only",children:i.jsx(H1,{children:"All prompts"})}),e[23]=j):j=e[23];let k;e[24]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[24]=k):k=e[24];let V;e[25]!==x||e[26]!==b?(V=i.jsxs(K1,{className:"h-[85vh] flex flex-col p-0 gap-0",children:[j,k,b,x]}),e[25]=x,e[26]=b,e[27]=V):V=e[27];let T;return e[28]!==r||e[29]!==n||e[30]!==V?(T=i.jsx(ro,{delayDuration:400,children:i.jsx(W1,{open:n,onOpenChange:r,children:V})}),e[28]=r,e[29]=n,e[30]=V,e[31]=T):T=e[31],T}let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ns,{className:"sr-only",children:i.jsx(is,{children:"All prompts"})}),e[32]=y):y=e[32];let L;e[33]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex items-center h-12 border-b border-border px-4 shrink-0",children:i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Prompts"})}),e[33]=L):L=e[33];let w;e[34]!==x||e[35]!==b?(w=i.jsxs(Ft,{className:"sm:max-w-[1100px] h-[680px] p-0 gap-0 overflow-hidden flex flex-col",children:[y,L,b,x]}),e[34]=x,e[35]=b,e[36]=w):w=e[36];let S;return e[37]!==r||e[38]!==n||e[39]!==w?(S=i.jsx(ro,{delayDuration:400,children:i.jsx(Ut,{open:n,onOpenChange:r,children:w})}),e[37]=r,e[38]=n,e[39]=w,e[40]=S):S=e[40],S}function x6(t){const e=B.c(29),{items:s,onSelect:n,loadingPrompt:r,className:o}=t,[a,l]=C.useState(!1);if(s.length===0)return null;let c,d,h;if(e[0]!==s||e[1]!==r||e[2]!==n){const v=s.slice(0,Au);let _;e[6]!==s?(_=s.slice(Au),e[6]=s,e[7]=_):_=e[7],c=_,d=!!r;let b;e[8]!==d||e[9]!==r?.name||e[10]!==n?(b=y=>i.jsx(Km,{item:y,onSelect:n,isLoading:r?.name===y.prompt.name,isDisabled:d&&r?.name!==y.prompt.name},y.prompt.name),e[8]=d,e[9]=r?.name,e[10]=n,e[11]=b):b=e[11],h=v.map(b),e[0]=s,e[1]=r,e[2]=n,e[3]=c,e[4]=d,e[5]=h}else c=e[3],d=e[4],h=e[5];const u=h;let f;e[12]!==o?(f=ne("w-full flex flex-wrap gap-2 justify-center",o),e[12]=o,e[13]=f):f=e[13];let m;e[14]!==c.length||e[15]!==d?(m=c.length>0&&i.jsxs("button",{type:"button",disabled:d,onClick:()=>l(!0),className:ne(Hm,"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]=m):m=e[16];let p;e[17]!==u||e[18]!==f||e[19]!==m?(p=i.jsxs("div",{className:f,children:[u,m]}),e[17]=u,e[18]=f,e[19]=m,e[20]=p):p=e[20];let g;e[21]!==s||e[22]!==r||e[23]!==a||e[24]!==n?(g=i.jsx(g6,{items:s,open:a,onOpenChange:l,onSelect:n,loadingPrompt:r}),e[21]=s,e[22]=r,e[23]=a,e[24]=n,e[25]=g):g=e[25];let x;return e[26]!==p||e[27]!==g?(x=i.jsxs(ro,{delayDuration:400,children:[p,g]}),e[26]=p,e[27]=g,e[28]=x):x=e[28],x}function v6(){return null}function _6(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 b6(t){const e=B.c(30),{connectionId:s}=t,{sendMessage:n}=js(),{org:r}=Ae();let o;e[0]!==s||e[1]!==r.id||e[2]!==r.slug?(o={connectionId:s,orgId:r.id,orgSlug:r.slug},e[0]=s,e[1]=r.id,e[2]=r.slug,e[3]=o):o=e[3];const a=pt(o);let l;e[4]!==a?(l={client:a,staleTime:6e4},e[4]=a,e[5]=l):l=e[5];const{data:c}=G1(l);let d;e[6]!==c?.prompts?(d=c?.prompts??[],e[6]=c?.prompts,e[7]=d):d=e[7];const h=d;let u;e[8]!==h?(u=h.map(y6),e[8]=h,e[9]=u):u=e[9];const f=u;let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m={stage:"idle"},e[10]=m):m=e[10];const[p,g]=C.useReducer(_6,m),[x,v]=C.useState(null);let _;e[11]!==a||e[12]!==n?(_=async(N,E)=>{if(!a){ce.error("MCP client not available"),g({type:"RESET"});return}try{const I=await Vo(a,N.name,E);g({type:"RESET"});const P={type:"doc",content:[{type:"paragraph",content:[w9({id:N.name,name:rr(N.name,rn(N._meta)),metadata:I.messages,char:"/",kind:"prompt",args:E}),{type:"text",text:" "}]}]};await n(P)}catch(I){console.error("[ice-breakers] Failed to fetch prompt:",I),ce.error("Failed to load prompt. Please try again."),g({type:"RESET"})}},e[11]=a,e[12]=n,e[13]=_):_=e[13];const b=_;let y;e[14]!==b?(y=async N=>{if(N.arguments&&N.arguments.length>0){g({type:"SELECT_PROMPT",prompt:N}),v(N);return}g({type:"START_LOADING",prompt:N}),await b(N)},e[14]=b,e[15]=y):y=e[15];const L=y;let w;e[16]!==x||e[17]!==b?(w=async N=>{x&&(g({type:"START_LOADING",prompt:x,arguments:N}),v(null),await b(x,N))},e[16]=x,e[17]=b,e[18]=w):w=e[18];const S=w;if(f.length===0)return null;const j=p.stage==="loading"?p.prompt:null;let k;e[19]!==L||e[20]!==f||e[21]!==j?(k=i.jsx(x6,{items:f,onSelect:L,loadingPrompt:j}),e[19]=L,e[20]=f,e[21]=j,e[22]=k):k=e[22];let V;e[23]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{v(null),g({type:"RESET"})},e[23]=V):V=e[23];let T;e[24]!==x||e[25]!==S?(T=i.jsx(io,{prompt:x,setPrompt:V,onSubmit:S}),e[24]=x,e[25]=S,e[26]=T):T=e[26];let A;return e[27]!==k||e[28]!==T?(A=i.jsxs(i.Fragment,{children:[k,T]}),e[27]=k,e[28]=T,e[29]=A):A=e[29],A}function y6(t){return{prompt:t}}function L6(t){const e=B.c(13),{className:s}=t,{selectedVirtualMcp:n}=xs(),{org:r}=Ae();let o;e[0]!==r.id?(o=ko(r.id),e[0]=r.id,e[1]=o):o=e[1];const a=o.id,l=n?.id??a;let c;e[2]!==s?(c=ne("w-full @container",s),e[2]=s,e[3]=c):c=e[3];const d=l??"default";let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(v6,{}),e[4]=h):h=e[4];let u;e[5]!==l?(u=i.jsx(b6,{connectionId:l}),e[5]=l,e[6]=u):u=e[6];let f;e[7]!==d||e[8]!==u?(f=i.jsx(ps,{fallback:null,children:i.jsx(C.Suspense,{fallback:h,children:u},d)}),e[7]=d,e[8]=u,e[9]=f):f=e[9];let m;return e[10]!==c||e[11]!==f?(m=i.jsx("div",{className:c,children:f}),e[10]=c,e[11]=f,e[12]=m):m=e[12],m}const gc="cubic-bezier(0.645, 0.045, 0.355, 1)",S6=44,w6={default:"",error:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-destructive/5 after:pointer-events-none after:-z-10",warning:"isolate after:content-[''] after:absolute after:inset-0 after:rounded-xl after:bg-amber-500/5 after:pointer-events-none after:-z-10"},j6={default:"border-border",error:"border-destructive/30",warning:"border-amber-500/30"},C6={default:"text-muted-foreground",error:"text-destructive",warning:"text-amber-600 dark:text-amber-500"};function Kn(t){const e=B.c(61),{icon:s,label:n,count:r,title:o,footerLeft:a,footerRight:l,children:c,defaultExpanded:d,variant:h,onClose:u}=t,f=h===void 0?"default":h,[m,p]=C.useState(d),[g,x]=C.useState(!1);let v;e[0]!==u?(v=()=>{x(!0),u?.()},e[0]=u,e[1]=v):v=e[1];const _=v;if(g)return null;const b=j6[f],y=w6[f];let L;e[2]!==b||e[3]!==y?(L=ne("relative flex flex-col rounded-xl bg-background border shadow-md","w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",b,y),e[2]=b,e[3]=y,e[4]=L):L=e[4];let w;e[5]===Symbol.for("react.memo_cache_sentinel")?(w=()=>p(k6),e[5]=w):w=e[5];const S=m&&"rounded-b-none",j=!m&&"rounded-b-xl";let k;e[6]!==S||e[7]!==j?(k=ne("flex items-center gap-2 w-full px-3 py-2 text-sm text-left","hover:bg-accent/50 transition-colors rounded-t-xl",S,j),e[6]=S,e[7]=j,e[8]=k):k=e[8];const V=C6[f];let T;e[9]!==V?(T=ne("shrink-0",V),e[9]=V,e[10]=T):T=e[10];let A;e[11]!==s||e[12]!==T?(A=i.jsx("span",{className:T,children:s}),e[11]=s,e[12]=T,e[13]=A):A=e[13];let N;e[14]!==n?(N=i.jsx("span",{className:"flex-1 min-w-0 truncate",children:n}),e[14]=n,e[15]=N):N=e[15];let E;e[16]!==r?(E=r?i.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:r}):null,e[16]=r,e[17]=E):E=e[17];const I=m?"rotate(180deg)":"rotate(0deg)";let P;e[18]!==I?(P=i.jsx("span",{"aria-hidden":"true",className:"text-muted-foreground shrink-0 flex items-center justify-center",children:i.jsx(Ht,{size:16,style:{transform:I,transition:`transform 180ms ${gc}`}})}),e[18]=I,e[19]=P):P=e[19];let R,D;e[20]!==_?(R=Z=>{Z.stopPropagation(),_()},D=Z=>{(Z.key==="Enter"||Z.key===" ")&&(Z.preventDefault(),Z.stopPropagation(),_())},e[20]=_,e[21]=R,e[22]=D):(R=e[21],D=e[22]);let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(ms,{size:16}),e[23]=M):M=e[23];let F;e[24]!==R||e[25]!==D?(F=i.jsx("span",{role:"button",tabIndex:0,"data-testid":"collapsible-highlight-close","aria-label":"Close",title:"Close",onClick:R,onKeyDown:D,className:"text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center justify-center -mr-1 ml-1 p-1 rounded-md hover:bg-accent",children:M}),e[24]=R,e[25]=D,e[26]=F):F=e[26];let $;e[27]!==m||e[28]!==A||e[29]!==N||e[30]!==E||e[31]!==P||e[32]!==F||e[33]!==k?($=i.jsxs("button",{type:"button","data-testid":"collapsible-highlight-chip","aria-expanded":m,onClick:w,className:k,children:[A,N,E,P,F]}),e[27]=m,e[28]=A,e[29]=N,e[30]=E,e[31]=P,e[32]=F,e[33]=k,e[34]=$):$=e[34];const O=m?"1fr":"0fr";let U;e[35]!==O?(U={display:"grid",gridTemplateRows:O,transition:`grid-template-rows 180ms ${gc}`},e[35]=O,e[36]=U):U=e[36];let K;e[37]===Symbol.for("react.memo_cache_sentinel")?(K={overflow:"hidden",minHeight:0},e[37]=K):K=e[37];const H=m?1:0;let q;e[38]!==H?(q={opacity:H,transition:`opacity 120ms ${gc}`},e[38]=H,e[39]=q):q=e[39];let J;e[40]!==o?(J=o?i.jsx("div",{className:"flex items-start gap-2 px-4 pt-4 pb-5 border-t border-dashed border-border/60",children:i.jsx("p",{className:"flex-1 text-base font-medium text-foreground min-w-0",children:o})}):i.jsx("div",{className:"border-t border-dashed border-border/60"}),e[40]=o,e[41]=J):J=e[41];let G;e[42]!==c||e[43]!==o?(G=c?i.jsx("div",{className:ne("overflow-clip pb-4",!o&&"pt-4"),children:c}):null,e[42]=c,e[43]=o,e[44]=G):G=e[44];let W;e[45]!==a||e[46]!==l?(W=a||l?i.jsx("div",{className:"border-t border-border px-3 py-3 pb-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{children:a}),i.jsx("div",{className:"flex items-center gap-2",children:l})]})}):null,e[45]=a,e[46]=l,e[47]=W):W=e[47];let z;e[48]!==q||e[49]!==J||e[50]!==G||e[51]!==W?(z=i.jsx("div",{style:K,children:i.jsxs("div",{style:q,children:[J,G,W]})}),e[48]=q,e[49]=J,e[50]=G,e[51]=W,e[52]=z):z=e[52];let X;e[53]!==U||e[54]!==z?(X=i.jsx("div",{"data-testid":"collapsible-highlight-body",style:U,children:z}),e[53]=U,e[54]=z,e[55]=X):X=e[55];let Q;return e[56]!==$||e[57]!==X||e[58]!==L||e[59]!==f?(Q=i.jsxs("div",{"data-testid":"collapsible-highlight","data-variant":f,className:L,children:[$,X]}),e[56]=$,e[57]=X,e[58]=L,e[59]=f,e[60]=Q):Q=e[60],Q}function k6(t){return!t}const V6=nn({content:Qt().min(1).describe("Imperative form, e.g. 'Implement the login flow'"),status:x9(["pending","in_progress","completed"]),activeForm:Qt().min(1).describe("Present-continuous form shown in the UI while the todo is in progress, e.g. 'Implementing the login flow'")}),Wm=nn({todos:A4(V6)}),N6="Plan and track multi-step work. Call with the FULL todo list every time — this replaces the prior list. Call at the start of every multi-step request. Skip only for true one-shots (a single tool call or a direct answer). Mark exactly one todo `in_progress` at a time. Flip a todo to `in_progress` before starting it and to `completed` the moment it finishes — do not batch completions. Your prior tool-call inputs are your current state — read your last call to see where you are.";U5({description:N6,inputSchema:H5(Wm),execute:async({todos:t})=>({ok:!0,count:t.length})});const A6="tool-todo_write",T6=new Set(["input-available","output-available"]);function qm(t){for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.role!=="assistant")continue;const n=s.parts;if(Array.isArray(n))for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type!==A6||typeof o.state!="string"||!T6.has(o.state))continue;const a=Wm.safeParse(o.input);if(a.success)return a.data.todos}}return[]}function Gm(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 n="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:n,friendlyName:di(h5(n)),input:s.input})}return e}function Ym(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 n=s.input;e.push({toolCallId:s.toolCallId,plan:n.plan,state:s.state})}return e}function E6(t){return t?t.message.startsWith("[CREDITS]"):!1}const R6={isCreditExhausted:!1,hasTodos:!1,showError:!1,showWarning:!1,hasApprovals:!1,hasPlans:!1,isWaitingForUserInput:!1};function P6(t){const{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=t;if(!r&&s&&E6(s))return{...R6,isCreditExhausted:!0};const a=e.at(-1),l=a?.role==="assistant"?a.parts:[],c=l,h=!!c.filter(b=>b.type==="tool-user_ask").filter(b=>b.state!=="output-available").length,u=Ym(l),f=Gm(c),m=qm(e),p=!r&&!!s,g=f.length>0||r&&o,x=u.length>0,_=!r&&!!n&&n!=="stop"&&!(n==="tool-calls"&&(h||g||x))&&!p;return{isCreditExhausted:!1,hasTodos:m.length>0,showError:p,showWarning:_,hasApprovals:g,hasPlans:x,isWaitingForUserInput:h}}function Jm(){const t=B.c(6),{messages:e,error:s,finishReason:n,isStreaming:r,isWaitingForApprovals:o}=js(),a=s??null,l=n??null;let c;return t[0]!==r||t[1]!==o||t[2]!==e||t[3]!==a||t[4]!==l?(c=P6({messages:e,error:a,finishReason:l,isStreaming:r,isWaitingForApprovals:o}),t[0]=r,t[1]=o,t[2]=e,t[3]=a,t[4]=l,t[5]=c):c=t[5],c}function I6(){const t=Jm();return t.isCreditExhausted?0:Number(t.hasTodos)+Number(t.showError)+Number(t.showWarning)+Number(t.hasApprovals)+Number(t.hasPlans)+Number(t.isWaitingForUserInput)}function Xm(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)}const D6="__home__";function ed(t,e){return v9.chatDraft(t,e)}function M6(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object"||typeof e.updatedAt!="number")return null;const s=e.tiptapDoc;return!s||typeof s!="object"||s.type!=="doc"||!Array.isArray(s.content)?null:s}function O6(t,e,s,n,r){const o=ed(e,s);if(Xm(n)){t.removeItem(o);return}const a={tiptapDoc:n,updatedAt:Date.now()},l=JSON.stringify(a);try{t.setItem(o,l)}catch(c){if(B6(c)){const d=new TextEncoder().encode(l).byteLength;r?.onQuotaExceeded?.({docSizeBytes:d});return}throw c}}function Tu(t,e,s){const n=ed(e,s),r=t.getItem(n),o=M6(r);return r!==null&&o===null&&t.removeItem(n),o}function $6(t,e,s){t.removeItem(ed(e,s))}function B6(t){if(!t||typeof t!="object")return!1;const e=t.name;return e==="QuotaExceededError"||e==="NS_ERROR_DOM_QUOTA_REACHED"}function z6(t){const e=B.c(21),{current:s,total:n,onPrev:r,onNext:o}=t;if(n<=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=ne("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=i.jsx(Tl,{size:14}),e[2]=d):d=e[2];let h;e[3]!==r||e[4]!==a||e[5]!==c?(h=i.jsx("button",{type:"button",onClick:r,disabled:a,className:c,"aria-label":"Previous question",children:d}),e[3]=r,e[4]=a,e[5]=c,e[6]=h):h=e[6];const u=s+1;let f;e[7]!==u||e[8]!==n?(f=i.jsxs("span",{className:"tabular-nums text-xs",children:[u," of ",n]}),e[7]=u,e[8]=n,e[9]=f):f=e[9];const m=s===n-1,p=s===n-1?"opacity-30 cursor-not-allowed":"hover:text-foreground cursor-pointer";let g;e[10]!==p?(g=ne("p-0.5 rounded transition-colors",p),e[10]=p,e[11]=g):g=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Eo,{size:14}),e[12]=x):x=e[12];let v;e[13]!==o||e[14]!==g||e[15]!==m?(v=i.jsx("button",{type:"button",onClick:o,disabled:m,className:g,"aria-label":"Next question",children:x}),e[13]=o,e[14]=g,e[15]=m,e[16]=v):v=e[16];let _;return e[17]!==v||e[18]!==h||e[19]!==f?(_=i.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[h,f,v]}),e[17]=v,e[18]=h,e[19]=f,e[20]=_):_=e[20],_}function Qm(t){const e=B.c(8),{currentIndex:s,total:n,onPrev:r,onNext:o,extraLeft:a}=t;let l;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(l=i.jsx(z6,{current:s,total:n,onPrev:r,onNext:o}),e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==a||e[6]!==l?(c=i.jsxs("div",{className:"flex items-center gap-2",children:[l,a]}),e[5]=a,e[6]=l,e[7]=c):c=e[7],c}function F6(t){const e=B.c(17),{isStreaming:s,isAllAnswered:n,isCurrentAnswered:r,onAdvanceOrSubmit:o,submitLabel:a,nextLabel:l}=t,h=n?a===void 0?"Submit":a:l===void 0?"Next":l,u=n?s:!r,f=u?n?"Waiting for the assistant to finish…":"Answer this item to continue":null;let m;e[0]!==u||e[1]!==o?(m=()=>{u||o()},e[0]=u,e[1]=o,e[2]=m):m=e[2];const p=u&&"opacity-50 cursor-not-allowed";let g;e[3]!==p?(g=ne("h-7 px-2.5 text-xs",p),e[3]=p,e[4]=g):g=e[4];let x;e[5]!==u||e[6]!==h||e[7]!==m||e[8]!==g?(x=i.jsx(re,{type:"button",size:"sm","aria-disabled":u,onClick:m,className:g,children:h}),e[5]=u,e[6]=h,e[7]=m,e[8]=g,e[9]=x):x=e[9];const v=x;if(!f)return v;let _;e[10]!==v?(_=i.jsx(Re,{asChild:!0,children:v}),e[10]=v,e[11]=_):_=e[11];let b;e[12]!==f?(b=i.jsx(Pe,{children:f}),e[12]=f,e[13]=b):b=e[13];let y;return e[14]!==_||e[15]!==b?(y=i.jsxs(Ie,{children:[_,b]}),e[14]=_,e[15]=b,e[16]=y):y=e[16],y}function Zm(t,e,s){return t.findIndex(n=>e(n)===s)}function Eu(t,e,s,n){return t.length===0?!1:t.every(r=>n(s[e(r)]))}function Ru(t,e,s,n,r){if(t.length===0)return null;const o=Zm(t,e,r);for(let a=1;a<=t.length;a++){const l=t[(o+a)%t.length];if(!l)continue;const c=e(l);if(c!==r&&!n(s[c]))return c}return null}function U6(t){return!t.isStreaming&&t.allAnswered}function e2(t){const{parts:e,partKey:s,schema:n,defaultValues:r,isStreaming:o,hasAnswer:a,onSubmit:l}=t,c=e[0]?s(e[0]):"",[d,h]=C.useState(c),[u,f]=C.useState(!1),m=_9({resolver:S1(n),defaultValues:r}),p=m.watch(),g=Zm(e,s,d),x=g>=0?e[g]:void 0,v=a(p[d]),_=Eu(e,s,p,a),b=U6({isStreaming:o,allAnswered:_}),y=()=>{if(g>0){const T=e[g-1];T&&h(s(T))}},L=()=>{if(g>=0&&g<e.length-1){const T=e[g+1];T&&h(s(T))}},w=()=>{const T=m.getValues(),A=Ru(e,s,T,a,d);A&&h(A)},S=()=>{m.handleSubmit(T=>{const A=T;for(const N of e)l(N,A[s(N)])})()},j=C.useRef(S);j.current=S;const k=()=>{b&&(f(!1),j.current())},V=()=>{const T=m.getValues();if(Eu(e,s,T,a)){if(o){f(!0);return}f(!1),j.current()}else{const A=Ru(e,s,T,a,d);A&&h(A)}};return C.useEffect(()=>{if(u&&!o){if(!_){f(!1);return}f(!1),j.current()}},[u,o,_]),{form:m,activeKey:d,setActiveKey:h,currentIndex:g,currentPart:x,isCurrentAnswered:v,isAllAnswered:_,canSubmit:b,goPrev:y,goNext:L,advanceToNextUnanswered:w,submit:k,submitOrAdvance:V}}const t2="User denied this tool call, give other alternatives.";function s2(t){const e=B.c(9),{onYolo:s}=t,[n,r]=sr();let o;e[0]!==s||e[1]!==n||e[2]!==r?(o=h=>{const u=h,f=n.toolApprovalLevel??"readonly";r({...n,toolApprovalLevel:u}),u==="auto"&&s(f)},e[0]=s,e[1]=n,e[2]=r,e[3]=o):o=e[3];const a=o;let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(zt,{size:"xs",className:"text-xs text-muted-foreground border-border/60 bg-transparent hover:bg-accent/60 h-7 gap-1",onClick:K6,children:i.jsx(Gt,{})}),e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx($t,{children:Pr.map(H6)}),e[5]=c):c=e[5];let d;return e[6]!==a||e[7]!==n.toolApprovalLevel?(d=i.jsxs(Bt,{value:n.toolApprovalLevel,onValueChange:a,children:[l,c]}),e[6]=a,e[7]=n.toolApprovalLevel,e[8]=d):d=e[8],d}function H6(t){return i.jsx(nt,{value:t.value,children:t.label},t.value)}function K6(t){return t.stopPropagation()}function n2(t){const e=B.c(5),{input:s}=t;if(s==null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("div",{className:"px-4 text-xs text-muted-foreground",children:"No input"}),e[0]=o):o=e[0],o}let n;try{let o;e[1]!==s?(o=JSON.stringify(s,null,2),e[1]=s,e[2]=o):o=e[2],n=o}catch{n=String(s)}let r;return e[3]!==n?(r=i.jsx("div",{className:"px-4",children:i.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:n})}),e[3]=n,e[4]=r):r=e[4],r}function W6(t){const e=B.c(28),{approval:s,onRespond:n}=t,[r]=sr(),o=r.toolApprovalLevel??"readonly";let a;e[0]!==s.approvalId||e[1]!==o||e[2]!==n?(a=()=>n(s.approvalId,!1,t2,o),e[0]=s.approvalId,e[1]=o,e[2]=n,e[3]=a):a=e[3];const l=a;let c;e[4]!==s.approvalId||e[5]!==o||e[6]!==n?(c=()=>n(s.approvalId,!0,void 0,o),e[4]=s.approvalId,e[5]=o,e[6]=n,e[7]=c):c=e[7];const d=c;let h;e[8]!==s.approvalId||e[9]!==n?(h=L=>n(s.approvalId,!0,void 0,L),e[8]=s.approvalId,e[9]=n,e[10]=h):h=e[10];const u=h;let f;e[11]!==u?(f=i.jsx("div",{className:"flex items-center gap-2",children:i.jsx(s2,{onYolo:u})}),e[11]=u,e[12]=f):f=e[12];const m=f;let p;e[13]!==l?(p=i.jsx(re,{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:l,children:"Deny"}),e[13]=l,e[14]=p):p=e[14];let g;e[15]!==d?(g=i.jsx(re,{type:"button",size:"sm",className:"h-7 px-2.5 text-xs active:scale-[0.97] transition-transform",onClick:d,children:"Accept"}),e[15]=d,e[16]=g):g=e[16];let x;e[17]!==p||e[18]!==g?(x=i.jsxs(i.Fragment,{children:[p,g]}),e[17]=p,e[18]=g,e[19]=x):x=e[19];const v=x;let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(Nl,{size:14}),e[20]=_):_=e[20];let b;e[21]!==s.input?(b=i.jsx(n2,{input:s.input}),e[21]=s.input,e[22]=b):b=e[22];let y;return e[23]!==s.friendlyName||e[24]!==m||e[25]!==v||e[26]!==b?(y=i.jsx(Kn,{icon:_,label:"Approval needed",title:s.friendlyName,defaultExpanded:!0,footerLeft:m,footerRight:v,children:b}),e[23]=s.friendlyName,e[24]=m,e[25]=v,e[26]=b,e[27]=y):y=e[27],y}const q6=T4(Qt(),nn({approved:E4().optional(),levelOverride:x9(["auto","readonly"]).optional()}));function G6(t){const e=B.c(42),{approvals:s,isStreaming:n,onRespond:r}=t,[o]=sr(),a=o.toolApprovalLevel??"readonly";let l;e[0]!==s?(l=Object.fromEntries(s.map(X6)),e[0]=s,e[1]=l):l=e[1];const c=l;let d;e[2]!==a||e[3]!==r?(d=(V,T)=>{const A=T;typeof A?.approved=="boolean"&&r(V.approvalId,A.approved,A.approved===!1?t2:void 0,A.levelOverride??a)},e[2]=a,e[3]=r,e[4]=d):d=e[4];let h;e[5]!==s||e[6]!==c||e[7]!==n||e[8]!==d?(h={parts:s,partKey:J6,schema:q6,defaultValues:c,isStreaming:n,hasAnswer:Y6,onSubmit:d},e[5]=s,e[6]=c,e[7]=n,e[8]=d,e[9]=h):h=e[9];const u=e2(h);let f;e[10]!==s||e[11]!==u?(f=V=>{u.form.reset(Object.fromEntries(s.map(T=>[T.approvalId,{approved:!0,levelOverride:V}]))),u.submitOrAdvance()},e[10]=s,e[11]=u,e[12]=f):f=e[12];const m=f,p=u.currentPart;let g;e[13]!==u?(g=V=>{V.preventDefault(),u.submit()},e[13]=u,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Nl,{size:14}),e[15]=x):x=e[15];const v=`${s.length} approvals pending`,_=p?.friendlyName??"";let b;e[16]!==m?(b=i.jsx(s2,{onYolo:m}),e[16]=m,e[17]=b):b=e[17];let y;e[18]!==s.length||e[19]!==u.currentIndex||e[20]!==u.goNext||e[21]!==u.goPrev||e[22]!==b?(y=i.jsx(Qm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext,extraLeft:b}),e[18]=s.length,e[19]=u.currentIndex,e[20]=u.goNext,e[21]=u.goPrev,e[22]=b,e[23]=y):y=e[23];let L;e[24]!==p||e[25]!==u.form.control||e[26]!==u.submitOrAdvance?(L=p?i.jsx(Q6,{approvalId:p.approvalId,control:u.form.control,onChange:u.submitOrAdvance}):null,e[24]=p,e[25]=u.form.control,e[26]=u.submitOrAdvance,e[27]=L):L=e[27];let w;e[28]!==p?(w=p?i.jsx(n2,{input:p.input}):null,e[28]=p,e[29]=w):w=e[29];let S;e[30]!==y||e[31]!==L||e[32]!==w||e[33]!==v||e[34]!==_?(S=i.jsx(Kn,{icon:x,label:v,title:_,defaultExpanded:!0,footerLeft:y,footerRight:L,children:w}),e[30]=y,e[31]=L,e[32]=w,e[33]=v,e[34]=_,e[35]=S):S=e[35];let j;e[36]!==S||e[37]!==g?(j=i.jsx("form",{onSubmit:g,children:S}),e[36]=S,e[37]=g,e[38]=j):j=e[38];let k;return e[39]!==u.form||e[40]!==j?(k=i.jsx(d0,{...u.form,children:j}),e[39]=u.form,e[40]=j,e[41]=k):k=e[41],k}function Y6(t){return typeof t?.approved=="boolean"}function J6(t){return t.approvalId}function X6(t){return[t.approvalId,{approved:void 0}]}function Q6(t){const e=B.c(6),{approvalId:s,control:n,onChange:r}=t,o=`${s}.approved`;let a;e[0]!==r?(a=c=>{const{field:d}=c,h=d.value===!0,u=d.value===!1;return i.jsxs(i.Fragment,{children:[i.jsx(re,{type:"button",variant:u?"secondary":"ghost",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!1),r()},"aria-pressed":u,children:"Deny"}),i.jsx(re,{type:"button",variant:h?"default":"outline",size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{d.onChange(!0),r()},"aria-pressed":h,children:"Accept"})]})},e[0]=r,e[1]=a):a=e[1];let l;return e[2]!==n||e[3]!==o||e[4]!==a?(l=i.jsx(fs,{control:n,name:o,render:a}),e[2]=n,e[3]=o,e[4]=a,e[5]=l):l=e[5],l}function Z6(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(Nl,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing approval request..."})]}),t[0]=e):e=t[0],e}function e_(t){const e=B.c(8),{approvals:s,isStreaming:n,onRespond:r}=t;if(n&&s.length===0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(Z6,{}),e[0]=a):a=e[0],a}if(s.length===0)return null;if(s.length===1){const a=s[0];if(!a)return null;let l;return e[1]!==r||e[2]!==a?(l=i.jsx(W6,{approval:a,onRespond:r}),e[1]=r,e[2]=a,e[3]=l):l=e[3],l}let o;return e[4]!==s||e[5]!==n||e[6]!==r?(o=i.jsx(G6,{approvals:s,isStreaming:n,onRespond:r}),e[4]=s,e[5]=n,e[6]=r,e[7]=o):o=e[7],o}function t_(t){const e=B.c(16),{plan:s,onApprove:n,onDismiss:r}=t;let o;e[0]!==n||e[1]!==s.plan?(o=()=>{n(s.plan)},e[0]=n,e[1]=s.plan,e[2]=o):o=e[2];const a=o;let l;e[3]!==r?(l=i.jsx(re,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2.5 text-xs text-muted-foreground [@media(hover:hover)]:hover:text-foreground active:scale-[0.97] transition-transform",onClick:r,children:"Keep iterating"}),e[3]=r,e[4]=l):l=e[4];let c;e[5]!==a?(c=i.jsx(re,{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=i.jsxs(i.Fragment,{children:[l,c]}),e[7]=l,e[8]=c,e[9]=d):d=e[9];const h=d;let u;e[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(em,{size:14}),e[10]=u):u=e[10];let f;e[11]!==s.plan?(f=i.jsx("div",{className:"px-4 max-h-64 overflow-y-auto",children:i.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:i.jsx(f5,{id:"plan-preview",part:{type:"text",text:s.plan}})})}),e[11]=s.plan,e[12]=f):f=e[12];let m;return e[13]!==h||e[14]!==f?(m=i.jsx(Kn,{icon:u,label:"Plan ready",title:"Implementation Plan",defaultExpanded:!0,footerRight:h,children:f}),e[13]=h,e[14]=f,e[15]=m):m=e[15],m}function s_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.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-[640px] mx-auto mb-2",children:[i.jsx(Tt,{className:"size-5 text-purple-500 shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing plan..."})]}),t[0]=e):e=t[0],e}function n_(t){const e=B.c(7),{plans:s,isStreaming:n,onApprove:r,onDismiss:o}=t;if(n&&s.length===0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(s_,{}),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]!==r||e[5]!==o?(c=i.jsx(t_,{plan:l,onApprove:r,onDismiss:o}),e[3]=l,e[4]=r,e[5]=o,e[6]=c):c=e[6],c}function i2(t){return t?"response"in t?t.response:t.option??t.draft:""}const Pu=nn({response:Qt().min(1,"Response is required")}),i_=nn({option:Qt().nullable(),draft:Qt()}).refine(t=>(t.option??t.draft).length>0,{message:"Please select or enter an option"}),r_=nn({response:x9(["yes","no"])});function o_(t){switch(t.type){case"text":return Pu;case"choice":return i_;case"confirm":return r_;default:return Pu}}function a_(t){const e={};for(const s of t)e[s.toolCallId]=o_(s.input);return nn(e)}function l_(t){const e=B.c(6),{control:s,name:n,placeholder:r}=t;let o;e[0]!==r?(o=l=>{const{field:c}=l,d=c.value??"";return i.jsxs($9,{children:[i.jsx(B9,{children:i.jsx("div",{className:"px-2",children:i.jsxs("div",{className:"flex items-center gap-3 px-2 py-3 rounded-lg bg-accent/50",children:[i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(E9,{size:16,className:"text-muted-foreground"})}),i.jsx("input",{...c,value:d,type:"text",placeholder:r||"Type your response...",autoFocus:!0,"aria-label":"Text response input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"})]})})}),i.jsx(z9,{})]})},e[0]=r,e[1]=o):o=e[1];let a;return e[2]!==s||e[3]!==n||e[4]!==o?(a=i.jsx(fm,{control:s,name:n,render:o}),e[2]=s,e[3]=n,e[4]=o,e[5]=a):a=e[5],a}function r2(t,e){const s=B.c(4);let n,r;s[0]!==t||s[1]!==e?(n=()=>{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)},r=[t,e],s[0]=t,s[1]=e,s[2]=n,s[3]=r):(n=s[2],r=s[3]),C.useEffect(n,r)}function c_(t){const e=B.c(40),{control:s,name:n,options:r}=t,o=`${n}.option`;let a;e[0]!==s||e[1]!==o?(a={control:s,name:o,defaultValue:null},e[0]=s,e[1]=o,e[2]=a):a=e[2];const{field:l}=vu(a),c=`${n}.draft`;let d;e[3]!==s||e[4]!==c?(d={control:s,name:c,defaultValue:""},e[3]=s,e[4]=c,e[5]=d):d=e[5];const{field:h}=vu(d),u=l.value,f=h.value??"";let m;if(e[6]!==l||e[7]!==r?(m=A=>{const N=r[A];N!=null&&l.onChange(N)},e[6]=l,e[7]=r,e[8]=m):m=e[8],r2(r.length,m),r.length===0)return null;const p=u===null;let g;if(e[9]!==l||e[10]!==u||e[11]!==r){let A;e[13]!==l||e[14]!==u?(A=(N,E)=>{const I=u===N;return i.jsxs("button",{type:"button",onClick:()=>l.onChange(N),className:ne("flex items-center gap-3 px-2 py-3 rounded-lg text-left transition-colors w-full",I&&"bg-accent/50",!I&&"hover:bg-accent/30"),"aria-label":`Select ${N}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",I?"bg-chart-1 text-white":"bg-muted text-foreground"),children:E+1}),i.jsx("span",{className:"text-sm text-foreground truncate",children:N})]},`${E}-${N}`)},e[13]=l,e[14]=u,e[15]=A):A=e[15],g=r.map(A),e[9]=l,e[10]=u,e[11]=r,e[12]=g}else g=e[12];const x=p&&"bg-accent/50",v=!p&&"hover:bg-accent/30";let _;e[16]!==x||e[17]!==v?(_=ne("flex items-center gap-3 px-2 py-3 rounded-lg transition-colors w-full cursor-text",x,v),e[16]=x,e[17]=v,e[18]=_):_=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("span",{className:"flex items-center justify-center size-6 rounded-md bg-muted shrink-0",children:i.jsx(E9,{size:16,className:"text-muted-foreground"})}),e[19]=b):b=e[19];const y=p?f:"";let L;e[20]!==h||e[21]!==l||e[22]!==u?(L=A=>{h.onChange(A.target.value),u!==null&&l.onChange(null)},e[20]=h,e[21]=l,e[22]=u,e[23]=L):L=e[23];let w;e[24]!==l||e[25]!==u?(w=()=>{u!==null&&l.onChange(null)},e[24]=l,e[25]=u,e[26]=w):w=e[26];let S;e[27]!==y||e[28]!==L||e[29]!==w?(S=i.jsx("input",{type:"text",value:y,onChange:L,onFocus:w,placeholder:"Something else...","aria-label":"Custom choice input",className:"flex-1 text-sm bg-transparent outline-none placeholder:text-foreground/25 text-foreground min-w-0"}),e[27]=y,e[28]=L,e[29]=w,e[30]=S):S=e[30];let j;e[31]!==S||e[32]!==_?(j=i.jsxs("label",{className:_,children:[b,S]}),e[31]=S,e[32]=_,e[33]=j):j=e[33];let k;e[34]!==j||e[35]!==g?(k=i.jsx(B9,{children:i.jsxs("div",{className:"flex flex-col px-2",role:"group","aria-label":"Choice options",children:[g,j]})}),e[34]=j,e[35]=g,e[36]=k):k=e[36];let V;e[37]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsx(z9,{}),e[37]=V):V=e[37];let T;return e[38]!==k?(T=i.jsxs($9,{children:[k,V]}),e[38]=k,e[39]=T):T=e[39],T}function d_(t){const e=B.c(6),{control:s,name:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=["yes","no"],e[0]=r):r=e[0];const o=r,a=C.useRef(null);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=h=>{a.current?.onChange(o[h]??"")},e[1]=l):l=e[1],r2(o.length,l);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=h=>{const{field:u}=h;return a.current=u,i.jsxs($9,{children:[i.jsx(B9,{children:i.jsx("div",{className:"flex gap-2 px-2",role:"group","aria-label":"Confirmation options",children:o.map(f=>{const m=u.value===f;return i.jsxs("button",{type:"button",onClick:()=>u.onChange(f),className:ne("flex items-center gap-3 px-4 py-3 rounded-lg text-left transition-colors flex-1",m&&"bg-accent/50",!m&&"hover:bg-accent/30"),"aria-label":`Confirm ${f}`,children:[i.jsx("span",{className:ne("flex items-center justify-center size-6 rounded-md text-sm shrink-0",m?"bg-chart-1 text-white":"bg-muted text-foreground"),children:f==="yes"?1:2}),i.jsx("span",{className:"text-sm text-foreground capitalize",children:f})]},f)})})}),i.jsx(z9,{})]})},e[2]=c):c=e[2];let d;return e[3]!==s||e[4]!==n?(d=i.jsx(fm,{control:s,name:n,render:c}),e[3]=s,e[4]=n,e[5]=d):d=e[5],d}function Iu(t){const e=B.c(13),{input:s,control:n,toolCallId:r}=t;switch(s.type){case"text":{const o=`${r}.response`;let a;return e[0]!==n||e[1]!==s.default||e[2]!==o?(a=i.jsx(l_,{control:n,name:o,placeholder:s.default}),e[0]=n,e[1]=s.default,e[2]=o,e[3]=a):a=e[3],a}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]!==n||e[7]!==a||e[8]!==r?(l=i.jsx(c_,{control:n,name:r,options:a}),e[6]=n,e[7]=a,e[8]=r,e[9]=l):l=e[9],l}case"confirm":{const o=`${r}.response`;let a;return e[10]!==n||e[11]!==o?(a=i.jsx(d_,{control:n,name:o}),e[10]=n,e[11]=o,e[12]=a):a=e[12],a}default:return null}}function u_(t){const e=B.c(71),{parts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=a_(s.map(p_)),e[0]=s,e[1]=o):o=e[1];const a=o;let l;e[2]!==s?(l=Object.fromEntries(s.map(m_)),e[2]=s,e[3]=l):l=e[3];const c=l;let d;e[4]!==r?(d=(R,D)=>{const M=i2(D);M&&r(R,M)},e[4]=r,e[5]=d):d=e[5];let h;e[6]!==c||e[7]!==n||e[8]!==s||e[9]!==a||e[10]!==d?(h={parts:s,partKey:f_,schema:a,defaultValues:c,isStreaming:n,hasAnswer:h_,onSubmit:d},e[6]=c,e[7]=n,e[8]=s,e[9]=a,e[10]=d,e[11]=h):h=e[11];const u=e2(h),f=u.currentPart;let m;e[12]!==f||e[13]!==u?(m=()=>{const R=f;if(!R)return;const D=R.toolCallId;R.input?.type==="choice"?(u.form.setValue(`${D}.option`,null),u.form.setValue(`${D}.draft`,"user has skip this question")):u.form.setValue(`${D}.response`,"user has skip this question"),u.advanceToNextUnanswered()},e[12]=f,e[13]=u,e[14]=m):m=e[14];const p=m;let g;e[15]!==u.currentIndex||e[16]!==u.goNext||e[17]!==u.goPrev||e[18]!==s.length?(g=i.jsx(Qm,{currentIndex:u.currentIndex,total:s.length,onPrev:u.goPrev,onNext:u.goNext}),e[15]=u.currentIndex,e[16]=u.goNext,e[17]=u.goPrev,e[18]=s.length,e[19]=g):g=e[19];const x=g;let v;e[20]!==p?(v=i.jsx(re,{type:"button",variant:"outline",size:"sm",onClick:p,className:"h-7",children:"Skip"}),e[20]=p,e[21]=v):v=e[21];let _;e[22]!==u.isAllAnswered||e[23]!==u.isCurrentAnswered||e[24]!==u.submitOrAdvance||e[25]!==n?(_=i.jsx(F6,{isStreaming:n,isAllAnswered:u.isAllAnswered,isCurrentAnswered:u.isCurrentAnswered,onAdvanceOrSubmit:u.submitOrAdvance}),e[22]=u.isAllAnswered,e[23]=u.isCurrentAnswered,e[24]=u.submitOrAdvance,e[25]=n,e[26]=_):_=e[26];let b;e[27]!==v||e[28]!==_?(b=i.jsxs(i.Fragment,{children:[v,_]}),e[27]=v,e[28]=_,e[29]=b):b=e[29];const y=b;if(s.length===1){const R=s[0];if(!R?.input)return null;let D;e[30]!==u?(D=q=>{q.preventDefault(),u.submit()},e[30]=u,e[31]=D):D=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx(u0,{size:14}),e[32]=M):M=e[32];const F=R.input?.prompt??"Question",$=R.input;let O;e[33]!==u.form.control||e[34]!==R.toolCallId||e[35]!==$?(O=i.jsx(Iu,{input:$,control:u.form.control,toolCallId:R.toolCallId}),e[33]=u.form.control,e[34]=R.toolCallId,e[35]=$,e[36]=O):O=e[36];let U;e[37]!==y||e[38]!==F||e[39]!==O?(U=i.jsx(Kn,{icon:M,label:"Question pending",title:F,defaultExpanded:!0,footerRight:y,children:O}),e[37]=y,e[38]=F,e[39]=O,e[40]=U):U=e[40];let K;e[41]!==D||e[42]!==U?(K=i.jsx("form",{onSubmit:D,autoComplete:"off",children:U}),e[41]=D,e[42]=U,e[43]=K):K=e[43];let H;return e[44]!==u.form||e[45]!==K?(H=i.jsx(d0,{...u.form,children:K}),e[44]=u.form,e[45]=K,e[46]=H):H=e[46],H}const L=u.form;let w;e[47]!==u?(w=R=>{R.preventDefault(),u.submit()},e[47]=u,e[48]=w):w=e[48];let S;e[49]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(u0,{size:14}),e[49]=S):S=e[49];const j=`${u.currentIndex+1} of ${s.length}`,k=f?.input?.prompt??"Question",V=u.activeKey,T=u.setActiveKey;let A;if(e[50]!==u.form||e[51]!==s){let R;e[53]!==u.form?(R=D=>i.jsx(ri,{value:D.toolCallId,className:"mt-0",children:i.jsx(Iu,{input:D.input,control:u.form.control,toolCallId:D.toolCallId})},D.toolCallId),e[53]=u.form,e[54]=R):R=e[54],A=s.map(R),e[50]=u.form,e[51]=s,e[52]=A}else A=e[52];let N;e[55]!==u.activeKey||e[56]!==u.setActiveKey||e[57]!==A?(N=i.jsx(Ro,{value:V,onValueChange:T,children:A}),e[55]=u.activeKey,e[56]=u.setActiveKey,e[57]=A,e[58]=N):N=e[58];let E;e[59]!==x||e[60]!==y||e[61]!==j||e[62]!==k||e[63]!==N?(E=i.jsx(Kn,{icon:S,label:"Question pending",count:j,title:k,defaultExpanded:!0,footerLeft:x,footerRight:y,children:N}),e[59]=x,e[60]=y,e[61]=j,e[62]=k,e[63]=N,e[64]=E):E=e[64];let I;e[65]!==w||e[66]!==E?(I=i.jsx("form",{onSubmit:w,autoComplete:"off",children:E}),e[65]=w,e[66]=E,e[67]=I):I=e[67];let P;return e[68]!==u.form||e[69]!==I?(P=i.jsx(d0,{...L,children:I}),e[68]=u.form,e[69]=I,e[70]=P):P=e[70],P}function h_(t){return!!i2(t)}function f_(t){return t.toolCallId}function m_(t){return t.input?.type==="choice"?[t.toolCallId,{option:null,draft:""}]:[t.toolCallId,{response:""}]}function p_(t){return{toolCallId:t.toolCallId,input:t.input}}function g_(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsxs("div",{className:"flex items-center gap-2 p-4 border border-dashed rounded-lg bg-accent/50 w-[calc(100%-16px)] max-w-[640px] mx-auto mb-2",children:[i.jsx(u0,{className:"size-5 text-muted-foreground shimmer"}),i.jsx("span",{className:"text-sm text-muted-foreground shimmer",children:"Preparing question..."})]}),t[0]=e):e=t[0],e}function o2(t){const e=B.c(7),{userAskParts:s,isStreaming:n,onSubmit:r}=t;let o;e[0]!==s?(o=s.filter(x_),e[0]=s,e[1]=o):o=e[1];const a=o;if(a.length===0){if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(g_,{}),e[2]=c):c=e[2],c}return null}let l;return e[3]!==n||e[4]!==r||e[5]!==a?(l=i.jsx(u_,{parts:a,isStreaming:n,onSubmit:r}),e[3]=n,e[4]=r,e[5]=a,e[6]=l):l=e[6],l}function x_(t){return t.state==="input-available"}function v_(t){const e=t.filter(o=>o.status==="in_progress"),s=t.filter(o=>o.status==="completed").length,n=t.length;if(n>0&&s===n)return{icon:"completed",activity:"All done",progress:`${n}/${n}`};const[r]=e;return r&&e.length===1?{icon:"in_progress",activity:r.activeForm,progress:`${s}/${n} done`}:e.length>1?{icon:"in_progress",activity:`${e.length} in progress`,progress:`${s}/${n} done`}:s>0?{icon:"pending",activity:`${n-s} pending`,progress:`${s}/${n} done`}:{icon:"pending",activity:`${n} todos`,progress:"not started"}}function __(){const t=B.c(21),{messages:e}=js();let s,n,r,o,a,l,c,d,h;if(t[0]!==e){h=Symbol.for("react.early_return_sentinel");e:{const m=qm(e);if(m.length===0){h=null;break e}const p=v_(m);s=Kn,a=i.jsx(S_,{status:p.icon}),l=p.activity,c=p.progress,d=!1,n="todos-list",r="flex flex-col px-2 max-h-[40vh] overflow-y-auto",o=m.map(b_)}t[0]=e,t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a,t[6]=l,t[7]=c,t[8]=d,t[9]=h}else s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],d=t[8],h=t[9];if(h!==Symbol.for("react.early_return_sentinel"))return h;let u;t[10]!==n||t[11]!==r||t[12]!==o?(u=i.jsx("ul",{"data-testid":n,className:r,children:o}),t[10]=n,t[11]=r,t[12]=o,t[13]=u):u=t[13];let f;return t[14]!==s||t[15]!==a||t[16]!==l||t[17]!==c||t[18]!==d||t[19]!==u?(f=i.jsx(s,{icon:a,label:l,count:c,defaultExpanded:d,children:u}),t[14]=s,t[15]=a,t[16]=l,t[17]=c,t[18]=d,t[19]=u,t[20]=f):f=t[20],f}function b_(t,e){return i.jsx(y_,{todo:t},e)}function y_(t){const e=B.c(14),{todo:s}=t,n=s.status==="completed",o=s.status==="in_progress"?s.activeForm:s.content;let a;e[0]!==s.status?(a=i.jsx(L_,{status:s.status}),e[0]=s.status,e[1]=a):a=e[1];const l=n&&"text-muted-foreground";let c;e[2]!==l?(c=ne("relative text-sm leading-snug pt-px select-none",l),e[2]=l,e[3]=c):c=e[3];const d=n?"100%":"0%",h=n?"width 300ms ease 200ms":"width 150ms ease";let u;e[4]!==d||e[5]!==h?(u=i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:"50%",height:"1px",background:"currentColor",width:d,transition:h}}),e[4]=d,e[5]=h,e[6]=u):u=e[6];let f;e[7]!==o||e[8]!==c||e[9]!==u?(f=i.jsxs("span",{className:c,children:[o,u]}),e[7]=o,e[8]=c,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==a||e[12]!==f?(m=i.jsxs("li",{className:"flex items-start gap-2.5 px-2 py-1.5 rounded-lg hover:bg-accent/50 transition-colors",children:[a,f]}),e[11]=a,e[12]=f,e[13]=m):m=e[13],m}function L_(t){const e=B.c(4),{status:s}=t,n=s==="completed"?"true":void 0,r=s==="in_progress"?"true":void 0;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("svg",{viewBox:"0 0 21 21",children:i.jsx("path",{d:"M5,10.75 L8.5,14.25 L19.4,2.3 C18.8333333,1.43333333 18.0333333,1 17,1 L4,1 C2.35,1 1,2.35 1,4 L1,17 C1,18.65 2.35,20 4,20 L17,20 C18.65,20 20,18.65 20,17 L20,7.99769186"})}),e[0]=o):o=e[0];let a;return e[1]!==n||e[2]!==r?(a=i.jsx("div",{className:"todo-cb mt-0.5","data-checked":n,"data-progress":r,"aria-hidden":"true",children:o}),e[1]=n,e[2]=r,e[3]=a):a=e[3],a}function S_(t){const e=B.c(3),{status:s}=t;if(s==="completed"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"completed",className:"inline-flex items-center justify-center w-3.5 h-3.5 rounded-sm bg-primary",children:i.jsx("svg",{viewBox:"0 0 10 8",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"w-2 h-2 text-primary-foreground",style:{strokeWidth:2},children:i.jsx("path",{d:"M1 4l2.5 2.5L9 1"})})}),e[0]=r):r=e[0],r}if(s==="in_progress"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("span",{"aria-label":"in progress",className:"inline-block w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),e[1]=r):r=e[1],r}let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("span",{"aria-label":"pending",className:"inline-block w-3.5 h-3.5 rounded-sm border-[1.5px] border-muted-foreground/50 shrink-0"}),e[2]=n):n=e[2],n}const w_={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"}]},j_=["Access to 100+ AI models","Unified API, no separate keys needed","Pay only for what you use"];function a2(t){const e=B.c(41),{onDismiss:s}=t,{org:n}=Ae(),r=St(),{decoKeyId:o}=F9(),a=Ms(),[l,c]=C.useState(""),[d,h]=C.useState(!1),[u,f]=C.useState("usd"),m=u==="brl"?"R$":"$";let p,g;e[0]!==n.id?(p=()=>{Ce("credits_exhausted_shown",{organization_id:n.id})},g=[n.id],e[0]=n.id,e[1]=p,e[2]=g):(p=e[1],g=e[2]),C.useEffect(p,g);let x;e[3]!==u||e[4]!==a?(x=async R=>{const{url:D}=await a.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:R,currency:u});return D},e[3]=u,e[4]=a,e[5]=x):x=e[5];let v;e[6]!==s?(v=R=>{R&&window.open(R,"_blank","noopener,noreferrer"),s?.()},e[6]=s,e[7]=v):v=e[7];let _;e[8]!==x||e[9]!==v?(_={mutationFn:x,onSuccess:v,onError:V_},e[8]=x,e[9]=v,e[10]=_):_=e[10];const{mutate:b,isPending:y}=Ds(_),L=parseFloat(l),w=!isNaN(L)&&L>=1;let S;e[11]!==s?(S=R=>!R&&s?.(),e[11]=s,e[12]=S):S=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=["radial-gradient(ellipse 40% 200% at -5% 100%, rgba(165,149,255,0.5) 0%, transparent 100%)","radial-gradient(ellipse 40% 200% at 105% -10%, rgba(208,236,26,0.45) 0%, transparent 100%)"],e[13]=j):j=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx("div",{className:"absolute inset-x-0 top-0 h-36 pointer-events-none",style:{backgroundImage:j.join(", "),maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)"}}),e[14]=k):k=e[14];let V;e[15]===Symbol.for("react.memo_cache_sentinel")?(V=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[k,i.jsxs(ns,{className:"relative gap-4",children:[i.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"}),i.jsxs("div",{children:[i.jsx(is,{className:"text-xl font-semibold tracking-tight",children:"Top up to keep building"}),i.jsx(qn,{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[15]=V):V=e[15];let T;e[16]!==u||e[17]!==m||e[18]!==l||e[19]!==L||e[20]!==o||e[21]!==w||e[22]!==y||e[23]!==d||e[24]!==b?(T=o&&i.jsxs("div",{className:"px-8 pt-5 pb-6",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(pm,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:R=>{R&&f(R)},children:[i.jsx(Ha,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(Ha,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsxs("div",{className:"rounded-xl border border-border p-5",children:[i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:w_[u].map(R=>{const{dollars:D,label:M}=R;return i.jsxs("button",{type:"button",disabled:y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:D*100,currency:u,tier_label:M,source:"exhausted_banner"}),b(D*100)},className:ne("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:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,D]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:M})]},D)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(Ye,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:R=>c(R.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(re,{className:"h-10",disabled:!w||y,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:Math.round(L*100),currency:u,tier_label:"custom",source:"exhausted_banner"}),b(Math.round(L*100))},children:y?"Opening...":"Add"})]}):i.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"})]}),i.jsx("div",{className:"mt-5 rounded-xl bg-muted/25 border border-border/50 p-4 space-y-3",children:j_.map(C_)})]}),e[16]=u,e[17]=m,e[18]=l,e[19]=L,e[20]=o,e[21]=w,e[22]=y,e[23]=d,e[24]=b,e[25]=T):T=e[25];let A;e[26]!==s?(A=i.jsx(re,{variant:"ghost",size:"sm",onClick:s,children:"Dismiss"}),e[26]=s,e[27]=A):A=e[27];let N;e[28]!==r||e[29]!==s||e[30]!==n.slug?(N=i.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{r({to:"/$org/settings/ai-providers",params:{org:n.slug}}),s?.()},children:"Manage providers"}),e[28]=r,e[29]=s,e[30]=n.slug,e[31]=N):N=e[31];let E;e[32]!==A||e[33]!==N?(E=i.jsxs("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-between",children:[A,N]}),e[32]=A,e[33]=N,e[34]=E):E=e[34];let I;e[35]!==T||e[36]!==E?(I=i.jsxs(Ft,{className:"sm:max-w-[520px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:k_,children:[V,T,E]}),e[35]=T,e[36]=E,e[37]=I):I=e[37];let P;return e[38]!==I||e[39]!==S?(P=i.jsx(Ut,{open:!0,onOpenChange:S,children:I}),e[38]=I,e[39]=S,e[40]=P):P=e[40],P}function C_(t){return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"flex items-center justify-center size-5 rounded-full bg-[hsl(var(--chart-1))]/15 shrink-0",children:i.jsx(Tt,{size:12,className:"text-[hsl(var(--chart-1))]"})}),i.jsx("span",{className:"text-sm text-foreground/80",children:t})]},t)}function k_(t){return t.preventDefault()}function V_(t){ce.error(`Top-up failed: ${t.message}`)}function N_(){const t=B.c(5),e=ir(),s=vm(),[n,r]=C.useState(!1);if(!(e?.lockedSandbox==="user-desktop")||!s.ready||s.online)return null;let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(ar,{size:14}),t[0]=a):a=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(re,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>r(!0),children:"Reconnect desktop"}),t[1]=l):l=t[1];let c;t[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Kn,{icon:a,label:"Your desktop is offline",title:"This chat runs on your desktop, which isn't connected right now.",defaultExpanded:!0,variant:"warning",footerRight:l,children:i.jsxs("p",{className:"mx-4 text-xs text-muted-foreground",children:["Run ",i.jsx("code",{className:"font-mono",children:"bunx decocms@latest link"})," in a terminal on that machine to bring it back. Messages you send while it's offline will fail."]})}),t[2]=c):c=t[2];let d;return t[3]!==n?(d=i.jsxs(i.Fragment,{children:[c,i.jsx(Ox,{open:n,onOpenChange:r})]}),t[3]=n,t[4]=d):d=t[4],d}function A_(t){const e=t.trim(),s=e.startsWith("<")&&/<[a-z][\s\S]*>/i.test(e),n=/cloudflare|cf-[a-z-]+|error[\s_-]?code[\s_-]?5\d\d/i.test(e),r=/failed to fetch|networkerror|load failed|offline/i.test(e),o=/timeout|timed out|aborted|deadline/i.test(e),a=e.length>240,l=/sandbox failed to start(?::\s*(.+))?/is.exec(e);if(l){const c=l[1]?.trim().replace(/\.$/,"");return{summary:c?`Your sandbox didn't finish starting up (${c}). Try again.`:"Your sandbox didn't finish starting up. Try again.",rawDetails:t}}return/link_unavailable|user_desktop_link_/i.test(e)?/user_desktop_link_capability_missing/i.test(e)?{summary:"Your desktop is connected, but the CLI this chat uses wasn't detected there. Install it and sign in on your desktop, then try again.",rawDetails:t}:{summary:"Your desktop is offline. Run `bunx decocms@latest link` in a terminal on it, then try again.",rawDetails:t}:n||s&&a?{summary:"Our servers are having a moment. Try sending again in a few seconds.",rawDetails:t}:r?{summary:"Lost connection. Check your network and try again.",rawDetails:t}:o?{summary:"That took longer than expected. Try again.",rawDetails:t}:s||a?{summary:"Something unexpected came back from the server. Try again.",rawDetails:t}:{summary:t,rawDetails:null}}const T_={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 sl(t){const e=B.c(19),{variant:s,onDismiss:n}=t,r=s==="error",o=r?"Error occurred":"Response incomplete",a=r?fn:nr,l=r?t.error.message:T_[t.finishReason]??`Response stopped unexpectedly: ${t.finishReason}`;let c;e[0]!==r||e[1]!==l?(c=r?A_(l):{summary:l,rawDetails:null},e[0]=r,e[1]=l,e[2]=c):c=e[2];const{summary:d,rawDetails:h}=c;let u;e[3]!==a?(u=i.jsx(a,{size:14}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r||e[6]!==t.onContinue||e[7]!==t.onFixInChat?(f=r?i.jsx(re,{size:"sm",variant:"outline",onClick:t.onFixInChat,className:"h-7 text-xs",children:"Fix in chat"}):i.jsx(re,{size:"sm",variant:"outline",onClick:t.onContinue,className:"h-7 text-xs",children:"Continue"}),e[5]=r,e[6]=t.onContinue,e[7]=t.onFixInChat,e[8]=f):f=e[8];let m;e[9]!==h?(m=h?i.jsxs("details",{className:"group mx-4",children:[i.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[i.jsx("svg",{"aria-hidden":"true",className:"size-3 transition-transform group-open:rotate-90",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"m4.5 3 3 3-3 3"})}),i.jsx("span",{className:"group-open:hidden",children:"Show technical details"}),i.jsx("span",{className:"hidden group-open:inline",children:"Hide technical details"})]}),i.jsxs("div",{className:"relative mt-2",children:[i.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(h).then(R_).catch(E_)},"aria-label":"Copy error details",title:"Copy",className:"absolute right-1.5 top-1.5 z-10 flex h-6 w-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-background hover:text-foreground",children:i.jsx(Ss,{className:"size-3.5"})}),i.jsx("pre",{className:"max-h-40 overflow-auto rounded-md border border-border/60 bg-background px-3 py-2 pr-8 font-mono text-xs text-foreground/80 whitespace-pre-wrap break-all",children:h})]})]}):null,e[9]=h,e[10]=m):m=e[10];let p;return e[11]!==o||e[12]!==n||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m||e[17]!==s?(p=i.jsx(Kn,{icon:u,label:o,title:d,defaultExpanded:!0,variant:s,onClose:n,footerRight:f,children:m}),e[11]=o,e[12]=n,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=s,e[18]=p):p=e[18],p}function E_(){return ce.error("Could not copy")}function R_(){return ce.success("Copied to clipboard")}function Ol(){const t=B.c(62),{error:e,clearError:s,finishReason:n,clearFinishReason:r,messages:o,isStreaming:a,submit:l,sendMessage:c}=js(),[d,h]=sr(),{virtualMcpId:u,createTaskWithMessage:f}=as(),{chatMode:m,simpleModeTier:p}=xs();let g;t[0]!==m||t[1]!==p||t[2]!==u?(g=Y=>({tier:p,mode:m,toolApprovalLevel:Y,agent:u?{id:u}:void 0}),t[0]=m,t[1]=p,t[2]=u,t[3]=g):g=t[3];const x=g;let v;t[4]!==d.toolApprovalLevel?(v=d.toolApprovalLevel??R4(),t[4]=d.toolApprovalLevel,t[5]=v):v=t[5];const _=v,b=o.at(-1),y=b?.role==="assistant"?b.parts:[],L=y.filter(M_),w=Ym(y),S=Gm(y);let j;t[6]!==e||t[7]!==c?(j=()=>{if(e){const ee={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${e.message}. Can you help me fix it?`}]}]};c(ee)}},t[6]=e,t[7]=c,t[8]=j):j=t[8];const k=j;let V;t[9]!==c?(V=()=>{c({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[9]=c,t[10]=V):V=t[10];const T=V;let A;t[11]!==x||t[12]!==_||t[13]!==l?(A=(Y,ee)=>{l({kind:"toolOutput",toolCallId:Y.toolCallId,output:{response:ee}},x(_))},t[11]=x,t[12]=_,t[13]=l,t[14]=A):A=t[14];const N=A;let E;t[15]!==f||t[16]!==d||t[17]!==h||t[18]!==u?(E=Y=>{h({...d,toolApprovalLevel:"auto"}),f({virtualMcpId:u,message:{parts:[{type:"text",text:`Implement this plan:
3
3
 
4
4
  ${Y}`}]}})},t[15]=f,t[16]=d,t[17]=h,t[18]=u,t[19]=E):E=t[19];const I=E,P=D_;let R;t[20]!==x||t[21]!==l?(R=(Y,ee,te,ae)=>{l({kind:"approval",approvalId:Y,approved:ee,...te?{reason:te}:{}},x(ae))},t[20]=x,t[21]=l,t[22]=R):R=t[22];const D=R,M=Jm();if(M.isCreditExhausted){let Y;return t[23]!==s?(Y=i.jsx(a2,{onDismiss:s}),t[23]=s,t[24]=Y):Y=t[24],Y}const{showError:F,showWarning:$,hasApprovals:O}=M,U=L.map(I_).join("|"),K=w[0]?.toolCallId??"",H=S.map(P_).join("|");let q,J;t[25]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx(__,{}),J=i.jsx(N_,{}),t[25]=q,t[26]=J):(q=t[25],J=t[26]);let G;t[27]!==s||t[28]!==e||t[29]!==k||t[30]!==F?(G=F&&i.jsx(sl,{variant:"error",error:e,onDismiss:s,onFixInChat:k}),t[27]=s,t[28]=e,t[29]=k,t[30]=F,t[31]=G):G=t[31];let W;t[32]!==r||t[33]!==n||t[34]!==T||t[35]!==$?(W=$&&i.jsx(sl,{variant:"warning",finishReason:n,onDismiss:r,onContinue:T}),t[32]=r,t[33]=n,t[34]=T,t[35]=$,t[36]=W):W=t[36];let z;t[37]!==H||t[38]!==D||t[39]!==O||t[40]!==a||t[41]!==S?(z=O&&i.jsx(e_,{approvals:S,isStreaming:a,onRespond:D},H),t[37]=H,t[38]=D,t[39]=O,t[40]=a,t[41]=S,t[42]=z):z=t[42];let X;t[43]!==M.hasPlans||t[44]!==I||t[45]!==P||t[46]!==a||t[47]!==w||t[48]!==K?(X=M.hasPlans&&i.jsx(n_,{plans:w,isStreaming:a,onApprove:I,onDismiss:P},K),t[43]=M.hasPlans,t[44]=I,t[45]=P,t[46]=a,t[47]=w,t[48]=K,t[49]=X):X=t[49];let Q;t[50]!==M.isWaitingForUserInput||t[51]!==N||t[52]!==a||t[53]!==U||t[54]!==L?(Q=M.isWaitingForUserInput&&i.jsx(o2,{userAskParts:L,isStreaming:a,onSubmit:N},U),t[50]=M.isWaitingForUserInput,t[51]=N,t[52]=a,t[53]=U,t[54]=L,t[55]=Q):Q=t[55];let Z;return t[56]!==W||t[57]!==z||t[58]!==X||t[59]!==Q||t[60]!==G?(Z=i.jsxs("div",{className:"absolute bottom-full left-0 right-0",children:[q,J,G,W,z,X,Q]}),t[56]=W,t[57]=z,t[58]=X,t[59]=Q,t[60]=G,t[61]=Z):Z=t[61],Z}function P_(t){return t.approvalId}function I_(t){return t.toolCallId}function D_(){document.querySelector("[data-chat-input]")?.focus()}function M_(t){return t.type==="tool-user_ask"}Ol.Error=function(e){return i.jsx(sl,{variant:"error",error:e.error,onDismiss:e.onDismiss,onFixInChat:e.onFixInChat})};Ol.Warning=function(e){return i.jsx(sl,{variant:"warning",finishReason:e.finishReason,onDismiss:e.onDismiss,onContinue:e.onContinue})};Ol.UserAskQuestion=o2;function O_(t){const e=B.c(12),{taskId:s}=t,n=P1(s),r=n5(n),o=i5(),{stop:a,removeLocalMessage:l}=js();if(r.length===0)return null;let c;e[0]!==a?(c=()=>{a()},e[0]=a,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(S9,{size:14}),e[2]=d):d=e[2];let h;e[3]!==c?(h=i.jsx(Re,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon-sm",onClick:c,children:d})}),e[3]=c,e[4]=h):h=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Pe,{side:"top",children:i.jsx("p",{className:"text-xs",children:"Send now"})}),e[5]=u):u=e[5];let f;e[6]!==h?(f=i.jsxs(Ie,{delayDuration:400,children:[h,u]}),e[6]=h,e[7]=f):f=e[7];let m;return e[8]!==o||e[9]!==l||e[10]!==s?(m=(p,g)=>i.jsxs("div",{className:"group/queuerow flex items-center gap-2 px-3 py-1.5",children:[i.jsx("span",{className:"flex size-[18px] shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground dark:bg-background",children:g+1}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:p.text}),i.jsx("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover/queuerow:opacity-100",children:i.jsx(re,{type:"button",variant:"ghost",size:"icon-sm",title:"Remove from queue",onClick:()=>{o.cancel(s,p.messageId).then(x=>{x&&(r5(s,p.messageId),l(p.messageId))})},children:i.jsx(yn,{className:"size-3.5"})})})]},p.messageId),e[8]=o,e[9]=l,e[10]=s,e[11]=m):m=e[11],i.jsxs("div",{className:"mb-1 overflow-hidden rounded-2xl border border-border bg-card dark:bg-muted",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-1.5 pr-2 pl-3 text-xs text-muted-foreground",children:[i.jsxs("span",{children:[r.length," queued message",r.length>1?"s":""]}),f]}),r.map(m)]})}function $_(t){return(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"user"}function l2(t){const e=$_(t),s=Date.now().toString(36).split("").reverse().join("");return`${e}-${s}`}const Ca=100;function B_(t,e,s){const n=e.trim().toLowerCase();return n?(t??[]).some(r=>r.branches.some(o=>typeof o.name=="string"&&!s.has(o.name)&&o.name.toLowerCase().includes(n))):!0}function z_(t,e){const s=e.trim().toLowerCase();return s?[...t].some(n=>n.toLowerCase().includes(s)):!0}function F_(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(n=>n.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function U_(t){const e=B.c(48),{orgId:s,orgSlug:n,userId:r,connectionId:o,sandboxMap:a,owner:l,repo:c,enabled:d}=t,h=d===void 0?!0:d,u=o??null;let f;e[0]!==s||e[1]!==n||e[2]!==u?(f={connectionId:u,orgId:s,orgSlug:n},e[0]=s,e[1]=n,e[2]=u,e[3]=f):f=e[3];const m=pt(f);let p;e[4]!==o||e[5]!==s||e[6]!==n||e[7]!==l||e[8]!==c?(p=P4.githubBranches(s,n,o,l,c),e[4]=o,e[5]=s,e[6]=n,e[7]=l,e[8]=c,e[9]=p):p=e[9];const g=h&&!!o&&!!l&&!!c;let x;e[10]!==m||e[11]!==l||e[12]!==c?(x=async $=>{const{pageParam:O,signal:U}=$,K=Number(O),H=await m.callTool({name:"list_branches",arguments:{owner:l,repo:c,page:K,perPage:Ca}},void 0,{signal:U}),q=F_(H);return{branches:Array.isArray(q)?q:q.branches??[],default_branch:Array.isArray(q)?null:q.default_branch??null,page:K}},e[10]=m,e[11]=l,e[12]=c,e[13]=x):x=e[13];let v;e[14]!==p||e[15]!==g||e[16]!==x?(v={queryKey:p,enabled:g,staleTime:3e4,retry:!1,initialPageParam:1,queryFn:x,getNextPageParam:Y_},e[14]=p,e[15]=g,e[16]=x,e[17]=v):v=e[17];const{data:_,isLoading:b,isError:y,hasNextPage:L,isFetchingNextPage:w,fetchNextPage:S}=ym(v);let j,k;e[18]!==a||e[19]!==r?(k=new Set(Object.keys(a?.[r]??{})),j=[...k].sort().map(G_),e[18]=a,e[19]=r,e[20]=j,e[21]=k):(j=e[20],k=e[21]);const V=j;let T;if(e[22]!==_?.pages){const $=new Map;for(const U of _?.pages??[])for(const K of U.branches)typeof K.name=="string"&&$.set(K.name,K);T=[...$.values()].filter(q_),e[22]=_?.pages,e[23]=T}else T=e[23];let A;e[24]!==T||e[25]!==k?(A=T.filter($=>!k.has($.name)).map(W_),e[24]=T,e[25]=k,e[26]=A):A=e[26];const N=A;let E;e[27]!==_?.pages?(E=_?.pages.find(K_)?.default_branch??null,e[27]=_?.pages,e[28]=E):E=e[28];const I=E;let P;e[29]!==_?.pages||e[30]!==S||e[31]!==w||e[32]!==k?(P=async($,O)=>{const U=O===void 0?H_:O;if(!U()||z_(k,$)||w)return;let K=_?.pages??[];for(;U()&&!B_(K,$,k)&&(K.at(-1)?.branches.length??Ca)>=Ca;){const H=await S();if(!U())break;const q=H.data?.pages??K;if(q.length===K.length)break;K=q}},e[29]=_?.pages,e[30]=S,e[31]=w,e[32]=k,e[33]=P):P=e[33];const R=P,D=L??!1;let M;e[34]!==S||e[35]!==L||e[36]!==w?(M=()=>{L&&!w&&S()},e[34]=S,e[35]=L,e[36]=w,e[37]=M):M=e[37];let F;return e[38]!==I||e[39]!==R||e[40]!==y||e[41]!==w||e[42]!==b||e[43]!==N||e[44]!==D||e[45]!==M||e[46]!==V?(F={yours:V,others:N,defaultBase:I,isLoading:b,isError:y,hasMore:D,isFetchingMore:w,fetchMore:M,fetchUntilMatch:R},e[38]=I,e[39]=R,e[40]=y,e[41]=w,e[42]=b,e[43]=N,e[44]=D,e[45]=M,e[46]=V,e[47]=F):F=e[47],F}function H_(){return!0}function K_(t){return t.default_branch}function W_(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function q_(t){return typeof t.name=="string"}function G_(t){return{name:t,source:"yours"}}function Y_(t){if(!(t.branches.length<Ca))return t.page+1}function J_(t){const e=B.c(85),{orgId:s,orgSlug:n,userId:r,userLabel:o,connectionId:a,owner:l,repo:c,sandboxMap:d,value:h,onChange:u,disabled:f,placement:m}=t,p=f===void 0?!1:f,x=(m===void 0?"chat":m)==="header",[v,_]=C.useState(!1),[b,y]=C.useState(""),[L,w]=C.useState(!1),S=C.useRef(0);let j;e[0]!==a||e[1]!==v||e[2]!==s||e[3]!==n||e[4]!==l||e[5]!==c||e[6]!==d||e[7]!==r?(j={orgId:s,orgSlug:n,userId:r,connectionId:a,sandboxMap:d,owner:l,repo:c,enabled:v},e[0]=a,e[1]=v,e[2]=s,e[3]=n,e[4]=l,e[5]=c,e[6]=d,e[7]=r,e[8]=j):j=e[8];const{yours:k,others:V,isLoading:T,isError:A,hasMore:N,isFetchingMore:E,fetchMore:I,fetchUntilMatch:P}=U_(j);let R;e[9]!==u?(R=ye=>{u(ye),_(!1)},e[9]=u,e[10]=R):R=e[10];const D=R,M=h??"Select branch…";let F;e[11]!==P?(F=ye=>{y(ye),S.current=S.current+1;const Be=S.current,Fe=ye.trim();if(!Fe){w(!1);return}w(!0),P(Fe,()=>Be===S.current).finally(()=>{Be===S.current&&w(!1)})},e[11]=P,e[12]=F):F=e[12];const $=F;let O;e[13]!==I?(O=ye=>{const Be=ye.currentTarget;Be.scrollHeight-Be.scrollTop-Be.clientHeight<48&&I()},e[13]=I,e[14]=O):O=e[14];const U=O,K=p?void 0:_,H=x?"outline":"ghost",q=x?"sm":"default";let J;e[15]!==p||e[16]!==x?(J=ne("font-mono shrink min-w-0 max-w-[200px]",x?"gap-1.5 text-xs":ne("text-xs text-muted-foreground hover:text-foreground transition-[gap] duration-200",p?"gap-0":"gap-0 @[320px]/chat-bottom:gap-1.5")),e[15]=p,e[16]=x,e[17]=J):J=e[17];let G;e[18]===Symbol.for("react.memo_cache_sentinel")?(G=i.jsx(an,{className:"h-3.5 w-3.5 shrink-0"}),e[18]=G):G=e[18];const W=x?"":"transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[200px] @[320px]/chat-bottom:opacity-100";let z;e[19]!==W?(z=ne("min-w-0 truncate",W),e[19]=W,e[20]=z):z=e[20];let X;e[21]!==M||e[22]!==z?(X=i.jsx("span",{className:z,children:M}),e[21]=M,e[22]=z,e[23]=X):X=e[23];let Q;e[24]!==p||e[25]!==x?(Q=!p&&i.jsx(Ht,{size:12,className:ne("opacity-60 shrink-0",x?"":"hidden @[320px]/chat-bottom:inline-block")}),e[24]=p,e[25]=x,e[26]=Q):Q=e[26];let Z;e[27]!==p||e[28]!==M||e[29]!==J||e[30]!==X||e[31]!==Q||e[32]!==H||e[33]!==q?(Z=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"inline-flex min-w-0 shrink",children:i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{variant:H,size:q,"aria-label":M,disabled:p,className:J,children:[G,X,Q]})})})}),e[27]=p,e[28]=M,e[29]=J,e[30]=X,e[31]=Q,e[32]=H,e[33]=q,e[34]=Z):Z=e[34];let Y;e[35]!==M?(Y=i.jsx(Pe,{children:M}),e[35]=M,e[36]=Y):Y=e[36];let ee;e[37]!==Z||e[38]!==Y?(ee=i.jsxs(Ie,{children:[Z,Y]}),e[37]=Z,e[38]=Y,e[39]=ee):ee=e[39];let te;e[40]!==$||e[41]!==b?(te=i.jsx(yi,{placeholder:"Search loaded branches…",value:b,onValueChange:$}),e[40]=$,e[41]=b,e[42]=te):te=e[42];let ae;e[43]!==D||e[44]!==o?(ae=i.jsx(re,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>D(l2(o)),children:"New"}),e[43]=D,e[44]=o,e[45]=ae):ae=e[45];let se;e[46]!==te||e[47]!==ae?(se=i.jsxs("div",{className:"*:data-[slot=command-input-wrapper]:flex-1 *:data-[slot=command-input-wrapper]:border-b-0 flex items-center border-b pr-2",children:[te,ae]}),e[46]=te,e[47]=ae,e[48]=se):se=e[48];let ie;e[49]!==A?(ie=A&&i.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[49]=A,e[50]=ie):ie=e[50];let fe;e[51]!==N||e[52]!==A||e[53]!==T?(fe=!A&&!T&&i.jsx(Li,{children:N?"Looking through more branches...":"No branches found."}),e[51]=N,e[52]=A,e[53]=T,e[54]=fe):fe=e[54];let me;e[55]!==D||e[56]!==k?(me=k.length>0&&i.jsx(Fs,{heading:"Your branches",children:k.map(ye=>i.jsxs(Ps,{value:ye.name,onSelect:()=>D(ye.name),children:[i.jsx(an,{className:"mr-2 h-4 w-4"}),i.jsx("span",{className:"flex-1 truncate",children:ye.name})]},ye.name))}),e[55]=D,e[56]=k,e[57]=me):me=e[57];let be;e[58]!==V||e[59]!==D?(be=V.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(Kx,{}),i.jsx(Fs,{heading:"Other branches in repo",children:V.map(ye=>i.jsxs(Ps,{value:ye.name,onSelect:()=>D(ye.name),children:[i.jsx(an,{className:"mr-2 h-4 w-4"}),i.jsx("span",{className:"flex-1 truncate",children:ye.name}),ye.author&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",ye.author]})]},ye.name))})]}),e[58]=V,e[59]=D,e[60]=be):be=e[60];let _e;e[61]!==I||e[62]!==N||e[63]!==E||e[64]!==L?(_e=N&&i.jsx("div",{className:"border-t p-2",children:i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-full text-xs",disabled:E,onClick:I,children:E||L?"Loading more…":"Load more branches"})}),e[61]=I,e[62]=N,e[63]=E,e[64]=L,e[65]=_e):_e=e[65];let xe;e[66]!==N||e[67]!==V.length?(xe=!N&&V.length>0&&i.jsx("div",{className:"border-t p-2 text-center text-xs text-muted-foreground",children:"All loaded"}),e[66]=N,e[67]=V.length,e[68]=xe):xe=e[68];let ke;e[69]!==U||e[70]!==ie||e[71]!==fe||e[72]!==me||e[73]!==be||e[74]!==_e||e[75]!==xe?(ke=i.jsxs(Si,{onScroll:U,children:[ie,fe,me,be,_e,xe]}),e[69]=U,e[70]=ie,e[71]=fe,e[72]=me,e[73]=be,e[74]=_e,e[75]=xe,e[76]=ke):ke=e[76];let Ne;e[77]!==se||e[78]!==ke?(Ne=i.jsx(ks,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:i.jsxs(lr,{children:[se,ke]})}),e[77]=se,e[78]=ke,e[79]=Ne):Ne=e[79];let we;return e[80]!==v||e[81]!==ee||e[82]!==Ne||e[83]!==K?(we=i.jsxs(Vs,{open:v,onOpenChange:K,children:[ee,Ne]}),e[80]=v,e[81]=ee,e[82]=Ne,e[83]=K,e[84]=we):we=e[84],we}function X_(t){const e=B.c(25);let s,n,r,o;e[0]!==t?({locked:s,placement:n,value:o,...r}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=r,e[4]=o):(s=e[1],n=e[2],r=e[3],o=e[4]);const a=n==="header";if(s){const c=o??"(no branch)",d=a?"h-8 gap-1.5 border border-input bg-background px-2.5":"h-9 gap-0 px-2";let h;e[5]!==d?(h=ne("inline-flex items-center rounded-md font-mono text-xs","text-muted-foreground cursor-default min-w-0 max-w-[200px]",d),e[5]=d,e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(an,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e[7]=u):u=e[7];const f=a?"":"max-w-0 opacity-0";let m;e[8]!==f?(m=ne("min-w-0 truncate",f),e[8]=f,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==m?(p=i.jsx("span",{className:m,children:c}),e[10]=c,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==h||e[14]!==p?(g=i.jsx(Re,{asChild:!0,children:i.jsxs("span",{"data-testid":"branch-picker-locked","aria-disabled":"true",className:h,children:[u,p]})}),e[13]=h,e[14]=p,e[15]=g):g=e[15];let x;e[16]!==c?(x=i.jsxs(Pe,{children:["This chat is using branch ",c,". Start a new chat to use a different branch."]}),e[16]=c,e[17]=x):x=e[17];let v;return e[18]!==g||e[19]!==x?(v=i.jsxs(Ie,{children:[g,x]}),e[18]=g,e[19]=x,e[20]=v):v=e[20],v}let l;return e[21]!==n||e[22]!==r||e[23]!==o?(l=i.jsx(J_,{...r,value:o,placement:n}),e[21]=n,e[22]=r,e[23]=o,e[24]=l):l=e[24],l}function $l(){const t=B.c(11),e=vm(),s=w1();let n;t[0]!==e.capabilities||t[1]!==e.online?(n=e.online&&e.capabilities.includes("claude-code"),t[0]=e.capabilities,t[1]=e.online,t[2]=n):n=t[2];let r;t[3]!==e.capabilities||t[4]!==e.online?(r=e.online&&e.capabilities.includes("codex"),t[3]=e.capabilities,t[4]=e.online,t[5]=r):r=t[5];let o;return t[6]!==e.online||t[7]!==s.runtime.agentSandbox||t[8]!==n||t[9]!==r?(o={agentSandbox:s.runtime.agentSandbox,userDesktop:e.online,claudeCode:n,codex:r},t[6]=e.online,t[7]=s.runtime.agentSandbox,t[8]=n,t[9]=r,t[10]=o):o=t[10],o}function c2(t){const e=Object.values(t),[s]=e;return s?e.find(n=>n.sandboxProviderKind!=="user-desktop")??s:null}async function Q_(t,e,s){const n=await t.callTool({name:e,arguments:s});if(n.isError){const r=n.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return n}const d2=["SANDBOX_START"],ea=new Map,Z_=t=>`${t.virtualMcpId}::${t.branch??""}`,xc=new Set,nl={mark:(t,e)=>xc.add(`${t}::${e}`),clear:(t,e)=>xc.delete(`${t}::${e}`),isStopped:(t,e)=>xc.has(`${t}::${e}`)};function td(t){const e=os();return Ds({mutationKey:d2,mutationFn:async s=>{s.branch&&nl.clear(s.virtualMcpId,s.branch);const n=Z_(s),r=ea.get(n);if(r)return r;const o=(async()=>(await Q_(t,"SANDBOX_START",s)).structuredContent)();ea.set(n,o);try{return await o}finally{ea.get(n)===o&&ea.delete(n)}},onSuccess:()=>{j1(e)}})}function eb(t,e){const s=B.c(3);let n;return s[0]!==e||s[1]!==t?(n={mutationKey:d2,predicate:o=>{if(!t)return!1;const a=o.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=n):n=s[2],f6(n)>0}const tb={phase:null,lifecycle:{phase:"idle"},status:{state:"running"},branch:{kind:"unknown"},notFound:!1,scripts:[],activeProcesses:[],getBuffer:()=>"",hasData:()=>!1,subscribeChunks:()=>()=>{},subscribeReload:()=>()=>{}},u2=C.createContext(tb),Du=16384;class sb{data="";append(e){this.data+=e,this.data.length>Du&&(this.data=this.data.slice(this.data.length-Du))}get(){return this.data}clear(){this.data=""}}const nb=1e3,ib=3e4,rb=3e3,Mu=["lifecycle","status","tasks","scripts","branch","reload","file-changed"],Ou="log";function ob(t){if(!t)return null;try{return new URL("/_sandbox/events",t).href}catch{return null}}function ab(t){return t===404}async function lb(t){try{const e=await fetch(t,{headers:{Accept:"text/event-stream"},cache:"no-store",signal:AbortSignal.timeout(rb)});return await e.body?.cancel().catch(()=>{}),ab(e.status)}catch{return!1}}function cb({virtualMcpId:t,branch:e,previewUrl:s=null,enabled:n=!0,children:r}){const{org:o}=Ae(),a=os(),[l,c]=C.useState(null),[d,h]=C.useState({phase:"idle"}),[u,f]=C.useState({state:"running"}),[m,p]=C.useState({kind:"unknown"}),[g,x]=C.useState(!1),[v,_]=C.useState([]),[b,y]=C.useState([]),[,L]=C.useState(0),w=C.useRef(new Map),S=C.useRef(new Set),j=C.useRef(new Set),k=C.useRef(null),V=ob(s),T=N=>{let E=w.current.get(N);return E||(E=new sb,w.current.set(N,E)),E};C.useEffect(()=>{if(c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),k.current=null,x(!1),_([]),y([]),w.current.clear(),!t||!e||!n)return;const N=`/api/${encodeURIComponent(o.slug)}/sandbox/${encodeURIComponent(t)}/${encodeURIComponent(e)}/events`;let E=!1,I=0,P=null,R=null,D=null,M=null,F=null;const $=W=>{try{const z=JSON.parse(W.data);c(z),z.kind!=="failed"&&(x(!1),I=0),z.kind==="ready"&&q()}catch(z){console.warn("[vm-events] bad phase payload",z)}},O=()=>{x(!0),c(null),h({phase:"idle"}),f({state:"running"}),p({kind:"unknown"}),_([]),y([]),w.current.clear()},U=W=>{try{const z=JSON.parse(W.data);if(typeof z.data!="string")return;I=0;const X=z.data.replace(/\r?\n/g,`\r
5
5
  `);T(z.source).append(X);for(const Q of S.current)try{Q(z.source,X)}catch{}L(Q=>Q+1)}catch{}},K=W=>{const z=W.type;try{const X=JSON.parse(W.data);switch(I=0,z){case"lifecycle":{const Q=X;h(Q.state);const Z=Q.state.phase==="running"?Q.state.port:null,Y=k.current;if(k.current=Z,Y!==null&&Z!==null&&Y!==Z)for(const ee of j.current)try{ee()}catch{}return}case"status":f(X);return;case"tasks":{const Z=X.active.map(Y=>Y.logName??"").filter(Boolean);y(Z);return}case"scripts":_(X.scripts);return;case"branch":{const Q=X.meta;p(Q);return}case"reload":for(const Q of j.current)try{Q()}catch{}return;case"file-changed":{const{path:Q}=X,Z=`${o.slug}/${t}/${e}`;Q.startsWith(".deco/")?(D&&clearTimeout(D),D=setTimeout(()=>{D=null,a.invalidateQueries({queryKey:Qe.decofile(Z)})},1e3)):(R&&clearTimeout(R),R=setTimeout(()=>{R=null,a.invalidateQueries({predicate:Y=>{const ee=Y.queryKey;return ee[0]==="live-meta"&&typeof ee[1]=="string"&&ee[1].startsWith(`${Z}/`)}})},1e3));return}}}catch{}};function H(){if(E)return;const W=new EventSource(N);M=W,W.onopen=()=>{},W.onerror=()=>{M===W&&W.readyState===EventSource.CLOSED&&G("studio")},W.addEventListener("phase",$),W.addEventListener("gone",O),W.addEventListener(Ou,U);for(const z of Mu)W.addEventListener(z,K)}function q(){if(E||!V||F)return;const W=new EventSource(V);F=W;let z=!1;W.onopen=()=>{if(E||F!==W)return;z=!0,I=0;const X=M;M=null,X?.close()},W.onerror=()=>{F===W&&W.readyState===EventSource.CLOSED&&J(W,z)},W.addEventListener(Ou,U);for(const X of Mu)W.addEventListener(X,K)}async function J(W,z){const X=V?await lb(V):!1;if(!(E||F!==W)){if(W.close(),F=null,X){O(),M||H();return}z&&G("direct")}}function G(W){if(E||P)return;const z=Math.min(nb*2**I,ib);I++,P=setTimeout(()=>{if(P=null,!E){if(W==="direct"){F?.close(),F=null,q();return}M?.close(),M=null,H()}},z)}return H(),()=>{E=!0,M?.close(),F?.close(),P&&clearTimeout(P),R&&clearTimeout(R),D&&clearTimeout(D)}},[t,e,o.slug,n,V,a]);const A={phase:l,lifecycle:d,status:u,branch:m,notFound:g,scripts:v,activeProcesses:b,getBuffer:N=>w.current.get(N)?.get()??"",hasData:N=>(w.current.get(N)?.get().length??0)>0,subscribeChunks:N=>(S.current.add(N),()=>{S.current.delete(N)}),subscribeReload:N=>(j.current.add(N),()=>{j.current.delete(N)})};return i.jsx(u2,{value:A,children:r})}function Os(){return C.use(u2)}function h2(t){const{subscribeChunks:e}=Os(),s=C.useRef(t);s.current=t,C.useEffect(()=>e((o,a)=>{s.current?.(o,a)}),[e])}function db(t){const{subscribeReload:e}=Os(),s=C.useRef(t);s.current=t,C.useEffect(()=>e(()=>{s.current?.()}),[e])}function f2(t){return t.appPaused||t.userStopped?{kind:"suspended"}:t.startError&&!t.previewUrl?{kind:"errored",error:t.startError}:t.previewUrl?{kind:"iframe",previewUrl:t.previewUrl}:{kind:"starting"}}const m2={githubNotAuthenticated:"GITHUB_NOT_AUTHENTICATED"},$u="::";function p2(t){const e=t.indexOf($u);if(e>0){const s=t.slice(0,e);if(Object.values(m2).includes(s))return{code:s,message:t.slice(e+$u.length)}}return{code:null,message:t}}function ub(t){return t.hasActiveGithubRepo&&!!t.userId&&!t.vmEntry&&!t.userStopped&&!t.isPending&&!t.attempted}function hb(t){return t.notFound&&!!t.deadVmId&&!t.isPending&&!t.userStopped&&t.deadVmId!==t.lastDeadVmId}function vc(t,e,s){const n={virtualMcpId:t};return e&&(n.branch=e),s&&(n.sandboxProviderKind=s),n}function fb(t){switch(t.kind){case"suspended":return"suspended";case"iframe":return"running";case"starting":return"starting";case"errored":return"errored"}}const mb={branch:null,previewState:{kind:"starting"},status:"idle",vmEntry:null,previewUrl:null,userStopped:!1,start:()=>{},stop:async()=>{},restart:async()=>{},retry:()=>{},resume:()=>{}},g2=C.createContext(mb);function dr(){return C.use(g2)}function pb({virtualMcpId:t,branch:e,userId:s,hasActiveGithubRepo:n,sandboxMap:r,sandboxProviderKind:o,children:a}){const{org:l}=Ae(),{setCurrentTaskBranch:c}=as(),d=Os(),h=os(),u=pt({connectionId:k9,orgId:l.id,orgSlug:l.slug}),f=td(u),{mutate:m,reset:p}=f,g=C.useRef(new Set),x=C.useRef(null),v=s&&e?Cl(r?.[s]?.[e]):{},_=o?v[o]??null:c2(v),b=_?.previewUrl??null,y=!!t&&!!e&&nl.isStopped(t,e),L=d.status.state==="paused",w=f.isError&&f.error?p2(f.error.message):null,S=f2({previewUrl:b,appPaused:L,userStopped:y,startError:w}),j=fb(S),k=e??"",V=g.current.has(k),T=ub({hasActiveGithubRepo:n,userId:s,vmEntry:_,userStopped:y,isPending:f.isPending,attempted:V});C.useEffect(()=>{if(!T||!t)return;g.current.add(k);const F=vc(t,e,o);m(F,{onSuccess:$=>{$?.branch&&!e&&c($.branch)},onError:$=>{console.error("[sandbox-lifecycle] auto-start failed:",$)}})},[T,k,e,t,o,m,c]);const A=d.notFound?_?.sandboxHandle??null:null,N=hb({notFound:d.notFound,deadVmId:A,lastDeadVmId:x.current,isPending:f.isPending,userStopped:y});C.useEffect(()=>{if(!N||!A||!t)return;x.current=A;const F=vc(t,e,o);m(F,{onSuccess:$=>{$?.branch&&!e&&c($.branch)},onError:$=>{console.error("[sandbox-lifecycle] self-heal failed:",$)}})},[N,A,t,e,o,m,c]);const E=()=>{if(!t)return;const F=vc(t,e,o);m(F,{onSuccess:$=>{$?.branch&&!e&&c($.branch)},onError:$=>{console.error("[sandbox-lifecycle] user start failed:",$)}})},I=async()=>{if(!t||!e)return;const F=_?.sandboxProviderKind;if(F){nl.mark(t,e);try{await u.callTool({name:"SANDBOX_DELETE",arguments:{virtualMcpId:t,branch:e,sandboxProviderKind:F}})}catch{}j1(h)}},P=async()=>{await I(),E()},R=()=>{g.current=new Set,x.current=null,p(),E()},M={branch:e,previewState:S,status:j,vmEntry:_,previewUrl:b,userStopped:y,start:E,stop:I,restart:P,retry:R,resume:R};return i.jsx(g2,{value:M,children:a})}function gb(t){return t==="user-desktop"?{key:"local",label:"This device",Icon:ar}:{key:"cloud",label:"Cloud sandbox",Icon:R9}}function Bu(t){const e=B.c(20),{icon:s,label:n,description:r,active:o,available:a,disabledHint:l,onSelect:c}=t,d=!a,h=a?"cursor-pointer hover:bg-accent":"cursor-not-allowed opacity-50";let u;e[0]!==h?(u=ne("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h),e[0]=h,e[1]=u):u=e[1];let f;e[2]!==s?(f=i.jsx("span",{className:"mt-0.5 shrink-0 text-muted-foreground",children:s}),e[2]=s,e[3]=f):f=e[3];let m;e[4]!==o?(m=o&&i.jsx(Tt,{size:13,className:"text-muted-foreground"}),e[4]=o,e[5]=m):m=e[5];let p;e[6]!==n||e[7]!==m?(p=i.jsxs("span",{className:"flex items-center gap-1.5 text-[13px] font-medium text-foreground",children:[n,m]}),e[6]=n,e[7]=m,e[8]=p):p=e[8];const g=a?r:l;let x;e[9]!==g?(x=i.jsx("span",{className:"block text-xs text-muted-foreground",children:g}),e[9]=g,e[10]=x):x=e[10];let v;e[11]!==p||e[12]!==x?(v=i.jsxs("span",{className:"min-w-0 flex-1",children:[p,x]}),e[11]=p,e[12]=x,e[13]=v):v=e[13];let _;return e[14]!==c||e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==v?(_=i.jsxs("button",{type:"button",disabled:d,onClick:c,className:u,children:[f,v]}),e[14]=c,e[15]=d,e[16]=u,e[17]=f,e[18]=v,e[19]=_):_=e[19],_}function xb(t){const e=B.c(50);let s;e[0]!==t?(s=t===void 0?{}:t,e[0]=t,e[1]=s):s=e[1];const{showLabel:n}=s,r=n===void 0?!1:n,{pendingSandboxProviderKind:o,setPendingAgentOption:a}=xs(),{isThreadLocked:l}=as(),{vmEntry:c}=dr(),d=$l();if(l)return null;let h;e[2]!==d?(h=I1(d),e[2]=d,e[3]=h):h=e[3];const u=h,f=c?.sandboxProviderKind??o??(d.agentSandbox?"agent-sandbox":u?"user-desktop":null);let m,p,g,x,v,_,b,y;if(e[4]!==f||e[5]!==r){x=gb(f);const M=x.Icon;g=Zt,p=Ie;const F=r?"h-9 gap-1.5 px-2 text-xs font-medium":"size-9";let $;e[14]!==F?($=ne("text-muted-foreground hover:text-foreground",F),e[14]=F,e[15]=$):$=e[15];const O=i.jsxs(re,{variant:"ghost",size:r?"sm":"icon","aria-label":`Runtime: ${x.label}`,className:$,children:[i.jsx(M,{size:16}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"truncate",children:x.label}),i.jsx(Ht,{size:12,className:"shrink-0 opacity-70"})]})]});e[16]!==O?(y=i.jsx(Re,{asChild:!0,children:i.jsx(es,{asChild:!0,children:O})}),e[16]=O,e[17]=y):y=e[17],m=Pe,v="bottom",_="Running on ",b=x.label.toLowerCase(),e[4]=f,e[5]=r,e[6]=m,e[7]=p,e[8]=g,e[9]=x,e[10]=v,e[11]=_,e[12]=b,e[13]=y}else m=e[6],p=e[7],g=e[8],x=e[9],v=e[10],_=e[11],b=e[12],y=e[13];let L;e[18]!==m||e[19]!==v||e[20]!==_||e[21]!==b?(L=i.jsxs(m,{side:v,children:[_,b]}),e[18]=m,e[19]=v,e[20]=_,e[21]=b,e[22]=L):L=e[22];let w;e[23]!==p||e[24]!==y||e[25]!==L?(w=i.jsxs(p,{children:[y,L]}),e[23]=p,e[24]=y,e[25]=L,e[26]=w):w=e[26];let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(Ir,{className:"text-xs font-normal text-muted-foreground",children:"Run on"}),e[27]=S):S=e[27];let j;e[28]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(R9,{size:14}),e[28]=j):j=e[28];const k=x.key==="cloud";let V;e[29]!==a?(V=()=>a("decopilot"),e[29]=a,e[30]=V):V=e[30];let T;e[31]!==d.agentSandbox||e[32]!==k||e[33]!==V?(T=i.jsx(Bu,{icon:j,label:"Cloud sandbox",description:"Runs in deco's cloud",active:k,available:d.agentSandbox,disabledHint:"Not available on this deployment",onSelect:V}),e[31]=d.agentSandbox,e[32]=k,e[33]=V,e[34]=T):T=e[34];let A;e[35]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(ar,{size:14}),e[35]=A):A=e[35];const N=x.key==="local",E=u!==null;let I;e[36]!==u||e[37]!==a?(I=()=>u&&a(u),e[36]=u,e[37]=a,e[38]=I):I=e[38];let P;e[39]!==N||e[40]!==E||e[41]!==I?(P=i.jsx(Bu,{icon:A,label:"This device",description:"Runs on your machine via deco link",active:N,available:E,disabledHint:"Run `decocms link` on your desktop",onSelect:I}),e[39]=N,e[40]=E,e[41]=I,e[42]=P):P=e[42];let R;e[43]!==T||e[44]!==P?(R=i.jsxs(ts,{align:"start",className:"w-64 p-1",children:[S,T,P]}),e[43]=T,e[44]=P,e[45]=R):R=e[45];let D;return e[46]!==g||e[47]!==R||e[48]!==w?(D=i.jsxs(g,{children:[w,R]}),e[46]=g,e[47]=R,e[48]=w,e[49]=D):D=e[49],D}function vb(t){const e=B.c(2),{branchPill:s}=t;if(!s)return null;let n;return e[0]!==s?(n=i.jsx(i.Fragment,{children:s}),e[0]=s,e[1]=n):n=e[1],n}function x2(t){const e=B.c(27),{virtualMcp:s,currentBranch:n,showRuntimeLabel:r}=t,o=r===void 0?!1:r,a=D1(),l=ir();let c;e[0]!==a?.messages||e[1]!==l?.isThreadLocked?(c=(a?.messages??[]).length>0||(l?.isThreadLocked??!1),e[0]=a?.messages,e[1]=l?.isThreadLocked,e[2]=c):c=e[2];const d=c,h=l?.setCurrentTaskBranch;let u;e[3]!==s?(u=Po(s),e[3]=s,e[4]=u):u=e[4];const f=u,m=f?.connectionId,p=!!f,{data:g}=vi.useSession(),x=g?.user?.id??"";let v;e[5]!==g?.user?.email||e[6]!==g?.user?.name?(v=g?.user?.name??g?.user?.email?.split("@")[0],e[5]=g?.user?.email,e[6]=g?.user?.name,e[7]=v):v=e[7];const _=v,{org:b}=Ae();let y;e[8]!==m||e[9]!==n||e[10]!==f||e[11]!==d||e[12]!==b||e[13]!==h||e[14]!==x||e[15]!==_||e[16]!==s?.id||e[17]!==s?.metadata?.sandboxMap?(y=f&&m?i.jsx(X_,{orgId:b.id,orgSlug:b.slug,userId:x,userLabel:_,virtualMcpId:s?.id??"",connectionId:m,owner:f.owner,repo:f.name,sandboxMap:s?.metadata?.sandboxMap,value:n,onChange:k=>{h&&h(k)},locked:d,placement:"chat"}):null,e[8]=m,e[9]=n,e[10]=f,e[11]=d,e[12]=b,e[13]=h,e[14]=x,e[15]=_,e[16]=s?.id,e[17]=s?.metadata?.sandboxMap,e[18]=y):y=e[18];const L=y;let w;e[19]!==p||e[20]!==o?(w=p&&i.jsx(xb,{showLabel:o}),e[19]=p,e[20]=o,e[21]=w):w=e[21];let S;e[22]!==L?(S=i.jsx(vb,{branchPill:L}),e[22]=L,e[23]=S):S=e[23];let j;return e[24]!==w||e[25]!==S?(j=i.jsxs(i.Fragment,{children:[w,S]}),e[24]=w,e[25]=S,e[26]=j):j=e[26],j}const _b={fast:{modelId:"claude-code:haiku",label:"Haiku 4.5"},smart:{modelId:"claude-code:sonnet",label:"Sonnet 5"},thinking:{modelId:"claude-code:opus-1m",label:"Opus 4.8 1M"}},bb={fast:{modelId:"codex:gpt-5.6-luna",label:"GPT-5.6 Luna"},smart:{modelId:"codex:gpt-5.6-terra",label:"GPT-5.6 Terra"},thinking:{modelId:"codex:gpt-5.6-sol",label:"GPT-5.6 Sol"}};function yb(t){return t==="claude-code"?_b:t==="codex"?bb:null}function zu(t,e){return yb(t)?.[e]??null}const Lb={decopilot:"cloud-decopilot","claude-code-desktop":"local-claude-code","codex-desktop":"local-codex"};function Sb(t){return t===null?"cloud-decopilot":Lb[t]}function wb(){const t=B.c(2),{pendingAgentOption:e}=xs();let s;return t[0]!==e?(s=Sb(e),t[0]=e,t[1]=s):s=t[1],s}function jb(){return xs().simpleModeTier}function Cb(){return xs().setSimpleModeTier}const kb={fast:"Quicker responses",smart:"Balanced quality",thinking:"Deeper reasoning"};function v2(t,e){return t==="local-claude-code"?zu("claude-code",e)?.label??null:t==="local-codex"?zu("codex",e)?.label??null:kb[e]}const _2=["fast","smart","thinking"],Mi={fast:"Fast",smart:"Smart",thinking:"Thinking"};function Vb(t){const e=B.c(29),{tier:s,pillIcon:n,pillLabel:r,groups:o,header:a}=t,l=r===void 0?Mi[s]:r,[c,d]=C.useState(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=k=>{k.onSelect(),d(!1)},e[0]=h):h=e[0];const u=h;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=ne("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),e[1]=f):f=e[1];let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=ne("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),e[2]=m):m=e[2];const p=Mi[s];let g;e[3]!==p?(g=i.jsx("span",{className:m,children:p}),e[3]=p,e[4]=g):g=e[4];let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Ht,{size:12,className:"opacity-60 hidden @[320px]/chat-bottom:inline-block"}),e[5]=x):x=e[5];let v;e[6]!==n||e[7]!==l||e[8]!==g?(v=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"inline-flex min-w-0 shrink",children:i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"ghost",size:"default","aria-label":l,className:f,children:[n,g,x]})})})}),e[6]=n,e[7]=l,e[8]=g,e[9]=v):v=e[9];let _;e[10]!==l?(_=i.jsx(Pe,{children:l}),e[10]=l,e[11]=_):_=e[11];let b;e[12]!==v||e[13]!==_?(b=i.jsxs(Ie,{children:[v,_]}),e[12]=v,e[13]=_,e[14]=b):b=e[14];let y;e[15]!==a?(y=a&&i.jsx("div",{className:"mb-1 border-b border-border/60 pb-1",children:a}),e[15]=a,e[16]=y):y=e[16];let L;if(e[17]!==o){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=V=>i.jsxs("div",{className:"flex flex-col",children:[V.label&&i.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1.5 pb-0.5 text-xs font-medium text-muted-foreground",children:i.jsx("span",{className:"truncate",children:V.label})}),V.rows.map(T=>i.jsxs("button",{type:"button",role:"menuitem","aria-label":V.label?`${V.label} ${T.title}`:T.title,onClick:()=>u(T),className:ne("flex items-start gap-2 px-2 py-1.5 rounded-md text-left","hover:bg-muted"),children:[T.icon&&i.jsx("span",{className:"shrink-0 text-muted-foreground mt-0.5",children:T.icon}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:T.title}),T.subtitle&&i.jsx("div",{className:"text-xs text-muted-foreground",children:T.subtitle})]}),T.active&&i.jsx(Tt,{size:14,className:"text-foreground mt-0.5"})]},T.key))]},V.key),e[19]=k):k=e[19],L=o.map(k),e[17]=o,e[18]=L}else L=e[18];let w;e[20]!==L?(w=i.jsx("div",{role:"menu",className:"flex flex-col",children:L}),e[20]=L,e[21]=w):w=e[21];let S;e[22]!==y||e[23]!==w?(S=i.jsxs(ks,{align:"end",className:"p-1 w-64",children:[y,w]}),e[22]=y,e[23]=w,e[24]=S):S=e[24];let j;return e[25]!==c||e[26]!==b||e[27]!==S?(j=i.jsxs(Vs,{open:c,onOpenChange:d,children:[b,S]}),e[25]=c,e[26]=b,e[27]=S,e[28]=j):j=e[28],j}function Fu(t){return t==="fast"?i.jsx(P9,{size:16}):t==="thinking"?i.jsx(tm,{size:16}):i.jsx(Bn,{size:16})}const Nb="flex items-center justify-center gap-1.5 flex-1 rounded-md px-2 py-1.5 text-xs font-medium transition-colors min-w-0",Ab="bg-background text-foreground shadow-sm",Tb="text-muted-foreground hover:text-foreground";function Eb(t){const e=B.c(4),{options:s}=t;let n;e[0]!==s?(n=s.map(Rb),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg bg-muted",children:n}),e[2]=n,e[3]=r):r=e[3],r}function Rb(t){return i.jsxs("button",{type:"button",onClick:t.onSelect,className:ne(Nb,t.active?Ab:Tb),children:[t.icon,i.jsx("span",{className:"truncate",children:t.label})]},t.key)}function Pb(){const t=B.c(18),{pendingHarnessId:e,setPendingAgentOption:s}=xs(),n=$l(),r=e==="claude-code"||e==="codex";let o;t[0]!==n?(o=I1(n)??"claude-code-desktop",t[0]=n,t[1]=o):o=t[1];const a=o;let l;t[2]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(R9,{size:14}),t[2]=l):l=t[2];const c=!r;let d;t[3]!==s?(d=()=>s("decopilot"),t[3]=s,t[4]=d):d=t[4];let h;t[5]!==c||t[6]!==d?(h={key:"cloud",icon:l,label:"Cloud",active:c,onSelect:d},t[5]=c,t[6]=d,t[7]=h):h=t[7];let u;t[8]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(ar,{size:14}),t[8]=u):u=t[8];let f;t[9]!==a||t[10]!==s?(f=()=>s(a),t[9]=a,t[10]=s,t[11]=f):f=t[11];let m;t[12]!==r||t[13]!==f?(m={key:"local",icon:u,label:"This device",active:r,onSelect:f},t[12]=r,t[13]=f,t[14]=m):m=t[14];let p;return t[15]!==h||t[16]!==m?(p=i.jsx("div",{className:"p-1",children:i.jsx(Eb,{options:[h,m]})}),t[15]=h,t[16]=m,t[17]=p):p=t[17],p}function Uu(t){return{key:t.key,label:t.label,rows:_2.map(e=>({key:`${t.key}-${e}`,icon:t.icon,title:Mi[e],subtitle:v2(t.mode,e),active:t.isActiveRuntime&&t.currentTier===e,onSelect:()=>{t.setOption(t.option),t.setTier(e)}}))}}function Ib(){const t=B.c(42),e=jb(),s=Cb(),n=wb(),{pendingHarnessId:r,setPendingAgentOption:o}=xs(),a=$l(),c=ir()?.isThreadLocked??!1,d=a.claudeCode||a.codex,h=n!=="cloud-decopilot";let u;if(h){const b=c?r==="claude-code":a.claudeCode||r==="claude-code",y=c?r==="codex":a.codex||r==="codex",L=b&&y;let w;if(t[0]!==L||t[1]!==r||t[2]!==o||t[3]!==s||t[4]!==b||t[5]!==y||t[6]!==e){if(w=[],b){const S=L?"Claude Code":void 0;let j;t[8]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx($x,{size:16}),t[8]=j):j=t[8];const k=r==="claude-code";let V;t[9]!==o||t[10]!==s||t[11]!==S||t[12]!==k||t[13]!==e?(V=Uu({key:"claude-code",label:S,icon:j,mode:"local-claude-code",option:"claude-code-desktop",isActiveRuntime:k,currentTier:e,setOption:o,setTier:s}),t[9]=o,t[10]=s,t[11]=S,t[12]=k,t[13]=e,t[14]=V):V=t[14],w.push(V)}if(y){const S=L?"Codex":void 0;let j;t[15]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Bx,{size:16}),t[15]=j):j=t[15];const k=r==="codex";let V;t[16]!==o||t[17]!==s||t[18]!==S||t[19]!==k||t[20]!==e?(V=Uu({key:"codex",label:S,icon:j,mode:"local-codex",option:"codex-desktop",isActiveRuntime:k,currentTier:e,setOption:o,setTier:s}),t[16]=o,t[17]=s,t[18]=S,t[19]=k,t[20]=e,t[21]=V):V=t[21],w.push(V)}t[0]=L,t[1]=r,t[2]=o,t[3]=s,t[4]=b,t[5]=y,t[6]=e,t[7]=w}else w=t[7];u=w}else{let b;t[22]!==s||t[23]!==e?(b=_2.map(L=>({key:`cloud-${L}`,icon:Fu(L),title:Mi[L],subtitle:v2("cloud-decopilot",L),active:e===L,onSelect:()=>s(L)})),t[22]=s,t[23]=e,t[24]=b):b=t[24];let y;t[25]!==b?(y=[{key:"cloud",rows:b}],t[25]=b,t[26]=y):y=t[26],u=y}let f;t[27]!==h||t[28]!==r?(f=h?zx(r):null,t[27]=h,t[28]=r,t[29]=f):f=t[29];const m=f,p=m?.Icon;let g;t[30]!==p||t[31]!==e?(g=p?i.jsx(p,{size:16}):Fu(e),t[30]=p,t[31]=e,t[32]=g):g=t[32];const x=m?`${m.label} ${Mi[e]}`:Mi[e];let v;t[33]!==d||t[34]!==c?(v=d&&!c?i.jsx(Pb,{}):void 0,t[33]=d,t[34]=c,t[35]=v):v=t[35];let _;return t[36]!==u||t[37]!==g||t[38]!==x||t[39]!==v||t[40]!==e?(_=i.jsx(Vb,{tier:e,pillIcon:g,pillLabel:x,groups:u,header:v}),t[36]=u,t[37]=g,t[38]=x,t[39]=v,t[40]=e,t[41]=_):_=t[41],_}async function sd(t,e,s,n,r){if(!Rl(e)){ce.error("Selected model does not support file uploads");return}const o=s.type||"application/octet-stream";if(!Fx(o,e)){const l=_m(e),c=e?.title??"This model";r?r({fileName:s.name,modelName:c,accepted:l}):ce.error(`"${s.name}" can't be attached`,{description:`${c} accepts ${l}.`});return}const a=10*1024*1024;if(s.size>a){ce.error(`File "${s.name}" exceeds 10MB limit`);return}try{const l=new FileReader,c=new Promise((u,f)=>{l.onload=()=>{const m=l.result;if(typeof m!="string"){f(new Error("Failed to read file as data URL"));return}const p=m.includes(",")?m.split(",")[1]??m:m;u(p)},l.onerror=f});l.readAsDataURL(s);const d=await c,h={id:crypto.randomUUID(),name:s.name,mimeType:s.type||"application/octet-stream",size:s.size,data:d};m5(t,{from:n,to:n},h)}catch(l){console.error("Failed to process file:",l),ce.error(`Failed to load file "${s.name}"`)}}function Db(t){const e=B.c(8),{editor:s,selectedModel:n,onUnsupportedFile:r}=t,o=C.useRef(Ob);let a,l;e[0]!==s||e[1]!==r||e[2]!==n?(a=()=>{o.current=async(h,u)=>{await sd(s,n,h,u,r)}},l=[s,n,r],e[0]=s,e[1]=r,e[2]=n,e[3]=a,e[4]=l):(a=e[3],l=e[4]),C.useEffect(a,l);let c,d;return e[5]!==s?(c=()=>{if(s?.isDestroyed)return;const h=new Ba("fileDropHandler");s.state.plugins.find(m=>m.spec.key===h)&&s.unregisterPlugin(h);const f=new M1({key:h,props:{handleDrop:(m,p,g,x)=>{if(x)return!1;const v=p.dataTransfer?.files;if(!v||v.length===0)return!1;p.preventDefault();const _=m.posAtCoords({left:p.clientX,top:p.clientY});if(!_)return!1;const b=Array.from(v),y=_.pos;for(const L of b)o.current?.(L,y);return!0},handlePaste:(m,p)=>{const g=p.clipboardData?.items;if(!g)return!1;const x=Array.from(g).filter(Mb);if(x.length===0)return!1;p.preventDefault();const{from:v}=m.state.selection;for(const _ of x){const b=_.getAsFile();b&&o.current?.(b,v)}return!0}}});return s.registerPlugin(f),()=>{s?.isDestroyed||s.unregisterPlugin(h)}},d=[s],e[5]=s,e[6]=c,e[7]=d):(c=e[6],d=e[7]),C.useEffect(c,d),null}function Mb(t){return t.kind==="file"}function Ob(){return Promise.resolve()}function $b(t){const e=B.c(26),{info:s,onClose:n}=t,r=s!==null;let o;e[0]!==n?(o=L=>!L&&n(),e[0]=n,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=i.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=i.jsx("div",{className:"flex items-center justify-center size-9 rounded-lg bg-amber-500/15 text-amber-600 dark:text-amber-400",children:i.jsx(nr,{size:18})}),d=i.jsx(is,{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 h=s?.fileName;let u;e[6]!==h?(u=i.jsxs("div",{className:"relative px-8 pt-8 pb-2 overflow-hidden",children:[l,i.jsxs(ns,{className:"relative gap-4",children:[c,i.jsxs("div",{children:[d,i.jsxs(qn,{className:"mt-1.5 text-sm leading-relaxed",children:[i.jsxs("span",{className:"font-medium text-foreground",children:["“",h,"”"]})," ","can't be attached to this chat."]})]})]})]}),e[6]=h,e[7]=u):u=e[7];const f=s?.modelName;let m;e[8]!==f?(m=i.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground mb-2",children:[f," accepts"]}),e[8]=f,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(J5,{size:14,className:"text-muted-foreground"}),e[10]=p):p=e[10];const g=s?.accepted;let x;e[11]!==g?(x=i.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[p,i.jsx("span",{className:"capitalize",children:g})]}),e[11]=g,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsx("div",{className:"px-8 pt-3 pb-6 space-y-3",children:i.jsxs("div",{className:"rounded-xl border border-border p-4",children:[m,x]})}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==n?(_=i.jsx("div",{className:"px-8 py-4 border-t border-border bg-muted/30 flex items-center justify-end",children:i.jsx(re,{onClick:n,children:"Got it"})}),e[16]=n,e[17]=_):_=e[17];let b;e[18]!==v||e[19]!==_||e[20]!==u?(b=i.jsxs(Ft,{className:"sm:max-w-[480px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:Bb,children:[u,v,_]}),e[18]=v,e[19]=_,e[20]=u,e[21]=b):b=e[21];let y;return e[22]!==r||e[23]!==b||e[24]!==o?(y=i.jsx(Ut,{open:r,onOpenChange:o,children:b}),e[22]=r,e[23]=b,e[24]=o,e[25]=y):y=e[25],y}function Bb(t){return t.preventDefault()}function zb(){const t=B.c(3),[e,s]=C.useState(null);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>s(null),t[0]=n):n=t[0];let r;return t[1]!==e?(r={unsupportedFile:e,onUnsupportedFile:s,clearUnsupportedFile:n},t[1]=e,t[2]=r):r=t[2],r}var Fb=p5;var Ub=["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] *)"],m0=Ub.join(","),b2=typeof Element>"u",mo=b2?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,il=!b2&&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},rl=function(e,s){var n;s===void 0&&(s=!0);var r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"inert"),o=r===""||r==="true",a=o||s&&e&&(typeof e.closest=="function"?e.closest("[inert]"):rl(e.parentNode));return a},Hb=function(e){var s,n=e==null||(s=e.getAttribute)===null||s===void 0?void 0:s.call(e,"contenteditable");return n===""||n==="true"},Kb=function(e,s,n){if(rl(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(m0));return s&&mo.call(e,m0)&&r.unshift(e),r=r.filter(n),r},p0=function(e,s,n){for(var r=[],o=Array.from(e);o.length;){var a=o.shift();if(!rl(a,!1))if(a.tagName==="SLOT"){var l=a.assignedElements(),c=l.length?l:a.children,d=p0(c,!0,n);n.flatten?r.push.apply(r,d):r.push({scopeParent:a,candidates:d})}else{var h=mo.call(a,m0);h&&n.filter(a)&&(s||!e.includes(a))&&r.push(a);var u=a.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(a),f=!rl(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(u&&f){var m=p0(u===!0?a.children:u.children,!0,n);n.flatten?r.push.apply(r,m):r.push({scopeParent:a,candidates:m})}else o.unshift.apply(o,a.children)}}return r},y2=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},L2=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||Hb(e))&&!y2(e)?0:e.tabIndex},Wb=function(e,s){var n=L2(e);return n<0&&s&&!y2(e)?0:n},qb=function(e,s){return e.tabIndex===s.tabIndex?e.documentOrder-s.documentOrder:e.tabIndex-s.tabIndex},S2=function(e){return e.tagName==="INPUT"},Gb=function(e){return S2(e)&&e.type==="hidden"},Yb=function(e){var s=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(n){return n.tagName==="SUMMARY"});return s},Jb=function(e,s){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===s)return e[n]},Xb=function(e){if(!e.name)return!0;var s=e.form||il(e),n=function(l){return s.querySelectorAll('input[type="radio"][name="'+l+'"]')},r;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")r=n(window.CSS.escape(e.name));else try{r=n(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=Jb(r,e.form);return!o||o===e},Qb=function(e){return S2(e)&&e.type==="radio"},Zb=function(e){return Qb(e)&&!Xb(e)},ey=function(e){var s,n=e&&il(e),r=(s=n)===null||s===void 0?void 0:s.host,o=!1;if(n&&n!==e){var a,l,c;for(o=!!((a=r)!==null&&a!==void 0&&(l=a.ownerDocument)!==null&&l!==void 0&&l.contains(r)||e!=null&&(c=e.ownerDocument)!==null&&c!==void 0&&c.contains(e));!o&&r;){var d,h,u;n=il(r),r=(d=n)===null||d===void 0?void 0:d.host,o=!!((h=r)!==null&&h!==void 0&&(u=h.ownerDocument)!==null&&u!==void 0&&u.contains(r))}}return o},Hu=function(e){var s=e.getBoundingClientRect(),n=s.width,r=s.height;return n===0&&r===0},ty=function(e,s){var n=s.displayCheck,r=s.getShadowRoot;if(n==="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=mo.call(e,"details>summary:first-of-type"),l=a?e.parentElement:e;if(mo.call(l,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="full-native"||n==="legacy-full"){if(typeof r=="function"){for(var c=e;e;){var d=e.parentElement,h=il(e);if(d&&!d.shadowRoot&&r(d)===!0)return Hu(e);e.assignedSlot?e=e.assignedSlot:!d&&h!==e.ownerDocument?e=h.host:e=d}e=c}if(ey(e))return!e.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return Hu(e);return!1},sy=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var s=e.parentElement;s;){if(s.tagName==="FIELDSET"&&s.disabled){for(var n=0;n<s.children.length;n++){var r=s.children.item(n);if(r.tagName==="LEGEND")return mo.call(s,"fieldset[disabled] *")?!0:!r.contains(e)}return!0}s=s.parentElement}return!1},ny=function(e,s){return!(s.disabled||Gb(s)||ty(s,e)||Yb(s)||sy(s))},Ku=function(e,s){return!(Zb(s)||L2(s)<0||!ny(e,s))},iy=function(e){var s=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(s)||s>=0)},w2=function(e){var s=[],n=[];return e.forEach(function(r,o){var a=!!r.scopeParent,l=a?r.scopeParent:r,c=Wb(l,a),d=a?w2(r.candidates):l;c===0?a?s.push.apply(s,d):s.push(l):n.push({documentOrder:o,tabIndex:c,item:r,isScope:a,content:d})}),n.sort(qb).reduce(function(r,o){return o.isScope?r.push.apply(r,o.content):r.push(o.content),r},[]).concat(s)},j2=function(e,s){s=s||{};var n;return s.getShadowRoot?n=p0([e],s.includeContainer,{filter:Ku.bind(null,s),flatten:!1,getShadowRoot:s.getShadowRoot,shadowRootFilter:iy}):n=Kb(e,s.includeContainer,Ku.bind(null,s)),w2(n)};function ry(){return/apple/i.test(navigator.vendor)}const Wu="data-floating-ui-focusable";function oy(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 g0(t,e){if(!t||!e)return!1;const s=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(s&&I4(s)){let n=e;for(;n;){if(t===n)return!0;n=n.parentNode||n.host}}return!1}function yr(t){return"composedPath"in t?t.composedPath()[0]:t.target}function _c(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 ay(t){return t.matches("html,body")}function po(t){return t?.ownerDocument||document}function ly(t){return t?t.hasAttribute(Wu)?t:t.querySelector("["+Wu+"]")||t:null}function ka(t,e,s){return s===void 0&&(s=!0),t.filter(r=>{var o;return r.parentId===e&&(!s||((o=r.context)==null?void 0:o.open))}).flatMap(r=>[r,...ka(t,r.id,s)])}function cy(t){return"nativeEvent"in t}var dy=typeof document<"u",uy=function(){},oi=dy?C.useLayoutEffect:uy;const hy={...C1},fy=hy.useInsertionEffect,my=fy||(t=>t());function Ti(t){const e=C.useRef(()=>{});return my(()=>{e.current=t}),C.useCallback(function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}const C2=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function k2(t,e){const s=j2(t,C2()),n=s.length;if(n===0)return;const r=oy(po(t)),o=s.indexOf(r),a=o===-1?e===1?0:n-1:o+e;return s[a]}function py(t){return k2(po(t).body,1)||t}function gy(t){return k2(po(t).body,-1)||t}function bc(t,e){const s=e||t.currentTarget,n=t.relatedTarget;return!n||!g0(s,n)}function xy(t){j2(t,C2()).forEach(s=>{s.dataset.tabindex=s.getAttribute("tabindex")||"",s.setAttribute("tabindex","-1")})}function qu(t){t.querySelectorAll("[data-tabindex]").forEach(s=>{const n=s.dataset.tabindex;delete s.dataset.tabindex,n?s.setAttribute("tabindex",n):s.removeAttribute("tabindex")})}const vy="data-floating-ui-focusable",Gu="active",Yu="selected",_y={...C1};let Ju=!1,by=0;const Xu=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+by++;function yy(){const[t,e]=C.useState(()=>Ju?Xu():void 0);return oi(()=>{t==null&&e(Xu())},[]),C.useEffect(()=>{Ju=!0},[]),t}const Ly=_y.useId,nd=Ly||yy;function Sy(){const t=new Map;return{emit(e,s){var n;(n=t.get(e))==null||n.forEach(r=>r(s))},on(e,s){t.has(e)||t.set(e,new Set),t.get(e).add(s)},off(e,s){var n;(n=t.get(e))==null||n.delete(s)}}}const wy=C.createContext(null),jy=C.createContext(null),V2=()=>{var t;return((t=C.useContext(wy))==null?void 0:t.id)||null},N2=()=>C.useContext(jy);function id(t){return"data-floating-ui-"+t}const Cy={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},Qu=C.forwardRef(function(e,s){const[n,r]=C.useState();oi(()=>{ry()&&r("button")},[]);const o={ref:s,tabIndex:0,role:n,"aria-hidden":n?void 0:!0,[id("focus-guard")]:"",style:Cy};return i.jsx("span",{...e,...o})}),ky={clipPath:"inset(50%)",position:"fixed",top:0,left:0},A2=C.createContext(null),Zu=id("portal");function Vy(t){t===void 0&&(t={});const{id:e,root:s}=t,n=nd(),r=Ay(),[o,a]=C.useState(null),l=C.useRef(null);return oi(()=>()=>{o?.remove(),queueMicrotask(()=>{l.current=null})},[o]),oi(()=>{if(!n||l.current)return;const c=e?document.getElementById(e):null;if(!c)return;const d=document.createElement("div");d.id=n,d.setAttribute(Zu,""),c.appendChild(d),l.current=d,a(d)},[e,n]),oi(()=>{if(s===null||!n||l.current)return;let c=s||r?.portalNode;c&&!z4(c)&&(c=c.current),c=c||document.body;let d=null;e&&(d=document.createElement("div"),d.id=e,c.appendChild(d));const h=document.createElement("div");h.id=n,h.setAttribute(Zu,""),c=d||c,c.appendChild(h),l.current=h,a(h)},[e,s,n,r]),o}function Ny(t){const{children:e,id:s,root:n,preserveTabOrder:r=!0}=t,o=Vy({id:s,root:n}),[a,l]=C.useState(null),c=C.useRef(null),d=C.useRef(null),h=C.useRef(null),u=C.useRef(null),f=a?.modal,m=a?.open,p=!!a&&!a.modal&&a.open&&r&&!!(n||o);return C.useEffect(()=>{if(!o||!r||f)return;function g(x){o&&bc(x)&&(x.type==="focusin"?qu:xy)(o)}return o.addEventListener("focusin",g,!0),o.addEventListener("focusout",g,!0),()=>{o.removeEventListener("focusin",g,!0),o.removeEventListener("focusout",g,!0)}},[o,r,f]),C.useEffect(()=>{o&&(m||qu(o))},[m,o]),i.jsxs(A2.Provider,{value:C.useMemo(()=>({preserveTabOrder:r,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:h,afterInsideRef:u,portalNode:o,setFocusManagerState:l}),[r,o]),children:[p&&o&&i.jsx(Qu,{"data-type":"outside",ref:c,onFocus:g=>{if(bc(g,o)){var x;(x=h.current)==null||x.focus()}else{const v=a?a.domReference:null,_=gy(v);_?.focus()}}}),p&&o&&i.jsx("span",{"aria-owns":o.id,style:ky}),o&&Ri.createPortal(e,o),p&&o&&i.jsx(Qu,{"data-type":"outside",ref:d,onFocus:g=>{if(bc(g,o)){var x;(x=u.current)==null||x.focus()}else{const v=a?a.domReference:null,_=py(v);_?.focus(),a?.closeOnFocusOut&&a?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const Ay=()=>C.useContext(A2),Ty={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},Ey={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},eh=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 Ry(t,e){e===void 0&&(e={});const{open:s,onOpenChange:n,elements:r,dataRef:o}=t,{enabled:a=!0,escapeKey:l=!0,outsidePress:c=!0,outsidePressEvent:d="pointerdown",referencePress:h=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:m,capture:p}=e,g=N2(),x=Ti(typeof c=="function"?c:()=>!1),v=typeof c=="function"?x:c,_=C.useRef(!1),{escapeKey:b,outsidePress:y}=eh(m),{escapeKey:L,outsidePress:w}=eh(p),S=C.useRef(!1),j=Ti(E=>{var I;if(!s||!a||!l||E.key!=="Escape"||S.current)return;const P=(I=o.current.floatingContext)==null?void 0:I.nodeId,R=g?ka(g.nodesRef.current,P):[];if(!b&&(E.stopPropagation(),R.length>0)){let D=!0;if(R.forEach(M=>{var F;if((F=M.context)!=null&&F.open&&!M.context.dataRef.current.__escapeKeyBubbles){D=!1;return}}),!D)return}n(!1,cy(E)?E.nativeEvent:E,"escape-key")}),k=Ti(E=>{var I;const P=()=>{var R;j(E),(R=yr(E))==null||R.removeEventListener("keydown",P)};(I=yr(E))==null||I.addEventListener("keydown",P)}),V=Ti(E=>{var I;const P=o.current.insideReactTree;o.current.insideReactTree=!1;const R=_.current;if(_.current=!1,d==="click"&&R||P||typeof v=="function"&&!v(E))return;const D=yr(E),M="["+id("inert")+"]",F=po(r.floating).querySelectorAll(M);let $=Zs(D)?D:null;for(;$&&!mc($);){const H=O4($);if(mc(H)||!Zs(H))break;$=H}if(F.length&&Zs(D)&&!ay(D)&&!g0(D,r.floating)&&Array.from(F).every(H=>!g0($,H)))return;if($4(D)&&N){const H=mc(D),q=B4(D),J=/auto|scroll/,G=H||J.test(q.overflowX),W=H||J.test(q.overflowY),z=G&&D.clientWidth>0&&D.scrollWidth>D.clientWidth,X=W&&D.clientHeight>0&&D.scrollHeight>D.clientHeight,Q=q.direction==="rtl",Z=X&&(Q?E.offsetX<=D.offsetWidth-D.clientWidth:E.offsetX>D.clientWidth),Y=z&&E.offsetY>D.clientHeight;if(Z||Y)return}const O=(I=o.current.floatingContext)==null?void 0:I.nodeId,U=g&&ka(g.nodesRef.current,O).some(H=>{var q;return _c(E,(q=H.context)==null?void 0:q.elements.floating)});if(_c(E,r.floating)||_c(E,r.domReference)||U)return;const K=g?ka(g.nodesRef.current,O):[];if(K.length>0){let H=!0;if(K.forEach(q=>{var J;if((J=q.context)!=null&&J.open&&!q.context.dataRef.current.__outsidePressBubbles){H=!1;return}}),!H)return}n(!1,E,"outside-press")}),T=Ti(E=>{var I;const P=()=>{var R;V(E),(R=yr(E))==null||R.removeEventListener(d,P)};(I=yr(E))==null||I.addEventListener(d,P)});C.useEffect(()=>{if(!s||!a)return;o.current.__escapeKeyBubbles=b,o.current.__outsidePressBubbles=y;let E=-1;function I(F){n(!1,F,"ancestor-scroll")}function P(){window.clearTimeout(E),S.current=!0}function R(){E=window.setTimeout(()=>{S.current=!1},M4()?5:0)}const D=po(r.floating);l&&(D.addEventListener("keydown",L?k:j,L),D.addEventListener("compositionstart",P),D.addEventListener("compositionend",R)),v&&D.addEventListener(d,w?T:V,w);let M=[];return f&&(Zs(r.domReference)&&(M=fc(r.domReference)),Zs(r.floating)&&(M=M.concat(fc(r.floating))),!Zs(r.reference)&&r.reference&&r.reference.contextElement&&(M=M.concat(fc(r.reference.contextElement)))),M=M.filter(F=>{var $;return F!==(($=D.defaultView)==null?void 0:$.visualViewport)}),M.forEach(F=>{F.addEventListener("scroll",I,{passive:!0})}),()=>{l&&(D.removeEventListener("keydown",L?k:j,L),D.removeEventListener("compositionstart",P),D.removeEventListener("compositionend",R)),v&&D.removeEventListener(d,w?T:V,w),M.forEach(F=>{F.removeEventListener("scroll",I)}),window.clearTimeout(E)}},[o,r,l,v,d,s,n,f,a,b,y,j,L,k,V,w,T]),C.useEffect(()=>{o.current.insideReactTree=!1},[o,v,d]);const A=C.useMemo(()=>({onKeyDown:j,...h&&{[Ty[u]]:E=>{n(!1,E.nativeEvent,"reference-press")},...u!=="click"&&{onClick(E){n(!1,E.nativeEvent,"reference-press")}}}}),[j,n,h,u]),N=C.useMemo(()=>{function E(I){I.button===0&&(_.current=!0)}return{onKeyDown:j,onMouseDown:E,onMouseUp:E,[Ey[d]]:()=>{o.current.insideReactTree=!0}}},[j,d,o]);return C.useMemo(()=>a?{reference:A,floating:N}:{},[a,A,N])}function Py(t){const{open:e=!1,onOpenChange:s,elements:n}=t,r=nd(),o=C.useRef({}),[a]=C.useState(()=>Sy()),l=V2()!=null,[c,d]=C.useState(n.reference),h=Ti((m,p,g)=>{o.current.openEvent=m?p:void 0,a.emit("openchange",{open:m,event:p,reason:g,nested:l}),s?.(m,p,g)}),u=C.useMemo(()=>({setPositionReference:d}),[]),f=C.useMemo(()=>({reference:c||n.reference||null,floating:n.floating||null,domReference:n.reference}),[c,n.reference,n.floating]);return C.useMemo(()=>({dataRef:o,open:e,onOpenChange:h,elements:f,events:a,floatingId:r,refs:u}),[e,h,f,a,r,u])}function Iy(t){t===void 0&&(t={});const{nodeId:e}=t,s=Py({...t,elements:{reference:null,floating:null,...t.elements}}),n=t.rootContext||s,r=n.elements,[o,a]=C.useState(null),[l,c]=C.useState(null),h=r?.domReference||o,u=C.useRef(null),f=N2();oi(()=>{h&&(u.current=h)},[h]);const m=D4({...t,elements:{...r,...l&&{reference:l}}}),p=C.useCallback(b=>{const y=Zs(b)?{getBoundingClientRect:()=>b.getBoundingClientRect(),getClientRects:()=>b.getClientRects(),contextElement:b}:b;c(y),m.refs.setReference(y)},[m.refs]),g=C.useCallback(b=>{(Zs(b)||b===null)&&(u.current=b,a(b)),(Zs(m.refs.reference.current)||m.refs.reference.current===null||b!==null&&!Zs(b))&&m.refs.setReference(b)},[m.refs]),x=C.useMemo(()=>({...m.refs,setReference:g,setPositionReference:p,domReference:u}),[m.refs,g,p]),v=C.useMemo(()=>({...m.elements,domReference:h}),[m.elements,h]),_=C.useMemo(()=>({...m,...n,refs:x,elements:v,nodeId:e}),[m,x,v,e,n]);return oi(()=>{n.dataRef.current.floatingContext=_;const b=f?.nodesRef.current.find(y=>y.id===e);b&&(b.context=_)}),C.useMemo(()=>({...m,context:_,refs:x,elements:v}),[m,x,v,_])}function yc(t,e,s){const n=new Map,r=s==="item";let o=t;if(r&&t){const{[Gu]:a,[Yu]:l,...c}=t;o=c}return{...s==="floating"&&{tabIndex:-1,[vy]:""},...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,h]=c;if(!(r&&[Gu,Yu].includes(d)))if(d.indexOf("on")===0){if(n.has(d)||n.set(d,[]),typeof h=="function"){var u;(u=n.get(d))==null||u.push(h),a[d]=function(){for(var f,m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];return(f=n.get(d))==null?void 0:f.map(x=>x(...p)).find(x=>x!==void 0)}}}else a[d]=h}),a),{})}}function Dy(t){t===void 0&&(t=[]);const e=t.map(l=>l?.reference),s=t.map(l=>l?.floating),n=t.map(l=>l?.item),r=C.useCallback(l=>yc(l,t,"reference"),e),o=C.useCallback(l=>yc(l,t,"floating"),s),a=C.useCallback(l=>yc(l,t,"item"),n);return C.useMemo(()=>({getReferenceProps:r,getFloatingProps:o,getItemProps:a}),[r,o,a])}const My=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function Oy(t,e){var s,n;e===void 0&&(e={});const{open:r,elements:o,floatingId:a}=t,{enabled:l=!0,role:c="dialog"}=e,d=nd(),h=((s=o.domReference)==null?void 0:s.id)||d,u=C.useMemo(()=>{var _;return((_=ly(o.floating))==null?void 0:_.id)||a},[o.floating,a]),f=(n=My.get(c))!=null?n:c,p=V2()!=null,g=C.useMemo(()=>f==="tooltip"||c==="label"?{["aria-"+(c==="label"?"labelledby":"describedby")]:r?u:void 0}:{"aria-expanded":r?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":r?u:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:h},...f==="menu"&&p&&{role:"menuitem"},...c==="select"&&{"aria-autocomplete":"none"},...c==="combobox"&&{"aria-autocomplete":"list"}},[f,u,p,r,h,c]),x=C.useMemo(()=>{const _={id:u,...f&&{role:f}};return f==="tooltip"||c==="label"?_:{..._,...f==="menu"&&{"aria-labelledby":h}}},[f,u,h,c]),v=C.useCallback(_=>{let{active:b,selected:y}=_;const L={role:"option",...b&&{id:u+"-fui-option"}};switch(c){case"select":case"combobox":return{...L,"aria-selected":y}}return{}},[u,c]);return C.useMemo(()=>l?{reference:g,floating:x,item:v}:{},[l,g,x,v])}function $y(t){var e;const{char:s,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:a,$position:l}=t,c=n&&!r,d=v5(s),h=new RegExp(`\\s${d}$`),u=a?"^":"",f=r?"":d,m=c?new RegExp(`${u}${d}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${d}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,x=Array.from(p.matchAll(m)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const v=x.input.slice(Math.max(0,x.index-1),x.index),_=new RegExp(`^[${o?.join("")}\0]?$`).test(v);if(o!==null&&!_)return null;const b=g+x.index;let y=b+x[0].length;return c&&h.test(p.slice(y-1,y+1))&&(x[0]+=" ",y+=1),b<l.pos&&y>=l.pos?{range:{from:b,to:y},query:x[0].slice(s.length),text:x[0]}:null}var By=new Ba("suggestion");function zy({pluginKey:t=By,editor:e,char:s="@",allowSpaces:n=!1,allowToIncludeChar:r=!1,allowedPrefixes:o=[" "],startOfLine:a=!1,decorationTag:l="span",decorationClass:c="suggestion",decorationContent:d="",decorationEmptyClass:h="is-empty",command:u=()=>null,items:f=()=>[],render:m=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=$y,shouldShow:x}){let v;const _=m?.(),b=()=>{const S=e.state.selection.$anchor.pos,j=e.view.coordsAtPos(S),{top:k,right:V,bottom:T,left:A}=j;try{return new DOMRect(A,k,V-A,T-k)}catch{return null}},y=(S,j)=>j?()=>{const k=t.getState(e.state),V=k?.decorationId,T=S.dom.querySelector(`[data-decoration-id="${V}"]`);return T?.getBoundingClientRect()||null}:b;function L(S,j){var k;try{const T=t.getState(S.state),A=T?.decorationId?S.dom.querySelector(`[data-decoration-id="${T.decorationId}"]`):null,N={editor:e,range:T?.range||{from:0,to:0},query:T?.query||null,text:T?.text||null,items:[],command:E=>u({editor:e,range:T?.range||{from:0,to:0},props:E}),decorationNode:A,clientRect:y(S,A)};(k=_?.onExit)==null||k.call(_,N)}catch{}const V=S.state.tr.setMeta(j,{exit:!0});S.dispatch(V)}const w=new M1({key:t,view(){return{update:async(S,j)=>{var k,V,T,A,N,E,I;const P=(k=this.key)==null?void 0:k.getState(j),R=(V=this.key)==null?void 0:V.getState(S.state),D=P.active&&R.active&&P.range.from!==R.range.from,M=!P.active&&R.active,F=P.active&&!R.active,$=!M&&!F&&P.query!==R.query,O=M||D&&$,U=$||D,K=F||D&&$;if(!O&&!U&&!K)return;const H=K&&!O?P:R,q=S.dom.querySelector(`[data-decoration-id="${H.decorationId}"]`);v={editor:e,range:H.range,query:H.query,text:H.text,items:[],command:J=>u({editor:e,range:H.range,props:J}),decorationNode:q,clientRect:y(S,q)},O&&((T=_?.onBeforeStart)==null||T.call(_,v)),U&&((A=_?.onBeforeUpdate)==null||A.call(_,v)),(U||O)&&(v.items=await f({editor:e,query:H.query})),K&&((N=_?.onExit)==null||N.call(_,v)),U&&((E=_?.onUpdate)==null||E.call(_,v)),O&&((I=_?.onStart)==null||I.call(_,v))},destroy:()=>{var S;v&&((S=_?.onExit)==null||S.call(_,v))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(S,j,k,V){const{isEditable:T}=e,{composing:A}=e.view,{selection:N}=S,{empty:E,from:I}=N,P={...j},R=S.getMeta(t);if(R&&R.exit)return P.active=!1,P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null,P;if(P.composing=A,T&&(E||e.view.composing)){(I<j.range.from||I>j.range.to)&&!A&&!j.composing&&(P.active=!1);const D=g({char:s,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:a,$position:N.$from}),M=`id_${Math.floor(Math.random()*4294967295)}`;D&&p({editor:e,state:V,range:D.range,isActive:j.active})&&(!x||x({editor:e,range:D.range,query:D.query,text:D.text,transaction:S}))?(P.active=!0,P.decorationId=j.decorationId?j.decorationId:M,P.range=D.range,P.query=D.query,P.text=D.text):P.active=!1}else P.active=!1;return P.active||(P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null),P}},props:{handleKeyDown(S,j){var k,V,T,A;const{active:N,range:E}=w.getState(S.state);if(!N)return!1;if(j.key==="Escape"||j.key==="Esc"){const P=w.getState(S.state),R=(k=v?.decorationNode)!=null?k:null,D=R??(P?.decorationId?S.dom.querySelector(`[data-decoration-id="${P.decorationId}"]`):null);if(((V=_?.onKeyDown)==null?void 0:V.call(_,{view:S,event:j,range:P.range}))||!1)return!0;const F={editor:e,range:P.range,query:P.query,text:P.text,items:[],command:$=>u({editor:e,range:P.range,props:$}),decorationNode:D,clientRect:D?()=>D.getBoundingClientRect()||null:null};return(T=_?.onExit)==null||T.call(_,F),L(S,t),!0}return((A=_?.onKeyDown)==null?void 0:A.call(_,{view:S,event:j,range:E}))||!1},decorations(S){const{active:j,range:k,decorationId:V,query:T}=w.getState(S);if(!j)return null;const A=!T?.length,N=[c];return A&&N.push(h),g5.create(S.doc,[x5.inline(k.from,k.to,{nodeName:l,class:N.join(" "),"data-decoration-id":V,"data-decoration-content":d})])}}});return w}function Fy(t){const e=B.c(24),{editor:s,query:n,items:r,onSelect:o,onClose:a}=t,[l,c]=C.useState(0),d=C.useRef(r),h=C.useRef(l),u=C.useRef(o),f=C.useRef(a),m=C.useDeferredValue(n);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{c(0)},e[0]=p):p=e[0];let g;e[1]!==m?(g=[m],e[1]=m,e[2]=g):g=e[2],C.useEffect(p,g);let x,v;e[3]!==r.length||e[4]!==l?(x=()=>{l>=r.length&&r.length>0&&c(0)},v=[r.length,l],e[3]=r.length,e[4]=l,e[5]=x,e[6]=v):(x=e[5],v=e[6]),C.useEffect(x,v);let _,b;e[7]!==r?(_=()=>{d.current=r},b=[r],e[7]=r,e[8]=_,e[9]=b):(_=e[8],b=e[9]),C.useEffect(_,b);let y,L;e[10]!==l?(y=()=>{h.current=l},L=[l],e[10]=l,e[11]=y,e[12]=L):(y=e[11],L=e[12]),C.useEffect(y,L);let w,S;e[13]!==o?(S=()=>{u.current=o},w=[o],e[13]=o,e[14]=w,e[15]=S):(w=e[14],S=e[15]),C.useEffect(S,w);let j,k;e[16]!==a?(j=()=>{f.current=a},k=[a],e[16]=a,e[17]=j,e[18]=k):(j=e[17],k=e[18]),C.useEffect(j,k);let V,T;e[19]!==s?(V=()=>{if(s?.isDestroyed)return;let E;try{E=s.view.dom}catch{return}if(!E)return;const I=R=>{const D=d.current;if(!D.length)return!1;const M=()=>c($=>($+1)%D.length),F=()=>c($=>($-1+D.length)%D.length);switch(R.key){case"ArrowUp":return R.preventDefault(),F(),!0;case"ArrowDown":return R.preventDefault(),M(),!0;case"Tab":return R.preventDefault(),R.shiftKey?F():M(),!0;case"Home":return R.preventDefault(),c(0),!0;case"End":return R.preventDefault(),c(D.length-1),!0;case"Enter":{if(R.isComposing)return!1;R.preventDefault();const $=h.current;return $!==-1&&D[$]&&u.current?.(D[$],$),!0}case"Escape":return R.preventDefault(),f.current?.(),!0;default:return!1}},P=R=>{I(R)};return E.addEventListener("keydown",P,!0),()=>{E?.removeEventListener("keydown",P,!0)}},T=[s],e[19]=s,e[20]=V,e[21]=T):(V=e[20],T=e[21]),C.useEffect(V,T);const A=r.length?l:void 0;let N;return e[22]!==A?(N={selectedIndex:A,setSelectedIndex:c},e[22]=A,e[23]=N):N=e[23],N}function Uy(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 T2=C.createContext(void 0);function E2(){const t=C.useContext(T2);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function Hy({editor:t,char:e,pluginKey:s,allow:n,onOpenChange:r}){const[o,a]=C.useReducer(Uy,{open:!1,element:null,query:"",range:null,selectedItem:null}),l=C.useRef(r);return l.current=r,C.useEffect(()=>{if(t?.isDestroyed)return;const c=s instanceof Ba?s:new Ba(s);t.state.plugins.find(u=>u.spec.key===c)&&t.unregisterPlugin(c);const h=zy({pluginKey:c,editor:t,char:e,allow(u){const f=t.state.doc.resolve(u.range.from);for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="image")return!1;return!(n&&!n(u))},command(){},render:()=>({onStart:u=>{a({type:"ON_START",payload:{element:u.decorationNode??null,query:u.query,range:u.range}}),l.current?.(!0)},onUpdate:u=>{a({type:"ON_UPDATE",payload:{element:u.decorationNode??null,query:u.query,range:u.range}})},onKeyDown:u=>u.event.key==="Escape"?(a({type:"ON_EXIT"}),!0):!1,onExit:()=>{a({type:"ON_EXIT"}),l.current?.(!1)}}),items:()=>[]});return t.registerPlugin(h),()=>{t?.isDestroyed||t.unregisterPlugin(c)}},[t,s,e,a,n]),{state:o,dispatch:a}}function Ky({editor:t,queryKey:e,queryFn:s,onSelect:n}){const{state:r,dispatch:o}=E2(),a=C.useDeferredValue(r.query),{data:l}=b9({queryKey:Qe.suggestionItems(e,r.open,a),queryFn:()=>r.open?s({query:a}):[]}),c=()=>{o({type:"ON_EXIT"})},d=async(u,f)=>{if(!(r.selectedItem!==null||!r.range)){o({type:"SET_SELECTED_ITEM",payload:u});try{const{view:m}=t,g=m.state.selection.$to.nodeAfter?.text?.startsWith(" "),x=r.range?{...r.range}:{from:0,to:0};g&&r.range&&(x.to+=1),await n({range:x,item:u})===!1?o({type:"SET_SELECTED_ITEM",payload:null}):c()}catch{c()}}},{selectedIndex:h}=Fy({editor:t,query:a,items:l,onSelect:d,onClose:c});return{selectedItem:r.selectedItem,items:l,selectedIndex:h,close:c,onSelect:d}}function Wy({children:t}){const{state:e,dispatch:s}=E2(),{open:n,element:r}=e,o=()=>{s({type:"ON_EXIT"})},{refs:a,floatingStyles:l,context:c}=Iy({placement:"bottom-start",open:n,onOpenChange:f=>{f||o()},elements:{reference:r},middleware:[F4(10),U4(),H4()],whileElementsMounted:K4}),d=Ry(c,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),h=Oy(c,{role:"listbox"}),{getFloatingProps:u}=Dy([d,h]);return n?i.jsx(Ny,{children:i.jsx("div",{ref:a.setFloating,style:l,...u(),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 qy=t=>{const e=B.c(29),{item:s,isSelected:n,onSelect:r,isLoading:o,ref:a}=t;let l;if(e[0]!==s){const w=rn(s._meta);l=s.title||j9(s.name,w),e[0]=s,e[1]=l}else l=e[1];const c=l,d=s.description||null,h=s.icon,u=n&&"bg-accent text-accent-foreground",f=o&&"pointer-events-none opacity-50";let m;e[2]!==u||e[3]!==f?(m=ne("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",u,f),e[2]=u,e[3]=f,e[4]=m):m=e[4];let p;e[5]!==h||e[6]!==c?(p=h!==void 0&&i.jsx(Hn,{icon:h,name:c,size:"xs",className:"mr-2"}),e[5]=h,e[6]=c,e[7]=p):p=e[7];let g;e[8]!==c?(g=i.jsx("span",{className:"font-medium flex items-center truncate capitalize",children:c}),e[8]=c,e[9]=g):g=e[9];let x;e[10]!==o?(x=o&&i.jsx(Ui,{size:"xs"}),e[10]=o,e[11]=x):x=e[11];let v;e[12]!==g||e[13]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g,x]}),e[12]=g,e[13]=x,e[14]=v):v=e[14];let _;e[15]!==d?(_=d&&i.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:d}),e[15]=d,e[16]=_):_=e[16];let b;e[17]!==v||e[18]!==_?(b=i.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[v,_]}),e[17]=v,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==s.drillable?(y=s.drillable&&i.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 L;return e[22]!==r||e[23]!==a||e[24]!==b||e[25]!==y||e[26]!==m||e[27]!==p?(L=i.jsxs("div",{ref:a,onClick:r,className:m,children:[p,b,y]}),e[22]=r,e[23]=a,e[24]=b,e[25]=y,e[26]=m,e[27]=p,e[28]=L):L=e[28],L},Gy=t=>{const e=B.c(18),{editor:s,queryKey:n,queryFn:r,onSelect:o}=t;let a;e[0]!==s||e[1]!==o||e[2]!==r||e[3]!==n?(a={editor:s,queryKey:n,queryFn:r,onSelect:o},e[0]=s,e[1]=o,e[2]=r,e[3]=n,e[4]=a):a=e[4];const{items:l,selectedIndex:c,onSelect:d,selectedItem:h}=Ky(a);if(!l.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=i.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 u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={maxHeight:"min(320px, var(--radix-popover-content-available-height, 320px))"},e[6]=u):u=e[6];let f;if(e[7]!==d||e[8]!==l||e[9]!==c||e[10]!==h?.name){let p;e[12]!==d||e[13]!==c||e[14]!==h?.name?(p=(g,x)=>i.jsx(qy,{item:g,isSelected:x===c,ref:x===c?Xy:void 0,onSelect:()=>d(g,x),isLoading:h?.name===g.name},`${g.kind??"item"}:${g.name}`),e[12]=d,e[13]=c,e[14]=h?.name,e[15]=p):p=e[15],f=l.map(p),e[7]=d,e[8]=l,e[9]=c,e[10]=h?.name,e[11]=f}else f=e[11];let m;return e[16]!==f?(m=i.jsx("div",{className:"min-w-[360px] max-w-[520px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:u,children:i.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=m):m=e[17],m};function Yy(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"p-1",children:[...Array(3)].map(Jy)}),t[0]=e):e=t[0],e}function Jy(t,e){return i.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 animate-pulse",children:[i.jsx("div",{className:"h-4 w-24 bg-muted rounded"}),i.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function R2(t){const e=B.c(18),{editor:s,char:n,pluginKey:r,queryKey:o,queryFn:a,onSelect:l,allow:c,onOpenChange:d}=t;let h;e[0]!==c||e[1]!==n||e[2]!==s||e[3]!==d||e[4]!==r?(h={editor:s,char:n,pluginKey:r,allow:c,onOpenChange:d},e[0]=c,e[1]=n,e[2]=s,e[3]=d,e[4]=r,e[5]=h):h=e[5];const{state:u,dispatch:f}=Hy(h);let m;e[6]!==f||e[7]!==u?(m={state:u,dispatch:f},e[6]=f,e[7]=u,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Yy,{}),e[9]=p):p=e[9];let g;e[10]!==s||e[11]!==l||e[12]!==a||e[13]!==o?(g=i.jsx(Wy,{children:i.jsx(C.Suspense,{fallback:p,children:i.jsx(Gy,{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 x;return e[15]!==m||e[16]!==g?(x=i.jsx(T2.Provider,{value:m,children:g}),e[15]=m,e[16]=g,e[17]=x):x=e[17],x}function Xy(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}const Qy=[{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}],Zy=({editor:t,virtualMcpId:e})=>{const s=os(),{org:n}=Ae(),r=Ao(),o=U9(r),a=pt({connectionId:e,orgId:n.id,orgSlug:n.slug}),l=Qe.virtualMcpResources(e,n.id),[c,d]=C.useState("categories"),h=C.useRef(c);h.current=c;const u=C.useRef(null),f=C.useRef(!1),m=["at-mention",n.id,e??"default",c],p=async({item:v,range:_})=>{if(Ce("chat_picker_item_selected",{picker:"@",item_kind:v.kind,item_name:v.name}),v.kind!=="category"&&(f.current=!0),v.kind==="category")return d(v.name==="agents"?"agents":"resources"),!1;if(v.kind==="agent"&&v.agentId){Hi(t,_,{id:v.agentId,name:v.name,metadata:{agentId:v.agentId,title:v.name},char:"@"}),d("categories");return}if(v.kind==="resource"&&v.uri&&a){try{const b=await k1(a,v.uri);Hi(t,_,{id:v.uri,name:v.uri,metadata:b.contents,char:"@"})}catch(b){console.error("[at-mention] Failed to fetch resource:",b),ce.error("Failed to load resource. Please try again.")}d("categories");return}},g=async v=>{const{query:_}=v,b=h.current;if(b==="categories"){if(!_.trim())return Qy;const w=_.toLowerCase(),S=r.filter(k=>k.status==="active"&&(!k.id||!za(k.id))&&!o.has(k.id)&&k.id!==e&&(k.title.toLowerCase().includes(w)||k.description?.toLowerCase().includes(w))).map(k=>({name:k.title,title:k.title,description:k.description??void 0,icon:k.icon??null,kind:"agent",agentId:k.id})),j=await(async()=>{if(!a)return[];let k=s.getQueryData(l);return k||(k=await s.fetchQuery({queryKey:l,queryFn:()=>Kr(a),staleTime:6e4})),(k?.resources??[]).filter(V=>V.uri.toLowerCase().includes(w)||V.name?.toLowerCase().includes(w)||V.description?.toLowerCase().includes(w)).map(V=>({name:V.name??V.uri,title:V.name,description:V.description,kind:"resource",uri:V.uri}))})();return[...S,...j]}if(b==="agents"){let w=r.filter(S=>S.status==="active"&&(!S.id||!za(S.id))&&!o.has(S.id)&&S.id!==e);if(_.trim()){const S=_.toLowerCase();w=w.filter(j=>j.title.toLowerCase().includes(S)||j.description?.toLowerCase().includes(S))}return w.map(S=>({name:S.title,title:S.title,description:S.description??void 0,icon:S.icon??null,kind:"agent",agentId:S.id}))}if(!a)return[];let y=s.getQueryData(l);y?s.fetchQuery({queryKey:l,queryFn:()=>Kr(a),staleTime:6e4}).catch(()=>{}):y=await s.fetchQuery({queryKey:l,queryFn:()=>Kr(a),staleTime:6e4});let L=y?.resources??[];if(_.trim()){const w=_.toLowerCase();L=L.filter(S=>S.uri.toLowerCase().includes(w)||S.name?.toLowerCase().includes(w)||S.description?.toLowerCase().includes(w))}return L.map(w=>({name:w.name??w.uri,title:w.name,description:w.description,kind:"resource",uri:w.uri}))},x=v=>{if(v)u.current=Date.now(),f.current=!1,Ce("chat_picker_opened",{picker:"@"});else{const _=u.current;Ce("chat_picker_closed",{picker:"@",outcome:f.current?"selected":"dismissed",duration_ms:_?Date.now()-_:null}),u.current=null,d("categories")}};return i.jsx(R2,{editor:t,char:"@",pluginKey:"atDropdownMenu",queryKey:m,queryFn:g,onSelect:p,onOpenChange:x})};async function th(t,e,s,n,r,o){try{const a=await Vo(s,n,o);Hi(t,e,{id:n,name:rr(n,r),metadata:a.messages,char:"/",kind:"prompt",args:o})}catch(a){console.error("[slash] Failed to fetch prompt:",a),ce.error("Failed to load prompt. Please try again.")}}async function e8(t,e,s,n){try{const r=await k1(s,n);Hi(t,e,{id:n,name:n,metadata:r.contents,char:"/",kind:"resource"})}catch(r){console.error("[slash] Failed to fetch resource:",r),ce.error("Failed to load resource. Please try again.")}}async function t8(t,e,s,n){try{const{files:r,omittedPaths:o}=await qx(s,n.volume,n.path),a={sandboxPath:n.sandboxPath,files:r,omittedPaths:o};Hi(t,e,{id:n.id,name:n.name,metadata:a,char:"/",kind:"skill"})}catch(r){console.error("[slash] Failed to fetch skill:",r),ce.error("Failed to load skill. Please try again.")}}const s8=({editor:t,virtualMcpId:e})=>{const s=os(),{org:n}=Ae(),r=pt({connectionId:e,orgId:n.id,orgSlug:n.slug}),o=Qe.virtualMcpPrompts(e,n.id),a=Qe.virtualMcpResources(e,n.id),l=Qe.slashSkills(n.id),c=["slash-mention",n.id,e??"default"],[d,h]=C.useState(null),[u,f]=C.useState(null),m=_5(t);m&&(m.onEditChip=async L=>{if(r)try{const S=(await sh(s,o,r)).find(j=>j.name===L.promptId);if(!S?.arguments||S.arguments.length===0)return;f({...L,prompt:S})}catch(w){console.error("[slash] Failed to load prompt for editing:",w),ce.error("Failed to load prompt. Please try again.")}});const p=C.useRef(null),g=C.useRef(!1),x=async({item:L,range:w})=>{if(Ce("chat_picker_item_selected",{picker:"/",item_kind:L.kind,item_name:L.name}),g.current=!0,!!r)if(L.kind==="prompt"){if(L.arguments&&L.arguments.length>0){h({range:w,item:L});return}const S=rn(L._meta);await th(t,w,r,L.name,S)}else L.kind==="skill"?L.skill&&await t8(t,w,n.slug,L.skill):L.uri&&await e8(t,w,r,L.uri)},v=async L=>{if(!d||!r)return;const{range:w,item:S}=d,j=rn(S._meta);await th(t,w,r,S.name,j,L),h(null)},_=async L=>{if(!(!u||!r)){try{const w=await Vo(r,u.promptId,L),S=rn(u.prompt._meta);t.chain().focus().setNodeSelection(u.pos).deleteSelection().insertContentAt(u.pos,w9({id:u.promptId,name:rr(u.promptId,S),metadata:w.messages,char:"/",kind:"prompt",args:L})).run(),Ce("chat_picker_item_selected",{picker:"/edit",item_kind:"prompt",item_name:u.promptId})}catch(w){console.error("[slash] Failed to update prompt:",w),ce.error("Failed to update prompt. Please try again.")}f(null)}},b=async L=>{const{query:w}=L;if(!r)return[];const[S,j,k]=await Promise.all([sh(s,o,r),i8(s,a,r),n8(s,l,n.slug)]),V=w.trim().toLowerCase(),T=(S??[]).filter(E=>!V||E.name.toLowerCase().includes(V)||E.title?.toLowerCase().includes(V)||E.description?.toLowerCase().includes(V)).map(E=>({name:E.name,title:E.title,description:E.description,kind:"prompt",arguments:E.arguments,_meta:E._meta})),A=(j??[]).filter(E=>!V||E.uri.toLowerCase().includes(V)||E.name?.toLowerCase().includes(V)||E.description?.toLowerCase().includes(V)).map(E=>({name:E.name??E.uri,title:E.name,description:E.description,kind:"resource",uri:E.uri})),N=(k??[]).filter(E=>!V||E.name.toLowerCase().includes(V)||E.id.toLowerCase().includes(V)||E.description?.toLowerCase().includes(V)).map(E=>({name:E.name,title:E.name,description:E.description??void 0,kind:"skill",skill:E}));return[...T,...A,...N]},y=d?.item.kind==="prompt"?{name:d.item.name,title:d.item.title,arguments:d.item.arguments,description:d.item.description,_meta:d.item._meta}:null;return i.jsxs(i.Fragment,{children:[i.jsx(R2,{editor:t,char:"/",pluginKey:"slashDropdownMenu",queryKey:c,queryFn:b,onSelect:x,onOpenChange:L=>{if(L)p.current=Date.now(),g.current=!1,Ce("chat_picker_opened",{picker:"/"});else{const w=p.current;Ce("chat_picker_closed",{picker:"/",outcome:g.current?"selected":"dismissed",duration_ms:w?Date.now()-w:null}),p.current=null}}}),i.jsx(io,{prompt:y,setPrompt:()=>h(null),onSubmit:v}),i.jsx(io,{prompt:u?.prompt??null,setPrompt:()=>f(null),onSubmit:_,defaultValues:u?.args},u?`edit-${u.promptId}-${u.pos}`:"edit-idle")]})};async function sh(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>a0(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>a0(s),staleTime:6e4}),n?.prompts??[]}async function n8(t,e,s){const n=t.getQueryData(e),r=()=>t.fetchQuery({queryKey:e,queryFn:()=>Gx(s),staleTime:6e4});return n?(r().catch(()=>{}),n):r().catch(()=>[])}async function i8(t,e,s){let n=t.getQueryData(e);return n?t.fetchQuery({queryKey:e,queryFn:()=>Kr(s),staleTime:6e4}).catch(()=>{}):n=await t.fetchQuery({queryKey:e,queryFn:()=>Kr(s),staleTime:6e4}),n?.resources??[]}function r8(t){return[$1.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,dropcursor:!1}),Fb.configure({placeholder:()=>t.current??"Ask anything, / for prompts & skills, @ for agents & resources...",showOnlyWhenEditable:!1}),y5,L5]}function P2({tiptapDoc:t,setTiptapDoc:e,disabled:s=!1,enterToSubmit:n=!1,placeholder:r,onSubmit:o,children:a}){const l=C.useRef(o),c=C.useRef(e),d=C.useRef(n),h=C.useRef(r),u=O1({extensions:r8(h),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:(f,m)=>m.key==="Enter"&&!m.shiftKey&&d.current?(m.preventDefault(),l.current?.(),!0):!1},onUpdate:({editor:f})=>{c.current(f?.getJSON())}});return C.useEffect(()=>{u?.setEditable(!s)},[u,s]),C.useEffect(()=>{l.current=o},[o]),C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{d.current=n},[n]),C.useEffect(()=>{h.current=r},[r]),C.useEffect(()=>{if(!u||u.isDestroyed)return;const f=JSON.stringify(u.getJSON()),m=JSON.stringify(t||{type:"doc",content:[]});f!==m&&u.commands.setContent(t||{type:"doc",content:[]})},[u,t]),i.jsx(b5.Provider,{value:{editor:u},children:a})}function I2(t){const e=B.c(26),{disabled:s,virtualMcpId:n,showFileUploader:r,selectedModel:o,onUnsupportedFile:a,ref:l,className:c}=t,d=s===void 0?!1:s,h=r===void 0?!1:r,{editor:u}=C9();let f,m;if(e[0]!==u?(f=()=>({focus:()=>{u?.commands.focus()},clear:()=>{u?.commands.clearContent(!0)},appendText:j=>{if(!u)return;const k=u.state.doc.textContent.trim()==="";u.commands.focus("end"),k||u.commands.insertContent(" "),u.commands.insertContent(j)},syncVoiceText:(j,k)=>{if(u&&(u.commands.setContent(j||{type:"doc",content:[]}),k)){u.commands.focus("end");const V=u.state.doc.textContent.trim().length>0;u.commands.insertContent(V?" "+k:k)}},restoreContent:j=>{u&&u.commands.setContent(j||{type:"doc",content:[]})}}),m=[u],e[0]=u,e[1]=f,e[2]=m):(f=e[1],m=e[2]),C.useImperativeHandle(l??null,f,m),!u)return null;const p=d&&"cursor-not-allowed opacity-70",g=d&&"[&_.ProseMirror]:cursor-not-allowed";let x;e[3]!==c||e[4]!==p||e[5]!==g?(x=ne("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]=x):x=e[6];let v;e[7]!==u||e[8]!==x?(v=i.jsx(B1,{editor:u,className:x}),e[7]=u,e[8]=x,e[9]=v):v=e[9];const _=n??null;let b;e[10]!==u||e[11]!==_?(b=i.jsx(C.Suspense,{fallback:null,children:i.jsx(s8,{editor:u,virtualMcpId:_})}),e[10]=u,e[11]=_,e[12]=b):b=e[12];const y=n??null;let L;e[13]!==u||e[14]!==y?(L=i.jsx(C.Suspense,{fallback:null,children:i.jsx(Zy,{editor:u,virtualMcpId:y})}),e[13]=u,e[14]=y,e[15]=L):L=e[15];let w;e[16]!==u||e[17]!==a||e[18]!==o||e[19]!==h?(w=h&&o?i.jsx(Db,{editor:u,selectedModel:o,onUnsupportedFile:a}):null,e[16]=u,e[17]=a,e[18]=o,e[19]=h,e[20]=w):w=e[20];let S;return e[21]!==b||e[22]!==L||e[23]!==w||e[24]!==v?(S=i.jsxs(i.Fragment,{children:[v,b,L,w]}),e[21]=b,e[22]=L,e[23]=w,e[24]=v,e[25]=S):S=e[25],S}function D2(t){const e=B.c(3),[s]=sr();let n;return e[0]!==s.enableSounds||e[1]!==t?(n=()=>{s.enableSounds&&pv(t.dataUri).catch(o=>{console.warn(`[sound] ${t.name} playback failed:`,o)})},e[0]=s.enableSounds,e[1]=t,e[2]=n):n=e[2],n}const o8={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"},a8=K5.togglePlanMode.keys.map(t=>t==="Shift"?"⇧":t).join(""),l8=[{src:"/connections/gmail.png",name:"Gmail"},{src:"/connections/perplexity.png",name:"Perplexity"},{src:"/connections/github.png",name:"GitHub"}];function c8(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center -space-x-1.5",children:l8.map(d8)}),t[0]=e):e=t[0],e}function d8(t){return i.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-1 ring-border object-cover bg-white"},t.name)}function u8({disabled:t,onOpenConnections:e,virtualMcpId:s,selectedModel:n,isStreaming:r,onUnsupportedFile:o}){const[a,l]=C.useState(!1),c=D2(o8),{org:d}=Ae(),{editor:h}=C9(),u=C.useRef(null),f=Rl(n),m=()=>{!f||r||(l(!1),u.current?.click())},p=async H=>{const q=H.target.files;if(!q||q.length===0||!h)return;const J=Array.from(q),{from:G}=h.state.selection;try{for(const W of J)await sd(h,n??null,W,G,o)}finally{u.current&&(u.current.value="")}},g=pt({connectionId:s,orgId:d.id,orgSlug:d.slug}),x=Qe.virtualMcpPrompts(s,d.id),{data:v,isLoading:_}=gs({queryKey:x,queryFn:()=>a0(g),staleTime:6e4,enabled:a&&!!g}),b=v?.prompts??[],[y,L]=C.useState(null),{chatMode:w,setChatMode:S}=xs(),[j,k]=sr(),T=(Pr.find(H=>H.value===j.toolApprovalLevel)??Pr[0]).short,A=H=>{const q=Pr.find(J=>J.value===H);if(q){if(q.value===j.toolApprovalLevel){l(!1);return}c(),Ce("chat_approval_level_changed",{from_level:j.toolApprovalLevel,to_level:q.value,source:"tools_popover"}),k({...j,toolApprovalLevel:q.value}),l(!1)}},N=w==="plan",E=()=>{c();const H=N?"default":"plan";Ce("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},I=()=>{e(),l(!1)},P=async(H,q)=>{if(!h||!g)return;const J=rn(H._meta),G={from:h.state.selection.from,to:h.state.selection.to};try{const W=await Vo(g,H.name,q);Hi(h,G,{id:H.name,name:rr(H.name,J),metadata:W.messages,char:"/",kind:"prompt",args:q})}catch{ce.error("Failed to load prompt. Please try again.")}},R=async H=>{l(!1);const q=!!(H.arguments&&H.arguments.length>0);if(Ce("chat_prompt_inserted",{prompt_name:H.name,with_arguments:q}),q){L(H);return}await P(H)},D=async H=>{y&&(await P(y,H),L(null))},M=()=>{c();const H=w==="gen-image"?"default":"gen-image";Ce("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},F=()=>{c();const H=w==="web-search"?"default":"web-search";Ce("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},$=()=>{c();const H=w==="deep-research"?"default":"deep-research";Ce("chat_mode_changed",{from_mode:w,to_mode:H,source:"tools_popover"}),S(H),l(!1)},O=w==="gen-image",U=w==="web-search",K=w==="deep-research";return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:u,type:"file",multiple:!0,accept:Ux(n??null),className:"hidden",onChange:p,disabled:r}),i.jsxs(Zt,{open:a,onOpenChange:H=>{H&&!a&&Ce("chat_tools_popover_opened",{chat_mode:w}),l(H)},children:[i.jsx(es,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"ghost",size:"default",disabled:t,title:"Tools","aria-label":"Tools",className:ne("text-muted-foreground hover:text-foreground transition-[gap] duration-200 shrink min-w-0","gap-0 @[320px]/chat-bottom:gap-1.5"),children:[i.jsx(sm,{size:14}),i.jsx("span",{className:ne("min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0","@[320px]/chat-bottom:max-w-24 @[320px]/chat-bottom:opacity-100"),children:"Tools"})]})}),i.jsxs(ts,{align:"start",className:"w-52 p-1.5 space-y-1",children:[f?i.jsxs(He,{onClick:m,disabled:r,children:[i.jsx(Lt,{size:16}),i.jsx("span",{className:"flex-1",children:"Add file"})]}):i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsxs(He,{"aria-disabled":"true",className:"opacity-50 cursor-not-allowed",onSelect:H=>H.preventDefault(),children:[i.jsx(Lt,{size:16}),i.jsx("span",{className:"flex-1",children:"Add file"})]})}),i.jsx(Pe,{side:"right",children:"The selected model does not support reading files or images."})]}),i.jsxs(He,{onClick:E,className:ne(N&&"text-violet-600 dark:text-violet-400"),children:[i.jsx(Ki,{size:16,className:ne(N&&"text-violet-500")}),i.jsx("span",{className:"flex-1",children:"Plan mode"}),i.jsx("span",{className:ne("text-xs text-muted-foreground",N&&"text-violet-500 font-medium"),children:a8})]}),i.jsxs(He,{onClick:M,className:ne(O&&"text-pink-600 dark:text-pink-400"),children:[i.jsx(_n,{size:16,className:ne(O&&"text-pink-500")}),i.jsx("span",{className:"flex-1",children:"Create image"}),O&&i.jsx("span",{className:"text-xs text-pink-500 font-medium",children:"On"})]}),i.jsxs(He,{onClick:F,className:ne(U&&"text-blue-600 dark:text-blue-400"),children:[i.jsx(on,{size:16,className:ne(U&&"text-blue-500")}),i.jsx("span",{className:"flex-1",children:"Web search"}),U&&i.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),i.jsxs(He,{onClick:$,className:ne(K&&"text-blue-600 dark:text-blue-400"),children:[i.jsx(nm,{size:16,className:ne(K&&"text-blue-500")}),i.jsx("span",{className:"flex-1",children:"Deep research"}),K&&i.jsx("span",{className:"text-xs text-blue-500 font-medium",children:"On"})]}),i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2",children:[i.jsx("span",{className:"flex size-4 items-center justify-center text-base font-medium text-muted-foreground",children:"/"}),i.jsx("span",{className:"flex-1",children:"Prompts"})]}),i.jsx(lo,{className:"w-80 max-h-72 overflow-y-auto p-1.5",children:_?i.jsxs("div",{className:"flex items-center gap-2 px-2 py-3 text-sm text-muted-foreground",children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Loading prompts…"]}):b.length===0?i.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground",children:"No prompts available"}):b.map(H=>i.jsxs(He,{onClick:()=>R(H),className:"flex flex-col items-start gap-0.5",children:[i.jsx("span",{className:"font-medium text-sm capitalize",children:H.title||j9(H.name,rn(H._meta))}),H.description&&i.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:H.description})]},H.name))})]}),i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2",children:[i.jsx(Nl,{size:16}),i.jsx("span",{className:"flex-1",children:"Approval"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:T})]}),i.jsx(lo,{className:"w-48 p-1.5",children:i.jsx(h0,{value:j.toolApprovalLevel,onValueChange:A,children:Pr.map(H=>i.jsx(Io,{value:H.value,children:H.label},H.value))})})]}),i.jsxs(He,{onClick:I,children:[i.jsx(mm,{size:16}),i.jsx("span",{className:"flex-1",children:"Connections"}),i.jsx(C.Suspense,{children:i.jsx(c8,{})})]})]})]}),i.jsx(io,{prompt:y,setPrompt:L,onSubmit:D})]})}const h8=[{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 f8(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex items-center -space-x-1",children:h8.map(m8)}),t[0]=e):e=t[0],e}function m8(t){return i.jsx("img",{src:t.src,alt:t.name,className:"size-5 rounded-sm ring-2 ring-muted object-cover bg-white"},t.name)}function p8(t){const e=B.c(6),{onClick:s}=t;let n,r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=ne("group relative z-10 flex items-center gap-3 w-full px-4 py-3","rounded-b-2xl","cursor-pointer"),r=i.jsx("p",{className:"flex-1 text-xs text-muted-foreground truncate text-left",children:"Connect tools and get more done"}),o=i.jsx(f8,{}),a=i.jsx(cn,{size:14,className:"shrink-0 text-muted-foreground/60 group-hover:text-muted-foreground transition-colors"}),e[0]=n,e[1]=r,e[2]=o,e[3]=a):(n=e[0],r=e[1],o=e[2],a=e[3]);let l;return e[4]!==s?(l=i.jsxs("button",{type:"button",onClick:s,className:n,children:[r,o,a]}),e[4]=s,e[5]=l):l=e[5],l}const Dr=48;function g8(){const t=B.c(9),[e,s]=C.useState("idle"),[n,r]=C.useState(""),[o,a]=C.useState(""),[l,c]=C.useState(_8),d=C.useRef(null),h=C.useRef(null),u=C.useRef(null),f=C.useRef(null),m=C.useRef(0),p=C.useRef(!1),g=C.useRef(""),x=C.useRef(""),v=typeof window<"u"&&!!(window.SpeechRecognition||window.webkitSpeechRecognition);let _;t[0]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{m.current&&(cancelAnimationFrame(m.current),m.current=0),h.current?.close().catch(v8),f.current?.getTracks().forEach(x8),u.current=null,h.current=null,f.current=null},t[0]=_):_=t[0];const b=_;let y;if(t[1]===Symbol.for("react.memo_cache_sentinel")){const T=A=>{f.current=A;const N=new AudioContext;h.current=N;const E=N.createMediaStreamSource(A),I=N.createAnalyser();I.fftSize=128,I.smoothingTimeConstant=.8,E.connect(I),u.current=I;const P=new Uint8Array(I.frequencyBinCount),R=()=>{if(!u.current)return;u.current.getByteFrequencyData(P);const D=[];for(let M=0;M<Dr;M++){const F=Math.floor(M/Dr*P.length);D.push(Math.max(.04,(P[F]??0)/255))}c(D),m.current=requestAnimationFrame(R)};R()};y=async()=>{const A=window.SpeechRecognition||window.webkitSpeechRecognition;if(!A){s("unsupported");return}let N;try{N=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{s("permission-denied");return}r(""),a(""),x.current="",g.current="",p.current=!0,s("recording"),T(N);const E=new A;d.current=E,E.interimResults=!0,E.continuous=!0,E.lang=navigator.language||"en-US",E.onresult=I=>{let P="",R="";for(let D=I.resultIndex;D<I.results.length;D++){const M=I.results[D],F=M?.[0]?.transcript??"";M?.isFinal?R=R+F:P=P+F}R&&(g.current=g.current+R,r(g.current)),x.current=P,a(P)},E.onend=()=>{if(p.current)try{E.start()}catch{}};try{E.start()}catch{s("idle")}},t[1]=y}else y=t[1];const L=y;let w;t[2]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{p.current=!1,d.current?.stop(),b(),s("idle"),c(Array(Dr).fill(.05)),a("");const T=(g.current+(x.current?" "+x.current:"")).trim();return r(""),g.current="",x.current="",T},t[2]=w):w=t[2];const S=w;let j;t[3]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{p.current=!1,d.current?.abort(),b(),s("idle"),r(""),a(""),c(Array(Dr).fill(.05)),g.current="",x.current=""},t[3]=j):j=t[3];const k=j;let V;return t[4]!==o||t[5]!==e||t[6]!==n||t[7]!==l?(V={status:e,transcript:n,interimTranscript:o,waveformData:l,isSupported:v,startRecording:L,stopRecording:S,cancelRecording:k},t[4]=o,t[5]=e,t[6]=n,t[7]=l,t[8]=V):V=t[8],V}function x8(t){return t.stop()}function v8(){}function _8(){return Array(Dr).fill(.05)}function b8(t){const e=B.c(4),{data:s}=t;let n;e[0]!==s?(n=s.map(y8),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"flex items-center justify-center gap-[2px] h-10 overflow-hidden","aria-hidden":"true",children:n}),e[2]=n,e[3]=r):r=e[3],r}function y8(t,e){return i.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)}function L8({messageCount:t,showConnectionsBanner:e}){return t>0||e}function S8(t){return t.hasDraft?"send":t.isStreaming||t.isRunInProgress?"stop":"disabled"}function w8(t){const e=B.c(3),{message:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(y9,{size:14,className:"shrink-0"}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-muted/40 text-muted-foreground",children:[n,i.jsx("span",{className:"text-sm",children:s})]}),e[1]=s,e[2]=r):r=e[2],r}function j8(t,e){const s=B.c(5),{editor:n}=C9(),[r,o]=C.useState(!1),a=C.useRef(0);let l,c;return s[0]!==n||s[1]!==e||s[2]!==t?(l=()=>{const d=m=>{m.dataTransfer?.types.includes("Files")&&(m.preventDefault(),a.current=a.current+1,o(!0))},h=m=>{m.preventDefault(),a.current=Math.max(0,a.current-1),a.current===0&&o(!1)},u=C8,f=m=>{if(m.preventDefault(),a.current=0,o(!1),!n||!t||!Rl(t))return;const p=m.dataTransfer?.files;if(!p||p.length===0)return;const{from:g}=n.state.selection;for(const x of Array.from(p))sd(n,t,x,g,e)};return window.addEventListener("dragenter",d),window.addEventListener("dragleave",h),window.addEventListener("dragover",u),window.addEventListener("drop",f),()=>{window.removeEventListener("dragenter",d),window.removeEventListener("dragleave",h),window.removeEventListener("dragover",u),window.removeEventListener("drop",f)}},c=[n,t,e],s[0]=n,s[1]=e,s[2]=t,s[3]=l,s[4]=c):(l=s[3],c=s[4]),C.useEffect(l,c),r}function C8(t){t.dataTransfer?.types.includes("Files")&&t.preventDefault()}function k8(t){const e=B.c(11),{selectedModel:s,onUnsupportedFile:n}=t,r=j8(s,n);let o;e[0]!==s?(o=Rl(s),e[0]=s,e[1]=o):o=e[1];const a=o,l=r?"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=ne("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 h;e[5]!==s||e[6]!==a?(h=a?i.jsxs(i.Fragment,{children:[i.jsx(or,{size:24}),i.jsxs("span",{className:"text-sm font-medium",children:["Drop ",_m(s)," here"]})]}):i.jsxs(i.Fragment,{children:[i.jsx(y9,{size:24}),i.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]=h):h=e[7];let u;return e[8]!==d||e[9]!==h?(u=i.jsx("div",{className:d,children:h}),e[8]=d,e[9]=h,e[10]=u):u=e[10],u}function V8(){const t=B.c(6),e=St(),{org:s,locator:n}=Ae(),{create:r}=Vl();let o;return t[0]!==r||t[1]!==n||t[2]!==e||t[3]!==s.id||t[4]!==s.slug?(o=async a=>{const{tiptapDoc:l,virtualMcp:c}=a,d=crypto.randomUUID(),h=c?.id??ko(s.id).id;Q1(sessionStorage,n,d,{tiptapDoc:l});try{await r({id:d,virtual_mcp_id:h})}catch{}const u={virtualmcpid:h,autosend:G5};e({to:"/$org/$taskId",params:{org:s.slug,taskId:d},search:u})},t[0]=r,t[1]=n,t[2]=e,t[3]=s.id,t[4]=s.slug,t[5]=o):o=t[5],o}function N8({onOpenContextPanel:t,showConnectionsBanner:e=!1}){const s=D1(),n=ir(),r=s?.messages??[],o=s?.isStreaming??!1,a=s?.isRunInProgress??!1,l=s?.stop??(()=>{}),c=n?.taskId??"",d=c||D6,h=V8(),{selectedModel:u,selectedVirtualMcp:f,isModelsLoading:m,tiptapDocRef:p,imageModel:g,webSearchModel:x,deepResearchModel:v,chatMode:_,setChatMode:b}=xs(),{data:y}=vi.useSession(),L=y?.user?.id,{org:w,locator:S}=Ae(),j=ko(w.id).id,k=qs(f?.id??j),V=D2(gv),[T,A]=C.useState(!1),{unsupportedFile:N,onUnsupportedFile:E,clearUnsupportedFile:I}=zb(),P=g8(),R=C.useRef(void 0),D=async()=>{R.current=O,await P.startRecording();const ie=P.status==="recording"?"started":P.status==="unsupported"?"unsupported":P.status==="permission-denied"?"permission_denied":"unknown";Ce("chat_voice_started",{thread_id:c,outcome:ie})},M=()=>{Ce("chat_voice_confirmed",{thread_id:c});const ie=P.stopRecording();G.current?.syncVoiceText(R.current,ie),G.current?.focus()},F=()=>{Ce("chat_voice_cancelled",{thread_id:c}),P.cancelRecording(),G.current?.restoreContent(R.current)};C.useEffect(()=>{if(P.status!=="recording")return;const ie=(P.transcript+(P.interimTranscript?" "+P.interimTranscript:"")).trim();G.current?.syncVoiceText(R.current,ie)},[P.transcript,P.interimTranscript,P.status]);const $=n?.activeTask??null,[O,U]=C.useState(()=>Tu(sessionStorage,S,d)??void 0),K=ie=>{U(ie),p.current=ie,O6(sessionStorage,S,d,ie,{onQuotaExceeded:({docSizeBytes:fe})=>{Ce("chat_draft_quota_exceeded",{thread_id:c||null,doc_size_bytes:fe}),console.warn("[chat-draft] sessionStorage quota exceeded; draft not saved")}})},H=C.useRef(c);if(H.current!==c){H.current=c;const ie=Tu(sessionStorage,S,d)??void 0;U(ie),p.current=ie}const J=[...r].reverse().find(ie=>ie.role==="assistant")?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow,G=C.useRef(null),W=_==="plan";C.useEffect(()=>{const ie=fe=>{J1(fe)&&fe.code==="KeyL"&&(fe.preventDefault(),fe.shiftKey&&b(_==="plan"?"default":"plan"),G.current?.focus())};return document.addEventListener("keydown",ie),()=>document.removeEventListener("keydown",ie)},[_,b]);const z=z1(r),Q=[...r].reverse().find(ie=>ie.role==="assistant"&&ie.metadata?.usage)?.metadata?.usage?.contextTokens??0,Z=!m&&!Xm(O),Y=S8({hasDraft:Z,isStreaming:o,isRunInProgress:a}),ee=Y==="send",te=Y==="stop",ae=L8({messageCount:r.length,showConnectionsBanner:e}),se=ie=>{if(ie?.preventDefault(),Y==="send"&&O){if(Ce("chat_message_sent",{thread_id:c||null,mode:_,model_id:u?.modelId??null,model_provider:u?.providerId??null,virtual_mcp_id:f?.id??null,submission:ie?"button_or_enter":"programmatic"}),s){if(s.isSendInFlight()){ce.info("Still sending your previous message — try again in a moment");return}s.sendMessage(O)}else h({tiptapDoc:O,virtualMcp:f});$6(sessionStorage,S,d),K(void 0)}else Y==="stop"&&(Ce("chat_message_stopped",{thread_id:c}),l())};return L&&$?.created_by&&$.created_by!==L?i.jsx(w8,{message:"Read only - you're viewing someone else's thread"}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col w-full justify-end",children:i.jsxs("div",{className:"relative rounded-2xl w-full flex flex-col",children:[e&&i.jsx("div",{className:"absolute inset-0 rounded-2xl pointer-events-none bg-muted/50"}),s&&n&&i.jsx(Ol,{}),s&&n&&c?i.jsx(O_,{taskId:c}):null,i.jsx(P2,{tiptapDoc:O,setTiptapDoc:K,disabled:!1,enterToSubmit:!0,onSubmit:se,children:i.jsxs("form",{onSubmit:se,className:ne("w-full relative rounded-2xl min-h-[110px] md:min-h-[130px] flex flex-col bg-card dark:bg-muted card-shadow overflow-hidden"),children:[i.jsx(k8,{selectedModel:u,onUnsupportedFile:E}),i.jsx("div",{className:"group/input relative flex flex-col gap-2 flex-1",children:i.jsx(I2,{ref:G,disabled:P.status==="recording",virtualMcpId:f?.id??j,showFileUploader:!0,selectedModel:u,onUnsupportedFile:E})}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-between p-2.5 gap-1",children:P.status==="recording"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[i.jsx(b8,{data:P.waveformData.slice(0,28)}),i.jsx("button",{type:"button",onClick:F,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:i.jsx(ms,{size:16})}),i.jsx("button",{type:"button",onClick:M,className:"flex items-center justify-center size-8 rounded-lg bg-foreground text-background hover:opacity-80 transition-opacity","aria-label":"Use transcription",children:i.jsx(Tt,{size:16})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[i.jsx(u8,{disabled:!1,onOpenConnections:()=>{Ce("connections_dialog_opened",{source:"tools_popover",mode:"add"}),A(!0)},virtualMcpId:f?.id??j,selectedModel:u,isStreaming:o,onUnsupportedFile:E}),W&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ce("chat_mode_changed",{from_mode:"plan",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Plan mode","aria-label":"Plan mode",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 min-w-0 shrink animate-in fade-in duration-200",children:[i.jsx(Ki,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-32 @[320px]/chat-bottom:opacity-100",children:"Plan mode"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="gen-image"&&g&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ce("chat_mode_changed",{from_mode:"gen-image",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Create image","aria-label":"Create image",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 min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[i.jsx(_n,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Create image"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="web-search"&&x&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ce("chat_mode_changed",{from_mode:"web-search",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Web search","aria-label":"Web search",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 min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[i.jsx(on,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Web search"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),_==="deep-research"&&v&&i.jsxs("button",{type:"button",onClick:()=>{V(),Ce("chat_mode_changed",{from_mode:"deep-research",to_mode:"default",source:"pill_dismiss"}),b("default")},title:"Deep research","aria-label":"Deep research",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 min-w-0 shrink animate-in fade-in duration-200 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[i.jsx(nm,{size:14,className:"shrink-0"}),i.jsx("span",{className:"min-w-0 truncate transition-[max-width,opacity] duration-200 ease-out max-w-0 opacity-0 @[320px]/chat-bottom:max-w-[120px] @[320px]/chat-bottom:opacity-100",children:"Deep research"}),i.jsx(ms,{size:14,className:"shrink-0 hidden group-hover:block group-disabled:hidden"})]}),J&&Q>0&&i.jsx(S5,{usage:z,totalTokens:Q,contextWindow:J,onOpenContextPanel:t})]}),i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[ae&&i.jsx(x2,{virtualMcp:k,currentBranch:n?.currentBranch??null}),i.jsx(Ib,{}),P.isSupported&&i.jsx(re,{type:"button",onClick:D,disabled:!1,variant:"ghost",size:"icon",className:ne("size-8 rounded-lg transition-colors",P.status==="permission-denied"?"text-destructive hover:text-destructive hover:bg-destructive/10":"text-muted-foreground hover:text-foreground"),title:P.status==="permission-denied"?"Microphone access denied — click to try again":"Voice input",children:i.jsx(X5,{size:18})}),i.jsx(re,{type:te?"button":"submit",onClick:ie=>{te&&(ie.preventDefault(),ie.stopPropagation(),l())},variant:ee||te?"default":"ghost",size:"icon",disabled:!ee&&!te,className:ne("size-8 rounded-lg transition-all",!ee&&!te&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed"),title:Y==="stop"?o?"Stop generating":"Cancel run":"Send message (Enter)",children:te?i.jsx(Q5,{size:20}):i.jsx(S9,{size:20})})]})]})})]})},c),e&&i.jsx(p8,{onClick:()=>{Ce("connections_banner_clicked",{source:"home_chat_input"}),Ce("connections_dialog_opened",{source:"home_banner",mode:"add"}),A(!0)}})]})}),i.jsx(gm,{mode:"browse",open:T,onOpenChange:A,defaultTab:"all"}),i.jsx($b,{info:N,onClose:I})]})}const A8={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 M2(t){return`deco-credits-empty-dismissed:${t}`}function T8(t){try{return localStorage.getItem(M2(t))==="1"}catch{return!1}}function E8(){const t=B.c(47),{org:e}=Ae(),s=St(),{decoKeyId:n}=F9(),r=Ms(),[o,a]=C.useState(!0),[l,c]=C.useState(""),[d,h]=C.useState(!1),[u,f]=C.useState("usd"),m=u==="brl"?"R$":"$";let p;t[0]!==e.id?(p=()=>{Ce("credits_empty_state_dismissed",{organization_id:e.id}),a(!1);try{localStorage.setItem(M2(e.id),"1")}catch{}},t[0]=e.id,t[1]=p):p=t[1];const g=p;let x,v;t[2]!==o||t[3]!==e.id?(x=()=>{o&&Ce("credits_empty_state_shown",{organization_id:e.id})},v=[o,e.id],t[2]=o,t[3]=e.id,t[4]=x,t[5]=v):(x=t[4],v=t[5]),C.useEffect(x,v);let _;t[6]!==u||t[7]!==r?(_=async $=>{const{url:O}=await r.call("AI_PROVIDER_TOPUP_URL",{providerId:"deco",amountCents:$,currency:u});return O},t[6]=u,t[7]=r,t[8]=_):_=t[8];let b;t[9]!==g?(b=$=>{$&&window.open($,"_blank","noopener,noreferrer"),g()},t[9]=g,t[10]=b):b=t[10];let y;t[11]!==_||t[12]!==b?(y={mutationFn:_,onSuccess:b,onError:P8},t[11]=_,t[12]=b,t[13]=y):y=t[13];const{mutate:L,isPending:w}=Ds(y),S=parseFloat(l),j=!isNaN(S)&&S>=1;if(!o)return null;let k;t[14]!==g?(k=$=>!$&&g(),t[14]=g,t[15]=k):k=t[15];let V;t[16]===Symbol.for("react.memo_cache_sentinel")?(V=i.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[16]=V):V=t[16];let T;t[17]===Symbol.for("react.memo_cache_sentinel")?(T=i.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:i.jsx(im,{size:20,className:"text-amber-600 dark:text-amber-400"})}),t[17]=T):T=t[17];let A;t[18]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsxs("div",{className:"relative px-6 pt-7 pb-5",children:[V,i.jsxs(ns,{className:"relative gap-3",children:[T,i.jsxs("div",{className:"text-center",children:[i.jsx(is,{className:"text-lg font-semibold",children:"This workspace has no credits"}),i.jsx(qn,{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[18]=A):A=t[18];let N;t[19]!==u||t[20]!==m||t[21]!==l||t[22]!==S||t[23]!==n||t[24]!==j||t[25]!==w||t[26]!==d||t[27]!==L?(N=n&&i.jsxs("div",{className:"px-6 pb-5",children:[i.jsx("div",{className:"mb-4",children:i.jsxs(pm,{type:"single",variant:"outline",size:"sm",value:u,onValueChange:$=>{$&&f($)},children:[i.jsx(Ha,{value:"usd",className:"h-8 px-3 text-xs",children:"USD"}),i.jsx(Ha,{value:"brl",className:"h-8 px-3 text-xs",children:"BRL"})]})}),i.jsx("div",{className:"grid grid-cols-3 gap-2.5",children:A8[u].map($=>{const{dollars:O,label:U}=$;return i.jsxs("button",{type:"button",disabled:w,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:O*100,currency:u,tier_label:U,source:"empty_state"}),L(O*100)},className:ne("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:[i.jsxs("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:[m,O]}),i.jsx("span",{className:"text-xs text-muted-foreground",children:U})]},O)})}),d?i.jsxs("div",{className:"flex gap-2 mt-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground select-none",children:m}),i.jsx(Ye,{type:"number",min:"1",step:"1",placeholder:"50",value:l,onChange:$=>c($.target.value),className:"h-10 text-sm pl-7",autoFocus:!0})]}),i.jsx(re,{className:"h-10",disabled:!j||w,onClick:()=>{Ce("credits_topup_clicked",{amount_cents:Math.round(S*100),currency:u,tier_label:"custom",source:"empty_state"}),L(Math.round(S*100))},children:w?"Opening...":"Add"})]}):i.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[19]=u,t[20]=m,t[21]=l,t[22]=S,t[23]=n,t[24]=j,t[25]=w,t[26]=d,t[27]=L,t[28]=N):N=t[28];let E;t[29]!==g||t[30]!==s||t[31]!==e.slug?(E=()=>{s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),g()},t[29]=g,t[30]=s,t[31]=e.slug,t[32]=E):E=t[32];let I;t[33]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(Eo,{size:12,className:"transition-transform duration-150 group-hover:translate-x-0.5"}),t[33]=I):I=t[33];let P;t[34]!==E?(P=i.jsxs("button",{type:"button",className:"group flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:E,children:["Use your own provider",I]}),t[34]=E,t[35]=P):P=t[35];let R;t[36]!==g?(R=i.jsx(re,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:g,children:"Skip for now"}),t[36]=g,t[37]=R):R=t[37];let D;t[38]!==P||t[39]!==R?(D=i.jsxs("div",{className:"px-6 py-3.5 border-t border-border bg-muted/30 flex items-center justify-between",children:[P,R]}),t[38]=P,t[39]=R,t[40]=D):D=t[40];let M;t[41]!==N||t[42]!==D?(M=i.jsxs(Ft,{className:"sm:max-w-[500px] gap-0 p-0 overflow-hidden",onOpenAutoFocus:R8,children:[A,N,D]}),t[41]=N,t[42]=D,t[43]=M):M=t[43];let F;return t[44]!==M||t[45]!==k?(F=i.jsx(Ut,{open:!0,onOpenChange:k,children:M}),t[44]=M,t[45]=k,t[46]=F):F=t[46],F}function R8(t){return t.preventDefault()}function P8(t){ce.error(`Top-up failed: ${t.message}`)}function I8(t){const e=B.c(6),{balanceDollars:s}=t;let n;e[0]!==s?(n=s.toFixed(2),e[0]=s,e[1]=n):n=e[1];const r=n;let o,a;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=ne("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=i.jsx(im,{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]!==r?(l=i.jsxs("div",{className:o,children:[a,i.jsxs("span",{className:"text-xs font-medium text-emerald-700 dark:text-emerald-300 tabular-nums",children:["$",r," in credits to get started"]})]}),e[4]=r,e[5]=l):l=e[5],l}function D8(){const t=B.c(8),{org:e}=Ae(),s=St();let n;t[0]!==s||t[1]!==e.slug?(n=()=>s({to:"/$org/settings/ai-providers",params:{org:e.slug}}),t[0]=s,t[1]=e.slug,t[2]=n):n=t[2];let r,o,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=ne("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=i.jsx(fn,{size:13,className:"text-amber-600 dark:text-amber-400"}),a=i.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"No credits remaining · Add more"}),t[3]=r,t[4]=o,t[5]=a):(r=t[3],o=t[4],a=t[5]);let l;return t[6]!==n?(l=i.jsxs("button",{type:"button",onClick:n,className:r,children:[o,a]}),t[6]=n,t[7]=l):l=t[7],l}function M8(t){const e=B.c(11),{className:s}=t;let n;e[0]!==s?(n=ne("flex h-full w-full flex-col bg-background",s),e[0]=s,e[1]=n):n=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),e[2]=r):r=e[2];let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex items-center gap-3",children:[r,i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),i.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=i.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),i.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=i.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:i.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[i.jsx(ta,{align:"right",width:"w-3/4"}),i.jsx(ta,{align:"left",width:"w-full",lines:3}),i.jsx(ta,{align:"right",width:"w-2/3"}),i.jsx(ta,{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=i.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:i.jsx("div",{className:"relative flex-1",children:i.jsxs("div",{className:"space-y-2 p-2",children:[i.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),i.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=i.jsx("div",{className:"flex items-center gap-1",children:i.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),e[7]=d):d=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx("div",{className:"px-4 py-4",children:i.jsx("div",{className:"mx-auto w-full max-w-2xl",children:i.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl bg-background card-shadow",children:[c,i.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[d,i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),i.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})}),e[8]=h):h=e[8];let u;return e[9]!==n?(u=i.jsxs("div",{className:n,children:[a,l,h]}),e[9]=n,e[10]=u):u=e[10],u}function ta(t){const e=B.c(22),{align:s,width:n,lines:r}=t,o=n===void 0?"w-full":n,a=r===void 0?1:r,l=s==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==l?(c=ne("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 h;e[2]!==d?(h=ne("flex min-w-0 flex-col gap-2",d),e[2]=d,e[3]=h):h=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=u):u=e[4];const f=s==="right"?"bg-muted":"bg-transparent border border-border/40";let m;e[5]!==f||e[6]!==o?(m=ne("min-w-0 rounded-2xl p-4",f,o),e[5]=f,e[6]=o,e[7]=m):m=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=i.jsx("div",{className:"space-y-2",children:p.map((b,y)=>i.jsx("div",{className:ne("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 x;e[13]!==g||e[14]!==m?(x=i.jsx("div",{className:m,children:g}),e[13]=g,e[14]=m,e[15]=x):x=e[15];let v;e[16]!==x||e[17]!==h?(v=i.jsxs("div",{className:h,children:[u,x]}),e[16]=x,e[17]=h,e[18]=v):v=e[18];let _;return e[19]!==v||e[20]!==c?(_=i.jsx("div",{className:c,children:v}),e[19]=v,e[20]=c,e[21]=_):_=e[21],_}function O8(t){const e=B.c(7),{scrollRef:s,sentinelRef:n,hasMoreOlder:r,isFetchingOlder:o,fetchOlderMessages:a}=t;let l,c;e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n?(l=()=>{const d=n.current,h=s.current;if(!d||!h||!r)return;const u=new IntersectionObserver(async f=>{if(!f[0]?.isIntersecting||o||!r)return;const p=h.scrollHeight,g=h.scrollTop;await a(),requestAnimationFrame(()=>{const x=h.scrollHeight;h.scrollTop=g+(x-p)})},{root:h,rootMargin:"200px 0px 0px 0px"});return u.observe(d),()=>u.disconnect()},c=[s,n,r,o,a],e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=l,e[6]=c):(l=e[5],c=e[6]),C.useEffect(l,c)}function $8(t){const e=B.c(5),{className:s,children:n}=t;let r;e[0]!==s?(r=ne("flex flex-col h-full w-full bg-background transform-[translateZ(0)]",s),e[0]=s,e[1]=r):r=e[1];let o;return e[2]!==n||e[3]!==r?(o=i.jsx("div",{className:r,children:n}),e[2]=n,e[3]=r,e[4]=o):o=e[4],o}function B8(t){const e=B.c(5),{children:s,className:n}=t;let r;e[0]!==n?(r=ne("flex-1 min-h-0 overflow-y-auto isolate",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=i.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}function z8(t){const e=B.c(2),{children:s}=t;let n;return e[0]!==s?(n=i.jsx("div",{className:"min-h-full shrink-0 w-full flex items-center justify-center max-w-2xl mx-auto py-10",children:s}),e[0]=s,e[1]=n):n=e[1],n}function F8(){const{messages:t,status:e,hasMoreOlder:s,isFetchingOlder:n,fetchOlderMessages:r}=js(),{taskId:o}=as(),a=P1(o??""),l=l5(a),c=l.size===0?t:t.filter(v=>!l.has(v.id)),d=w5(c),h=d.at(-1),f=I6()*S6+16,m=C.useRef(null),p=C.useRef(null);O8({scrollRef:m,sentinelRef:p,hasMoreOlder:s,isFetchingOlder:n,fetchOlderMessages:r});const g=j5({initial:!1}),x=v=>{m.current=v,g.scrollRef(v)};return i.jsx(C5,{messages:t,children:i.jsxs("div",{className:"relative h-full w-full min-w-0",children:[i.jsx("div",{ref:x,"data-chat-scroller":!0,className:"w-full min-w-0 max-w-full overflow-y-auto h-full [container-type:size]",style:{paddingBottom:f},children:i.jsxs("div",{ref:g.contentRef,className:"overflow-x-clip",children:[i.jsxs("div",{className:"flex flex-col min-w-0 max-w-2xl mx-auto w-full",children:[i.jsx("div",{ref:p,"aria-hidden":!0,className:"h-px"}),n&&i.jsx("div",{className:"flex items-center justify-center py-3 text-xs text-muted-foreground",children:"Loading older messages…"}),d.slice(0,-1).map((v,_)=>i.jsx(_u,{pair:v,isLastPair:!1,status:_===d.length-1?e:void 0},`pair-${v.user?.id??v.assistant?.id}`))]}),h&&i.jsx("div",{className:"min-h-[100cqh] min-w-0 max-w-2xl mx-auto w-full",children:i.jsx(_u,{pair:h,isLastPair:!0,status:e},`pair-${h.user?.id??h.assistant?.id}`)})]})}),!g.isAtBottom&&i.jsx(re,{type:"button",variant:"outline",size:"icon-sm","aria-label":"Jump to latest",className:"absolute left-1/2 z-50 -translate-x-1/2 rounded-full shadow-md animate-in fade-in duration-200 dark:bg-background dark:hover:bg-accent",style:{bottom:f+8},onClick:()=>{g.scrollToBottom()},children:i.jsx(s5,{size:14})})]})})}function U8(t){const e=B.c(5),{children:s,className:n}=t;let r;e[0]!==n?(r=ne("flex-none w-full mx-auto p-2 pt-0","max-w-2xl min-w-0",n),e[0]=n,e[1]=r):r=e[1];let o;return e[2]!==s||e[3]!==r?(o=i.jsx("div",{className:r,children:s}),e[2]=s,e[3]=r,e[4]=o):o=e[4],o}const dt=Object.assign($8,{Main:B8,Messages:F8,EmptyState:z8,Footer:U8,Input:N8,Provider:a5,ActiveTaskProvider:o5,Skeleton:M8,IceBreakers:L6,NoAiProviderEmptyState:bm,CreditsEmptyState:E8,CreditsEyebrow:I8,NoCreditsEyebrow:D8,CreditsExhaustedBanner:a2});function rd(){const t=Sm(),{pendingAgentOption:e}=xs(),s=$l();if(ir()?.isThreadLocked)return!1;const r=e==="claude-code-desktop"&&s.claudeCode||e==="codex-desktop"&&s.codex;return t.length===0&&!r}function Lr(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function nh(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 H8(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function K8(t){const e=B.c(4),{items:s}=t;let n;e[0]!==s?(n=s.map(W8),e[0]=s,e[1]=n):n=e[1];let r;return e[2]!==n?(r=i.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:n}),e[2]=n,e[3]=r):r=e[3],r}function W8(t){return i.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[i.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),i.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function q8(t){const e=B.c(30),{userTokens:s,assistantTokens:n,otherTokens:r}=t,o=s+n+r,a=o>0?s/o*100:0,l=o>0?n/o*100:0,c=o>0?r/o*100:0;let d;e[0]!==a?(d=a>0&&i.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=d):d=e[1];let h;e[2]!==l?(h=l>0&&i.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=h):h=e[3];let u;e[4]!==c?(u=c>0&&i.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${c}%`}}),e[4]=c,e[5]=u):u=e[5];let f;e[6]!==d||e[7]!==h||e[8]!==u?(f=i.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[d,h,u]}),e[6]=d,e[7]=h,e[8]=u,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=m):m=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=i.jsxs("div",{className:"flex items-center gap-1.5",children:[m,i.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",p,"%"]})]}),e[13]=p,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=x):x=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let _;e[18]!==v?(_=i.jsxs("div",{className:"flex items-center gap-1.5",children:[x,i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=_):_=e[19];let b;e[20]!==c||e[21]!==r?(b=r>0&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",c.toFixed(1),"%"]})]}),e[20]=c,e[21]=r,e[22]=b):b=e[22];let y;e[23]!==_||e[24]!==b||e[25]!==g?(y=i.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[g,_,b]}),e[23]=_,e[24]=b,e[25]=g,e[26]=y):y=e[26];let L;return e[27]!==y||e[28]!==f?(L=i.jsxs("div",{className:"flex flex-col gap-2",children:[f,y]}),e[27]=y,e[28]=f,e[29]=L):L=e[29],L}function G8(t){const e=B.c(11),{agentId:s,isError:n}=t,r=qs(s),o=r?.title??"Subtask",a=r?.icon??null;let l;e[0]!==a||e[1]!==o?(l=i.jsx(Gs,{icon:a,name:o,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=o,e[2]=l):l=e[2];const c=n?"text-destructive":"text-foreground";let d;e[3]!==c?(d=ne("shrink-0 font-medium",c),e[3]=c,e[4]=d):d=e[4];let h;e[5]!==o||e[6]!==d?(h=i.jsx("span",{className:d,children:o}),e[5]=o,e[6]=d,e[7]=h):h=e[7];let u;return e[8]!==l||e[9]!==h?(u=i.jsxs(i.Fragment,{children:[l,h]}),e[8]=l,e[9]=h,e[10]=u):u=e[10],u}function Y8(t){const e=B.c(5),{isError:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(Gs,{icon:null,name:"Subtask",size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=n):n=e[0];const r=s?"text-destructive":"text-foreground";let o;e[1]!==r?(o=ne("shrink-0 font-medium",r),e[1]=r,e[2]=o):o=e[2];let a;return e[3]!==o?(a=i.jsxs(i.Fragment,{children:[n,i.jsx("span",{className:o,children:"Subtask"})]}),e[3]=o,e[4]=a):a=e[4],a}function J8(t){const e=B.c(18),{part:s}=t,n=s.input?.agent_id,r=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,o=s.state==="output-error",a=s.state==="approval-requested";let l;e[0]!==o?(l=i.jsx(Y8,{isError:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==o?(c=i.jsx(G8,{agentId:n,isError:o}),e[2]=n,e[3]=o,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==c?(d=i.jsx(C.Suspense,{fallback:l,children:c}),e[5]=l,e[6]=c,e[7]=d):d=e[7];let h;e[8]!==s.input?(h=s.input?.prompt&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-muted-foreground/50",children:"·"}),i.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==o||e[12]!==r?(u=i.jsx("span",{className:"ml-auto shrink-0",children:r?i.jsx(qe,{size:12,className:"animate-spin text-muted-foreground"}):o?i.jsx(Px,{size:12,className:"text-destructive"}):a?i.jsx(fn,{size:12,className:"text-warning"}):i.jsx(Pl,{size:12,className:"text-emerald-500"})}),e[10]=a,e[11]=o,e[12]=r,e[13]=u):u=e[13];let f;return e[14]!==d||e[15]!==h||e[16]!==u?(f=i.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[d,h,u]}),e[14]=d,e[15]=h,e[16]=u,e[17]=f):f=e[17],f}function X8(t){const e=B.c(55),{onClose:s,back:n,className:r}=t,[o,a]=C.useState(null),{messages:l}=js(),{activeTask:c}=as(),{selectedModel:d,selectedVirtualMcp:h}=xs();let u,f,m,p,g,x,v,_;if(e[0]!==c||e[1]!==n||e[2]!==r||e[3]!==l||e[4]!==s||e[5]!==o?.id||e[6]!==d||e[7]!==h?.title){_=Symbol.for("react.early_return_sentinel");e:{const L=z1(l),w=[...l].reverse().find(lL),S=w?.metadata?.usage,j=w?.metadata?.modelLimits?.contextWindow??d?.limits?.contextWindow??null,k=S?.contextTokens??0,V=j&&j>0?(k/j*100).toFixed(1):null,T=l;let A;e[16]!==T?(A=T.filter(aL).reduce(oL,0),e[16]=T,e[17]=A):A=e[17];const N=A,E=l;let I;e[18]!==E?(I=E.filter(rL).reduce(iL,0),e[18]=E,e[19]=I):I=e[19];const P=I,R=Math.max(0,L.totalTokens-N-P),D=l[0],M=l.at(-1),F=D?.metadata?.created_at??c?.created_at,$=M?.metadata?.created_at??c?.updated_at,O=l.filter(nL),U=l.flatMap(tL),K=d?.modelId?H8(d.modelId):"—",H=h?.title??"Super Agent",q=[{label:"Session",value:c?.title??"New chat"},{label:"Messages",value:O.length},{label:"Agent",value:H},{label:"Model",value:K},{label:"Context Limit",value:j?Lr(j):"—"},{label:"Session Tokens (billed)",value:L.totalTokens>0?Lr(L.totalTokens):"0"},{label:"Usage",value:V!==null?`${V}%`:"—"},{label:"Input Tokens",value:L.inputTokens>0?Lr(L.inputTokens):"0"},{label:"Output Tokens",value:L.outputTokens>0?Lr(L.outputTokens):"0"},{label:"Reasoning Tokens",value:L.reasoningTokens>0?Lr(L.reasoningTokens):"0"},{label:"Cost",value:L.cost>0?`$${L.cost<.001?L.cost.toFixed(6):L.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:nh(F)},{label:"Last Activity",value:nh($)}];if(!c&&O.length===0){let z;e[20]!==r?(z=ne("flex flex-col h-full w-full border-l border-border bg-background",r),e[20]=r,e[21]=z):z=e[21];let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[22]=X):X=e[22];let Q;e[23]!==n?(Q=n?i.jsx(Cu,{size:14,className:"text-muted-foreground"}):i.jsx(yn,{size:14,className:"text-muted-foreground"}),e[23]=n,e[24]=Q):Q=e[24];let Z;e[25]!==s||e[26]!==Q?(Z=i.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[X,i.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:Q})]}),e[25]=s,e[26]=Q,e[27]=Z):Z=e[27];let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[28]=Y):Y=e[28];let ee;e[29]!==z||e[30]!==Z?(ee=i.jsxs("div",{className:z,children:[Z,Y]}),e[29]=z,e[30]=Z,e[31]=ee):ee=e[31],_=ee;break e}e[32]!==r?(x=ne("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[32]=r,e[33]=x):x=e[33];let J;e[34]===Symbol.for("react.memo_cache_sentinel")?(J=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[34]=J):J=e[34];let G;e[35]!==n?(G=n?i.jsx(Cu,{size:14}):i.jsx(yn,{size:14}),e[35]=n,e[36]=G):G=e[36],e[37]!==s||e[38]!==G?(v=i.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[J,i.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:G})]}),e[37]=s,e[38]=G,e[39]=v):v=e[39],u="flex flex-col gap-8 p-6",f=U.length>0&&i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),i.jsx("div",{className:"flex flex-col gap-1",children:U.map(eL)})]}),m=i.jsx(K8,{items:q});let W;e[40]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[40]=W):W=e[40],e[41]!==P||e[42]!==R||e[43]!==N?(p=i.jsxs("div",{className:"flex flex-col gap-3",children:[W,i.jsx(q8,{userTokens:N,assistantTokens:P,otherTokens:R})]}),e[41]=P,e[42]=R,e[43]=N,e[44]=p):p=e[44],g=O.length>0&&i.jsxs("div",{className:"flex flex-col gap-3",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),i.jsx("div",{className:"flex flex-col gap-1",children:O.map(z=>{const X=z.metadata?.created_at,Q=o?.id===z.id;return i.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>a(Q?null:z),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:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx("span",{className:ne("shrink-0 font-medium",z.role==="user"?"text-chart-1":"text-chart-2"),children:z.role}),i.jsx("span",{className:"text-muted-foreground",children:"•"}),i.jsx("span",{className:"truncate text-muted-foreground font-mono",children:z.id})]}),X&&i.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(X).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),Q&&i.jsxs(i.Fragment,{children:[z.role==="assistant"&&(()=>{const Z=z.metadata?._request;if(!Z)return null;const Y=Z.systemSections??[],ee=Math.max(1,...Y.map(Z8)),te=Y.reduce(Q8,0);return i.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-medium text-foreground",children:"Request"}),i.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[Z.activeTools??0," / ",Z.tools??0," ","tools active"]})]}),Y.length>0&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",i.jsxs("span",{className:"tabular-nums",children:["~",Math.round(te/4).toLocaleString()," ","tok"]})]}),Y.map((ae,se)=>{const ie=ae.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${se}`,fe=ae.chars/ee*100,me=Math.round(ae.chars/4);return i.jsxs("div",{className:"space-y-0.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("span",{className:"font-mono text-foreground truncate",children:ie}),i.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",me.toLocaleString()," tok"]})]}),i.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${fe}%`}})})]},se)})]})]})})(),i.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(z,null,2)})]})]},z.id)})})]})}e[0]=c,e[1]=n,e[2]=r,e[3]=l,e[4]=s,e[5]=o?.id,e[6]=d,e[7]=h?.title,e[8]=u,e[9]=f,e[10]=m,e[11]=p,e[12]=g,e[13]=x,e[14]=v,e[15]=_}else u=e[8],f=e[9],m=e[10],p=e[11],g=e[12],x=e[13],v=e[14],_=e[15];if(_!==Symbol.for("react.early_return_sentinel"))return _;let b;e[45]!==u||e[46]!==f||e[47]!==m||e[48]!==p||e[49]!==g?(b=i.jsxs("div",{className:u,children:[f,m,p,g]}),e[45]=u,e[46]=f,e[47]=m,e[48]=p,e[49]=g,e[50]=b):b=e[50];let y;return e[51]!==x||e[52]!==v||e[53]!==b?(y=i.jsxs("div",{className:x,children:[v,b]}),e[51]=x,e[52]=v,e[53]=b,e[54]=y):y=e[54],y}function Q8(t,e){return t+e.chars}function Z8(t){return t.chars}function eL(t,e){return i.jsx(J8,{part:t},e)}function tL(t){return(t.parts??[]).filter(sL)}function sL(t){return t.type==="tool-subtask"}function nL(t){return t.role!=="system"}function iL(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function rL(t){return t.role==="assistant"}function oL(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function aL(t){return t.role==="user"}function lL(t){return t.role==="assistant"&&t.metadata?.usage}function cL(t){const e=B.c(27),{onOpenContextPanel:s}=t,{org:n}=Ae(),{selectedVirtualMcp:r}=xs(),{currentBranch:o}=as();let a;e[0]!==n.id?(a=ko(n.id),e[0]=n.id,e[1]=a):a=e[1];const c=r??a,d=qs(c.id),h=d??c,u=h.title??"Super Agent",f=h.icon??null,m=h.description??null;let p;e[2]!==f||e[3]!==u?(p=i.jsx(Hn,{icon:f,name:u,size:"lg"}),e[2]=f,e[3]=u,e[4]=p):p=e[4];let g;e[5]!==u?(g=i.jsx("h2",{className:"text-2xl font-semibold tracking-tight text-foreground",children:u}),e[5]=u,e[6]=g):g=e[6];let x;e[7]!==m?(x=m?i.jsx("p",{className:"text-sm text-muted-foreground max-w-md text-balance",children:m}):null,e[7]=m,e[8]=x):x=e[8];let v;e[9]!==g||e[10]!==x?(v=i.jsxs("div",{className:"space-y-1.5",children:[g,x]}),e[9]=g,e[10]=x,e[11]=v):v=e[11];let _;e[12]!==p||e[13]!==v?(_=i.jsxs("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center gap-4 px-6 text-center overflow-hidden",children:[p,v]}),e[12]=p,e[13]=v,e[14]=_):_=e[14];let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(dt.IceBreakers,{className:"pb-3"}),e[15]=b):b=e[15];let y;e[16]!==o||e[17]!==d?(y=i.jsx("div",{"data-chat-above-row":"true",className:"@container/chat-bottom pb-1 flex justify-start gap-1",children:i.jsx(x2,{virtualMcp:d,currentBranch:o,showRuntimeLabel:!0})}),e[16]=o,e[17]=d,e[18]=y):y=e[18];let L;e[19]!==s?(L=i.jsx(dt.Input,{onOpenContextPanel:s}),e[19]=s,e[20]=L):L=e[20];let w;e[21]!==y||e[22]!==L?(w=i.jsxs(dt.Footer,{children:[b,y,L]}),e[21]=y,e[22]=L,e[23]=w):w=e[23];let S;return e[24]!==w||e[25]!==_?(S=i.jsxs(i.Fragment,{children:[_,w]}),e[24]=w,e[25]=_,e[26]=S):S=e[26],S}function ih(t){const e=B.c(17),{outputs:s,collapsed:n,onToggle:r,variant:o}=t,a=o==="card"?"rounded-xl border border-border bg-muted/95 shadow-sm backdrop-blur-sm":"border-b border-border bg-background";let l;e[0]!==a?(l=ne(a),e[0]=a,e[1]=l):l=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-sm font-medium text-foreground",children:"Files in this task"}),e[2]=c):c=e[2];const d=n&&"-rotate-90";let h;e[3]!==d?(h=ne("size-4 text-muted-foreground transition-transform",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==h?(u=i.jsx(Ht,{className:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==r||e[8]!==u?(f=i.jsxs("button",{type:"button",onClick:r,className:"flex w-full items-center justify-between px-3 py-2.5 text-left",children:[c,u]}),e[7]=r,e[8]=u,e[9]=f):f=e[9];let m;e[10]!==n||e[11]!==s?(m=!n&&i.jsx("div",{className:"flex max-h-72 flex-col gap-1.5 overflow-y-auto px-2 pb-2",children:s.map(dL)}),e[10]=n,e[11]=s,e[12]=m):m=e[12];let p;return e[13]!==l||e[14]!==f||e[15]!==m?(p=i.jsxs("div",{className:l,children:[f,m]}),e[13]=l,e[14]=f,e[15]=m,e[16]=p):p=e[16],p}function dL(t){return i.jsx(V5,{file:t},t.key)}function uL(){const t=B.c(13),e=ir()?.taskId??null,s=k5();let n;t[0]!==s?(n={enabled:s},t[0]=s,t[1]=n):n=t[1];const{data:r}=F1(e,n),[o,a]=C.useState(!1),[l,c]=C.useState(!0);if(!e||!r||r.length===0)return null;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>a(fL),t[2]=d):d=t[2];let h;t[3]!==o||t[4]!==r?(h=i.jsx("div",{className:"absolute top-2 right-2 z-10 hidden w-72 @[1280px]:block",children:i.jsx(ih,{variant:"card",outputs:r,collapsed:o,onToggle:d})}),t[3]=o,t[4]=r,t[5]=h):h=t[5];let u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=()=>c(hL),t[6]=u):u=t[6];let f;t[7]!==l||t[8]!==r?(f=i.jsx("div",{className:"shrink-0 @[1280px]:hidden",children:i.jsx(ih,{variant:"bar",outputs:r,collapsed:l,onToggle:u})}),t[7]=l,t[8]=r,t[9]=f):f=t[9];let m;return t[10]!==h||t[11]!==f?(m=i.jsxs(i.Fragment,{children:[h,f]}),t[10]=h,t[11]=f,t[12]=m):m=t[12],m}function hL(t){return!t}function fL(t){return!t}function mL(){const t=B.c(27),{org:e}=Ae(),{isChatEmpty:s}=js(),{openTab:n}=No(),[r,o]=C.useState("chat"),a=F9();if(rd()){let y;return t[0]!==n?(y=i.jsx(dt,{className:"animate-in fade-in-0 duration-200",children:i.jsx(dt.Main,{className:"flex flex-col items-center",children:i.jsx(dt.EmptyState,{children:i.jsx(dt.NoAiProviderEmptyState,{onLocalRuntimePicked:()=>n("overview")})})})}),t[0]=n,t[1]=y):y=t[1],y}let c;t[2]!==a.hasDecoKey||t[3]!==a.hasOnlyDecoProvider||t[4]!==a.isLoading||t[5]!==a.isZeroBalance||t[6]!==s||t[7]!==e?(c=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&s&&!T8(e.id),t[2]=a.hasDecoKey,t[3]=a.hasOnlyDecoProvider,t[4]=a.isLoading,t[5]=a.isZeroBalance,t[6]=s,t[7]=e,t[8]=c):c=t[8];const d=c;let h;t[9]!==d?(h=d&&i.jsx(dt.CreditsEmptyState,{}),t[9]=d,t[10]=h):h=t[10];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let f;t[11]!==u?(f=ne("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[11]=u,t[12]=f):f=t[12];let m;t[13]!==s?(m=s?i.jsx(cL,{onOpenContextPanel:()=>o("context")}):i.jsxs(i.Fragment,{children:[i.jsxs(dt.Main,{className:"relative flex flex-col overflow-hidden @container",children:[i.jsx(uL,{}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(dt.Messages,{})})]}),i.jsx(dt.Footer,{children:i.jsx(dt.Input,{onOpenContextPanel:()=>o("context")})})]}),t[13]=s,t[14]=m):m=t[14];let p;t[15]!==f||t[16]!==m?(p=i.jsx("div",{className:f,children:m}),t[15]=f,t[16]=m,t[17]=p):p=t[17];const g=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let x;t[18]!==g?(x=ne("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",g),t[18]=g,t[19]=x):x=t[19];let v;t[20]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx(X8,{back:!0,onClose:()=>o("chat")}),t[20]=v):v=t[20];let _;t[21]!==x?(_=i.jsx("div",{className:x,children:v}),t[21]=x,t[22]=_):_=t[22];let b;return t[23]!==h||t[24]!==p||t[25]!==_?(b=i.jsxs(dt,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[h,p,_]}),t[23]=h,t[24]=p,t[25]=_,t[26]=b):b=t[26],b}function O2(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(dt.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(ps,{fallback:e,children:i.jsx(C.Suspense,{fallback:i.jsx(dt.Skeleton,{}),children:i.jsx(mL,{})})}),t[1]=s):s=t[1],s}function Lc(t,e){if(Number(e.chatOpen)+Number(e.blocksOpen)+Number(e.mainOpen)<=1)return!1;switch(t){case"chat":return e.chatOpen;case"blocks":return e.blocksOpen;case"main":return e.mainOpen}}function $2(t){return t.chatOpen||t.blocksOpen||t.mainOpen?t:{...t,chatOpen:!0}}function x0(t,e){return t===1?!0:t===0?!1:e}function pL(t,e){return $2({chatOpen:x0(e.chat,t.chatOpen),blocksOpen:x0(e.blocks,t.blocksOpen),mainOpen:t.mainOpen})}function sa(t,e){switch(t.type){case"toggleChat":return e.chatOpen&&!Lc("chat",e)?null:{chat:e.chatOpen?0:1};case"toggleBlocks":return e.blocksOpen&&!Lc("blocks",e)?null:{blocks:e.blocksOpen?0:1};case"toggleMain":return e.mainOpen?Lc("main",e)?{main:0}:null:{main:t.openMainValue};case"openChat":return e.chatOpen?null:{chat:1}}}function gL(t){const e=t.mainParamValue===0?"0":t.mainParamValue,s=t.entityMetadata?.defaultMainView??null,n=s==null||s.type==="chat",r=s?.type==="blocks",o=t.mainParamPresent&&e==="blocks",a=o?!1:t.mainParamPresent?e!=="0":!n&&!r,l=o||r?!1:n?!0:t.entityMetadata?.chatDefaultOpen??!1,c=x0(t.blocksParamPresent?t.blocksParamValue:void 0,o||r);return $2({mainOpen:a,chatOpen:l,blocksOpen:c})}function xL(t){const{chatOpen:e,blocksOpen:s,mainOpen:n}=t;return e&&s&&n?{chat:25,blocks:35,main:40}:e&&s?{chat:40,blocks:60,main:0}:e&&n?{chat:33,blocks:0,main:67}:s&&n?{chat:0,blocks:40,main:60}:e?{chat:100,blocks:0,main:0}:s?{chat:0,blocks:100,main:0}:n?{chat:0,blocks:0,main:100}:{chat:0,blocks:0,main:0}}function vL(t,e){switch(t){case"chat":return{chat:1,blocks:0,main:0};case"blocks":return{chat:0,blocks:1,main:0};case"main":return{chat:0,blocks:0,main:e}}}function _L(t,e){const s=St(),n=jo({strict:!1}),r=L9({strict:!1}),{create:o}=Vl(),{locator:a}=Ae(),{virtualMcpId:l,orgSlug:c,isAgentRoute:d}=e,h=n.main===0?"0":n.main,u=gL({entityMetadata:t,mainParamPresent:n.main!==void 0,mainParamValue:h,blocksParamPresent:n.blocks!==void 0,blocksParamValue:n.blocks}),{chatOpen:f,blocksOpen:m,mainOpen:p}=pL(u,n),g={chatOpen:f,blocksOpen:m,mainOpen:p},x=C.useRef(crypto.randomUUID()),v=r.taskId??x.current,_="/$org/$taskId",b=E=>({org:c,taskId:E}),y=d?{virtualmcpid:l}:{},L=(E,I)=>{s({to:_,params:b(v),search:P=>({...P,...E}),replace:I?.replace??!1})};return{taskId:v,mainOpen:p,chatOpen:f,blocksOpen:m,mainParam:h,setTaskId:(E,I)=>{s({to:_,params:b(E),search:P=>{const R={};return I?R.virtualmcpid=I:d&&(R.virtualmcpid=l),R}})},toggleMain:()=>{const E=sa({type:"toggleMain",openMainValue:Ka(t)},g);E&&L(E,{replace:!0})},toggleChat:()=>{const E=sa({type:"toggleChat"},g);E&&L(E,{replace:!0})},toggleBlocks:()=>{const E=sa({type:"toggleBlocks"},g);E&&L(E,{replace:!0})},setMobileSurface:E=>{const I=h&&h!=="0"&&h!=="blocks"?h:Ka(t);L(vL(E,I),{replace:!0})},openChat:()=>{const E=sa({type:"openChat"},g);E&&L(E,{replace:!0})},createNewTask:async()=>{const E=crypto.randomUUID(),I=W5(c,a,v);try{await o({id:E,virtual_mcp_id:l,...I?{branch:I}:{}})}catch{}s({to:_,params:b(E),search:P=>({...y,chat:1})})},openTab:E=>{L({...h==="blocks"&&n.blocks===void 0?{blocks:1}:{},main:E==="0"?0:E},{replace:!0})}}}function B2(t){try{const{hostname:e}=new URL(t);return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="::1"}catch{return!1}}function bL(){if(typeof document>"u")return null;const t=Array.from(document.querySelectorAll("iframe"));for(const e of t){const s=e.getAttribute("src");if(s&&B2(s))return s}return null}function yL(t){const e=t.previewUrl??t.getFallbackPreviewUrl?.()??bL();if(e&&B2(e))return new URL("/.decofile",e).toString();const s=new URLSearchParams({path:"/.decofile"});return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-fetch?${s.toString()}`}function Bl(t,e){const s=B.c(8),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}`:"",r=e?.fetchEnabled??!0;let o;s[0]!==n?(o=Qe.decofile(n),s[0]=n,s[1]=o):o=s[1];let a;s[2]!==t?(a=async()=>{const d=await fetch(yL(t),{cache:"no-store"});if(!d.ok){const h=new Error(`Failed to fetch decofile: ${d.status}`);throw h.status=d.status,h}return await d.json()},s[2]=t,s[3]=a):a=s[3];const l=!!t&&r;let c;return s[4]!==o||s[5]!==a||s[6]!==l?(c={queryKey:o,queryFn:a,enabled:l,staleTime:3e4,retry:SL,retryDelay:LL},s[4]=o,s[5]=a,s[6]=l,s[7]=c):c=s[7],gs(c)}function LL(t){return Dm(5e3,1e3,t,2,0)}function SL(t,e){return e.status!==502&&t<2}function zl(t,e){const s=B.c(9),n=t?`${t.orgSlug}/${t.virtualMcpId}/${t.branch}/${t.previewUrl??""}`:"",r=e?.fetchEnabled??!0,o=t?.previewUrl;let a;s[0]!==n?(a=Qe.liveMeta(n),s[0]=n,s[1]=a):a=s[1];let l;s[2]!==o?(l=async()=>{const u=new URL("/live/_meta",o).href,f=await fetch(u,{cache:"no-store"});if(!f.ok){const m=new Error(`Failed to fetch live meta: ${f.status}`);throw m.status=f.status,m}return await f.json()},s[2]=o,s[3]=l):l=s[3];const c=!!t&&!!o&&r,d=e?.refetchInterval;let h;return s[4]!==a||s[5]!==l||s[6]!==c||s[7]!==d?(h={queryKey:a,queryFn:l,enabled:c,refetchInterval:d,refetchIntervalInBackground:!1,staleTime:3e5,retry:jL,retryDelay:wL},s[4]=a,s[5]=l,s[6]=c,s[7]=d,s[8]=h):h=s[8],gs(h)}function wL(t){return Dm(5e3,1e3,t,2,0)}function jL(t,e){return e.status!==502&&t<3}function rh(t){if(!t.startsWith("#")||!t.includes("@"))return null;const e=t.indexOf("@");return{moduleResolveType:t.slice(1,e),blockId:t.slice(e+1)}}function qr(t){return t.includes("@")}function v0(t){const e=t.lastIndexOf("@");return e<0||e===t.length-1?null:t.slice(e+1)}function oh(t,e){if(t===e)return!0;const s=v0(t);return s?e===s||v0(e)===s:!1}function od(t,e){const s=t.manifest?.blocks??{};for(const[n,r]of Object.entries(s))if(e in r)return n;return null}function z2(t,e){const s=od(t,e);return s!==null&&s.includes("sections")}function CL(t,e){const s=od(t,e);return s!==null&&s.includes("apps")}function kL(t,e){const s=od(t,e);return s!==null&&s.includes("matchers")}function dn(t){return!(/\.\w+$/.test(t)||t==="__proto__"||t==="constructor")}function Fl(t){try{return decodeURIComponent(t).startsWith("Preview ")}catch{return t.startsWith("Preview ")}}const ad="oklch(0.7278 0.151 289)",F2="website/matchers/always.ts",$o="website/matchers/never.ts",wi="website/flags/multivariate.ts",Bo="website/flags/multivariate/section.ts";function Ji(){return{__resolveType:F2}}function vt(t){const e=t.split("/");return(e[e.length-1]??t).replace(/\.(tsx?|jsx?)$/,"").replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())||t}const VL=12,na=8,NL=40;function AL(t){const e=t.type;return e==="array"||Array.isArray(e)&&e.includes("array")}function TL(t,e){let s=t.items;if(!s)return!1;if(typeof s.$ref=="string"&&(s=e(s.$ref)),Array.isArray(s.anyOf)||Array.isArray(s.oneOf))return!0;const r=s.properties?.__resolveType?.enum;return Array.isArray(r)&&typeof r[0]=="string"}const EL="VideoWidget";function U2(t){return typeof btoa=="function"?btoa(t):Buffer.from(t).toString("base64")}function ld(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function cd(t){const e=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return e?{vendor:e[1],app:e[2]}:null}function H2(t,e){return[`site/apps/${t}/${e}.ts`,`site/apps/${t}/${e}.tsx`,`${t}/apps/${e}.ts`,`${t}/apps/${e}.tsx`]}function dd(t,e){const s=e.manifest?.blocks??{};for(const l of Object.values(s))if(l[t])return l[t];const n=ld(t)??cd(t);if(n){for(const l of H2(n.vendor,n.app))for(const c of Object.values(s))if(c[l])return c[l]}const r=U2(t);for(const l of Object.values(s))if(l[r])return l[r];const o=e.schema??{};return(o.$defs??o.definitions??{})[r]?{$ref:`#/definitions/${r}`}:{}}function K2(t,e){if(CL(t,e))return!0;const s=ld(e)??cd(e);if(!s)return!1;const n=t.manifest?.blocks?.apps??{};if(H2(s.vendor,s.app).some(a=>a in n))return!0;const r=U2(e),o=t.schema?.$defs??t.schema?.definitions??{};return r in o}function W2(t){return t==="site/apps/site.ts"?!1:ld(t)!==null||cd(t)!==null}function Ln(t,e){const s=e.schema??{},n=dd(t,e),r=s.$defs??s.definitions??{},o=s.root??{},a=v=>{if(v.startsWith("#/root/")){const b=v.slice(7);return o[b]??{}}const _=v.split("/").pop()??"";return r[_]??{}};let l;typeof n.$ref=="string"?l=a(n.$ref):Object.keys(n).length>0?l=n:l=s;const c=v=>typeof v.$ref=="string"?a(v.$ref):v,d=v=>{const b=c(v).properties?.type;if(b){if(typeof b.const=="string")return b.const;if(typeof b.default=="string")return b.default;if(Array.isArray(b.enum)&&typeof b.enum[0]=="string")return b.enum[0]}},h=(v,_)=>{const b=c(v);return typeof b.title=="string"&&!b.title.startsWith("#")?b.title:_},u=(v,_=new Set)=>{if(typeof v.$ref!="string"||v.properties||v.anyOf||v.allOf||v.oneOf||v.type)return v;const b=v.$ref.split("/").pop()??"";return!b||_.has(b)?v:u(a(v.$ref),new Set([..._,b]))},f=v=>{const _=v.hide;return _===!0||_==="true"},m=(v,_=new Set,b=0)=>{if(b>VL)return{};if(typeof v.$ref=="string"){const L=v.$ref.split("/").pop()??"";return _.has(L)?{}:m(a(v.$ref),new Set([..._,L]),b+1)}let y={};if(v.properties&&typeof v.properties=="object"&&(y={...y,...v.properties}),Array.isArray(v.required)){const L=Array.isArray(y.__required)?y.__required:[];y.__required=[...L,...v.required]}for(const L of["allOf","anyOf","oneOf"]){const w=v[L];if(Array.isArray(w))for(const S of w)y={...y,...m(S,_,b+1)}}return y},p=(v,_=0,b=new Set)=>{let y=v,L;if(typeof v.$ref=="string"){y=a(v.$ref);const P=v.$ref.split("/").pop()??"";L=P,P===EL&&!y.format&&(y={...y,format:"video-uri"})}y=u(y);const w=L!==void 0&&b.has(L),S=L!==void 0?new Set([...b,L]):b,j=(P,R,D,M=!0)=>!w&&(!M||D<=NL)&&R<na?p(P,R,S):void 0;let k;{const P=y.anyOf??y.oneOf;if(Array.isArray(P)){const R=P.filter(M=>!(M.type==="null"||M.type===null)),D=M=>{if(typeof M.const=="string"||typeof M.const=="number")return M.const;if(Array.isArray(M.enum)&&M.enum.length===1&&(typeof M.enum[0]=="string"||typeof M.enum[0]=="number"))return M.enum[0]};R.length>0&&R.every(M=>D(M)!==void 0)&&(k=R.map(M=>D(M)))}}let V,T;if(y.type)V=Array.isArray(y.type)?String(y.type.find(P=>P!=="null")??y.type[0]):String(y.type);else if(y.anyOf||y.allOf||y.oneOf){const R=(y.anyOf??y.allOf??y.oneOf).filter(D=>!(D.type==="null"||D.type===null));if(R.length===0)V="null";else if(R.length===1){const D=R[0];T=D,V=D.type?Array.isArray(D.type)?String(D.type[0]):String(D.type):typeof D.$ref=="string"?"object":"string"}else{if(k)return{type:"string",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,enum:k};const D=R.filter(G=>{const W=G.properties?.__resolveType?.enum;return Array.isArray(W)&&typeof W[0]=="string"}),M=R.find(AL),F=D.some(G=>{const W=G.properties?.__resolveType?.enum;return Array.isArray(W)&&W[0]===wi});if(M){if(!TL(M,a)&&R.length>1){const W=p(M,_+1,S);return{...W,type:"array",title:typeof y.title=="string"?y.title:W.title,description:typeof y.description=="string"?y.description:W.description}}if(F){const W=p(M,_+1,S);return{...W,type:"array",title:typeof y.title=="string"?y.title:W.title,description:typeof y.description=="string"?y.description:W.description}}}if(D.length>0){const G=D.map(Y=>{const te=Y.properties?.__resolveType?.enum??[],ae=String(te[0]);return{resolveType:ae,title:typeof Y.title=="string"?Y.title:vt(ae),description:typeof Y.description=="string"?Y.description:void 0,schema:j(Y,_+1,R.length)}}),W=[];for(const Y of R){if(D.includes(Y)||typeof Y.$ref!="string")continue;const ee=a(Y.$ref);let te;const ae=ee.properties?.__resolveType;if(Array.isArray(ae?.enum)&&typeof ae.enum[0]=="string"&&(te=ae.enum[0]),!te&&Array.isArray(ee.allOf))for(const se of ee.allOf){const ie=se.properties?.__resolveType?.enum;if(Array.isArray(ie)&&typeof ie[0]=="string"){te=ie[0];break}}te&&W.push({resolveType:te,title:typeof ee.title=="string"&&!ee.title.startsWith("#")?ee.title:vt(te),description:typeof ee.description=="string"?ee.description:void 0,schema:j(ee,_+1,R.length)})}const z=new Set(G.map(Y=>Y.resolveType)),X=[...G,...W.filter(Y=>!z.has(Y.resolveType))],Q=R.filter(Y=>!D.includes(Y)),Z=Q.length===1?j(Q[0],_+1,R.length):void 0;return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:X,plainSchema:Z,hidden:f(y)||f(v)?!0:void 0}}const $=R.map(G=>d(G));if(R.length>1&&$.every(G=>typeof G=="string")){const G=R.map((W,z)=>{const X=c(W),Q=$[z];return{resolveType:Q,title:h(W,Q),description:typeof X.description=="string"?X.description:void 0,discriminatorValue:Q,schema:j(X,_+1,R.length,!1)}});return{type:"block-ref",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:void 0,discriminatorKey:"type",anyOfRefs:G,hidden:f(y)||f(v)?!0:void 0}}const U=G=>{const W=c(G);if(typeof W.title=="string"&&rh(W.title))return!0;const z=W.properties?.__resolveType?.enum;if(Array.isArray(z)&&typeof z[0]=="string")return!0;if(Array.isArray(W.allOf))for(const X of W.allOf){const Q=X.properties?.__resolveType?.enum;if(Array.isArray(Q)&&typeof Q[0]=="string")return!0}return!1},K=G=>{if(U(G))return!1;const W=c(G);return W.type==="object"||!!W.properties},q=(Array.isArray(y.anyOf)||Array.isArray(y.oneOf))&&_<na&&R.every(K);if(R.every(G=>typeof G.$ref=="string")&&!q){const G=[];for(const W of R){const z=a(W.$ref);let X,Q;if(typeof z.title=="string"){const Y=rh(z.title);Y&&(X=Y.blockId,Q=Y.blockId)}if(!X&&Array.isArray(z.allOf))for(const Y of z.allOf){const ae=((Y.properties??{}).__resolveType??{}).enum;if(Array.isArray(ae)&&typeof ae[0]=="string"){X=ae[0];break}}if(!X){const ee=z.properties?.__resolveType?.enum;Array.isArray(ee)&&typeof ee[0]=="string"&&(X=ee[0])}X||(X=W.$ref.split("/").pop()??"");const Z=d(W);!Z&&!X.includes("/")||G.push({resolveType:Z??X,title:Q??(typeof z.title=="string"&&!z.title.startsWith("#")?z.title:vt(X)),description:typeof z.description=="string"?z.description:void 0,discriminatorValue:Z,schema:j(z,_+1,R.length)})}return{type:"block-ref",title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,anyOfRefs:G,hidden:f(y)||f(v)?!0:void 0}}if(q){const G=z=>{if(typeof z.const=="string"||typeof z.const=="number"||typeof z.const=="boolean")return z.const;if(Array.isArray(z.enum)&&z.enum.length===1&&(typeof z.enum[0]=="string"||typeof z.enum[0]=="number"||typeof z.enum[0]=="boolean"))return z.enum[0]},W=R.map((z,X)=>{const Q=c(z).properties??{},Z={};for(const[Y,ee]of Object.entries(Q)){const te=G(ee);te!==void 0&&(Z[Y]=te)}return{title:h(z,`Option ${X+1}`),schema:p(z,_+1),discriminators:Object.keys(Z).length?Z:void 0}});return{type:"inline-union",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:void 0,description:typeof y.description=="string"?y.description:void 0,inlineUnionBranches:W,hidden:f(y)||f(v)?!0:void 0}}V="object"}}else typeof v.$ref=="string"&&(V="object");let A;if(_<na){const P=m(y),R=Object.entries(P).filter(([D])=>!D.startsWith("__")&&D!=="@type");if(R.length>0){A={};for(const[D,M]of R)A[D]=p(M,_+1,S)}}let N;if((V==="array"||y.type==="array")&&_<na){let P=y.items;P&&(typeof P.$ref=="string"&&(P=a(P.$ref)),N=p(P,_+1,S),typeof P.title=="string"&&P.title.includes("{{")&&(N.titleBy=P.title))}const E=P=>{const R=T?.[P];return typeof R=="string"?R:void 0},I=()=>{if("default"in v)return v.default;if("default"in y)return y.default;if(T&&"default"in T)return T.default};return{type:V??"string",title:typeof v.title=="string"?v.title:typeof y.title=="string"?y.title:E("title"),description:typeof v.description=="string"?v.description:typeof y.description=="string"?y.description:E("description"),default:I(),enum:Array.isArray(y.enum)?y.enum:k??void 0,format:typeof y.format=="string"?y.format:E("format"),properties:A,items:N,hidden:f(y)||f(v)?!0:void 0,titleBy:typeof y.titleBy=="string"?y.titleBy:E("titleBy"),image:typeof y.image=="string"?y.image:E("image"),options:typeof y.options=="string"?y.options:E("options")}},g=m(l),x={};for(const[v,_]of Object.entries(g))v.startsWith("__")||v==="@type"||(x[v]=p(_,0));return Object.keys(x).length===0?null:{type:"object",title:typeof l.title=="string"?l.title:void 0,properties:x}}function RL(t,e){const s=e.schema??{},n=dd(t,e),r=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?r[n.$ref.split("/").pop()??""]??{}:n,a=o.properties??{};if(Object.keys(a).some(d=>!d.startsWith("__")))return!1;if(o.additionalProperties===!0)return!0;const c=a.__resolveType;return!!c&&Array.isArray(c.enum)&&c.enum[0]===t}function PL(t){const e=n=>{switch(typeof n){case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"object":{if(n===null)return{type:"string"};if(Array.isArray(n))return{type:"array",items:e(n[0])};const r={};for(const[o,a]of Object.entries(n))o.startsWith("__")||(r[o]=e(a));return{type:"object",properties:r}}default:return{type:"string"}}},s={};for(const[n,r]of Object.entries(t))n.startsWith("__")||(s[n]=e(r));return Object.keys(s).length===0?null:{type:"object",properties:s}}function Jn(t,e){const s=e.schema??{},n=dd(t,e),r=s.$defs??s.definitions??{},o=typeof n.$ref=="string"?r[n.$ref.split("/").pop()??""]??{}:Object.keys(n).length>0?n:{...s,...n},a=o.icon,l=o.logo,c=o,d=u=>u===!0||u==="true",h=d(c.hide)||d(c.ignore)||d(c.unlisted);return{title:typeof o.title=="string"?o.title:void 0,description:typeof o.description=="string"?o.description:void 0,icon:typeof a=="string"?a:void 0,logo:typeof l=="string"?l:void 0,hidden:h||void 0}}function IL(t,e){if(!t||!e?.length)return t;const s=Object.fromEntries(Object.entries(t.properties??{}).filter(([n])=>!e.includes(n)));return Object.keys(s).length>0?{...t,properties:s}:t}function DL(t,e,s){return typeof t!="string"?null:IL(Ln(t,e),s)}function q2(t,e,s){if(!e||typeof t!="string")return!1;const n=DL(t,e,s);return!!n&&Object.keys(n.properties??{}).length>0}const ML=700;function Ul(t){const e=B.c(21),{orgSlug:s,virtualMcpId:n,branch:r}=t,o=os();let a;e[0]!==r||e[1]!==s||e[2]!==n?(a=async u=>{const{blockKey:f,data:m}=u,p=Lm(f),g=JSON.stringify(m,null,2),x=await fetch(`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/write`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:p,content:g})});if(!x.ok){const v=await x.json().catch(OL);throw new Error(v.error??`Write failed (${x.status})`)}return x.json()},e[0]=r,e[1]=s,e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r||e[5]!==s||e[6]!==o||e[7]!==n?(l=async u=>{const{blockKey:f,data:m}=u,p=`${s}/${n}/${r}`,g=Qe.decofile(p);await o.cancelQueries({queryKey:g});const x=o.getQueryData(g);return o.setQueryData(g,v=>({...v??{},[f]:m})),{previous:x,queryKey:g}},e[4]=r,e[5]=s,e[6]=o,e[7]=n,e[8]=l):l=e[8];let c;e[9]!==o?(c=(u,f,m)=>{m?.queryKey&&o.setQueryData(m.queryKey,m.previous)},e[9]=o,e[10]=c):c=e[10];let d;e[11]!==r||e[12]!==s||e[13]!==o||e[14]!==n?(d=(u,f)=>{const{blockKey:m,data:p}=f,g=`${s}/${n}/${r}`;o.setQueryData(Qe.decofile(g),x=>({...x??{},[m]:p}))},e[11]=r,e[12]=s,e[13]=o,e[14]=n,e[15]=d):d=e[15];let h;return e[16]!==a||e[17]!==l||e[18]!==c||e[19]!==d?(h={mutationFn:a,onMutate:l,onError:c,onSuccess:d},e[16]=a,e[17]=l,e[18]=c,e[19]=d,e[20]=h):h=e[20],Ds(h)}function OL(){return{}}function G2(t,e){const s=B.c(15),n=Ul(t);let r;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=new Map,s[0]=r):r=s[0];const o=C.useRef(r);let a;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=new Map,s[1]=a):a=s[1];const l=C.useRef(a);let c;s[2]!==e||s[3]!==n?(c=v=>{const _=o.current.get(v);if(!_)return;const b=typeof _=="function"?_():_;o.current.delete(v),b&&n.mutate({blockKey:v,data:b},{onSuccess:()=>e?.onSaved?.(),onError:$L})},s[2]=e,s[3]=n,s[4]=c):c=s[4];const d=c;let h;s[5]!==d?(h=()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear();for(const v of[...o.current.keys()])d(v)},s[5]=d,s[6]=h):h=s[6];const u=h;let f,m;s[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{const v=l.current;return()=>{for(const _ of v.values())clearTimeout(_)}},m=[],s[7]=f,s[8]=m):(f=s[7],m=s[8]),C.useEffect(f,m);let p;s[9]!==d?(p=(v,_)=>{o.current.set(v,_);const b=l.current.get(v);b&&clearTimeout(b),l.current.set(v,setTimeout(()=>{l.current.delete(v),d(v)},ML))},s[9]=d,s[10]=p):p=s[10];const g=p;let x;return s[11]!==u||s[12]!==g||s[13]!==n.isPending?(x={save:g,flush:u,isPending:n.isPending},s[11]=u,s[12]=g,s[13]=n.isPending,s[14]=x):x=s[14],x}function $L(t){return ce.error(`Save failed: ${t.message}`)}function BL({orgSlug:t,virtualMcpId:e,branch:s}){const n=os();return Ds({mutationFn:async({blockKey:r})=>{const o=Lm(r),a=await fetch(`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/unlink`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:o})});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error??`Delete failed (${a.status})`)}return a.json()},onMutate:async({blockKey:r})=>{const o=`${t}/${e}/${s}`,a=Qe.decofile(o);await n.cancelQueries({queryKey:a});const l=n.getQueryData(a);return n.setQueryData(a,c=>{if(!c)return c;const{[r]:d,...h}=c;return h}),{previous:l,queryKey:a}},onError:(r,o,a)=>{a?.queryKey&&n.setQueryData(a.queryKey,a.previous)},onSuccess:()=>{const r=`${t}/${e}/${s}`;n.invalidateQueries({queryKey:Qe.liveMeta(r)})}})}function ai(t){return t.replace(/\/+$/,"")||"/"}function zL(t){const e=t.trim();return!(!e.startsWith("/")||e.startsWith("//")||e.includes("..")||e.includes("\\"))}function ud(t){const e=t.trim();return e?zL(e)?null:"Path must start with / and must not contain .. or //.":"Path is required."}const Y2=/:([A-Za-z0-9_-]+)|\*/g;function _0(t){const e=[];let s=0;for(const n of t.matchAll(Y2))n.index>s&&e.push({type:"text",text:t.slice(s,n.index)}),e.push({type:"param",name:n[1]??"*"}),s=n.index+n[0].length;return s<t.length&&e.push({type:"text",text:t.slice(s)}),e}function Sr(t,e){return t.replace(Y2,(s,n)=>{const r=e[n??"*"]?.trim();return r?n!==void 0?encodeURIComponent(r):r.split("/").filter(Boolean).map(encodeURIComponent).join("/")||s:s})}const FL=["website/sections/Rendering/Lazy.tsx","website/sections/Rendering/SingleDeferred.tsx"],ah="website/sections/Rendering/Lazy.tsx";function ss(t){return FL.some(e=>t.endsWith(e))}const J2=["website/pages/Page.tsx","$live/pages/LivePage.tsx"],X2=new Set(J2),UL=new Set(["site/sections/Theme/Theme.tsx"]);function Hl(t){return!!(UL.has(t)||ss(t)||t.toLowerCase().includes("preview"))}function b0(t){const e=t.manifest?.blocks??{};for(const s of Object.values(e))for(const n of Object.keys(s))if(X2.has(n))return n;return J2[0]}function y0(t){if(!t)return[];if(t.anyOfRefs?.length)return t.anyOfRefs;if(t.items)return y0(t.items);if(t.properties){const e=[];for(const s of Object.values(t.properties))e.push(...y0(s));return e}return[]}function HL(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(r)){if(Hl(o))continue;const a=Jn(o,t);s.push({resolveType:o,title:a.title??vt(o),description:a.description,previewBlock:o,isSavedBlock:!1})}return s}function KL(t){const e=t.manifest?.blocks??{},s=[];for(const[n,r]of Object.entries(e))if(n.includes("sections"))for(const o of Object.keys(r))Hl(o)||s.push({resolveType:o,title:vt(o)});return s.sort((n,r)=>n.title.localeCompare(r.title))}function Q2(t,e){const s=[];for(const[n,r]of Object.entries(e)){if(n.includes("/")||Fl(n)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(X2.has(a)||typeof o.path!="string"&&(Hl(a)||z2(t,a)&&s.push({resolveType:n,title:n,description:typeof o.name=="string"?o.name:void 0,previewBlock:n,isSavedBlock:!0})))}return s}function WL(t,e){const s=dn(e.resolveType),n=s?{}:Jn(e.resolveType,t);return{resolveType:e.resolveType,title:e.title||n.title||vt(e.resolveType),description:e.description??n.description,previewBlock:e.resolveType,isSavedBlock:s}}function Xz(t,e){const s=b0(t),n=Ln(s,t),r=y0(n?.properties?.sections),o=new Map,a=l=>{if(!Hl(l.resolveType)){if(dn(l.resolveType)){Fl(l.resolveType)||o.set(l.resolveType,l);return}z2(t,l.resolveType)&&(o.has(l.resolveType)||o.set(l.resolveType,l))}};for(const l of HL(t))a(l);for(const l of r)a(WL(t,l));for(const l of Q2(t,e))a(l);return[...o.values()].sort((l,c)=>l.title.localeCompare(c.title))}function Qz(t){const e=t.site;if(!e||typeof e!="object"||Array.isArray(e))return;const s=e.theme;if(!(!s||typeof s!="object"||Array.isArray(s)))return s}function qL(t){let e=t;e.startsWith("pages-")&&(e=e.slice(6)),e=e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,""),e=e.replace(/-[0-9a-f]{8,}$/i,"");try{return decodeURIComponent(e)}catch{return e}}function GL(t,e,s){const n=ai;if(s){const o=t.find(a=>a.key===s);if(o)return o}const r=t.filter(o=>n(o.path)===n(e));return r.length===0?null:r.length===1?r[0]??null:[...r].sort((o,a)=>o.key.localeCompare(a.key))[0]??null}const Z2=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]),Mr="site",hd="site/apps/site.ts";function ol(t,e){return t===Mr?!0:e.__resolveType===hd}function fd(t,e){return t?md(t).length>0?!0:e?pd(t,e).length>0||L0(t,e)?!0:YL(t,e).length>0:!1:!1}function md(t){const e=[];for(const[s,n]of Object.entries(t))if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;typeof r.__resolveType=="string"&&Z2.has(r.__resolveType)&&typeof r.path=="string"&&e.push({key:s,name:typeof r.name=="string"?r.name:qL(s),path:r.path})}return e}function Kl(t,e){if(typeof e.name=="string"){const s=e.name.trim();if(s)return s}return t.replace(/[-_]/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function al(t,e,s){const n=typeof e.__resolveType=="string"?e.__resolveType:"",r=n?Jn(n,s):{};if(r.title)return r.title;if(typeof e.name=="string"){const o=e.name.trim();if(o)return o}return t.replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase())}function L0(t,e){const s=t[Mr];if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s,r=n.__resolveType;if(typeof r=="string"&&(ol(Mr,n)||K2(e,r)))return{key:Mr,name:al(Mr,n,e),resolveType:r}}for(const[n,r]of Object.entries(t)){if(n.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;if(!ol(n,o))continue;const a=typeof o.__resolveType=="string"?o.__resolveType:hd;return{key:n,name:al(n,o,e),resolveType:a}}return null}function YL(t,e){const s=[];for(const[n,r]of Object.entries(t)){if(n.includes("/")||!r||typeof r!="object"||Array.isArray(r))continue;const o=r,a=o.__resolveType;typeof a=="string"&&(Z2.has(a)||typeof o.path!="string"&&(ol(n,o)||!K2(e,a)&&!W2(a)||s.push({key:n,name:al(n,o,e),resolveType:a})))}return s.sort((n,r)=>n.name.localeCompare(r.name))}function pd(t,e){return Q2(e,t).map(s=>{const n=t[s.resolveType],r=typeof n.__resolveType=="string"?n.__resolveType:"";return{key:s.resolveType,name:s.description??Kl(s.resolveType,n),resolveType:r}}).sort((s,n)=>s.name.localeCompare(n.name))}function Wl(t,e){return`${t}-${e}`}function ep(t,e){return`site/apps/${t}/${e}.ts`}function tp(t){const e=t.match(/^site\/apps\/([^/]+)\/([^/.]+)\.tsx?$/);if(e)return{vendor:e[1],app:e[2]};const s=t.match(/^([^/]+)\/apps\/([^/.]+)\.tsx?$/);return s?{vendor:s[1],app:s[2]}:null}function JL(t){const e=t.match(/^([^-]+)-(.+)$/);return e?{vendor:e[1],app:e[2]}:null}function XL(t){return t==="local"?"Custom":"Installed"}function sp(t,e,s){const n=new Set([Wl(t,e),e].map(o=>o.toLowerCase())),r=ep(t,e);for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=a;if(n.has(o.toLowerCase())||l.__resolveType===r)return o}return null}function QL(t,e){const s=t.vendor.alias,n=t.name,r=sp(s,n,e);return{id:Wl(s,n),app:n,vendor:s,title:t.title||t.name,description:t.description,category:t.category??"Other",logo:t.logo||void 0,resolveType:ep(s,n),blockKey:r,installed:r!==null}}function ZL(t,e,s){if(t===hd)return null;const n=tp(t);if(!n)return null;const{vendor:r,app:o}=n,a=sp(r,o,s),l=Jn(t,e);return{id:Wl(r,o),app:o,vendor:r,title:l.title??o,description:l.description??"",category:"Others",logo:l.logo??l.icon,resolveType:t,blockKey:a,installed:a!==null}}function e7(t,e,s){const n=e.__resolveType;if(typeof n!="string"||ol(t,e)||!W2(n))return null;const r=tp(n)??JL(t);if(!r)return null;const o=Jn(n,s),{vendor:a,app:l}=r;return{id:Wl(a,l),app:l,vendor:a,title:o.title??al(t,e,s),description:o.description??"",category:XL(a),logo:o.logo??o.icon,resolveType:n,blockKey:t,installed:!0}}function t7(t,e,s){const n=new Map;for(const o of t){const a=QL(o,s);n.set(a.id,a)}const r=e.manifest?.blocks?.apps??{};for(const o of Object.keys(r)){const a=ZL(o,e,s);!a||n.has(a.id)||n.set(a.id,a)}for(const[o,a]of Object.entries(s)){if(o.includes("/")||!a||typeof a!="object"||Array.isArray(a))continue;const l=e7(o,a,e);!l||n.has(l.id)||n.set(l.id,l)}return[...n.values()].sort(s7)}function s7(t,e){return t.installed!==e.installed?t.installed?-1:1:t.title.localeCompare(e.title)}async function n7(){const t=await fetch("/api/deco-apps");if(!t.ok)throw new Error(`Failed to fetch deco apps: ${t.status}`);return(await t.json()).apps??[]}function i7(t,e,s){const n=B.c(12),r=s?.enabled??!0;let o;n[0]===Symbol.for("react.memo_cache_sentinel")?(o=Qe.decoApps(),n[0]=o):o=n[0];let a;n[1]!==r?(a={queryKey:o,queryFn:n7,staleTime:3e5,retry:1,enabled:r},n[1]=r,n[2]=a):a=n[2];const l=gs(a);let c;n[3]!==e||n[4]!==t||n[5]!==l.data?(c=t&&e?t7(l.data??[],t,e):[],n[3]=e,n[4]=t,n[5]=l.data,n[6]=c):c=n[6];const d=c,h=l.isLoading&&!l.isError;let u;return n[7]!==d||n[8]!==l.isError||n[9]!==l.refetch||n[10]!==h?(u={catalog:d,isLoading:h,isError:l.isError,refetch:l.refetch},n[7]=d,n[8]=l.isError,n[9]=l.refetch,n[10]=h,n[11]=u):u=n[11],u}const r7=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function o7(t){return t.includes("matchers")||t.includes("Match")}function np(t,e){const s=t.__resolveType;return typeof s!="string"||!s||r7.has(s)?!1:e?kL(e,s):o7(s)}function a7(t,e){const s=[];for(const[n,r]of Object.entries(e)){if(n.includes("/")||!dn(n)||Fl(n)||!r||typeof r!="object"||Array.isArray(r))continue;const o=r;np(o,t)&&s.push({blockKey:n,matcherResolveType:o.__resolveType??"",name:typeof o.name=="string"?o.name:void 0})}return s.sort((n,r)=>(n.name??n.blockKey).localeCompare(r.name??r.blockKey))}function zo(t,e,s){if(!t)return!1;const n=t.__resolveType;if(typeof n!="string"||!dn(n)||!Object.hasOwn(e,n))return!1;const r=e[n];return!r||typeof r!="object"||Array.isArray(r)?!1:np(r,s)}function Zz(t,e,s){return zo(t,e,s)?t?.__resolveType??null:null}function ip(t,e,s){if(!t)return null;const n=t.__resolveType??"";if(!n)return null;if(zo(t,e,s)){const a=e[n]??{},l=a.__resolveType??n,{__resolveType:c,name:d,...h}=a;return{resolveType:l,data:h,blockKey:n}}const{__resolveType:r,...o}=t;return{resolveType:n,data:o}}function rp(t,e,s){const n=ip(t,e,s);return n?{__resolveType:n.resolveType,...n.data}:{__resolveType:""}}function eF(t,e,s){if(t)return zo(t,e,s)?rp(t,e,s):t}function l7(t,e,s,n){if(!t)return"Default";if(zo(t,e,n)){const r=t.__resolveType??"",o=e[r];return Kl(r,o)}return s(t)}function tF(t,e,s){return{__resolveType:t,...e,name:s}}function c7(t){return{__resolveType:t}}function sF(t,e,s){const n=ip(t,e,s);return n?{resolveType:n.resolveType,formValue:n.data}:{resolveType:"",formValue:{}}}function op(t){const e=t.__resolveType??"";return ss(e)?t.section??t:t}function ll(t){const r=(ss(t.__resolveType??"")?t.section:t)?.variants?.[0];return r?.rule?.__resolveType!==$o?null:r?.value??null}function nF(t){const e=op(t);return{__resolveType:Bo,variants:[{value:e,rule:{__resolveType:$o}}]}}function iF(t){const e=t.__resolveType??"";if(!e)return null;if(ss(e))return t.section??null;const s=ll(t);return s?ss(s.__resolveType??"")?s:{__resolveType:ah,section:op(s)}:{__resolveType:ah,section:t}}function ia(t){const e=t.__resolveType??"";if(!e)return null;if(ss(e)){const s=t.section,n=s?.__resolveType??"";return!n||!s?null:{resolveType:n,data:s}}return{resolveType:e,data:t}}function rF(t){const e=ll(t);if(e)return ia(e);if(ss(t.__resolveType??"")){const n=t.section;if(!n)return null;const r=ll(n);return ia(r||n)}return ia(t)}function oF(t){return ll(t)}const d7=["website/matchers/always.ts","$live/matchers/MatchAlways.ts"];function gd(t){if(!t)return!1;const e=t.__resolveType??"";return e===""?Object.keys(t).length===0:d7.includes(e)||e.includes("always")}function u7(t){const e=t.variants??[];if(e.length===0)return-1;const s=e.findIndex(n=>gd(n.rule));return s!==-1?s:e.length-1}function aF(t,e,s){const n=s.variants??[];if(n.length===0)return null;const r=u7(s),o=n[r]?.value;if(!o)return null;const a=structuredClone(o);return e.isLazy?{...t,section:a}:a}function ap(t,e){return e.isMultivariate?e.isLazy?t.section??null:t:null}function lF(t,e){return Array.isArray(t.variants)?t.variants.map((s,n)=>({label:e(s.rule)||`Variant ${n+1}`,value:s.value??{},rule:s.rule})):[]}function cF(t,e){const s=t.__resolveType??"";if(!s)return null;if(ss(s)){const n=t.section??t,r=n.__resolveType??s;if(!r.includes("/")&&r in e){const o=e[r]??{};return{data:{...o},resolveType:o.__resolveType??r}}return{data:{...n},resolveType:r}}if(!s.includes("/")&&s in e){const n=e[s]??{};return{data:{...n},resolveType:n.__resolveType??s}}return{data:{...t},resolveType:s}}function h7(t,e){const s=t.__resolveType??"";return ss(s)?{...t,section:e}:e}function f7(t,e,s){return e.isLazy?{...t,section:s}:s}function dF(t,e,s){const n=[...t.variants??[]],r=n[e];if(!r)return t;const o=r.value??{};return n[e]={...r,value:h7(o,s)},{...t,variants:n}}function uF(t,e,s){const n=[...t.variants??[]];return n[e]?(n[e]={...n[e],rule:s},{...t,variants:n}):t}function hF(t,e){const s=[...t.variants??[]],n=s[e];return n?(s.splice(e+1,0,structuredClone(n)),{...t,variants:s}):t}function fF(t,e,s){const n=[...t.variants??[]];if(e===s||e<0||s<0||e>=n.length||s>=n.length)return t;const[r]=n.splice(e,1);return r?(n.splice(s,0,r),{...t,variants:n}):t}function mF(t,e){const s=[...t.variants??[]];return s.length<=1?null:(s.splice(e,1),{...t,variants:s})}function S0(t){return{rule:Ji(),value:structuredClone(t)}}function lp(t,e){return{...e,__resolveType:Bo,variants:t}}function pF(t){return t.isHidden!==!0&&t.isSavedBlock!==!0}function m7(t,e){if(e.isHidden)return null;if(e.isMultivariate){const n=ap(t,e)?.variants??[],r=n[n.length-1]?.value;return r?structuredClone(r):null}if(e.isLazy){const s=t.section;return s?structuredClone(s):null}return structuredClone(t)}function p7(t,e,s){if(e.isMultivariate||e.isHidden)return null;const n=m7(t,e);if(!n)return null;const r=lp([S0(n),S0(n)]);return e.isLazy?{...t,section:r}:r}function gF(t,e,s){if(e.isHidden||e.isSavedBlock)return null;if(e.isMultivariate){const r=ap(t,e);if(!r)return null;const o=r.variants??[],a=o[o.length-1]?.value;if(!a)return null;const l=lp([...o,S0(a)],r);return{section:f7(t,e,l),newVariantIndex:o.length}}const n=p7(t,e);return n?{section:n,newVariantIndex:1}:null}const g7=new Set(["website/pages/Page.tsx","$live/pages/LivePage.tsx"]);function ql(t){return t.anyOfRefs?.some(e=>e.resolveType!==wi?!1:e.schema?.properties?.variants?.items?.properties?.value?.type==="array")??!1}function cl(t){return!t||typeof t!="object"||Array.isArray(t)?!1:t.__resolveType===wi}function x7(t){if(!cl(t))return null;const e=t.variants;if(!Array.isArray(e))return null;const s=e[0]?.value;return Array.isArray(s)?s:null}function v7(t,e){if(!cl(t))return e;const s=structuredClone(t),n=[...s.variants??[]];return n.length===0?n.push({rule:Ji(),value:e}):n[0]={...n[0],value:e},{...s,variants:n}}function _7(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;return typeof e.__resolveType=="string"&&g7.has(e.__resolveType)&&typeof e.path=="string"}function cp(t,e){const n=t[e]?.sections;if(!n||Array.isArray(n))return 1;const r=n;return Array.isArray(r.variants)?r.variants.length:1}function b7(t,e,s){const r=t[e]?.sections;if(Array.isArray(r))return s===0?r:[];if(r&&typeof r=="object"){const o=r.variants;if(Array.isArray(o)){const a=o[s];return Array.isArray(a?.value)?a.value:[]}}return[]}function xF(t,e,s){if(Array.isArray(t))return[{label:"Default",sections:t}];if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.variants)){const r=n.variants,o=r.map(c=>l7(c.rule,e,s)),a=o.reduce((c,d)=>(c[d]=(c[d]??0)+1,c),{}),l={};return r.map((c,d)=>{const h=o[d]??`Variant ${d+1}`,u=a[h]??1;let f=h;return u>1&&(l[h]=(l[h]??0)+1,f=`${h} ${l[h]}`),{label:f||`Variant ${d+1}`,sections:Array.isArray(c.value)?c.value:[],rule:c.rule}})}}return[]}function wr(t){return{rule:Ji(),value:t}}function Oi(t,e){return{...e,__resolveType:wi,variants:t}}function y7(t,e){const s=structuredClone(e);if(Array.isArray(t))return Oi([wr(t),wr(s)]);if(t&&typeof t=="object"){const n=t;return Array.isArray(n.variants)?Oi([...n.variants,wr(s)],n):null}return Oi([wr([]),wr(s)])}function vF(t){const e=t.variants;return Array.isArray(e)?e.length-1:1}function _F(t,e){const s=t[e];if(!s)return null;const n=[...t];return n.splice(e+1,0,structuredClone(s)),n}function bF(t,e){if(e.length===0)return Oi([],t);if(e.length===1){const s=e[0],n=s?.rule;if(!gd(n))return Oi(e,t);if(Array.isArray(s?.value))return s.value}return Oi(e,t)}function L7(t,e){for(const[s,n]of Object.entries(t)){if(!_7(n))continue;const r=n.sections;if(Array.isArray(r)){e(void 0,s,0);continue}if(!r||typeof r!="object")continue;const o=r.variants;if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a];e(l?.rule,s,a)}}}function yF(t,e,s){let n=0;return L7(t,r=>{if(!r)return;(r.__resolveType??"")===e&&zo(r,t,s)&&n++}),n}function LF(t,e,s,n,r){const o={...t[e]};if(r.length>1){const a=o.sections,l=[...a?.variants??[]];l[n]&&(l[n]={...l[n],value:s}),o.sections={...a,variants:l}}else o.sections=s;return o}function SF(t){return structuredClone(t)}function wF(t){return!t.isSavedBlock&&!t.isMultivariate&&!t.isHidden}function dp(t){const e=t.replace(/[^A-Za-z0-9_ -]/g,"").replace(/\s+/g," ").trim();return/^[A-Za-z]/.test(e)?e:e?`Block ${e}`:""}function xd(t,e){const s=t.trim();return s?s.includes("/")?"Block name cannot contain slashes.":Object.hasOwn(e,s)?"A block with this name already exists.":/^[A-Za-z][A-Za-z0-9_ -]*$/.test(s)?null:"Use letters, numbers, spaces, hyphens, or underscores. Must start with a letter.":"Block name is required."}function up(t){return(e,s)=>{Yx(e),t(e,s)}}var S7=N5.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(s=>e.updateAttributes(s,{textAlign:t})).some(s=>s):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:s})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?s.unsetTextAlign():s.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),w7=S7;const j7=new Set(["http:","https:","mailto:","tel:","ftp:"]);function C7(t){if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const e=new URL(t,"https://placeholder.invalid");return j7.has(e.protocol)}catch{return!1}}function _s(t){const e=B.c(8),{active:s,label:n,onClick:r,children:o}=t,a=s?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let l;e[0]!==a?(l=ne("flex h-7 w-7 items-center justify-center rounded transition-colors cursor-pointer",a),e[0]=a,e[1]=l):l=e[1];let c;return e[2]!==s||e[3]!==o||e[4]!==n||e[5]!==r||e[6]!==l?(c=i.jsx("button",{type:"button","aria-label":n,"aria-pressed":s,onMouseDown:k7,onClick:r,className:l,children:o}),e[2]=s,e[3]=o,e[4]=n,e[5]=r,e[6]=l,e[7]=c):c=e[7],c}function k7(t){return t.preventDefault()}function V7({schema:t,value:e,onChange:s,path:n,label:r}){const o=typeof e=="string"?e:"",a=C.useRef(s);a.current=s;const l=O1({extensions:[$1.configure({heading:{levels:[1,2,3]}}),w7.configure({types:["heading","paragraph"]})],content:o||"",editorProps:{attributes:{class:ne("prose prose-sm dark:prose-invert max-w-none focus:outline-none","min-h-[80px] px-3 py-2")}},onUpdate:({editor:c})=>{const d=c.getHTML();a.current(d==="<p></p>"?"":d)}});return l?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"space-y-0.5",children:[i.jsx(Xe,{htmlFor:n,children:r}),t.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:t.description})]}),i.jsxs("div",{className:"overflow-hidden rounded-md border border-input",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 border-b border-border/60 bg-muted/30 px-1.5 py-1",children:[i.jsx(_s,{active:l.isActive("bold"),label:"Bold",onClick:()=>l.chain().focus().toggleBold().run(),children:i.jsx(Z5,{size:14})}),i.jsx(_s,{active:l.isActive("italic"),label:"Italic",onClick:()=>l.chain().focus().toggleItalic().run(),children:i.jsx(ex,{size:14})}),i.jsx(_s,{active:l.isActive("underline"),label:"Underline",onClick:()=>l.chain().focus().toggleUnderline().run(),children:i.jsx(tx,{size:14})}),i.jsx(_s,{active:l.isActive("strike"),label:"Strikethrough",onClick:()=>l.chain().focus().toggleStrike().run(),children:i.jsx(sx,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive("heading",{level:1}),label:"Heading 1",onClick:()=>l.chain().focus().toggleHeading({level:1}).run(),children:i.jsx(nx,{size:14})}),i.jsx(_s,{active:l.isActive("heading",{level:2}),label:"Heading 2",onClick:()=>l.chain().focus().toggleHeading({level:2}).run(),children:i.jsx(ix,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive("bulletList"),label:"Bullet list",onClick:()=>l.chain().focus().toggleBulletList().run(),children:i.jsx(l6,{size:14})}),i.jsx(_s,{active:l.isActive("orderedList"),label:"Ordered list",onClick:()=>l.chain().focus().toggleOrderedList().run(),children:i.jsx("span",{className:"text-[11px] font-semibold leading-none",children:"1."})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive("link"),label:"Link",onClick:()=>{const c=l.getAttributes("link").href,d=window.prompt("Link URL",c??"https://");d!==null&&(d===""?l.chain().focus().unsetLink().run():C7(d)&&l.chain().focus().setLink({href:d}).run())},children:i.jsx(mm,{size:14})}),i.jsx("div",{className:"mx-0.5 h-4 w-px bg-border"}),i.jsx(_s,{active:l.isActive({textAlign:"left"}),label:"Align left",onClick:()=>l.chain().focus().setTextAlign("left").run(),children:i.jsx(Y5,{size:14})}),i.jsx(_s,{active:l.isActive({textAlign:"center"}),label:"Align center",onClick:()=>l.chain().focus().setTextAlign("center").run(),children:i.jsx(rx,{size:14})}),i.jsx(_s,{active:l.isActive({textAlign:"right"}),label:"Align right",onClick:()=>l.chain().focus().setTextAlign("right").run(),children:i.jsx(ox,{size:14})}),i.jsx(_s,{active:l.isActive({textAlign:"justify"}),label:"Justify",onClick:()=>l.chain().focus().setTextAlign("justify").run(),children:i.jsx(ax,{size:14})})]}),i.jsx(B1,{editor:l})]})]}):null}const Pi=t=>String(t).padStart(2,"0"),N7="1900-01-01",A7="2099-12-31",T7="1900-01-01T00:00",E7="2099-12-31T23:59";function R7(t){if(!t)return"";const e=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const s=new Date(t);return Number.isNaN(s.getTime())?"":`${s.getUTCFullYear()}-${Pi(s.getUTCMonth()+1)}-${Pi(s.getUTCDate())}`}function P7(t){return!t||!/^\d{4}-\d{2}-\d{2}$/.test(t)?"":`${t}T00:00:00.000Z`}function I7(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Pi(e.getMonth()+1)}-${Pi(e.getDate())}T${Pi(e.getHours())}:${Pi(e.getMinutes())}`}function D7(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toISOString()}function M7(t){const e=B.c(29),{id:s,withTime:n,value:r,onChange:o}=t,[a,l]=C.useState(!1);let c;e[0]!==r||e[1]!==n?(c=n?I7(r):R7(r),e[0]=r,e[1]=n,e[2]=c):c=e[2];const d=c;let h;e[3]!==o||e[4]!==n?(h=k=>{o(n?D7(k.target.value):P7(k.target.value))},e[3]=o,e[4]=n,e[5]=h):h=e[5];const u=h;let f;if(e[6]!==r){const k=r?new Date(r):null;f=k&&!Number.isNaN(k.getTime())?k:null,e[6]=r,e[7]=f}else f=e[7];const m=f;let p;e[8]!==o||e[9]!==m||e[10]!==n?(p=k=>{k&&(n&&m?k.setHours(m.getHours(),m.getMinutes(),0,0):k.setHours(0,0,0,0),o(k.toISOString()),l(!1))},e[8]=o,e[9]=m,e[10]=n,e[11]=p):p=e[11];const g=p,x=n?"datetime-local":"date",v=n?T7:N7,_=n?E7:A7;let b;e[12]!==u||e[13]!==s||e[14]!==d||e[15]!==x||e[16]!==v||e[17]!==_?(b=i.jsx(Ye,{id:s,type:x,min:v,max:_,value:d,onChange:u,className:"h-10 flex-1 [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:opacity-0"}),e[12]=u,e[13]=s,e[14]=d,e[15]=x,e[16]=v,e[17]=_,e[18]=b):b=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Cs,{asChild:!0,children:i.jsx(re,{type:"button",variant:"outline",size:"icon",className:"h-10 w-10 shrink-0","aria-label":"Open calendar",children:i.jsx(wm,{className:"h-4 w-4"})})}),e[19]=y):y=e[19];const L=m??void 0;let w;e[20]!==g||e[21]!==L?(w=i.jsx(ks,{className:"w-auto p-0",align:"end",children:i.jsx(a6,{mode:"single",selected:L,onSelect:g,initialFocus:!0})}),e[20]=g,e[21]=L,e[22]=w):w=e[22];let S;e[23]!==a||e[24]!==w?(S=i.jsxs(Vs,{open:a,onOpenChange:l,children:[y,w]}),e[23]=a,e[24]=w,e[25]=S):S=e[25];let j;return e[26]!==S||e[27]!==b?(j=i.jsxs("div",{className:"flex gap-1",children:[b,S]}),e[26]=S,e[27]=b,e[28]=j):j=e[28],j}function ra(t){const e=B.c(8),{htmlFor:s,label:n,description:r}=t;let o;e[0]!==s||e[1]!==n?(o=i.jsx(Xe,{htmlFor:s,children:n}),e[0]=s,e[1]=n,e[2]=o):o=e[2];let a;e[3]!==r?(a=r&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:r}),e[3]=r,e[4]=a):a=e[4];let l;return e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:"space-y-0.5",children:[o,a]}),e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function oa(t){const e=B.c(67),{schema:s,value:n,onChange:r,path:o,label:a}=t,l=typeof n=="string"?n:"",c=s.format;if(c==="rich-text"||c==="rich-text-inline"||c==="html"){let g;return e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==s||e[4]!==n?(g=i.jsx(V7,{schema:s,value:n,onChange:r,path:o,label:a}),e[0]=a,e[1]=r,e[2]=o,e[3]=s,e[4]=n,e[5]=g):g=e[5],g}if(c==="textarea"||c==="markdown"){let g;e[6]!==a||e[7]!==o||e[8]!==s.description?(g=i.jsx(ra,{htmlFor:o,label:a,description:s.description}),e[6]=a,e[7]=o,e[8]=s.description,e[9]=g):g=e[9];let x;e[10]!==r?(x=b=>r(b.target.value),e[10]=r,e[11]=x):x=e[11];let v;e[12]!==o||e[13]!==l||e[14]!==x?(v=i.jsx(Yi,{id:o,value:l,onChange:x,rows:4}),e[12]=o,e[13]=l,e[14]=x,e[15]=v):v=e[15];let _;return e[16]!==g||e[17]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[g,v]}),e[16]=g,e[17]=v,e[18]=_):_=e[18],_}if(c==="date"||c==="date-time"){let g;e[19]!==a||e[20]!==o||e[21]!==s.description?(g=i.jsx(ra,{htmlFor:o,label:a,description:s.description}),e[19]=a,e[20]=o,e[21]=s.description,e[22]=g):g=e[22];const x=c==="date-time";let v;e[23]!==r||e[24]!==o||e[25]!==l||e[26]!==x?(v=i.jsx(M7,{id:o,withTime:x,value:l,onChange:r}),e[23]=r,e[24]=o,e[25]=l,e[26]=x,e[27]=v):v=e[27];let _;return e[28]!==g||e[29]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[g,v]}),e[28]=g,e[29]=v,e[30]=_):_=e[30],_}if(c==="color-input"||c==="color"){let g;e[31]!==a||e[32]!==o||e[33]!==s.description?(g=i.jsx(ra,{htmlFor:o,label:a,description:s.description}),e[31]=a,e[32]=o,e[33]=s.description,e[34]=g):g=e[34];const x=l||"#000000";let v;e[35]!==r?(v=S=>r(S.target.value),e[35]=r,e[36]=v):v=e[36];let _;e[37]!==x||e[38]!==v?(_=i.jsx("input",{type:"color",value:x,onChange:v,className:"h-10 w-10 cursor-pointer rounded-lg border border-border bg-background p-1"}),e[37]=x,e[38]=v,e[39]=_):_=e[39];let b;e[40]!==r?(b=S=>r(S.target.value),e[40]=r,e[41]=b):b=e[41];let y;e[42]!==o||e[43]!==l||e[44]!==b?(y=i.jsx(Ye,{id:o,value:l,onChange:b,placeholder:"#000000",className:"h-10 flex-1"}),e[42]=o,e[43]=l,e[44]=b,e[45]=y):y=e[45];let L;e[46]!==_||e[47]!==y?(L=i.jsxs("div",{className:"flex items-center gap-2",children:[_,y]}),e[46]=_,e[47]=y,e[48]=L):L=e[48];let w;return e[49]!==g||e[50]!==L?(w=i.jsxs("div",{className:"space-y-2",children:[g,L]}),e[49]=g,e[50]=L,e[51]=w):w=e[51],w}let d;e[52]!==a||e[53]!==o||e[54]!==s.description?(d=i.jsx(ra,{htmlFor:o,label:a,description:s.description}),e[52]=a,e[53]=o,e[54]=s.description,e[55]=d):d=e[55];const h=c==="url"?"url":"text";let u;e[56]!==r?(u=g=>r(g.target.value),e[56]=r,e[57]=u):u=e[57];const f=s.default!=null?String(s.default):void 0;let m;e[58]!==o||e[59]!==l||e[60]!==h||e[61]!==u||e[62]!==f?(m=i.jsx(Ye,{id:o,type:h,value:l,onChange:u,placeholder:f,className:"h-10"}),e[58]=o,e[59]=l,e[60]=h,e[61]=u,e[62]=f,e[63]=m):m=e[63];let p;return e[64]!==d||e[65]!==m?(p=i.jsxs("div",{className:"space-y-2",children:[d,m]}),e[64]=d,e[65]=m,e[66]=p):p=e[66],p}const O7=/^[+-]?\d*\.?\d*(?:[eE][+-]?\d*)?$/;function $7(t){const e=B.c(18),{schema:s,value:n,onChange:r,path:o,label:a}=t,l=typeof n=="number"?String(n):"",[c,d]=C.useState(l),[h,u]=C.useState(l);l!==h&&(u(l),c!==""&&l!==""&&Number(c)===Number(l)||d(l));let f;e[0]!==a||e[1]!==o?(f=i.jsx(Xe,{htmlFor:o,children:a}),e[0]=a,e[1]=o,e[2]=f):f=e[2];let m;e[3]!==s.description?(m=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[3]=s.description,e[4]=m):m=e[4];let p;e[5]!==f||e[6]!==m?(p=i.jsxs("div",{className:"space-y-0.5",children:[f,m]}),e[5]=f,e[6]=m,e[7]=p):p=e[7];const g=s.type==="integer"?"numeric":"decimal";let x;e[8]!==r?(x=b=>{const y=b.target.value;if(y!==""&&!O7.test(y))return;d(y);const L=Number(y);r(y===""||Number.isNaN(L)?void 0:L)},e[8]=r,e[9]=x):x=e[9];let v;e[10]!==o||e[11]!==c||e[12]!==g||e[13]!==x?(v=i.jsx(Ye,{id:o,type:"text",inputMode:g,value:c,onChange:x,className:"h-10"}),e[10]=o,e[11]=c,e[12]=g,e[13]=x,e[14]=v):v=e[14];let _;return e[15]!==p||e[16]!==v?(_=i.jsxs("div",{className:"space-y-2",children:[p,v]}),e[15]=p,e[16]=v,e[17]=_):_=e[17],_}function B7(t){const e=B.c(17),{value:s,onChange:n,path:r,label:o,schema:a}=t,l=typeof s=="boolean"?s:!1;let c;e[0]!==o||e[1]!==r?(c=i.jsx(Xe,{htmlFor:r,children:o}),e[0]=o,e[1]=r,e[2]=c):c=e[2];let d;e[3]!==a.description?(d=a.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:a.description}),e[3]=a.description,e[4]=d):d=e[4];let h;e[5]!==c||e[6]!==d?(h=i.jsxs("div",{className:"space-y-0.5",children:[c,d]}),e[5]=c,e[6]=d,e[7]=h):h=e[7];let u;e[8]!==n?(u=p=>n(p),e[8]=n,e[9]=u):u=e[9];let f;e[10]!==l||e[11]!==r||e[12]!==u?(f=i.jsx(ho,{id:r,checked:l,onCheckedChange:u}),e[10]=l,e[11]=r,e[12]=u,e[13]=f):f=e[13];let m;return e[14]!==h||e[15]!==f?(m=i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h,f]}),e[14]=h,e[15]=f,e[16]=m):m=e[16],m}const vd="__enum_empty__";function _d(t){return t===""?vd:String(t)}function z7(t,e){if(t===vd)return"";const s=e.find(n=>_d(n)===t);return s!==void 0?s:t}function F7(t,e){return t==null?e.some(s=>s==="")?vd:void 0:_d(t)}function U7(t){return t===""?"":String(t)}function H7(t){const e=B.c(28),{schema:s,value:n,onChange:r,path:o,label:a}=t;let l;e[0]!==s.enum?(l=s.enum??[],e[0]=s.enum,e[1]=l):l=e[1];const c=l;let d;e[2]!==c||e[3]!==n?(d=F7(n,c),e[2]=c,e[3]=n,e[4]=d):d=e[4];const h=d;let u;e[5]!==a||e[6]!==o?(u=i.jsx(Xe,{htmlFor:o,children:a}),e[5]=a,e[6]=o,e[7]=u):u=e[7];let f;e[8]!==s.description?(f=s.description&&i.jsx("p",{className:"text-xs leading-normal text-muted-foreground",children:s.description}),e[8]=s.description,e[9]=f):f=e[9];let m;e[10]!==u||e[11]!==f?(m=i.jsxs("div",{className:"space-y-0.5",children:[u,f]}),e[10]=u,e[11]=f,e[12]=m):m=e[12];let p;e[13]!==r||e[14]!==c?(p=y=>r(z7(y,c)),e[13]=r,e[14]=c,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(zt,{className:"h-10",children:i.jsx(Gt,{placeholder:"Select..."})}),e[16]=g):g=e[16];let x;e[17]!==c?(x=c.map(K7),e[17]=c,e[18]=x):x=e[18];let v;e[19]!==x?(v=i.jsx($t,{children:x}),e[19]=x,e[20]=v):v=e[20];let _;e[21]!==h||e[22]!==p||e[23]!==v?(_=i.jsxs(Bt,{value:h,onValueChange:p,children:[g,v]}),e[21]=h,e[22]=p,e[23]=v,e[24]=_):_=e[24];let b;return e[25]!==_||e[26]!==m?(b=i.jsxs("div",{className:"space-y-2",children:[m,_]}),e[25]=_,e[26]=m,e[27]=b):b=e[27],b}function K7(t){const e=_d(t);return i.jsx(nt,{value:e,children:U7(t)},e)}function W7(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return C.useMemo(()=>n=>{e.forEach(r=>r(n))},e)}const Gl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ur(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function bd(t){return"nodeType"in t}function ls(t){var e,s;return t?ur(t)?t:bd(t)&&(e=(s=t.ownerDocument)==null?void 0:s.defaultView)!=null?e:window:window}function yd(t){const{Document:e}=ls(t);return t instanceof e}function Fo(t){return ur(t)?!1:t instanceof ls(t).HTMLElement}function hp(t){return t instanceof ls(t).SVGElement}function hr(t){return t?ur(t)?t.document:bd(t)?yd(t)?t:Fo(t)||hp(t)?t.ownerDocument:document:document:document}const Us=Gl?C.useLayoutEffect:C.useEffect;function Yl(t){const e=C.useRef(t);return Us(()=>{e.current=t}),C.useCallback(function(){for(var s=arguments.length,n=new Array(s),r=0;r<s;r++)n[r]=arguments[r];return e.current==null?void 0:e.current(...n)},[])}function q7(){const t=C.useRef(null),e=C.useCallback((n,r)=>{t.current=setInterval(n,r)},[]),s=C.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,s]}function go(t,e){e===void 0&&(e=[t]);const s=C.useRef(t);return Us(()=>{s.current!==t&&(s.current=t)},e),s}function Uo(t,e){const s=C.useRef();return C.useMemo(()=>{const n=t(s.current);return s.current=n,n},[...e])}function dl(t){const e=Yl(t),s=C.useRef(null),n=C.useCallback(r=>{r!==s.current&&e?.(r,s.current),s.current=r},[]);return[s,n]}function ul(t){const e=C.useRef();return C.useEffect(()=>{e.current=t},[t]),e.current}let Sc={};function Ho(t,e){return C.useMemo(()=>{if(e)return e;const s=Sc[t]==null?0:Sc[t]+1;return Sc[t]=s,t+"-"+s},[t,e])}function fp(t){return function(e){for(var s=arguments.length,n=new Array(s>1?s-1:0),r=1;r<s;r++)n[r-1]=arguments[r];return n.reduce((o,a)=>{const l=Object.entries(a);for(const[c,d]of l){const h=o[c];h!=null&&(o[c]=h+t*d)}return o},{...e})}}const $i=fp(1),xo=fp(-1);function G7(t){return"clientX"in t&&"clientY"in t}function Jl(t){if(!t)return!1;const{KeyboardEvent:e}=ls(t.target);return e&&t instanceof e}function Y7(t){if(!t)return!1;const{TouchEvent:e}=ls(t.target);return e&&t instanceof e}function hl(t){if(Y7(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 G7(t)?{x:t.clientX,y:t.clientY}:null}const un=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[un.Translate.toString(t),un.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:s,easing:n}=t;return e+" "+s+"ms "+n}}}),lh="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function J7(t){return t.matches(lh)?t:t.querySelector(lh)}const X7={display:"none"};function Q7(t){let{id:e,value:s}=t;return Ge.createElement("div",{id:e,style:X7},s)}function Z7(t){let{id:e,announcement:s,ariaLiveType:n="assertive"}=t;const r={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 Ge.createElement("div",{id:e,style:r,role:"status","aria-live":n,"aria-atomic":!0},s)}function eS(){const[t,e]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const mp=C.createContext(null);function tS(t){const e=C.useContext(mp);C.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function sS(){const[t]=C.useState(()=>new Set),e=C.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[C.useCallback(n=>{let{type:r,event:o}=n;t.forEach(a=>{var l;return(l=a[r])==null?void 0:l.call(a,o)})},[t]),e]}const nS={draggable:`
@@ -21,7 +21,7 @@ ${Y}`}]}})},t[15]=f,t[16]=d,t[17]=h,t[18]=u,t[19]=E):E=t[19];const I=E,P=D_;let
21
21
  8% { opacity: 1; }
22
22
  22% { opacity: 0; }
23
23
  }
24
- `}),e[26]=y):y=e[26];let L;return e[27]!==b||e[28]!==h?(L=i.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,b,y]}),e[27]=b,e[28]=h,e[29]=L):L=e[29],L}function ha(t){const e=B.c(10),{phase:s,current:n,children:r}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ne("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==x?(v=i.jsx("div",{"aria-hidden":f,className:m,style:x,children:r}),e[6]=r,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function rc(t){const e=B.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),o=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),a=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&i.jsx("div",{className:ne("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",en)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=i.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function pk(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"flex flex-1 px-8 py-5",children:i.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:ck.map(gk)})})]}),t[1]=s):s=t[1],s}function gk(t,e){if(e===a3)return i.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return i.jsx("div",{className:ne("relative rounded-md",Es),children:i.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${l3}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function xk(){const t=B.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:ne("w-[18%] rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function vk(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:i.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:hk.map(_k)})})]}),t[1]=s):s=t[1],s}function _k(t,e){return i.jsx("div",{className:ne("aspect-square rounded-md",fk[e]?"bg-chart-2/70":Es),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function bk(){const t=B.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=i.jsx("div",{className:ne("h-1.5 w-[70%] rounded-sm",Es)}),r=i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",Es)}),o=i.jsx("div",{className:ne("h-1.5 w-[80%] rounded-sm",Es)}),a=i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a):(s=t[1],n=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,r,o,a,i.jsx("div",{className:"mt-auto",children:i.jsx("div",{className:ne("h-4 rounded-md",Es)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:i.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[i.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",en)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[i.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),i.jsx("div",{className:ne("h-4 w-10 rounded-full",en)}),i.jsx("div",{className:ne("h-4 w-14 rounded-full",en)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs("div",{className:ne("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",en),children:[i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),i.jsx("div",{className:ne("h-1 w-[75%] rounded-sm",Es)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[i.jsx("div",{className:ne("rounded-md",en)}),i.jsx("div",{className:ne("rounded-md",en)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Bi(t){const e=B.c(25);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsx(mk,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}if(t.kind==="errored"){const l=t.error.code===m2.githubNotAuthenticated;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(nr,{className:"size-12 text-destructive"}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("h3",{className:"text-lg font-medium",children:Fh("errored")}),e[4]=d):d=e[4];const h=l?"This agent's GitHub repo isn't authenticated. Reconnect it in Connections, then retry.":t.error.message;let u;e[5]!==h?(u=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==t.connectionsHref?(f=l&&t.connectionsHref&&i.jsx(re,{asChild:!0,children:i.jsx("a",{href:t.connectionsHref,children:"Reconnect GitHub"})}),e[7]=l,e[8]=t.connectionsHref,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(zi,{className:"size-4"}),e[10]=m):m=e[10];let p;e[11]!==t.onRetry?(p=i.jsxs(re,{variant:"outline",onClick:t.onRetry,children:[m," Retry"]}),e[11]=t.onRetry,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=i.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let x;return e[16]!==u||e[17]!==g?(x=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[c,d,u,g]})}),e[16]=u,e[17]=g,e[18]=x):x=e[18],x}let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(lx,{className:"size-12 text-blue-500"}),e[19]=s):s=e[19];let n,r;e[20]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("h3",{className:"text-lg font-medium",children:Fh("suspended")}),r=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[20]=n,e[21]=r):(n=e[20],r=e[21]);let o;e[22]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fi,{className:"size-4"}),e[22]=o):o=e[22];let a;return e[23]!==t.onResume?(a=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,n,r,i.jsxs(re,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[23]=t.onResume,e[24]=a):a=e[24],a}const Hh={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function $d(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function c3(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:Hh.seoResolveType},__resolveType:Hh.resolveType}}function Kh(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function yk(t,e){const s=ai,n=e.replace(/-copy(?:-\d+)?$/,""),r=`${n}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function Lk(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Sk(t){const e=$d(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function wk(t,e){return c3(t,e)}const jk=1e3;function Ck(t,e){for(let s=0;s<jk;s++){const n=$d(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const zn="__blank__";function d3(t){const e=B.c(44),{id:s,value:n,onChange:r,templates:o,disabled:a}=t,[l,c]=C.useState(!1);let d;if(e[0]!==o||e[1]!==n){let A;e[3]!==n?(A=N=>N.key===n,e[3]=n,e[4]=A):A=e[4],d=o.find(A),e[0]=o,e[1]=n,e[2]=d}else d=e[2];const h=d,u=h?.name??"Blank page";let f;e[5]!==u?(f=i.jsx("span",{className:"truncate",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==h?(m=h?.path?i.jsx("span",{className:"truncate text-muted-foreground",children:h.path}):null,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f,m]}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(N9,{className:"shrink-0 opacity-50"}),e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==p?(x=i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":l,disabled:a,className:"w-full justify-between font-normal",children:[p,g]})}),e[13]=a,e[14]=s,e[15]=l,e[16]=p,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v={width:"var(--radix-popover-trigger-width)"},e[18]=v):v=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yi,{placeholder:"Search pages…",className:"h-9"}),e[19]=_):_=e[19];let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Li,{children:"No pages found."}),e[20]=b):b=e[20];let y;e[21]!==r?(y=()=>{r(zn),c(!1)},e[21]=r,e[22]=y):y=e[22];const L=n===zn?"opacity-100":"opacity-0";let w;e[23]!==L?(w=ne("ml-auto",L),e[23]=L,e[24]=w):w=e[24];let S;e[25]!==w?(S=i.jsx(Tt,{className:w}),e[25]=w,e[26]=S):S=e[26];let j;e[27]!==y||e[28]!==S?(j=i.jsxs(Ps,{value:"Blank page",onSelect:y,children:["Blank page",S]}),e[27]=y,e[28]=S,e[29]=j):j=e[29];let k;if(e[30]!==r||e[31]!==o||e[32]!==n){let A;e[34]!==r||e[35]!==n?(A=N=>i.jsxs(Ps,{value:`${N.name} ${N.path}`,onSelect:()=>{r(N.key),c(!1)},children:[i.jsxs("div",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{className:"truncate",children:N.name}),i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:N.path})]}),i.jsx(Tt,{className:ne("ml-auto",n===N.key?"opacity-100":"opacity-0")})]},N.key),e[34]=r,e[35]=n,e[36]=A):A=e[36],k=o.map(A),e[30]=r,e[31]=o,e[32]=n,e[33]=k}else k=e[33];let V;e[37]!==j||e[38]!==k?(V=i.jsx(ks,{className:"p-0",style:v,children:i.jsxs(lr,{children:[_,i.jsxs(Si,{onWheel:kk,children:[b,i.jsxs(Fs,{children:[j,k]})]})]})}),e[37]=j,e[38]=k,e[39]=V):V=e[39];let T;return e[40]!==l||e[41]!==V||e[42]!==x?(T=i.jsxs(Vs,{open:l,onOpenChange:c,children:[x,V]}),e[40]=l,e[41]=V,e[42]=x,e[43]=T):T=e[43],T}function kk(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}const Vk={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Nk={create:"Create",duplicate:"Duplicate",rename:"Save"},Ak={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Tk(t){const e=B.c(62),{open:s,mode:n,initialName:r,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,[m,p]=C.useState(r),[g,x]=C.useState(o),[v,_]=C.useState(zn),[b,y]=C.useState(null),[L,w]=C.useState(s);s!==L&&(w(s),s&&(p(r),x(o),_(zn),y(null)));const S=n==="create"&&!!c?.length;let j;e[0]!==f||e[1]!==u?(j=Q=>{!Q&&!f&&(y(null),u(!1))},e[0]=f,e[1]=u,e[2]=j):j=e[2];const k=j;let V;e[3]!==f||e[4]!==m||e[5]!==h||e[6]!==g||e[7]!==S||e[8]!==v||e[9]!==d?(V=async Q=>{Q.preventDefault();const Z=m.trim(),Y=g.trim();if(!Z||!Y||f)return;const ee=ud(Y);if(ee){y(ee);return}const te=d?.({name:Z,path:Y});if(te){y(te);return}y(null),await h({name:Z,path:Y,templateKey:S&&v!==zn?v:null})},e[3]=f,e[4]=m,e[5]=h,e[6]=g,e[7]=S,e[8]=v,e[9]=d,e[10]=V):V=e[10];const T=V,A=b??l,N=Vk[n];let E;e[11]!==N?(E=i.jsx(ns,{children:i.jsx(is,{children:N})}),e[11]=N,e[12]=E):E=e[12];let I;e[13]!==f||e[14]!==S||e[15]!==v||e[16]!==c?(I=S&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),i.jsx(d3,{id:"page-form-template",value:v,onChange:_,templates:c??[],disabled:f})]}),e[13]=f,e[14]=S,e[15]=v,e[16]=c,e[17]=I):I=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=i.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[18]=P):P=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=Q=>p(Q.target.value),e[19]=R):R=e[19];let D;e[20]!==f||e[21]!==m?(D=i.jsxs("div",{className:"space-y-1.5",children:[P,i.jsx(Ye,{id:"page-form-name",value:m,onChange:R,placeholder:"My page",autoFocus:!0,disabled:f})]}),e[20]=f,e[21]=m,e[22]=D):D=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[23]=M):M=e[23];let F;e[24]===Symbol.for("react.memo_cache_sentinel")?(F=Q=>x(Q.target.value),e[24]=F):F=e[24];let $;e[25]!==f||e[26]!==g?($=i.jsxs("div",{className:"space-y-1.5",children:[M,i.jsx(Ye,{id:"page-form-path",value:g,onChange:F,placeholder:"/example",disabled:f})]}),e[25]=f,e[26]=g,e[27]=$):$=e[27];let O;e[28]!==A?(O=A&&i.jsx("p",{className:"text-xs text-destructive",children:A}),e[28]=A,e[29]=O):O=e[29];let U;e[30]!==$||e[31]!==O||e[32]!==I||e[33]!==D?(U=i.jsxs("div",{className:"space-y-4 py-4",children:[I,D,$,O]}),e[30]=$,e[31]=O,e[32]=I,e[33]=D,e[34]=U):U=e[34];let K;e[35]!==u?(K=()=>u(!1),e[35]=u,e[36]=K):K=e[36];let H;e[37]!==f||e[38]!==K?(H=i.jsx(re,{type:"button",variant:"outline",onClick:K,disabled:f,children:"Cancel"}),e[37]=f,e[38]=K,e[39]=H):H=e[39];let q;e[40]!==f||e[41]!==m||e[42]!==g?(q=!m.trim()||!g.trim()||f,e[40]=f,e[41]=m,e[42]=g,e[43]=q):q=e[43];let J;e[44]!==f||e[45]!==n?(J=f?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),Ak[n]]}):Nk[n],e[44]=f,e[45]=n,e[46]=J):J=e[46];let G;e[47]!==q||e[48]!==J?(G=i.jsx(re,{type:"submit",disabled:q,children:J}),e[47]=q,e[48]=J,e[49]=G):G=e[49];let W;e[50]!==H||e[51]!==G?(W=i.jsxs(_i,{children:[H,G]}),e[50]=H,e[51]=G,e[52]=W):W=e[52];let z;e[53]!==T||e[54]!==U||e[55]!==W||e[56]!==E?(z=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:T,children:[E,U,W]})}),e[53]=T,e[54]=U,e[55]=W,e[56]=E,e[57]=z):z=e[57];let X;return e[58]!==k||e[59]!==s||e[60]!==z?(X=i.jsx(Ut,{open:s,onOpenChange:k,children:z}),e[58]=k,e[59]=s,e[60]=z,e[61]=X):X=e[61],X}function Ek(t){const e=B.c(43),{open:s,blockKey:n,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,[d,h]=C.useState(r),[u,f]=C.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==c||e[1]!==l?(m=P=>{!P&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async P=>{P.preventDefault();const R=d.trim();!R||c||await a(R)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsxs(ns,{children:[i.jsx(is,{children:"Rename section"}),i.jsx(qn,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=_):_=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=P=>h(P.target.value),e[9]=b):b=e[9];let y;e[10]!==c||e[11]!==d?(y=i.jsxs("div",{className:"space-y-1.5",children:[_,i.jsx(Ye,{id:"section-rename-name",value:d,onChange:b,autoFocus:!0,disabled:c})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=L):L=e[13];let w;e[14]!==n?(w=i.jsxs("div",{className:"space-y-1.5",children:[L,i.jsx(Ye,{value:n,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=n,e[15]=w):w=e[15];let S;e[16]!==y||e[17]!==w?(S=i.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=S):S=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let k;e[21]!==c||e[22]!==j?(k=i.jsx(re,{type:"button",variant:"outline",onClick:j,disabled:c,children:"Cancel"}),e[21]=c,e[22]=j,e[23]=k):k=e[23];let V;e[24]!==c||e[25]!==d?(V=!d.trim()||c,e[24]=c,e[25]=d,e[26]=V):V=e[26];let T;e[27]!==c?(T=c?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=c,e[28]=T):T=e[28];let A;e[29]!==V||e[30]!==T?(A=i.jsx(re,{type:"submit",disabled:V,children:T}),e[29]=V,e[30]=T,e[31]=A):A=e[31];let N;e[32]!==k||e[33]!==A?(N=i.jsxs(_i,{children:[k,A]}),e[32]=k,e[33]=A,e[34]=N):N=e[34];let E;e[35]!==x||e[36]!==S||e[37]!==N?(E=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:x,children:[v,S,N]})}),e[35]=x,e[36]=S,e[37]=N,e[38]=E):E=e[38];let I;return e[39]!==p||e[40]!==s||e[41]!==E?(I=i.jsx(Ut,{open:s,onOpenChange:p,children:E}),e[39]=p,e[40]=s,e[41]=E,e[42]=I):I=e[42],I}const Rc={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},Bd=["posts","authors","categories"],eo={posts:"post",authors:"author",categories:"category"};function to(t){return Bd.includes(t)}const zd={posts:"post",authors:"author",categories:"category"},u3={posts:Rc.post,authors:Rc.author,categories:Rc.category},Rk=Object.fromEntries(Object.entries(u3).map(([t,e])=>[e,t]));function Pk(t){return typeof t=="string"?Rk[t]??null:null}function Qi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Bs(t){return typeof t=="string"?t:""}function Ik(t,e){switch(t){case"posts":return{label:Bs(e.title)||"Untitled post",subtitle:Bs(e.slug)};case"authors":return{label:Bs(e.name)||"Unnamed author",subtitle:Bs(e.email)};case"categories":return{label:Bs(e.name)||"Unnamed category",subtitle:Bs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function h3(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const r=Qi(n);if(!r)continue;const o=Pk(r.__resolveType);if(!o)continue;const a=Qi(r[zd[o]])??{},{label:l,subtitle:c}=Ik(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of Bd)e[s].sort((n,r)=>n.label.localeCompare(r.label));return e}function Dk(t,e){return h3(t)[e]}function bo(t,e){return Dk(t,e).map(s=>({key:s.key,payload:Na(Qi(t[s.key])??void 0,e)}))}const Wh=Object.freeze({});function Na(t,e){return t?Qi(t[zd[e]])??Wh:Wh}function fa(t,e,s){return{name:t,__resolveType:u3[e],[zd[e]]:s}}function f3(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Zi(t){return Array.isArray(t)?t:[]}function Fn(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.slug):""}function Mk(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.email):""}function m3(t){return bo(t,"posts").map(({key:e,payload:s})=>({key:e,title:Bs(s.title)||"Untitled post",slug:Bs(s.slug),date:Bs(s.date),categorySlugs:Zi(s.categories).map(Fn).filter(Boolean),authorEmails:Zi(s.authors).map(Mk).filter(Boolean)}))}function Ok(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function $k(t,e){const s=Zi(t.categories);return s.length===1&&Fn(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function VF(t,e,s){const n=Zi(t.categories);if(!n.some(l=>Fn(l)===e))return t;const r=n.map(l=>{const c=Fn(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=r.filter(l=>{const c=Fn(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function Bk(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e)?{...t,categories:s.filter(n=>Fn(n)!==e)}:t}function V0(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function qh(t,e){const s=`collections/blog/${e}/${V0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function zk(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${V0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${V0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const Fk={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Gh="Box";function Uk(t){return t.startsWith("site/")?"site":"app"}function Hk(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function jr(...t){for(const e of t)if(e!==void 0)return e}function NF(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const r of Object.values(n))for(const o of Object.keys(r)){if(!qk(o)||e.has(o))continue;e.add(o);const a=Jn(o,t),l=Kk(o),c=Fk[l],d=Uk(o),h=(d==="site"?jr(a.title,c?.title):jr(c?.title,a.title))??l,u=d==="site"?jr(a.description,c?.description):jr(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&Hk(f)?f:void 0,p=m!==void 0?c?.iconName??Gh:jr(f,c?.iconName)??Gh;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function Kk(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const Wk=["blog/sections/blocks/","site/sections/Blog/Post/"];function qk(t){return Wk.some(e=>t.startsWith(e))}function p3({orgSlug:t,virtualMcpId:e,branch:s}){return Qe.decofile(`${t}/${e}/${s}`)}function g3({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}function Gk(t){const e=B.c(11),s=os();let n;e[0]!==t?(n=async l=>{const{blockKey:c,data:d}=l,h=await fetch(g3(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:f3(c),content:JSON.stringify(d,null,2)})});if(!h.ok){const u=await h.json().catch(Yk);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:c,data:d}=l,h=p3(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==o?(a={mutationFn:n,onMutate:r,onError:o},e[7]=n,e[8]=r,e[9]=o,e[10]=a):a=e[10],Ds(a)}function Yk(){return{}}function Jk(t){const e=os();return Ds({mutationFn:async({blockKey:s})=>{const n=await fetch(g3(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:f3(s)})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${n.status})`)}return n.json()},onMutate:async({blockKey:s})=>{const n=p3(t);await e.cancelQueries({queryKey:n});const r=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:n}},onError:(s,n,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function Xk(t){const e=B.c(20),{open:s,onOpenChange:n,pageKey:r,decofile:o}=t,[a,l]=C.useState(!1),c=o[r];let d;e[0]!==c?(d=c===void 0?"// Page not found.":JSON.stringify(c,null,2),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(is,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?i.jsx(Pl,{size:12}):i.jsx(Ss,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let x;e[7]!==f||e[8]!==p||e[9]!==g?(x=i.jsxs(ns,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,i.jsxs(re,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(Sn,{className:"max-h-[70vh]",children:i.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=v):v=e[12];let _;e[13]!==x||e[14]!==v?(_=i.jsxs(Ft,{className:"max-w-2xl p-0 gap-0",children:[x,v]}),e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;return e[16]!==n||e[17]!==s||e[18]!==_?(b=i.jsx(Ut,{open:s,onOpenChange:n,children:_}),e[16]=n,e[17]=s,e[18]=_,e[19]=b):b=e[19],b}function Qk(t){const e=B.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[i.jsx(fn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[i.jsx(qe,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[i.jsx(Tt,{size:13}),"Saved"]}),e[2]=r):r=e[2],r}const Zk={loaders:"loader",actions:"action"},x3=new Set(["workflows"]);function v3(t){return Zk[t]}function _3(t,e,s){const n=t.manifest?.blocks??{};for(const[r,o]of Object.entries(n))if(r.includes(s)&&e in o)return!0;return!1}function eV(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function b3(t,e){const s=t.manifest?.blocks??{},n=[],r=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))r.add(l);for(const o of r){if(o.toLowerCase().includes("preview")||x3.has(Fd(o))||eV(o,r))continue;const a=Jn(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:vt(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function Yh(t,e){return b3(t,e).length}function Fd(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const tV={deco:"Deco",std:"Deco Standard",website:"Website"};function sV(t){return tV[t]??t}function y3(t){const e=Fd(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function nV(t,e,s){const n=[];for(const[r,o]of Object.entries(e)){if(r.includes("/")||Fl(r)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(x3.has(Fd(l))||_3(t,l,s)&&n.push({key:r,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:r}))}return n.sort((r,o)=>r.title.localeCompare(o.title))}const Jh=3e4;function L3(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function iV(t,e,s,n){const r=new URL(`/deco/invoke/${e}`,t);return r.searchParams.set("__cb",n.toString(36)),r.searchParams.set("__decoFBT","0"),r.searchParams.set("__d",`run-${n.toString(36)}`),r.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),r.href}async function rV(t,{resolveType:e,props:s}){let n;try{n=await fetch(L3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Jh)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${Jh/1e3}s — the block may be slow or the preview unresponsive.`):l}const r=await n.text();let o=null,a=!1;try{o=r?JSON.parse(r):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:r||`Run failed (${n.status})`;throw new Error(l)}return a?o:r}function oV(t){const e=B.c(2);let s;return e[0]!==t?(s={mutationFn:n=>rV(t,n)},e[0]=t,e[1]=s):s=e[1],Ds(s)}function aV({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:r,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=kn(),p=m?.entity?.id===e?m.entity.metadata?.siteSlug??null:null,g=Ln(l.resolveType,r),x=!g&&RL(l.resolveType,r),v=x?PL(c):null,_=g??v,[b,y]=C.useState(c),[L,w]=C.useState([]),[S,j]=C.useState(0),[k,V]=C.useState(!1),[T,A]=C.useState(null),[N,E]=C.useState(!1),[I,P]=C.useState(!1),[R,D]=C.useState(!1),M=T!==null,{save:F,flush:$,isPending:O}=G2({orgSlug:t,virtualMcpId:e,branch:s}),U=oV({orgSlug:t,virtualMcpId:e,branch:s});C.useEffect(()=>()=>{$()},[]);const K=v3(a),H=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,q={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:p},J=ee=>{y(ee),l.mode==="saved"&&F(l.blockKey,{__resolveType:l.resolveType,...ee})},G=()=>{M?(A(null),V(!1),j(ee=>ee+1)):A(JSON.stringify(b,null,2))},W=ee=>{const te=ee??"";try{const ae=JSON.parse(te);if(ae&&typeof ae=="object"&&!Array.isArray(ae)){V(!1),J(ae);return}V(!0)}catch{V(!0)}},z=async ee=>{const te=xd(ee,o);if(te){ce.error(te);return}await h(ee,{__resolveType:l.resolveType,...b}),E(!1)},X=()=>{P(!0),U.mutate({resolveType:l.resolveType,props:b})},Q=()=>{n&&window.open(iV(n,l.resolveType,b,Date.now()),"_blank","noopener")},Z=[l.title,...L],Y=ee=>{w(L.slice(0,ee)),j(te=>te+1)};return i.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&i.jsx(re,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":"Back to list",children:i.jsx(Tl,{size:14})}),i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:Z.map((ee,te)=>{const ae=te===Z.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[te>0&&i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>Y(te),title:ee,className:ne("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ae?"font-medium text-foreground":"text-muted-foreground"),children:ee})]},`${ee}-${te}`)})}),l.mode==="saved"&&i.jsx(Qk,{isPending:O,isError:!1}),i.jsxs(re,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:X,disabled:U.isPending,"aria-label":`Run ${K}`,children:[U.isPending?i.jsx(qe,{size:14,className:"animate-spin"}):i.jsx(fi,{size:14}),"Run"]}),l.mode==="available"&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>E(!0),"aria-label":`Save as global ${K}`,children:i.jsx(I9,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Save as global ",K]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:M?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:G,"aria-label":M?"Close JSON editor":"Edit as JSON","aria-pressed":M,children:M?i.jsx(ms,{size:14}):i.jsx(To,{size:14})})}),i.jsx(Pe,{side:"bottom",children:M?"Close JSON editor":"Edit as JSON"})]})]}),i.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?`Global ${K} — changes save automatically. Run to invoke it against the live preview.`:`${H} — edits stay local until you save this as a global ${K}. Run to invoke it against the live preview.`})]}),i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:ne("relative min-h-0 flex-1",I&&R&&"hidden"),children:[i.jsx(Sn,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsxs("div",{className:"mx-auto max-w-2xl",children:[v&&_===v&&i.jsxs("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:["This ",K," doesn't publish a props schema — fields below are inferred from its saved values. Use the JSON editor to add props not shown here."]}),_?i.jsx(Xn,{schema:_,value:b,onChange:ee=>J(ee),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:r,decofile:o,onSaveReferencedBlock:u,sandbox:q},S):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:x?`This ${K} doesn't publish a props schema. Edit its props as JSON, then run it.`:`This ${K} takes no configurable input. Run it to see its output.`})]})})}),T!==null&&i.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[k&&i.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(Ml,{language:"json",height:"100%",code:T,onChange:W,onSave:ee=>{W(ee),$()}})})]})]}),I&&i.jsx(lV,{singular:K,result:{isPending:U.isPending,error:U.error,data:U.data,hasRun:U.status!=="idle"},expanded:R,onToggleExpand:()=>D(ee=>!ee),onOpenInNewTab:n?Q:void 0,onClose:()=>{P(!1),D(!1)}})]}),i.jsx(Pd,{open:N,onOpenChange:E,defaultBlockId:"",isPending:d,onSubmit:z})]})}function lV(t){const e=B.c(37),{singular:s,result:n,expanded:r,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t;let c;e[0]!==n.data?(c=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=c):c=e[1];const d=c,h=r?"flex-1":"h-[45%] shrink-0";let u;e[2]!==h?(u=ne("flex min-h-0 flex-col border-t",h),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),e[4]=f):f=e[4];let m;e[5]!==a||e[6]!==s?(m=a&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":"Open result in new tab",children:i.jsx(wn,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Open in new tab (re-runs the ",s,")"]})]}),e[5]=a,e[6]=s,e[7]=m):m=e[7];const p=r?"Collapse result":"Expand result";let g;e[8]!==r?(g=r?i.jsx(cx,{size:14}):i.jsx(rm,{size:14}),e[8]=r,e[9]=g):g=e[9];let x;e[10]!==r||e[11]!==o||e[12]!==p||e[13]!==g?(x=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":p,"aria-pressed":r,children:g})}),e[10]=r,e[11]=o,e[12]=p,e[13]=g,e[14]=x):x=e[14];const v=r?"Collapse":"Expand";let _;e[15]!==v?(_=i.jsx(Pe,{side:"bottom",children:v}),e[15]=v,e[16]=_):_=e[16];let b;e[17]!==_||e[18]!==x?(b=i.jsxs(Ie,{children:[x,_]}),e[17]=_,e[18]=x,e[19]=b):b=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ms,{size:14}),e[20]=y):y=e[20];let L;e[21]!==l?(L=i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":"Close result",children:y}),e[21]=l,e[22]=L):L=e[22];let w;e[23]!==b||e[24]!==L||e[25]!==m?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[f,i.jsxs("div",{className:"flex items-center gap-0.5",children:[m,b,L]})]}),e[23]=b,e[24]=L,e[25]=m,e[26]=w):w=e[26];let S;e[27]!==n.error||e[28]!==n.hasRun||e[29]!==n.isPending||e[30]!==d||e[31]!==s?(S=i.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[i.jsx(qe,{size:16,className:"animate-spin"}),"Running ",s,"…"]}):n.error?i.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[i.jsxs("p",{className:"text-xs font-medium text-destructive",children:["Failed to run ",s]}),i.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?i.jsx(Ml,{language:"json",height:"100%",code:d,readOnly:!0}):i.jsxs("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:["Press Run to invoke this ",s,"."]})}),e[27]=n.error,e[28]=n.hasRun,e[29]=n.isPending,e[30]=d,e[31]=s,e[32]=S):S=e[32];let j;return e[33]!==w||e[34]!==S||e[35]!==u?(j=i.jsxs("div",{className:u,children:[w,S]}),e[33]=w,e[34]=S,e[35]=u,e[36]=j):j=e[36],j}const cV={loaders:Fa,actions:ui},dV={loaders:"Loaders",actions:"Actions"},uV={analytics:dx,blog:Ki,commerce:D9,site:Nv,website:Yn};function hV(t,e){return e===0?uV[t.toLowerCase()]??hi:hi}function ma(t,e){return e===0?sV(t):t}function fV(t){const e=B.c(87),{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];const[h,u]=C.useState(d),[f,m]=C.useState(null),[p,g]=C.useState(""),[x,v]=C.useState(yV),[_,b]=C.useState(c);_!==c&&(b(c),u([]),m(null),g(""),v(new Set));let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{v(K=>{const H=new Set(K);return H.has(U)?H.delete(U):H.add(U),H})},e[1]=y):y=e[1];const L=y;let w;e[2]!==r||e[3]!==s||e[4]!==n?(w={orgSlug:s,virtualMcpId:n,branch:r},e[2]=r,e[3]=s,e[4]=n,e[5]=w):w=e[5];const S=Ul(w);let j;e[6]!==S?(j=up((U,K)=>S.mutate({blockKey:U,data:K})),e[6]=S,e[7]=j):j=e[7];const k=j;let V;e[8]!==c?(V=v3(c),e[8]=c,e[9]=V):V=e[9];const T=V,A=cV[c];let N,E,I,P,R,D,M;if(e[10]!==A||e[11]!==r||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==x||e[16]!==s||e[17]!==h||e[18]!==o||e[19]!==S||e[20]!==k||e[21]!==p||e[22]!==f||e[23]!==T||e[24]!==n){I=Symbol.for("react.early_return_sentinel");e:{const U=[...nV(a,l,c).map(bV),...b3(a,c).map(_V)],K=p.trim().toLowerCase(),H=K.length>0,q=H?U.filter(pe=>pe.title.toLowerCase().includes(K)||pe.resolveType.toLowerCase().includes(K)):[],J=new Map,G=[],W=new Map;if(!H){for(const pe of U){const Ee=pe.folderPath;if(!(Ee.length<h.length)&&h.every((De,ue)=>Ee[ue]===De))if(Ee.length===h.length)if(pe.savedKey!==void 0){const De=W.get(pe.resolveType);De?De.push(pe):W.set(pe.resolveType,[pe])}else G.push(pe);else{const De=Ee[h.length],ue=J.get(De)??{count:0,savedCount:0};pe.savedKey!==void 0?ue.savedCount=ue.savedCount+1:ue.count=ue.count+1,J.set(De,ue)}}G.sort(vV);for(const pe of W.values())pe.sort(xV)}const z=[...W.entries()].filter(pe=>{const[Ee]=pe;return!G.some(De=>De.resolveType===Ee)}).flatMap(gV).sort(pV);let X;e[32]!==h?(X=(pe,Ee)=>ma(pe.name,h.length).localeCompare(ma(Ee.name,h.length)),e[32]=h,e[33]=X):X=e[33];const Q=[...J.entries()].map(mV).sort(X);let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=pe=>{m(pe.savedKey!==void 0?{mode:"saved",key:pe.savedKey}:{mode:"available",resolveType:pe.resolveType,title:pe.title})},e[34]=Z):Z=e[34];const Y=Z;let ee;e[35]!==S||e[36]!==T?(ee=async(pe,Ee)=>{await S.mutateAsync({blockKey:pe,data:Ee}),ce.success(`Saved ${T} "${pe}"`),m({mode:"saved",key:pe})},e[35]=S,e[36]=T,e[37]=ee):ee=e[37];const te=ee;let ae;e[38]!==l||e[39]!==f?(ae=LV(f,l),e[38]=l,e[39]=f,e[40]=ae):ae=e[40];const se=ae;if(se){const pe=`${se.mode}:${se.mode==="saved"?se.blockKey:se.resolveType}`;let Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>m(null),e[41]=Ee):Ee=e[41];let De;e[42]!==r||e[43]!==l||e[44]!==te||e[45]!==c||e[46]!==a||e[47]!==s||e[48]!==o||e[49]!==S.isPending||e[50]!==k||e[51]!==pe||e[52]!==se.editorTarget||e[53]!==se.initialValue||e[54]!==n?(De=i.jsx(aV,{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c,target:se.editorTarget,initialValue:se.initialValue,isCreating:S.isPending,onCreate:te,onSaveReferencedBlock:k,onBack:Ee},pe),e[42]=r,e[43]=l,e[44]=te,e[45]=c,e[46]=a,e[47]=s,e[48]=o,e[49]=S.isPending,e[50]=k,e[51]=pe,e[52]=se.editorTarget,e[53]=se.initialValue,e[54]=n,e[55]=De):De=e[55],I=De;break e}M="flex h-full w-full min-w-0 flex-col";let ie;e[56]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>u([]),e[56]=ie):ie=e[56];const fe=h.length===0?"font-medium text-foreground":"text-muted-foreground";let me;e[57]!==fe?(me=ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",fe),e[57]=fe,e[58]=me):me=e[58];const be=dV[c];let _e;e[59]!==me||e[60]!==be?(_e=i.jsx("button",{type:"button",onClick:ie,className:me,children:be}),e[59]=me,e[60]=be,e[61]=_e):_e=e[61];let xe;e[62]!==h?(xe=h.map((pe,Ee)=>{const De=Ee===h.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>u(h.slice(0,Ee+1)),className:ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",De?"font-medium text-foreground":"text-muted-foreground"),children:ma(pe,Ee)})]},`${pe}-${Ee}`)}),e[62]=h,e[63]=xe):xe=e[63];let ke;e[64]!==_e||e[65]!==xe?(ke=i.jsxs("nav",{"aria-label":"Folder breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[_e,xe]}),e[64]=_e,e[65]=xe,e[66]=ke):ke=e[66];let Ne;e[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=i.jsx(K9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[67]=Ne):Ne=e[67];let we;e[68]===Symbol.for("react.memo_cache_sentinel")?(we=pe=>g(pe.target.value),e[68]=we):we=e[68];const ye=`Search all ${c}…`,Be=`Search all ${c}`;let Fe;e[69]!==p||e[70]!==ye||e[71]!==Be?(Fe=i.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Ne,i.jsx("input",{type:"text",value:p,onChange:we,placeholder:ye,"aria-label":Be,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[69]=p,e[70]=ye,e[71]=Be,e[72]=Fe):Fe=e[72],e[73]!==ke||e[74]!==Fe?(E=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[ke,Fe]}),e[73]=ke,e[74]=Fe,e[75]=E):E=e[75],N=Sn,D="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",P="mx-auto w-full max-w-4xl px-6 py-5",R=H?q.length===0?i.jsx(Mn,{title:`No ${c} match "${p.trim()}"`,description:"Search covers every folder — try a different term."}):i.jsx("div",{className:"flex flex-col gap-1",children:q.map(pe=>i.jsx(tn,{icon:A,accent:pe.savedKey!==void 0?"global":void 0,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Y(pe)},pe.savedKey??pe.resolveType))}):Q.length===0&&G.length===0&&z.length===0?i.jsx(Mn,{title:`No ${c} here`,description:h.length===0?"Start the preview dev server so its manifest loads.":"This folder is empty."}):i.jsxs(i.Fragment,{children:[Q.length>0&&i.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:Q.map(pe=>{const Ee=hV(pe.name,h.length);return i.jsxs("button",{type:"button",onClick:()=>u([...h,pe.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[i.jsx(Ee,{size:18,className:"shrink-0 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium",children:ma(pe.name,h.length)}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[pe.count," ",pe.count===1?T:c,pe.savedCount>0&&i.jsxs(i.Fragment,{children:[" · ",pe.savedCount," saved"]})]})]})]},pe.name)})}),(G.length>0||z.length>0)&&i.jsxs("div",{className:ne("flex flex-col gap-1",Q.length>0&&"mt-4"),children:[G.map(pe=>{const Ee=W.get(pe.resolveType)??[],De=x.has(pe.resolveType);return i.jsxs("div",{className:"flex flex-col",children:[i.jsx(tn,{icon:A,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Y(pe)}),Ee.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>L(pe.resolveType),"aria-expanded":De,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:ad},children:[De?i.jsx(Ht,{size:12,className:"shrink-0"}):i.jsx(cn,{size:12,className:"shrink-0"}),De?"Hide saved":"See saved"," (",Ee.length,")"]}),De&&i.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Ee.map(ue=>i.jsx(tn,{icon:A,accent:"global",title:ue.title,subtitle:ue.resolveType,active:!1,onClick:()=>Y(ue)},ue.savedKey))})]})]},pe.resolveType)}),z.map(pe=>i.jsx(tn,{icon:A,accent:"global",title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Y(pe)},pe.savedKey))]})]})}e[10]=A,e[11]=r,e[12]=l,e[13]=c,e[14]=a,e[15]=x,e[16]=s,e[17]=h,e[18]=o,e[19]=S,e[20]=k,e[21]=p,e[22]=f,e[23]=T,e[24]=n,e[25]=N,e[26]=E,e[27]=I,e[28]=P,e[29]=R,e[30]=D,e[31]=M}else N=e[25],E=e[26],I=e[27],P=e[28],R=e[29],D=e[30],M=e[31];if(I!==Symbol.for("react.early_return_sentinel"))return I;let F;e[76]!==P||e[77]!==R?(F=i.jsx("div",{className:P,children:R}),e[76]=P,e[77]=R,e[78]=F):F=e[78];let $;e[79]!==N||e[80]!==F||e[81]!==D?($=i.jsx(N,{className:D,children:F}),e[79]=N,e[80]=F,e[81]=D,e[82]=$):$=e[82];let O;return e[83]!==E||e[84]!==$||e[85]!==M?(O=i.jsxs("div",{className:M,children:[E,$]}),e[83]=E,e[84]=$,e[85]=M,e[86]=O):O=e[86],O}function mV(t){const[e,s]=t;return{name:e,...s}}function pV(t,e){return t.title.localeCompare(e.title)}function gV(t){const[,e]=t;return e}function xV(t,e){return t.title.localeCompare(e.title)}function vV(t,e){return t.title.localeCompare(e.title)}function _V(t){return{resolveType:t.resolveType,title:t.title,folderPath:y3(t.resolveType)}}function bV(t){return{resolveType:t.resolveType,title:t.title,folderPath:y3(t.resolveType),savedKey:t.key}}function yV(){return new Set}function LV(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:r,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}const SV={target:null,editSeoPageKey:null,previewRevision:0};function wV(t,e){switch(e.type){case"select":return{...t,target:e.target};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"saved":return{...t,previewRevision:t.previewRevision+1}}}const S3=C.createContext(null);function jV(t){const e=B.c(9),{children:s}=t,[n,r]=C.useReducer(wV,SV);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>r({type:"select",target:u}),a=u=>r({type:"edit-seo",target:u}),l=()=>r({type:"consume-edit-seo"}),c=()=>r({type:"saved"}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,notifySaved:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=i.jsx(S3,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function w3(){const t=C.use(S3);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}const Xh=C.lazy(()=>Ws(()=>import("./app-editor-CQyzSGAt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppEditor}))),CV=C.lazy(()=>Ws(()=>import("./post-editor-By-N3zg4.js"),__vite__mapDeps([149,1,2,51,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,105,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,109,117,150,151,107,108,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.PostEditor}))),kV=C.lazy(()=>Ws(()=>import("./record-editor-BPDdom2o.js"),__vite__mapDeps([152,1,2,105,104,117,151,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,85,86,87,14,15,16,88,89,90,17,13,91,69,92,82,93,4,5,6,10,11,12,18,19,21,23,24,25,26,27,68,70,71,72,73,74,75,76,77,78,79,80,81,83,84,94,95,96,97,98,99,100,101,102,103,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.RecordEditor}))),VV=C.lazy(()=>Ws(()=>import("./category-editor-BXQcvflh.js"),__vite__mapDeps([153,1,2,35,31,28,32,33,34,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,96,105,104,150,73,74,75,76,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,97,98,99,100,101,102,103,151,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.CategoryEditor}))),NV=C.lazy(()=>Ws(()=>import("./bulk-category-panel-CzfCRQM_.js"),__vite__mapDeps([154,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,155,5,6])).then(t=>({default:t.BulkCategoryPanel}))),AV=C.lazy(()=>Ws(()=>import("./sections-editor-CXVf5rkb.js"),__vite__mapDeps([156,1,2,8,39,3,9,31,28,32,33,34,35,36,37,38,29,7,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,126,157,135,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SectionsEditor}))),TV=C.lazy(()=>Ws(()=>import("./seo-editor-Mkk341P4.js"),__vite__mapDeps([158,1,2,3,31,28,32,33,34,35,36,37,38,39,29,7,8,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoEditor}))),EV=C.lazy(()=>Ws(()=>import("./variant-calendar-BmacLARX.js"),__vite__mapDeps([159,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,135,160])).then(t=>({default:t.VariantCalendar}))),N0="oklch(0.65 0.15 160)";function Pc(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function RV(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function PV(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function IV(t){const e=new Map;for(const s of t){const n=PV(s.resolveType),r=e.get(n);r?r.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function j3(t){const e=B.c(20),{mode:s}=t,n=s===void 0?"content":s,r=kn(),{data:o}=vi.useSession(),{currentBranch:a}=as(),{org:l}=Ae(),c=r?.entity?.id??null,d=o?.user?.id,h=r?.entity?.metadata,u=d&&a?Cl(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(DV)??f[0])?.previewUrl??null,g=Os(),x=r?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:k9,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const _=pt(v),b=td(_);let y;e[3]!==a||e[4]!==b||e[5]!==c?(y=()=>{if(!c)return;const k={virtualMcpId:c};a&&(k.branch=a),b.mutate(k)},e[3]=a,e[4]=b,e[5]=c,e[6]=y):y=e[6];const L=y,w=!!c&&!!a&&nl.isStopped(c,a),S=f2({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:b.isError&&b.error?p2(b.error.message):null});if(S.kind!=="iframe"){const k=`/${l.slug}/settings/connections`;let V;return e[7]!==S||e[8]!==k||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(V=i.jsx(nN,{state:S,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:k}),e[7]=S,e[8]=k,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=V):V=e[12],V}if(!c||!a){let k;return e[13]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Mn,{title:"Waiting for sandbox context…"}),e[13]=k):k=e[13],k}let j;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==c?(j=i.jsx(OV,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=c,e[19]=j):j=e[19],j}function DV(t){return t.sandboxProviderKind!=="user-desktop"}const Qh=2e3,MV=15;function Zh(t,e,s,n){return typeof e!="string"||s&&(q2(e,s,n)||t.state.dataUpdateCount>=MV)?!1:Qh}function OV({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:r}){const o=w3(),a={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},{data:l,isLoading:c}=Bl(a),[d,h]=C.useState("pages"),[u,f]=C.useState(()=>r==="blocks"?Pc(o.state.target):null),[m,p]=C.useState(()=>r==="blocks"?o.state.editSeoPageKey:null),g=RV(o.state.target),[x,v]=C.useState(g);if(r==="blocks"&&x!==g){v(g);const oe=Pc(o.state.target);f(oe),(oe?.collection==="pages"||oe?.collection==="sections")&&h(oe.collection)}const[_,b]=C.useState(o.state.editSeoPageKey);if(r==="blocks"&&_!==o.state.editSeoPageKey&&(b(o.state.editSeoPageKey),o.state.editSeoPageKey)){const oe=o.state.target;oe?.kind==="page"&&(h("pages"),f(Pc(oe)),p(oe.key))}const[y,L]=C.useState(""),[w,S]=C.useState(null),[j,k]=C.useState(null),[V,T]=C.useState("date-desc"),[A,N]=C.useState(()=>new Set),[E,I]=C.useState(null),P=()=>{N(new Set),I(null)},R=oe=>{f(oe),p(null),!(r!=="blocks"||!oe)&&(oe.collection==="pages"?o.selectTarget({kind:"page",key:oe.key,path:oe.path}):oe.collection==="sections"&&o.selectTarget({kind:"section",key:oe.key}))},[D,M]=C.useState(d);D!==d&&(M(d),L(""),S(null),k(null),T("date-desc"),N(new Set),I(null));const{data:F,isLoading:$,isFetching:O}=zl(a,{refetchInterval:oe=>{const Le=oe.state.data;if(d==="apps"&&u&&u.collection==="apps"){const Te=l?.[u.key];return Zh(oe,typeof Te?.__resolveType=="string"?Te.__resolveType:void 0,Le)}if(d==="site"&&l){const Te=Le?L0(l,Le):null,$e=l.site,st=Te?.resolveType??(typeof $e?.__resolveType=="string"?$e.__resolveType:void 0);return Zh(oe,st,Le,["seo"])}return!1}}),U=(oe,Le)=>!q2(oe,F,Le)&&($||O),{catalog:K,isLoading:H}=i7(F??void 0,l??void 0,{enabled:d==="apps"}),q=Ul(a),J=BL(a),G=Gk(a),W=Jk(a),[z,X]=C.useState(null),[Q,Z]=C.useState(),[Y,ee]=C.useState(null),[te,ae]=C.useState(null),[se,ie]=C.useState(null);if(c||$)return i.jsx("div",{className:"h-full w-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})});if(!l||!F)return i.jsx(Mn,{title:"Could not load site data."});const fe=md(l).sort((oe,Le)=>oe.name.localeCompare(Le.name)),me=pd(l,F),be=d==="sections"?KL(F):[],_e=L0(l,F),xe=h3(l),ke=Bd.some(oe=>xe[oe].length>0),Ne=to(d)?xe[d]:[],we=(ke?bo(l,"categories"):[]).map(({key:oe,payload:Le})=>{const Te=typeof Le.slug=="string"?Le.slug:"",$e=typeof Le.name=="string"?Le.name:"";return{slug:Te||oe,name:$e||Te||oe}}).filter(oe=>oe.slug).sort((oe,Le)=>oe.name.localeCompare(Le.name)),ye=d==="posts"&&(A.size>0||E!==null),Be=ye?m3(l).filter(oe=>A.has(oe.key)):[],Fe=Yh(F,"loaders"),pe=Yh(F,"actions");if(!fd(l,F)&&!ke&&Fe===0&&pe===0)return i.jsx(Mn,{icon:fn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Ee={pages:fe.length,sections:me.length,apps:K.length,loaders:Fe,actions:pe,posts:xe.posts.length,authors:xe.authors.length,categories:xe.categories.length},De=new Set(fe.map(oe=>ai(oe.path))),ue=new Set(fe.map(oe=>oe.name)),le=new Set(me.map(oe=>oe.name)),Ve=async oe=>{const Le=l[oe.key];if(!Le)return;const Te=cp(l,oe.key),$e=b7(l,oe.key,Math.max(0,Te-1)),st=y7(Le.sections,$e);if(st)try{await q.mutateAsync({blockKey:oe.key,data:{...Le,sections:st}}),ce.success(`Variant added to "${oe.name}"`),f({collection:"pages",key:oe.key,path:oe.path})}catch(ht){ce.error(ht instanceof Error?ht.message:"Could not add variant")}},Me=()=>{Z(void 0),X({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},Ue=oe=>{Z(void 0),X({mode:"duplicate",sourceKey:oe.key,initialName:Kh(ue,oe.name),initialPath:yk(De,oe.path)})},it=oe=>{Z(void 0),X({mode:"rename",sourceKey:oe.key,initialName:oe.name,initialPath:oe.path})},Yt=async oe=>{if(!z)return;const{mode:Le,sourceKey:Te}=z;try{if(Le==="create"){let $e;if(oe.templateKey){const ht=l[oe.templateKey];if(!ht)throw new Error("Selected template no longer exists.");$e={...ht,name:oe.name,path:oe.path}}else $e=wk(oe.name,oe.path);const st=Ck(l,oe.name);await q.mutateAsync({blockKey:st,data:$e}),ce.success(`Created "${oe.name}"`),f({collection:"pages",key:st,path:oe.path})}else if(Le==="duplicate"&&Te){const $e=l[Te];if(!$e)throw new Error("Source page not found");const{key:st,data:ht}=Sk({source:$e,pages:fe,newName:oe.name,newPath:oe.path});await q.mutateAsync({blockKey:st,data:ht}),ce.success(`Duplicated as "${oe.name}"`),f({collection:"pages",key:st,path:oe.path})}else if(Le==="rename"&&Te){const $e=l[Te];if(!$e)throw new Error("Page not found");const st={...$e,name:oe.name,path:oe.path};await q.mutateAsync({blockKey:Te,data:st}),ce.success("Page updated"),u?.collection==="pages"&&u.key===Te&&f({collection:"pages",key:Te,path:oe.path})}X(null)}catch($e){Z($e instanceof Error?$e.message:"Save failed")}},Rt=({path:oe})=>{if(!z)return null;const Le=ai(oe);return(z.mode==="rename"?ai(z.initialPath):null)!==Le&&De.has(Le)?`A page with path "${oe}" already exists.`:null},rt=async(oe,Le,Te)=>{await q.mutateAsync({blockKey:Le,data:{...Te,name:Le,__resolveType:oe}}),ce.success(`Created section "${Le}"`),f({collection:"sections",key:Le})},gt=up((oe,Le)=>q.mutate({blockKey:oe,data:Le})),lt=async oe=>{const Le=l[oe.key];if(!Le){ce.error("Section not found.");return}const Te=Lk(l,oe.key),$e=Kh(le,oe.name),st={...Le,name:$e};try{await q.mutateAsync({blockKey:Te,data:st}),ce.success(`Duplicated "${oe.name}"`),f({collection:"sections",key:Te})}catch(ht){ce.error(ht instanceof Error?ht.message:"Duplicate failed")}},wt=async oe=>{if(!Y)return;const Le=l[Y];if(!Le){ce.error("Section not found.");return}try{await q.mutateAsync({blockKey:Y,data:{...Le,name:oe}}),ce.success("Section renamed"),ee(null)}catch(Te){ce.error(Te instanceof Error?Te.message:"Rename failed")}},ct=async oe=>{const Le=qh(l,oe),Te=fa(Le,oe,zk(oe));try{await G.mutateAsync({blockKey:Le,data:Te}),ce.success(`Created ${eo[oe]}`),f({collection:oe,key:Le})}catch($e){ce.error($e instanceof Error?$e.message:"Could not create")}},he=async oe=>{const Le=l[oe.key];if(!Le){ce.error("Record not found.");return}const Te=qh(l,oe.kind),$e=oe.kind==="posts"?"title":"name",st={...structuredClone(Na(Le,oe.kind)),[$e]:`${oe.label} (copy)`};try{await G.mutateAsync({blockKey:Te,data:fa(Te,oe.kind,st)}),ce.success(`Duplicated "${oe.label}"`),f({collection:oe.kind,key:Te})}catch(ht){ce.error(ht instanceof Error?ht.message:"Duplicate failed")}},Oe=oe=>{N(Le=>{const Te=new Set(Le);return Te.has(oe)?Te.delete(oe):Te.add(oe),Te})},et=oe=>{h("posts"),M("posts"),f(null),p(null),L(""),S(null),k(null),T("date-desc"),N(new Set),I(oe||null)},tt=async(oe,Le)=>{const Te=[...A];let $e=0;for(const st of Te){const ht=l[st],Vn=Na(ht,"posts"),Qn=oe==="add"?Ok(Vn,Le):$k(Vn,Le);Qn!==Vn&&(await G.mutateAsync({blockKey:st,data:fa(st,"posts",Qn)}),$e+=1)}return $e},vs=async(oe,Le)=>{const Te=A.size;try{const $e=await tt(oe,Le),st=oe==="add"?"Added to":"Moved",ht=Te-$e;ce.success(`${st} ${$e} ${$e===1?"post":"posts"}`+(ht>0?` (${ht} already set)`:"")),P()}catch($e){ce.error($e instanceof Error?$e.message:"Bulk update failed")}},us=async()=>{if(te)try{if(te.kind==="blog-bulk"){for(const $e of te.keys)await W.mutateAsync({blockKey:$e});ce.success(`Deleted ${te.count} ${te.count===1?"post":"posts"}`),u&&u.collection!=="available-section"&&te.keys.includes(u.key)&&f(null),P(),ae(null);return}const{kind:oe,key:Le,label:Te}=te;if(oe==="blog"){if(te.blogKind==="categories"){const $e=Na(l[Le],"categories").slug,st=typeof $e=="string"?$e:"";if(st)for(const{key:ht,payload:Vn}of bo(l,"posts")){const Qn=Bk(Vn,st);Qn!==Vn&&await G.mutateAsync({blockKey:ht,data:fa(ht,"posts",Qn)})}}await W.mutateAsync({blockKey:Le})}else await J.mutateAsync({blockKey:Le});ce.success(`Deleted "${Te}"`),u&&u.collection!=="available-section"&&u.key===Le&&f(null),ae(null)}catch(oe){ce.error(oe instanceof Error?oe.message:"Delete failed")}},Jt=J.isPending||W.isPending||G.isPending,mn=te?.kind==="blog"?eo[te.blogKind]:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"}`:te?.kind??"item";return i.jsxs("div",{className:"flex h-full w-full",children:[r==="content"&&i.jsx(BV,{active:d,counts:Ee,showBlog:ke,onSelect:oe=>{h(oe),f(null),p(null)}}),d!=="seo"&&d!=="site"&&d!=="calendar"&&d!=="loaders"&&d!=="actions"&&i.jsx(zV,{blocksMode:r==="blocks",activeCollection:d,pages:fe,sections:me,availableSections:be,appCatalog:K,appCatalogLoading:H,blogEntries:Ne,decofile:l,searchQuery:y,onSearchChange:L,postCategoryFilter:w,postAuthorFilter:j,postSort:V,onPostCategoryFilterChange:oe=>{S(oe),N(new Set)},onPostAuthorFilterChange:oe=>{k(oe),N(new Set)},onPostSortChange:T,selectedPostKeys:A,postBulkPanelOpen:ye,onTogglePostSelect:Oe,onSelectAllPosts:oe=>N(new Set(oe)),onClearPostSelection:()=>N(new Set),onExitPostSelection:P,onBulkDeletePosts:()=>ae({kind:"blog-bulk",keys:[...A],count:A.size}),selection:u,onSelect:R,onCollectionSelect:oe=>{h(oe),f(null),p(null)},onCreate:()=>{d==="pages"?Me():to(d)&&ct(d)},onDuplicatePage:Ue,onRenamePage:it,onAddPageVariant:Ve,onDeletePage:oe=>ae({kind:"page",key:oe.key,label:oe.name}),onEditPageSeo:oe=>{const Le={collection:"pages",key:oe.key,path:oe.path};f(Le),p(oe.key),r==="blocks"&&o.editSeo({kind:"page",key:oe.key,path:oe.path})},onViewPageJson:oe=>ie(oe.key),onDuplicateSection:lt,onRenameSection:oe=>ee(oe.key),onDeleteSection:oe=>ae({kind:"section",key:oe.key,label:oe.name}),onDuplicateBlog:he,onDeleteBlog:oe=>ae({kind:"blog",blogKind:oe.kind,key:oe.key,label:oe.label})}),i.jsx("div",{className:"flex-1 min-w-0",children:d==="loaders"||d==="actions"?i.jsx(fV,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:F,decofile:l,kind:d}):i.jsx(C.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),children:d==="calendar"?i.jsx(EV,{decofile:l}):d==="site"?_e?i.jsx(Xh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:_e.key,block:l[_e.key],decofile:l,meta:F,title:"Site",excludeFields:["seo"],schemaPending:U(_e.resolveType,["seo"]),previewBaseUrl:n},`site:${_e.key}`):i.jsx(Mn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):d==="seo"?i.jsx(TV,{orgSlug:t,virtualMcpId:e,branch:s,decofile:l,meta:F,target:{kind:"site"},previewBaseUrl:n}):d==="sections"?i.jsx($V,{selection:u?.collection==="sections"||u?.collection==="available-section"?u:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:F,decofile:l,isCreating:q.isPending,onCreateAvailable:rt,onSaveReferencedBlock:gt}):ye?i.jsx(NV,{posts:Be,categories:we,initialSlug:E,isPending:G.isPending,onApply:(oe,Le)=>{vs(oe,Le)},onClose:P},E??"selection"):u&&u.collection!=="available-section"?u.collection==="apps"?i.jsx(Xh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:F,previewBaseUrl:n,schemaPending:U(typeof l[u.key]?.__resolveType=="string"?String(l[u.key].__resolveType):void 0)},`app:${u.key}`):u.collection==="posts"?i.jsx(CV,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:F,previewBaseUrl:n},`post:${u.key}`):u.collection==="categories"?i.jsx(VV,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:F,onManagePosts:et,onOpenPost:oe=>{h("posts"),M("posts"),f({collection:"posts",key:oe}),p(null)},previewBaseUrl:n},`category:${u.key}`):u.collection==="authors"?i.jsx(kV,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:u.key,block:l[u.key]},`authors:${u.key}`):i.jsx(AV,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:u.collection==="pages"?u.path:"/",activePageBlockKey:u.collection==="pages"?u.key:null,activeGlobalBlockKey:u.collection==="sections"?u.key:null,initialEditSeo:u.collection==="pages"&&m===u.key,onExitSeo:()=>{p(null),r==="blocks"&&o.consumeEditSeo()},onSaved:r==="blocks"?o.notifySaved:void 0},u.collection==="pages"?`page:${u.key}`:`section:${u.key}`):i.jsx(Mn,{title:`Select ${to(d)?`a ${eo[d]}`:d==="pages"?"a page":d==="apps"?"an app":"a section"} to edit`,description:d==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),z&&i.jsx(Tk,{open:!!z,mode:z.mode,initialName:z.initialName,initialPath:z.initialPath,isPending:q.isPending,error:Q,templates:fe,validate:Rt,onSubmit:Yt,onOpenChange:oe=>{oe||(X(null),Z(void 0))}}),Y&&i.jsx(Ek,{open:!!Y,blockKey:Y,initialName:me.find(oe=>oe.key===Y)?.name??Y,isPending:q.isPending,onSubmit:wt,onOpenChange:oe=>{oe||ee(null)}}),se&&i.jsx(Xk,{open:!!se,onOpenChange:oe=>{oe||ie(null)},pageKey:se,decofile:l}),i.jsx(Wa,{open:!!te,onOpenChange:oe=>{!oe&&!Jt&&ae(null)},children:i.jsxs(qa,{children:[i.jsxs(Ga,{children:[i.jsx(Ya,{children:`Delete ${mn}?`}),i.jsx(Ja,{children:te?.kind==="section"?`"${te.label}" will be removed. Pages that still reference it will lose this section.`:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:te?`"${te.label}" will be removed permanently. This can't be undone.`:null})]}),i.jsxs(Xa,{children:[i.jsx(Qa,{disabled:Jt,children:"Cancel"}),i.jsx(Za,{onClick:oe=>{oe.preventDefault(),us()},disabled:Jt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Jt?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function $V(t){const e=B.c(30),{selection:s,orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Mn,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,x=s.title;let v;e[1]!==s.title?(v=dp(s.title),e[1]=s.title,e[2]=v):v=e[2];let _;e[3]!==h||e[4]!==s.resolveType?(_=(y,L)=>h(s.resolveType,y,L),e[3]=h,e[4]=s.resolveType,e[5]=_):_=e[5];let b;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==l||e[10]!==u||e[11]!==n||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==v||e[17]!==_||e[18]!==r?(b=i.jsx(sk,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:g,title:x,defaultBlockId:v,isCreating:d,onCreate:_,onSaveReferencedBlock:u},p),e[6]=o,e[7]=c,e[8]=d,e[9]=l,e[10]=u,e[11]=n,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=v,e[17]=_,e[18]=r,e[19]=b):b=e[19],b}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==c||e[22]!==l||e[23]!==u||e[24]!==n||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=i.jsx(ok,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=c,e[22]=l,e[23]=u,e[24]=n,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function ef(t){const e=B.c(8),{icon:s,label:n,className:r}=t;let o;e[0]!==r?(o=ne("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=i.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function BV(t){const e=B.c(47),{active:s,counts:n,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:i.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let c;e[1]!==n.pages||e[2]!==o||e[3]!==l?(c=i.jsx($s,{id:"pages",icon:Dn,label:"Pages",count:n.pages,active:l,onSelect:o}),e[1]=n.pages,e[2]=o,e[3]=l,e[4]=c):c=e[4];const d=s==="sections";let h;e[5]!==n.sections||e[6]!==o||e[7]!==d?(h=i.jsx($s,{id:"sections",icon:on,label:"Sections",count:n.sections,active:d,onSelect:o}),e[5]=n.sections,e[6]=o,e[7]=d,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==n.apps||e[10]!==o||e[11]!==u?(f=i.jsx($s,{id:"apps",icon:R1,label:"Apps",count:n.apps,active:u,onSelect:o}),e[9]=n.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="loaders";let p;e[13]!==n.loaders||e[14]!==o||e[15]!==m?(p=i.jsx($s,{id:"loaders",icon:Fa,label:"Loaders",count:n.loaders,active:m,onSelect:o}),e[13]=n.loaders,e[14]=o,e[15]=m,e[16]=p):p=e[16];const g=s==="actions";let x;e[17]!==n.actions||e[18]!==o||e[19]!==g?(x=i.jsx($s,{id:"actions",icon:ui,label:"Actions",count:n.actions,active:g,onSelect:o}),e[17]=n.actions,e[18]=o,e[19]=g,e[20]=x):x=e[20];const v=s==="site";let _;e[21]!==o||e[22]!==v?(_=i.jsx($s,{id:"site",icon:am,label:"Site",active:v,onSelect:o}),e[21]=o,e[22]=v,e[23]=_):_=e[23];const b=s==="seo";let y;e[24]!==o||e[25]!==b?(y=i.jsx($s,{id:"seo",icon:Ua,label:"SEO",active:b,onSelect:o}),e[24]=o,e[25]=b,e[26]=y):y=e[26];const L=s==="calendar";let w;e[27]!==o||e[28]!==L?(w=i.jsx($s,{id:"calendar",icon:wm,label:"Calendar",active:L,onSelect:o}),e[27]=o,e[28]=L,e[29]=w):w=e[29];let S;e[30]!==s||e[31]!==n.authors||e[32]!==n.categories||e[33]!==n.posts||e[34]!==o||e[35]!==r?(S=r&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[i.jsx(Ki,{size:13,className:"shrink-0"}),"Blog"]}),i.jsx($s,{id:"posts",icon:Wi,label:"Posts",count:n.posts,active:s==="posts",onSelect:o}),i.jsx($s,{id:"authors",icon:W9,label:"Authors",count:n.authors,active:s==="authors",onSelect:o}),i.jsx($s,{id:"categories",icon:om,label:"Categories",count:n.categories,active:s==="categories",onSelect:o})]}),e[30]=s,e[31]=n.authors,e[32]=n.categories,e[33]=n.posts,e[34]=o,e[35]=r,e[36]=S):S=e[36];let j;return e[37]!==x||e[38]!==_||e[39]!==y||e[40]!==w||e[41]!==S||e[42]!==c||e[43]!==h||e[44]!==f||e[45]!==p?(j=i.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,i.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[c,h,f,p,x,_,y,w,S]})]}),e[37]=x,e[38]=_,e[39]=y,e[40]=w,e[41]=S,e[42]=c,e[43]=h,e[44]=f,e[45]=p,e[46]=j):j=e[46],j}function $s(t){const e=B.c(18),{id:s,icon:n,label:r,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ne("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=i.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==r?(f=i.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&i.jsx("span",{className:ne("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=i.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function zV(t){const e=B.c(86),{blocksMode:s,activeCollection:n,pages:r,sections:o,availableSections:a,appCatalog:l,appCatalogLoading:c,blogEntries:d,decofile:h,searchQuery:u,onSearchChange:f,postCategoryFilter:m,postAuthorFilter:p,postSort:g,onPostCategoryFilterChange:x,onPostAuthorFilterChange:v,onPostSortChange:_,selectedPostKeys:b,postBulkPanelOpen:y,onTogglePostSelect:L,onSelectAllPosts:w,onClearPostSelection:S,onExitPostSelection:j,onBulkDeletePosts:k,selection:V,onSelect:T,onCollectionSelect:A,onCreate:N,onDuplicatePage:E,onRenamePage:I,onAddPageVariant:P,onDeletePage:R,onEditPageSeo:D,onViewPageJson:M,onDuplicateSection:F,onRenameSection:$,onDeleteSection:O,onDuplicateBlog:U,onDeleteBlog:K}=t;let H,q,J,G,W,z,X,Q;if(e[0]!==n||e[1]!==l||e[2]!==c||e[3]!==a||e[4]!==s||e[5]!==d||e[6]!==h||e[7]!==P||e[8]!==k||e[9]!==S||e[10]!==A||e[11]!==N||e[12]!==K||e[13]!==R||e[14]!==O||e[15]!==U||e[16]!==E||e[17]!==F||e[18]!==D||e[19]!==j||e[20]!==v||e[21]!==x||e[22]!==_||e[23]!==I||e[24]!==$||e[25]!==f||e[26]!==T||e[27]!==w||e[28]!==L||e[29]!==M||e[30]!==r||e[31]!==p||e[32]!==y||e[33]!==m||e[34]!==g||e[35]!==u||e[36]!==o||e[37]!==b||e[38]!==V){const te=u.toLowerCase(),ae=r.filter(he=>!te||he.name.toLowerCase().includes(te)||he.path.toLowerCase().includes(te)),se=o.filter(he=>!te||he.name.toLowerCase().includes(te)||he.key.toLowerCase().includes(te)||he.resolveType.toLowerCase().includes(te)),ie=a.filter(he=>!te||he.title.toLowerCase().includes(te)||he.resolveType.toLowerCase().includes(te)||(he.description?.toLowerCase().includes(te)??!1)),fe=IV(se),me=l.filter(he=>!te||he.title.toLowerCase().includes(te)||he.app.toLowerCase().includes(te)||he.vendor.toLowerCase().includes(te)||he.category.toLowerCase().includes(te)),be=d.filter(he=>!te||he.label.toLowerCase().includes(te)||he.subtitle.toLowerCase().includes(te)),_e=n==="posts",xe=KV,ke=_e?m3(h):[],Ne=new Map,we=new Map;for(const he of ke){for(const Oe of he.categorySlugs)Ne.set(Oe,(Ne.get(Oe)??0)+1);for(const Oe of he.authorEmails)we.set(Oe,(we.get(Oe)??0)+1)}const ye=(_e?bo(h,"categories"):[]).map(he=>{const{key:Oe,payload:et}=he,tt=xe(et.slug)||Oe;return{slug:tt,name:xe(et.name)||xe(et.slug)||Oe,count:Ne.get(tt)??0}}).filter(HV),Be=(_e?bo(h,"authors"):[]).map(he=>{const{key:Oe,payload:et}=he,tt=xe(et.email);return{email:tt,name:xe(et.name)||xe(et.email)||Oe,count:we.get(tt)??0}}).filter(UV);let Fe;e[47]!==m?(Fe=he=>!m||he.categorySlugs.includes(m),e[47]=m,e[48]=Fe):Fe=e[48];let pe;e[49]!==p?(pe=he=>!p||he.authorEmails.includes(p),e[49]=p,e[50]=pe):pe=e[50];let Ee;e[51]!==g?(Ee=(he,Oe)=>{if(g==="az")return he.title.localeCompare(Oe.title);if(g==="za")return Oe.title.localeCompare(he.title);const et=he.date.localeCompare(Oe.date);return g==="date-asc"?et:-et},e[51]=g,e[52]=Ee):Ee=e[52];const De=ke.filter(he=>!te||he.title.toLowerCase().includes(te)||he.slug.toLowerCase().includes(te)).filter(Fe).filter(pe).sort(Ee),ue=b.size,le=De.map(FV),Ve=le.length>0&&le.every(he=>b.has(he)),Me=ue>0||y,Ue=()=>{Ve?S():w(le)},it=`Search ${n}…`,Yt=to(n)?`Create new ${eo[n]}`:"Create new page",Rt=n!=="apps"&&n!=="sections",rt=s?"w-[240px]":"w-[300px]";e[53]!==rt?(W=ne("shrink-0 border-r flex flex-col min-h-0",rt),e[53]=rt,e[54]=W):W=e[54],e[55]!==n||e[56]!==s||e[57]!==A?(z=s&&i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[i.jsxs(re,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("pages"),children:[i.jsx(Dn,{size:14}),"Pages"]}),i.jsxs(re,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("sections"),children:[i.jsx(on,{size:14}),"Sections"]})]}),e[55]=n,e[56]=s,e[57]=A,e[58]=z):z=e[58];let gt;e[59]===Symbol.for("react.memo_cache_sentinel")?(gt=i.jsx(K9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[59]=gt):gt=e[59];let lt;e[60]!==f?(lt=he=>f(he.target.value),e[60]=f,e[61]=lt):lt=e[61];let wt;e[62]!==it||e[63]!==u||e[64]!==lt?(wt=i.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[gt,i.jsx("input",{type:"text",value:u,onChange:lt,placeholder:it,"aria-label":it,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[62]=it,e[63]=u,e[64]=lt,e[65]=wt):wt=e[65];let ct;e[66]!==Yt||e[67]!==N||e[68]!==Rt?(ct=Rt&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:N,"aria-label":Yt,children:i.jsx(Lt,{size:14})})}),i.jsx(Pe,{side:"bottom",children:Yt})]}),e[66]=Yt,e[67]=N,e[68]=Rt,e[69]=ct):ct=e[69],e[70]!==wt||e[71]!==ct?(X=i.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[wt,ct]}),e[70]=wt,e[71]=ct,e[72]=X):X=e[72],Q=_e&&(Me?i.jsx(eN,{count:ue,allSelected:Ve,onToggleSelectAll:Ue,onDelete:k,onExit:j}):i.jsx(qV,{categories:ye,authors:Be,categoryFilter:m,authorFilter:p,sort:g,onCategoryFilterChange:x,onAuthorFilterChange:v,onSortChange:_})),H=Sn,G="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",q="flex flex-col gap-1 p-1.5",J=n==="pages"?ae.length===0?i.jsx(Cr,{hasItems:r.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):ae.map(he=>{const Oe=V?.collection==="pages"&&V.key===he.key,et=cp(h,he.key);return i.jsx(tn,{icon:Dn,title:he.name,subtitle:he.path,active:Oe,variantCount:et,onClick:()=>T({collection:"pages",key:he.key,path:he.path}),menu:i.jsx(pa,{onDuplicate:()=>E(he),onRename:()=>I(he),onAddVariant:()=>P(he),onEditSeo:()=>D(he),onViewJson:()=>M(he),onDelete:()=>R(he)})},he.key)}):n==="sections"?se.length===0&&ie.length===0?i.jsx(Cr,{hasItems:o.length>0||a.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):i.jsxs(i.Fragment,{children:[fe.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(ef,{icon:on,label:"Saved sections"}),fe.map(he=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:he.label}),he.sections.map(Oe=>{const et=V?.collection==="sections"&&V.key===Oe.key;return i.jsx(tn,{icon:on,accent:"global",title:Oe.name,subtitle:he.label,active:et,onClick:()=>T({collection:"sections",key:Oe.key}),menu:i.jsx(pa,{onDuplicate:()=>F(Oe),onRename:()=>$(Oe),onDelete:()=>O(Oe)})},Oe.key)})]},he.label))]}),ie.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(ef,{icon:Dn,label:"Available sections",className:ne(fe.length>0&&"mt-3")}),ie.map(he=>{const Oe=V?.collection==="available-section"&&V.resolveType===he.resolveType,et=he.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return i.jsx(tn,{icon:Dn,title:he.title,subtitle:et??he.resolveType,active:Oe,onClick:()=>T({collection:"available-section",resolveType:he.resolveType,title:he.title})},he.resolveType)})]})]}):n==="apps"?c?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(qe,{size:18,className:"animate-spin text-muted-foreground"})}):me.length===0?i.jsx(Cr,{hasItems:l.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):me.map(he=>{const Oe=V?.collection==="apps"&&he.blockKey!==null&&V.key===he.blockKey;return i.jsx(tn,{icon:R1,logoUrl:he.logo,title:he.title,subtitle:he.category,active:Oe,trailing:he.installed?i.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!he.installed||!he.blockKey){ce.message(`${he.title} is not installed on this site.`);return}T({collection:"apps",key:he.blockKey})}},he.id)}):_e?De.length===0?i.jsx(Cr,{hasItems:ke.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):De.map(he=>{const Oe={key:he.key,kind:"posts",label:he.title,subtitle:he.slug};return i.jsx(tn,{icon:Wi,title:he.title,subtitle:he.slug,active:V?.collection==="posts"&&V.key===he.key,selectable:!0,selectionActive:Me,selected:b.has(he.key),onToggleSelect:()=>L(he.key),onClick:()=>Me?L(he.key):T({collection:"posts",key:he.key}),menu:i.jsx(pa,{onDuplicate:()=>U(Oe),onDelete:()=>K(Oe)})},he.key)}):be.length===0?i.jsx(Cr,{hasItems:d.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${to(n)?eo[n]:"item"}.`}):be.map(he=>{const Oe=V?.collection===he.kind&&V.key===he.key;return i.jsx(tn,{icon:he.kind==="posts"?Wi:he.kind==="authors"?W9:om,title:he.label,subtitle:he.subtitle,active:Oe,onClick:()=>T({collection:he.kind,key:he.key}),menu:i.jsx(pa,{onDuplicate:()=>U(he),onDelete:()=>K(he)})},he.key)}),e[0]=n,e[1]=l,e[2]=c,e[3]=a,e[4]=s,e[5]=d,e[6]=h,e[7]=P,e[8]=k,e[9]=S,e[10]=A,e[11]=N,e[12]=K,e[13]=R,e[14]=O,e[15]=U,e[16]=E,e[17]=F,e[18]=D,e[19]=j,e[20]=v,e[21]=x,e[22]=_,e[23]=I,e[24]=$,e[25]=f,e[26]=T,e[27]=w,e[28]=L,e[29]=M,e[30]=r,e[31]=p,e[32]=y,e[33]=m,e[34]=g,e[35]=u,e[36]=o,e[37]=b,e[38]=V,e[39]=H,e[40]=q,e[41]=J,e[42]=G,e[43]=W,e[44]=z,e[45]=X,e[46]=Q}else H=e[39],q=e[40],J=e[41],G=e[42],W=e[43],z=e[44],X=e[45],Q=e[46];let Z;e[73]!==q||e[74]!==J?(Z=i.jsx("div",{className:q,children:J}),e[73]=q,e[74]=J,e[75]=Z):Z=e[75];let Y;e[76]!==H||e[77]!==G||e[78]!==Z?(Y=i.jsx(H,{className:G,children:Z}),e[76]=H,e[77]=G,e[78]=Z,e[79]=Y):Y=e[79];let ee;return e[80]!==W||e[81]!==z||e[82]!==X||e[83]!==Q||e[84]!==Y?(ee=i.jsxs("div",{className:W,children:[z,X,Q,Y]}),e[80]=W,e[81]=z,e[82]=X,e[83]=Q,e[84]=Y,e[85]=ee):ee=e[85],ee}function FV(t){return t.key}function UV(t){return t.email}function HV(t){return t.slug}function KV(t){return typeof t=="string"?t:""}const tf="__all__",C3={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},WV={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},sf=C.forwardRef(function(e,s){const n=B.c(20);let r,o,a,l,c;n[0]!==e?({icon:r,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(r=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=ne("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==r?(u=i.jsx(r,{size:14,className:"shrink-0"}),n[9]=r,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Ht,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=i.jsxs(re,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function k3(t){const e=B.c(2),{count:s}=t;let n;return e[0]!==s?(n=i.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function qV(t){const e=B.c(60),{categories:s,authors:n,categoryFilter:r,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t;let h;if(e[0]!==s||e[1]!==r){let K;e[3]!==r?(K=H=>H.slug===r,e[3]=r,e[4]=K):K=e[4],h=s.find(K),e[0]=s,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;if(e[5]!==o||e[6]!==n){let K;e[8]!==o?(K=H=>H.email===o,e[8]=o,e[9]=K):K=e[9],f=n.find(K),e[5]=o,e[6]=n,e[7]=f}else f=e[7];const m=f,p=!!(r||o),g=u?.name??m?.name??"Filter",x=r?`cat:${r}`:o?`author:${o}`:tf;let v;e[10]!==c||e[11]!==l?(v=()=>{l(null),c(null)},e[10]=c,e[11]=l,e[12]=v):v=e[12];const _=v;let b;e[13]!==_||e[14]!==c||e[15]!==l?(b=K=>{K.startsWith("cat:")?(c(null),l(K.slice(4))):K.startsWith("author:")?(l(null),c(K.slice(7))):_()},e[13]=_,e[14]=c,e[15]=l,e[16]=b):b=e[16];const y=b;let L;e[17]!==g||e[18]!==p?(L=i.jsx(es,{asChild:!0,children:i.jsx(sf,{icon:ux,active:p,value:g,className:"min-w-0 shrink"})}),e[17]=g,e[18]=p,e[19]=L):L=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(Ir,{children:"Filter by"}),e[20]=w):w=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(Io,{value:tf,children:"All posts"}),e[21]=S):S=e[21];let j;e[22]!==s.length?(j=s.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Category"}),e[22]=s.length,e[23]=j):j=e[23];let k;e[24]!==s?(k=s.map(JV),e[24]=s,e[25]=k):k=e[25];let V;e[26]!==n.length?(V=n.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Author"}),e[26]=n.length,e[27]=V):V=e[27];let T;e[28]!==n?(T=n.map(YV),e[28]=n,e[29]=T):T=e[29];let A;e[30]!==x||e[31]!==y||e[32]!==V||e[33]!==T||e[34]!==j||e[35]!==k?(A=i.jsxs(ts,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[w,i.jsxs(h0,{value:x,onValueChange:y,children:[S,j,k,V,T]})]}),e[30]=x,e[31]=y,e[32]=V,e[33]=T,e[34]=j,e[35]=k,e[36]=A):A=e[36];let N;e[37]!==A||e[38]!==L?(N=i.jsxs(Zt,{children:[L,A]}),e[37]=A,e[38]=L,e[39]=N):N=e[39];let E;e[40]!==_||e[41]!==p?(E=p&&i.jsx(XV,{label:"Clear filter",onClick:_}),e[40]=_,e[41]=p,e[42]=E):E=e[42];const I=WV[a];let P;e[43]!==I?(P=i.jsx(es,{asChild:!0,children:i.jsx(sf,{icon:hx,active:!0,value:I})}),e[43]=I,e[44]=P):P=e[44];let R;e[45]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(Ir,{children:"Sort by"}),e[45]=R):R=e[45];let D;e[46]!==d?(D=K=>d(K),e[46]=d,e[47]=D):D=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(C3),e[48]=M):M=e[48];let F;e[49]===Symbol.for("react.memo_cache_sentinel")?(F=M.map(GV),e[49]=F):F=e[49];let $;e[50]!==a||e[51]!==D?($=i.jsxs(ts,{align:"end",className:"w-44",children:[R,i.jsx(h0,{value:a,onValueChange:D,children:F})]}),e[50]=a,e[51]=D,e[52]=$):$=e[52];let O;e[53]!==P||e[54]!==$?(O=i.jsx("div",{className:"ml-auto shrink-0",children:i.jsxs(Zt,{children:[P,$]})}),e[53]=P,e[54]=$,e[55]=O):O=e[55];let U;return e[56]!==N||e[57]!==E||e[58]!==O?(U=i.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[N,E,O]}),e[56]=N,e[57]=E,e[58]=O,e[59]=U):U=e[59],U}function GV(t){return i.jsx(Io,{value:t,children:C3[t]},t)}function YV(t){return i.jsxs(Io,{value:`author:${t.email}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(k3,{count:t.count})]},`author:${t.email}`)}function JV(t){return i.jsxs(Io,{value:`cat:${t.slug}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(k3,{count:t.count})]},`cat:${t.slug}`)}function XV(t){const e=B.c(4),{label:s,onClick:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(ms,{size:12}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==n?(o=i.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:r}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function QV(t){const e=B.c(12),{checked:s,disabled:n,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==n||e[4]!==o||e[5]!==a?(l=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:ZV,children:i.jsx(cr,{checked:s,disabled:n,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a,e[6]=l):l=e[6];const c=s?"Deselect all":"Select all";let d;e[7]!==c?(d=i.jsx(Pe,{side:"bottom",children:c}),e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==l||e[10]!==d?(h=i.jsxs(Ie,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=h):h=e[11],h}function ZV(t){return t.stopPropagation()}function eN(t){const e=B.c(25),{count:s,allSelected:n,onToggleSelectAll:r,onDelete:o,onExit:a}=t;let l;e[0]!==n||e[1]!==r?(l=i.jsx(QV,{checked:n,onToggle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;e[3]!==s?(c=i.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];const d=s===0;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(ws,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==d?(u=i.jsx(Re,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:d,onClick:o,"aria-label":"Delete selected posts",children:h})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{side:"bottom",children:"Delete selected"}),e[9]=f):f=e[9];let m;e[10]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(ms,{size:14}),e[12]=p):p=e[12];let g;e[13]!==a?(g=i.jsx(Re,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":"Exit selection",children:p})}),e[13]=a,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Exit selection"}),e[15]=x):x=e[15];let v;e[16]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[16]=g,e[17]=v):v=e[17];let _;e[18]!==v||e[19]!==m?(_=i.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,v]}),e[18]=v,e[19]=m,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==_||e[23]!==c?(b=i.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[l,c,_]}),e[21]=l,e[22]=_,e[23]=c,e[24]=b):b=e[24],b}function tn(t){const e=B.c(37),{icon:s,logoUrl:n,title:r,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,x=l==="global";let v;e[0]!==s||e[1]!==a||e[2]!==x||e[3]!==n||e[4]!==c?(v=c&&c>1?i.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(s,{size:16,className:"shrink-0",style:{color:N0}})}),i.jsxs(Pe,{side:"right",children:[c," variants"]})]})}):n?i.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):i.jsx("span",{className:ne("flex size-8 shrink-0 items-center justify-center rounded-lg",x?"bg-global-section/15":"bg-muted"),children:i.jsx(s,{size:16,className:ne("shrink-0",!x&&(a?"text-accent-foreground":"text-muted-foreground")),style:x?{color:ad}:void 0})}),e[0]=s,e[1]=a,e[2]=x,e[3]=n,e[4]=c,e[5]=v):v=e[5];const _=v,b=a?x?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":x?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==b?(y=ne("group relative flex min-w-0 items-center rounded-md transition-colors",b),e[6]=b,e[7]=y):y=e[7];let L;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(L=h&&i.jsx("span",{className:ne("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:tN,children:i.jsx(cr,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=L):L=e[13];let w;e[14]!==r?(w=i.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const S=a?"text-accent-foreground/70":"text-muted-foreground";let j;e[16]!==S?(j=ne("block truncate text-xs",S),e[16]=S,e[17]=j):j=e[17];let k;e[18]!==o||e[19]!==j?(k=i.jsx("span",{className:j,children:o}),e[18]=o,e[19]=j,e[20]=k):k=e[20];let V;e[21]!==w||e[22]!==k?(V=i.jsxs("span",{className:"min-w-0 flex-1",children:[w,k]}),e[21]=w,e[22]=k,e[23]=V):V=e[23];let T;e[24]!==p||e[25]!==_||e[26]!==V||e[27]!==d?(T=i.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[_,V,d]}),e[24]=p,e[25]=_,e[26]=V,e[27]=d,e[28]=T):T=e[28];let A;e[29]!==a||e[30]!==g?(A=g&&i.jsx("div",{className:ne("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=A):A=e[31];let N;return e[32]!==T||e[33]!==A||e[34]!==y||e[35]!==L?(N=i.jsxs("div",{className:y,children:[L,T,A]}),e[32]=T,e[33]=A,e[34]=y,e[35]=L,e[36]=N):N=e[36],N}function tN(t){return t.stopPropagation()}function pa(t){const e=B.c(21),{onDuplicate:s,onRename:n,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(es,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:sN,children:i.jsx(Gn,{size:14})})}),e[0]=c):c=e[0];let d;e[1]!==n?(d=n&&i.jsxs(He,{onClick:n,children:[i.jsx(A9,{size:14}),"Rename"]}),e[1]=n,e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Ss,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=i.jsxs(He,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:r,className:"cursor-pointer",style:{color:N0},children:[i.jsx(jm,{size:14,style:{color:N0}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),o&&i.jsxs(He,{onClick:o,children:[i.jsx(Ua,{size:14}),"Edit SEO"]}),a&&i.jsxs(He,{onClick:a,children:[i.jsx(To,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Di,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(ws,{size:14}),e[12]=g):g=e[12];let x;e[13]!==l?(x=i.jsxs(He,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=x):x=e[14];let v;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==x?(v=i.jsxs(Zt,{children:[c,i.jsxs(ts,{align:"end",className:"w-44",children:[d,u,f,m,p,x]})]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=x,e[20]=v):v=e[20],v}function sN(t){return t.stopPropagation()}function Cr(t){const e=B.c(6),{hasItems:s,emptyLabel:n,emptyHint:r}=t;let o;e[0]!==r||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":i.jsxs(i.Fragment,{children:[i.jsx("div",{children:n}),i.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function nN(t){const e=B.c(12),{state:s,claimPhase:n,lifecycle:r,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==r?(l=o3({claimPhase:n,lifecycle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=i.jsx(Bi,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=i.jsx(Bi,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=i.jsx(Bi,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function Mn(t){const e=B.c(10),{icon:s,title:n,description:r}=t;let o;e[0]!==s?(o=s&&i.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=i.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&i.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}const iN=new Set(["clone-failed","install-failed","start-failed","crashed"]);function rN(t){return iN.has(t.lifecyclePhase)?{kind:"error",source:"sandbox"}:t.lifecyclePhase!=="running"?{kind:"loading"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?{kind:"error",source:"data"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const oN="https://github.com/decocms/blocks";function aN(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(fx,{size:48,className:"text-muted-foreground"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(qi,{image:e,title:"No editable Blocks found",description:"This project does not expose editable Blocks content yet. Learn how to add Blocks to your project.",actions:i.jsx(re,{variant:"outline",size:"sm",asChild:!0,children:i.jsxs("a",{href:oN,target:"_blank",rel:"noreferrer",children:["View Blocks docs",i.jsx(wn,{size:14})]})})}),t[1]=s):s=t[1],s}function lN(t){const e=B.c(6),{source:s,onRetry:n}=t,r=s==="sandbox"?"The project preview could not start. Retry to make Blocks available.":"Studio could not load this project's Blocks metadata.";let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fn,{size:48,className:"text-muted-foreground"}),e[0]=o):o=e[0];let a;e[1]!==n?(a=i.jsx(re,{variant:"outline",size:"sm",onClick:n,children:"Retry"}),e[1]=n,e[2]=a):a=e[2];let l;return e[3]!==r||e[4]!==a?(l=i.jsx(qi,{image:o,title:"Blocks unavailable",description:r,actions:a}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function pi(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}function V3(t){const e=B.c(28),{virtualMcpId:s}=t,{org:n}=Ae(),{currentBranch:r}=as(),o=Os(),a=dr(),l=o.lifecycle.phase==="running";let c;e[0]!==r||e[1]!==l||e[2]!==a||e[3]!==n||e[4]!==s?(c=r&&l?{orgSlug:n.slug,virtualMcpId:s,branch:r,previewUrl:a.previewUrl}:null,e[0]=r,e[1]=l,e[2]=a,e[3]=n,e[4]=s,e[5]=c):c=e[5];const d=c;let h;e[6]!==l?(h={fetchEnabled:l},e[6]=l,e[7]=h):h=e[7];const u=Bl(d,h);let f;e[8]!==l?(f={fetchEnabled:l},e[8]=l,e[9]=f):f=e[9];const m=zl(d,f),p=u.data!==void 0;let g;e[10]!==u.data||e[11]!==u.status||e[12]!==m.data||e[13]!==m.status||e[14]!==o.lifecycle.phase||e[15]!==p?(g=rN({lifecyclePhase:o.lifecycle.phase,decofile:{status:u.status,hasData:p},meta:{status:m.status,hasData:m.data!==void 0},hasEditableContent:fd(u.data,m.data)}),e[10]=u.data,e[11]=u.status,e[12]=m.data,e[13]=m.status,e[14]=o.lifecycle.phase,e[15]=p,e[16]=g):g=e[16];const x=g;if(x.kind==="loading"){let _;return e[17]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(pi,{}),e[17]=_):_=e[17],_}if(x.kind==="empty"){let _;return e[18]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(aN,{}),e[18]=_):_=e[18],_}if(x.kind==="error"){let _;e[19]!==u||e[20]!==a||e[21]!==m||e[22]!==x.source?(_=()=>{if(x.source==="sandbox"){a.retry();return}Promise.all([u.refetch(),m.refetch()])},e[19]=u,e[20]=a,e[21]=m,e[22]=x.source,e[23]=_):_=e[23];const b=_;let y;return e[24]!==b||e[25]!==x.source?(y=i.jsx(lN,{source:x.source,onRetry:b}),e[24]=b,e[25]=x.source,e[26]=y):y=e[26],y}let v;return e[27]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:i.jsx(j3,{mode:"blocks"})}),e[27]=v):v=e[27],v}const cN=40;function N3(t,e=cN){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function dN(t){return N3(t)}function uN(){const t=B.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=v9.blocksPanelWidth(),t[0]=e):e=t[0];const[s,n]=N1(e,dN);let r;t[1]!==s?(r=N3(s),t[1]=s,t[2]=r):r=t[2];let o;return t[3]!==n||t[4]!==r?(o=[r,n],t[3]=n,t[4]=r,t[5]=o):o=t[5],o}const Ud=33;function A3(t,e=Ud){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function hN(t){return A3(t,Ud)}function fN(){const t=B.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=v9.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,n]=N1(e,hN);let r;t[1]!==s?(r=A3(s,Ud),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==n||t[4]!==o?(a=[o,n],t[3]=n,t[4]=o,t[5]=a):a=t[5],a}function mN(t){try{return JSON.parse(t)}catch{return null}}function pN(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?mN(s):null,r=e.structuredContent;return r==null?n:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?n??r:r}function ji(t){const e=pN(t);return e===null?null:e}function Hd(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function gN(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=Hd(s);return!n||!s?null:{number:n,htmlUrl:s}}const nf=/[\r\n<>]/,xN=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Wo(t){const e=t?.userName?.trim();if(!e||nf.test(e))return null;const s=t?.userEmail?.trim();return!s||nf.test(s)?{userName:e}:xN.test(s)?{userName:e,userEmail:s}:{userName:e}}function vN(t){return t.split(`
24
+ `}),e[26]=y):y=e[26];let L;return e[27]!==b||e[28]!==h?(L=i.jsxs("div",{className:"relative flex w-full flex-col items-center justify-center gap-12 select-none [clip-path:inset(-24px_0_-200px_0)]",children:[h,b,y]}),e[27]=b,e[28]=h,e[29]=L):L=e[29],L}function ha(t){const e=B.c(10),{phase:s,current:n,children:r}=t,o=s-n,a=o<0,l=o===0,c=a?90:o*-22,d=a?.94:1-Math.max(o,0)*.04,h=a?0:l?1:o===1?.8:.55,u=a?10:30-o,f=!l;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=ne("absolute inset-0 overflow-hidden rounded-xl border border-foreground/10 bg-background shadow-[0_20px_60px_-20px_rgb(0_0_0_/_0.35)] transition-all ease-[cubic-bezier(0.22,1,0.36,1)]"),e[0]=m):m=e[0];const p=`translateY(${c}px) scale(${d})`,g=l?"auto":"none";let x;e[1]!==h||e[2]!==p||e[3]!==g||e[4]!==u?(x={transform:p,opacity:h,zIndex:u,transitionDuration:"1000ms",pointerEvents:g},e[1]=h,e[2]=p,e[3]=g,e[4]=u,e[5]=x):x=e[5];let v;return e[6]!==r||e[7]!==f||e[8]!==x?(v=i.jsx("div",{"aria-hidden":f,className:m,style:x,children:r}),e[6]=r,e[7]=f,e[8]=x,e[9]=v):v=e[9],v}function rc(t){const e=B.c(7),{showUrl:s}=t,n=s===void 0?!1:s;let r,o,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),o=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),a=i.jsx("div",{className:ne("size-2.5 rounded-full",Es)}),e[0]=r,e[1]=o,e[2]=a):(r=e[0],o=e[1],a=e[2]);let l;e[3]!==n?(l=n&&i.jsx("div",{className:ne("ml-3 h-3.5 max-w-[220px] flex-1 rounded-sm",en)}),e[3]=n,e[4]=l):l=e[4];let c;return e[5]!==l?(c=i.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-1.5 px-3",children:[r,o,a,l]}),e[5]=l,e[6]=c):c=e[6],c}function pk(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"flex flex-1 px-8 py-5",children:i.jsx("div",{className:"grid h-full w-full grid-cols-8 grid-rows-6 gap-2",children:ck.map(gk)})})]}),t[1]=s):s=t[1],s}function gk(t,e){if(e===a3)return i.jsx("div",{className:"rounded-md bg-chart-1/[0.55]",style:{animation:"vm-breathe 2.4s ease-in-out infinite"}},e);const s=t;return i.jsx("div",{className:ne("relative rounded-md",Es),children:i.jsx("div",{className:"absolute inset-0 rounded-md bg-chart-1/40 opacity-0",style:{animation:`vm-rack-scan ${l3}s ease-in-out infinite`,animationDelay:`${s}s`}})},e)}function xk(){const t=B.c(5);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:ne("w-[18%] rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out infinite"}}),t[1]=s):s=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("div",{className:"h-[42%] shrink-0 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.4s infinite"}}),t[2]=n):n=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx("div",{className:"col-span-3 rounded-md bg-chart-3/[0.12]",style:{animation:"vm-breathe 3s ease-in-out 0.8s infinite"}}),t[3]=r):r=t[3];let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1 gap-1.5 p-3",children:[s,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[n,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-1.5",children:[r,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-1.5",children:[i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.2s infinite"}}),i.jsx("div",{className:ne("rounded-md",en),style:{animation:"vm-breathe 3s ease-in-out 1.6s infinite"}})]})]})]})]})]}),t[4]=o):o=t[4],o}function vk(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsx("div",{className:"relative flex flex-1 items-center justify-center px-8 py-5",children:i.jsx("div",{className:"grid w-full gap-2",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:hk.map(_k)})})]}),t[1]=s):s=t[1],s}function _k(t,e){return i.jsx("div",{className:ne("aspect-square rounded-md",fk[e]?"bg-chart-2/70":Es),style:{animation:`vm-pulse-soft 2.2s ease-in-out ${t}s infinite`}},e)}function bk(){const t=B.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(rc,{showUrl:!0}),t[0]=e):e=t[0];let s,n,r,o,a;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx("div",{className:"mb-2 h-5 rounded-md bg-chart-1/[0.10]"}),n=i.jsx("div",{className:ne("h-1.5 w-[70%] rounded-sm",Es)}),r=i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",Es)}),o=i.jsx("div",{className:ne("h-1.5 w-[80%] rounded-sm",Es)}),a=i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),t[1]=s,t[2]=n,t[3]=r,t[4]=o,t[5]=a):(s=t[1],n=t[2],r=t[3],o=t[4],a=t[5]);let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"flex w-[18%] shrink-0 flex-col gap-1.5 bg-chart-1/[0.05] p-2.5",children:[s,n,r,o,a,i.jsx("div",{className:"mt-auto",children:i.jsx("div",{className:ne("h-4 rounded-md",Es)})})]}),t[6]=l):l=t[6];let c;t[7]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("div",{className:"relative h-[42%] shrink-0 overflow-hidden bg-chart-1/[0.10]",children:i.jsxs("div",{className:"absolute right-3 bottom-3 left-3 space-y-1.5",children:[i.jsx("div",{className:"h-3 w-[35%] rounded-sm bg-chart-1/[0.15]"}),i.jsx("div",{className:ne("h-1.5 w-[55%] rounded-sm",en)})]})}),t[7]=c):c=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsxs("div",{className:"flex shrink-0 gap-1.5",children:[i.jsx("div",{className:"h-4 w-12 rounded-full bg-chart-1/[0.12]"}),i.jsx("div",{className:ne("h-4 w-10 rounded-full",en)}),i.jsx("div",{className:ne("h-4 w-14 rounded-full",en)})]}),t[8]=d):d=t[8];let h;t[9]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs("div",{className:ne("col-span-3 flex flex-col justify-end gap-1 rounded-md p-2",en),children:[i.jsx("div",{className:ne("h-1.5 w-[50%] rounded-sm",Es)}),i.jsx("div",{className:ne("h-1 w-[75%] rounded-sm",Es)})]}),t[9]=h):h=t[9];let u;return t[10]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsxs("div",{className:"flex h-full flex-col",children:[e,i.jsxs("div",{className:"flex min-h-0 flex-1",children:[l,i.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c,i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2.5 p-3",children:[d,i.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-5 gap-2",children:[h,i.jsxs("div",{className:"col-span-2 grid grid-rows-2 gap-2",children:[i.jsx("div",{className:ne("rounded-md",en)}),i.jsx("div",{className:ne("rounded-md",en)})]})]})]})]})]})]}),t[10]=u):u=t[10],u}function Bi(t){const e=B.c(25);if(t.kind==="starting"){let l;return e[0]!==t.claimPhase||e[1]!==t.progress?(l=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsx(mk,{progress:t.progress,claimPhase:t.claimPhase})}),e[0]=t.claimPhase,e[1]=t.progress,e[2]=l):l=e[2],l}if(t.kind==="errored"){const l=t.error.code===m2.githubNotAuthenticated;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(nr,{className:"size-12 text-destructive"}),e[3]=c):c=e[3];let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx("h3",{className:"text-lg font-medium",children:Fh("errored")}),e[4]=d):d=e[4];const h=l?"This agent's GitHub repo isn't authenticated. Reconnect it in Connections, then retry.":t.error.message;let u;e[5]!==h?(u=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:h}),e[5]=h,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==t.connectionsHref?(f=l&&t.connectionsHref&&i.jsx(re,{asChild:!0,children:i.jsx("a",{href:t.connectionsHref,children:"Reconnect GitHub"})}),e[7]=l,e[8]=t.connectionsHref,e[9]=f):f=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(zi,{className:"size-4"}),e[10]=m):m=e[10];let p;e[11]!==t.onRetry?(p=i.jsxs(re,{variant:"outline",onClick:t.onRetry,children:[m," Retry"]}),e[11]=t.onRetry,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=i.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let x;return e[16]!==u||e[17]!==g?(x=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[c,d,u,g]})}),e[16]=u,e[17]=g,e[18]=x):x=e[18],x}let s;e[19]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(lx,{className:"size-12 text-blue-500"}),e[19]=s):s=e[19];let n,r;e[20]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx("h3",{className:"text-lg font-medium",children:Fh("suspended")}),r=i.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Resume to continue."}),e[20]=n,e[21]=r):(n=e[20],r=e[21]);let o;e[22]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fi,{className:"size-4"}),e[22]=o):o=e[22];let a;return e[23]!==t.onResume?(a=i.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background p-6",children:i.jsxs("div",{className:"flex w-full max-w-md flex-col items-center gap-4 text-center",children:[s,n,r,i.jsxs(re,{onClick:t.onResume,className:"mt-2",children:[o," Resume"]})]})}),e[23]=t.onResume,e[24]=a):a=e[24],a}const Hh={resolveType:"website/pages/Page.tsx",seoResolveType:"website/sections/Seo/SeoV2.tsx"};function $d(t){return`pages-${encodeURIComponent(t)}-${crypto.randomUUID()}`}function c3(t,e){return{name:t,path:e,sections:[],seo:{__resolveType:Hh.seoResolveType},__resolveType:Hh.resolveType}}function Kh(t,e){const s=e.replace(/\s*\(copy(?:\s+\d+)?\)\s*$/,"").trim(),n=`${s} (copy)`;if(!t.has(n))return n;for(let r=2;r<1e3;r++){const o=`${s} (copy ${r})`;if(!t.has(o))return o}return`${s} (copy ${Date.now()})`}function yk(t,e){const s=ai,n=e.replace(/-copy(?:-\d+)?$/,""),r=`${n}-copy`;if(!t.has(s(r)))return r;for(let o=2;o<1e3;o++){const a=`${n}-copy-${o}`;if(!t.has(s(a)))return a}return`${n}-copy-${Date.now()}`}function Lk(t,e){const s=e.replace(/_copy(?:_\d+)?$/,""),n=`${s}_copy`;if(!Object.hasOwn(t,n))return n;for(let r=2;r<1e3;r++){const o=`${s}_copy_${r}`;if(!Object.hasOwn(t,o))return o}return`${s}_copy_${Date.now()}`}function Sk(t){const e=$d(t.newName),s={...t.source,name:t.newName,path:t.newPath};return{key:e,data:s}}function wk(t,e){return c3(t,e)}const jk=1e3;function Ck(t,e){for(let s=0;s<jk;s++){const n=$d(e);if(!Object.hasOwn(t,n))return n}throw new Error("Could not generate a unique page block key")}const zn="__blank__";function d3(t){const e=B.c(44),{id:s,value:n,onChange:r,templates:o,disabled:a}=t,[l,c]=C.useState(!1);let d;if(e[0]!==o||e[1]!==n){let A;e[3]!==n?(A=N=>N.key===n,e[3]=n,e[4]=A):A=e[4],d=o.find(A),e[0]=o,e[1]=n,e[2]=d}else d=e[2];const h=d,u=h?.name??"Blank page";let f;e[5]!==u?(f=i.jsx("span",{className:"truncate",children:u}),e[5]=u,e[6]=f):f=e[6];let m;e[7]!==h?(m=h?.path?i.jsx("span",{className:"truncate text-muted-foreground",children:h.path}):null,e[7]=h,e[8]=m):m=e[8];let p;e[9]!==f||e[10]!==m?(p=i.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[f,m]}),e[9]=f,e[10]=m,e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(N9,{className:"shrink-0 opacity-50"}),e[12]=g):g=e[12];let x;e[13]!==a||e[14]!==s||e[15]!==l||e[16]!==p?(x=i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{id:s,type:"button",variant:"outline",role:"combobox","aria-expanded":l,disabled:a,className:"w-full justify-between font-normal",children:[p,g]})}),e[13]=a,e[14]=s,e[15]=l,e[16]=p,e[17]=x):x=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v={width:"var(--radix-popover-trigger-width)"},e[18]=v):v=e[18];let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yi,{placeholder:"Search pages…",className:"h-9"}),e[19]=_):_=e[19];let b;e[20]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx(Li,{children:"No pages found."}),e[20]=b):b=e[20];let y;e[21]!==r?(y=()=>{r(zn),c(!1)},e[21]=r,e[22]=y):y=e[22];const L=n===zn?"opacity-100":"opacity-0";let w;e[23]!==L?(w=ne("ml-auto",L),e[23]=L,e[24]=w):w=e[24];let S;e[25]!==w?(S=i.jsx(Tt,{className:w}),e[25]=w,e[26]=S):S=e[26];let j;e[27]!==y||e[28]!==S?(j=i.jsxs(Ps,{value:"Blank page",onSelect:y,children:["Blank page",S]}),e[27]=y,e[28]=S,e[29]=j):j=e[29];let k;if(e[30]!==r||e[31]!==o||e[32]!==n){let A;e[34]!==r||e[35]!==n?(A=N=>i.jsxs(Ps,{value:`${N.name} ${N.path}`,onSelect:()=>{r(N.key),c(!1)},children:[i.jsxs("div",{className:"flex min-w-0 flex-col",children:[i.jsx("span",{className:"truncate",children:N.name}),i.jsx("span",{className:"truncate text-xs text-muted-foreground",children:N.path})]}),i.jsx(Tt,{className:ne("ml-auto",n===N.key?"opacity-100":"opacity-0")})]},N.key),e[34]=r,e[35]=n,e[36]=A):A=e[36],k=o.map(A),e[30]=r,e[31]=o,e[32]=n,e[33]=k}else k=e[33];let V;e[37]!==j||e[38]!==k?(V=i.jsx(ks,{className:"p-0",style:v,children:i.jsxs(lr,{children:[_,i.jsxs(Si,{onWheel:kk,children:[b,i.jsxs(Fs,{children:[j,k]})]})]})}),e[37]=j,e[38]=k,e[39]=V):V=e[39];let T;return e[40]!==l||e[41]!==V||e[42]!==x?(T=i.jsxs(Vs,{open:l,onOpenChange:c,children:[x,V]}),e[40]=l,e[41]=V,e[42]=x,e[43]=T):T=e[43],T}function kk(t){const e=t.deltaMode===1?16:1;t.currentTarget.scrollTop=t.currentTarget.scrollTop+t.deltaY*e}const Vk={create:"Create new page",duplicate:"Duplicate page",rename:"Rename page"},Nk={create:"Create",duplicate:"Duplicate",rename:"Save"},Ak={create:"Creating…",duplicate:"Duplicating…",rename:"Saving…"};function Tk(t){const e=B.c(62),{open:s,mode:n,initialName:r,initialPath:o,isPending:a,error:l,templates:c,validate:d,onSubmit:h,onOpenChange:u}=t,f=a===void 0?!1:a,[m,p]=C.useState(r),[g,x]=C.useState(o),[v,_]=C.useState(zn),[b,y]=C.useState(null),[L,w]=C.useState(s);s!==L&&(w(s),s&&(p(r),x(o),_(zn),y(null)));const S=n==="create"&&!!c?.length;let j;e[0]!==f||e[1]!==u?(j=Q=>{!Q&&!f&&(y(null),u(!1))},e[0]=f,e[1]=u,e[2]=j):j=e[2];const k=j;let V;e[3]!==f||e[4]!==m||e[5]!==h||e[6]!==g||e[7]!==S||e[8]!==v||e[9]!==d?(V=async Q=>{Q.preventDefault();const Z=m.trim(),Y=g.trim();if(!Z||!Y||f)return;const ee=ud(Y);if(ee){y(ee);return}const te=d?.({name:Z,path:Y});if(te){y(te);return}y(null),await h({name:Z,path:Y,templateKey:S&&v!==zn?v:null})},e[3]=f,e[4]=m,e[5]=h,e[6]=g,e[7]=S,e[8]=v,e[9]=d,e[10]=V):V=e[10];const T=V,A=b??l,N=Vk[n];let E;e[11]!==N?(E=i.jsx(ns,{children:i.jsx(is,{children:N})}),e[11]=N,e[12]=E):E=e[12];let I;e[13]!==f||e[14]!==S||e[15]!==v||e[16]!==c?(I=S&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("label",{htmlFor:"page-form-template",className:"text-xs font-medium text-muted-foreground",children:"Template"}),i.jsx(d3,{id:"page-form-template",value:v,onChange:_,templates:c??[],disabled:f})]}),e[13]=f,e[14]=S,e[15]=v,e[16]=c,e[17]=I):I=e[17];let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=i.jsx("label",{htmlFor:"page-form-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[18]=P):P=e[18];let R;e[19]===Symbol.for("react.memo_cache_sentinel")?(R=Q=>p(Q.target.value),e[19]=R):R=e[19];let D;e[20]!==f||e[21]!==m?(D=i.jsxs("div",{className:"space-y-1.5",children:[P,i.jsx(Ye,{id:"page-form-name",value:m,onChange:R,placeholder:"My page",autoFocus:!0,disabled:f})]}),e[20]=f,e[21]=m,e[22]=D):D=e[22];let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=i.jsx("label",{htmlFor:"page-form-path",className:"text-xs font-medium text-muted-foreground",children:"Path"}),e[23]=M):M=e[23];let F;e[24]===Symbol.for("react.memo_cache_sentinel")?(F=Q=>x(Q.target.value),e[24]=F):F=e[24];let $;e[25]!==f||e[26]!==g?($=i.jsxs("div",{className:"space-y-1.5",children:[M,i.jsx(Ye,{id:"page-form-path",value:g,onChange:F,placeholder:"/example",disabled:f})]}),e[25]=f,e[26]=g,e[27]=$):$=e[27];let O;e[28]!==A?(O=A&&i.jsx("p",{className:"text-xs text-destructive",children:A}),e[28]=A,e[29]=O):O=e[29];let U;e[30]!==$||e[31]!==O||e[32]!==I||e[33]!==D?(U=i.jsxs("div",{className:"space-y-4 py-4",children:[I,D,$,O]}),e[30]=$,e[31]=O,e[32]=I,e[33]=D,e[34]=U):U=e[34];let K;e[35]!==u?(K=()=>u(!1),e[35]=u,e[36]=K):K=e[36];let H;e[37]!==f||e[38]!==K?(H=i.jsx(re,{type:"button",variant:"outline",onClick:K,disabled:f,children:"Cancel"}),e[37]=f,e[38]=K,e[39]=H):H=e[39];let q;e[40]!==f||e[41]!==m||e[42]!==g?(q=!m.trim()||!g.trim()||f,e[40]=f,e[41]=m,e[42]=g,e[43]=q):q=e[43];let J;e[44]!==f||e[45]!==n?(J=f?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),Ak[n]]}):Nk[n],e[44]=f,e[45]=n,e[46]=J):J=e[46];let G;e[47]!==q||e[48]!==J?(G=i.jsx(re,{type:"submit",disabled:q,children:J}),e[47]=q,e[48]=J,e[49]=G):G=e[49];let W;e[50]!==H||e[51]!==G?(W=i.jsxs(_i,{children:[H,G]}),e[50]=H,e[51]=G,e[52]=W):W=e[52];let z;e[53]!==T||e[54]!==U||e[55]!==W||e[56]!==E?(z=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:T,children:[E,U,W]})}),e[53]=T,e[54]=U,e[55]=W,e[56]=E,e[57]=z):z=e[57];let X;return e[58]!==k||e[59]!==s||e[60]!==z?(X=i.jsx(Ut,{open:s,onOpenChange:k,children:z}),e[58]=k,e[59]=s,e[60]=z,e[61]=X):X=e[61],X}function Ek(t){const e=B.c(43),{open:s,blockKey:n,initialName:r,isPending:o,onSubmit:a,onOpenChange:l}=t,c=o===void 0?!1:o,[d,h]=C.useState(r),[u,f]=C.useState(s);s!==u&&(f(s),s&&h(r));let m;e[0]!==c||e[1]!==l?(m=P=>{!P&&!c&&l(!1)},e[0]=c,e[1]=l,e[2]=m):m=e[2];const p=m;let g;e[3]!==c||e[4]!==d||e[5]!==a?(g=async P=>{P.preventDefault();const R=d.trim();!R||c||await a(R)},e[3]=c,e[4]=d,e[5]=a,e[6]=g):g=e[6];const x=g;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsxs(ns,{children:[i.jsx(is,{children:"Rename section"}),i.jsx(qn,{children:"Updates the display name. The internal key stays the same so pages referencing this section keep working."})]}),e[7]=v):v=e[7];let _;e[8]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx("label",{htmlFor:"section-rename-name",className:"text-xs font-medium text-muted-foreground",children:"Name"}),e[8]=_):_=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=P=>h(P.target.value),e[9]=b):b=e[9];let y;e[10]!==c||e[11]!==d?(y=i.jsxs("div",{className:"space-y-1.5",children:[_,i.jsx(Ye,{id:"section-rename-name",value:d,onChange:b,autoFocus:!0,disabled:c})]}),e[10]=c,e[11]=d,e[12]=y):y=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Key"}),e[13]=L):L=e[13];let w;e[14]!==n?(w=i.jsxs("div",{className:"space-y-1.5",children:[L,i.jsx(Ye,{value:n,readOnly:!0,disabled:!0,className:"font-mono"})]}),e[14]=n,e[15]=w):w=e[15];let S;e[16]!==y||e[17]!==w?(S=i.jsxs("div",{className:"space-y-4 py-4",children:[y,w]}),e[16]=y,e[17]=w,e[18]=S):S=e[18];let j;e[19]!==l?(j=()=>l(!1),e[19]=l,e[20]=j):j=e[20];let k;e[21]!==c||e[22]!==j?(k=i.jsx(re,{type:"button",variant:"outline",onClick:j,disabled:c,children:"Cancel"}),e[21]=c,e[22]=j,e[23]=k):k=e[23];let V;e[24]!==c||e[25]!==d?(V=!d.trim()||c,e[24]=c,e[25]=d,e[26]=V):V=e[26];let T;e[27]!==c?(T=c?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Saving…"]}):"Save",e[27]=c,e[28]=T):T=e[28];let A;e[29]!==V||e[30]!==T?(A=i.jsx(re,{type:"submit",disabled:V,children:T}),e[29]=V,e[30]=T,e[31]=A):A=e[31];let N;e[32]!==k||e[33]!==A?(N=i.jsxs(_i,{children:[k,A]}),e[32]=k,e[33]=A,e[34]=N):N=e[34];let E;e[35]!==x||e[36]!==S||e[37]!==N?(E=i.jsx(Ft,{className:"sm:max-w-md",children:i.jsxs("form",{onSubmit:x,children:[v,S,N]})}),e[35]=x,e[36]=S,e[37]=N,e[38]=E):E=e[38];let I;return e[39]!==p||e[40]!==s||e[41]!==E?(I=i.jsx(Ut,{open:s,onOpenChange:p,children:E}),e[39]=p,e[40]=s,e[41]=E,e[42]=I):I=e[42],I}const Rc={post:"blog/loaders/Blogpost.ts",author:"blog/loaders/Author.ts",category:"blog/loaders/Category.ts"},Bd=["posts","authors","categories"],eo={posts:"post",authors:"author",categories:"category"};function to(t){return Bd.includes(t)}const zd={posts:"post",authors:"author",categories:"category"},u3={posts:Rc.post,authors:Rc.author,categories:Rc.category},Rk=Object.fromEntries(Object.entries(u3).map(([t,e])=>[e,t]));function Pk(t){return typeof t=="string"?Rk[t]??null:null}function Qi(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Bs(t){return typeof t=="string"?t:""}function Ik(t,e){switch(t){case"posts":return{label:Bs(e.title)||"Untitled post",subtitle:Bs(e.slug)};case"authors":return{label:Bs(e.name)||"Unnamed author",subtitle:Bs(e.email)};case"categories":return{label:Bs(e.name)||"Unnamed category",subtitle:Bs(e.slug)};default:{const s=t;throw new Error(`Unhandled blog kind: ${String(s)}`)}}}function h3(t){const e={posts:[],authors:[],categories:[]};for(const[s,n]of Object.entries(t)){const r=Qi(n);if(!r)continue;const o=Pk(r.__resolveType);if(!o)continue;const a=Qi(r[zd[o]])??{},{label:l,subtitle:c}=Ik(o,a);e[o].push({key:s,kind:o,label:l,subtitle:c})}for(const s of Bd)e[s].sort((n,r)=>n.label.localeCompare(r.label));return e}function Dk(t,e){return h3(t)[e]}function bo(t,e){return Dk(t,e).map(s=>({key:s.key,payload:Na(Qi(t[s.key])??void 0,e)}))}const Wh=Object.freeze({});function Na(t,e){return t?Qi(t[zd[e]])??Wh:Wh}function fa(t,e,s){return{name:t,__resolveType:u3[e],[zd[e]]:s}}function f3(t){return`.deco/blocks/${encodeURIComponent(t)}.json`}function Zi(t){return Array.isArray(t)?t:[]}function Fn(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.slug):""}function Mk(t){if(typeof t=="string")return t;const e=Qi(t);return e?Bs(e.email):""}function m3(t){return bo(t,"posts").map(({key:e,payload:s})=>({key:e,title:Bs(s.title)||"Untitled post",slug:Bs(s.slug),date:Bs(s.date),categorySlugs:Zi(s.categories).map(Fn).filter(Boolean),authorEmails:Zi(s.authors).map(Mk).filter(Boolean)}))}function Ok(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e.slug)?t:{...t,categories:[...s,{name:e.name,slug:e.slug}]}}function $k(t,e){const s=Zi(t.categories);return s.length===1&&Fn(s[0])===e.slug?t:{...t,categories:[{name:e.name,slug:e.slug}]}}function VF(t,e,s){const n=Zi(t.categories);if(!n.some(l=>Fn(l)===e))return t;const r=n.map(l=>{const c=Fn(l);return c===e||c===s.slug?{name:s.name,slug:s.slug}:l}),o=new Set,a=r.filter(l=>{const c=Fn(l);return c?o.has(c)?!1:(o.add(c),!0):!0});return{...t,categories:a}}function Bk(t,e){const s=Zi(t.categories);return s.some(n=>Fn(n)===e)?{...t,categories:s.filter(n=>Fn(n)!==e)}:t}function V0(t){const e=new Uint8Array(Math.ceil(t/2));return crypto.getRandomValues(e),Array.from(e,s=>s.toString(16).padStart(2,"0")).join("").slice(0,t)}function qh(t,e){const s=`collections/blog/${e}/${V0(12)}`;if(!Object.hasOwn(t,s))return s;throw new Error("Could not generate a unique blog block key")}function zk(t){switch(t){case"posts":return{title:"Untitled post",excerpt:"",slug:`untitled-${V0(8)}`,date:new Date().toISOString().slice(0,10),image:"",authors:[],categories:[],sections:[]};case"authors":return{name:"New author",email:"",jobTitle:"",company:"",avatar:""};case"categories":return{name:"New category",slug:`category-${V0(8)}`,description:"",sections:[]};default:{const e=t;throw new Error(`Unhandled blog kind: ${String(e)}`)}}}const Fk={Paragraph:{title:"Paragraph",description:"Rich text content",iconName:"Pilcrow01"},Heading:{title:"Heading",description:"Section title (H1–H6)",iconName:"HeadingSquare"},Quote:{title:"Quote",description:"Pull quote",iconName:"MessageTextSquare02"},Code:{title:"Code",description:"Code block with syntax highlighting",iconName:"Code02"},List:{title:"List",description:"Bulleted or numbered list",iconName:"List"},BlockImage:{title:"Image",description:"Image with optional caption",iconName:"Image01"},Video:{title:"Video",description:"Embedded video",iconName:"PlayCircle"},Divider:{title:"Divider",description:"Horizontal divider",iconName:"Divider"},Cta:{title:"Call to action",description:"Button linking to a URL",iconName:"CursorClick01"},Callout:{title:"Callout",description:"Highlighted note, tip or warning",iconName:"Lightbulb02"},Stat:{title:"Stat",description:"Single key metric",iconName:"BarChartSquareUp"},StatGroup:{title:"Stat group",description:"Row of metrics",iconName:"BarChartSquare02"},CardGroup:{title:"Card group",description:"Grid of cards",iconName:"LayoutGrid01"},Checklist:{title:"Checklist",description:"List of check items",iconName:"CheckSquare"},Steps:{title:"Steps",description:"Step-by-step guide",iconName:"LayersThree01"},Comparison:{title:"Comparison",description:"Side-by-side comparison",iconName:"Columns03"},Table:{title:"Table",description:"Rows and columns of structured data",iconName:"Table"},ProductCard:{title:"Product card",description:"Single product",iconName:"Tag01"},ProductShelf:{title:"Product shelf",description:"Row of products",iconName:"ShoppingBag01"}},Gh="Box";function Uk(t){return t.startsWith("site/")?"site":"app"}function Hk(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:")||t.startsWith("/")}function jr(...t){for(const e of t)if(e!==void 0)return e}function NF(t){const e=new Set,s=[],n=t.manifest?.blocks??{};for(const r of Object.values(n))for(const o of Object.keys(r)){if(!qk(o)||e.has(o))continue;e.add(o);const a=Jn(o,t),l=Kk(o),c=Fk[l],d=Uk(o),h=(d==="site"?jr(a.title,c?.title):jr(c?.title,a.title))??l,u=d==="site"?jr(a.description,c?.description):jr(c?.description,a.description),f=d==="site"?a.icon:void 0,m=f&&Hk(f)?f:void 0,p=m!==void 0?c?.iconName??Gh:jr(f,c?.iconName)??Gh;s.push({resolveType:o,title:h,description:u,iconName:p,iconUrl:m,source:d})}return s.sort((r,o)=>r.title.localeCompare(o.title))}function Kk(t){return(t.split("/").pop()??t).replace(/\.(tsx?|jsx?)$/,"")}const Wk=["blog/sections/blocks/","site/sections/Blog/Post/"];function qk(t){return Wk.some(e=>t.startsWith(e))}function p3({orgSlug:t,virtualMcpId:e,branch:s}){return Qe.decofile(`${t}/${e}/${s}`)}function g3({orgSlug:t,virtualMcpId:e,branch:s},n){return`/api/${t}/sandbox/${encodeURIComponent(e)}/${encodeURIComponent(s)}/${n}`}function Gk(t){const e=B.c(11),s=os();let n;e[0]!==t?(n=async l=>{const{blockKey:c,data:d}=l,h=await fetch(g3(t,"write"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:f3(c),content:JSON.stringify(d,null,2)})});if(!h.ok){const u=await h.json().catch(Yk);throw new Error(u.error??`Write failed (${h.status})`)}return h.json()},e[0]=t,e[1]=n):n=e[1];let r;e[2]!==t||e[3]!==s?(r=async l=>{const{blockKey:c,data:d}=l,h=p3(t);await s.cancelQueries({queryKey:h});const u=s.getQueryData(h);return s.setQueryData(h,f=>({...f??{},[c]:d})),{previous:u,queryKey:h}},e[2]=t,e[3]=s,e[4]=r):r=e[4];let o;e[5]!==s?(o=(l,c,d)=>{d?.queryKey&&s.setQueryData(d.queryKey,d.previous)},e[5]=s,e[6]=o):o=e[6];let a;return e[7]!==n||e[8]!==r||e[9]!==o?(a={mutationFn:n,onMutate:r,onError:o},e[7]=n,e[8]=r,e[9]=o,e[10]=a):a=e[10],Ds(a)}function Yk(){return{}}function Jk(t){const e=os();return Ds({mutationFn:async({blockKey:s})=>{const n=await fetch(g3(t,"unlink"),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:f3(s)})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??`Delete failed (${n.status})`)}return n.json()},onMutate:async({blockKey:s})=>{const n=p3(t);await e.cancelQueries({queryKey:n});const r=e.getQueryData(n);return e.setQueryData(n,o=>{if(!o)return o;const{[s]:a,...l}=o;return l}),{previous:r,queryKey:n}},onError:(s,n,r)=>{r?.queryKey&&e.setQueryData(r.queryKey,r.previous)}})}function Xk(t){const e=B.c(20),{open:s,onOpenChange:n,pageKey:r,decofile:o}=t,[a,l]=C.useState(!1),c=o[r];let d;e[0]!==c?(d=c===void 0?"// Page not found.":JSON.stringify(c,null,2),e[0]=c,e[1]=d):d=e[1];const h=d;let u;e[2]!==h?(u=()=>{navigator.clipboard.writeText(h).then(()=>{l(!0),setTimeout(()=>l(!1),2e3)})},e[2]=h,e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(is,{className:"text-sm font-semibold",children:"Page JSON"}),e[4]=m):m=e[4];let p;e[5]!==a?(p=a?i.jsx(Pl,{size:12}):i.jsx(Ss,{size:12}),e[5]=a,e[6]=p):p=e[6];const g=a?"Copied":"Copy";let x;e[7]!==f||e[8]!==p||e[9]!==g?(x=i.jsxs(ns,{className:"px-4 py-3 border-b flex-row items-center justify-between space-y-0",children:[m,i.jsxs(re,{variant:"ghost",size:"sm",onClick:f,className:"h-7 gap-1.5 text-xs",children:[p,g]})]}),e[7]=f,e[8]=p,e[9]=g,e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(Sn,{className:"max-h-[70vh]",children:i.jsx("pre",{className:"p-4 text-xs font-mono text-foreground/90 whitespace-pre overflow-auto",children:h})}),e[11]=h,e[12]=v):v=e[12];let _;e[13]!==x||e[14]!==v?(_=i.jsxs(Ft,{className:"max-w-2xl p-0 gap-0",children:[x,v]}),e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;return e[16]!==n||e[17]!==s||e[18]!==_?(b=i.jsx(Ut,{open:s,onOpenChange:n,children:_}),e[16]=n,e[17]=s,e[18]=_,e[19]=b):b=e[19],b}function Qk(t){const e=B.c(3),{isPending:s,isError:n}=t;if(n){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-destructive",children:[i.jsx(fn,{size:13}),"Couldn't save"]}),e[0]=o):o=e[0],o}if(s){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[i.jsx(qe,{size:13,className:"animate-spin"}),"Saving…"]}),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground/70",children:[i.jsx(Tt,{size:13}),"Saved"]}),e[2]=r):r=e[2],r}const Zk={loaders:"loader",actions:"action"},x3=new Set(["workflows"]);function v3(t){return Zk[t]}function _3(t,e,s){const n=t.manifest?.blocks??{};for(const[r,o]of Object.entries(n))if(r.includes(s)&&e in o)return!0;return!1}function eV(t,e){return/\.tsx?$/.test(t)?!1:e.has(`${t}.ts`)||e.has(`${t}.tsx`)}function b3(t,e){const s=t.manifest?.blocks??{},n=[],r=new Set;for(const[o,a]of Object.entries(s))if(o.includes(e))for(const l of Object.keys(a))r.add(l);for(const o of r){if(o.toLowerCase().includes("preview")||x3.has(Fd(o))||eV(o,r))continue;const a=Jn(o,t);if(a.hidden)continue;const l=a.title&&a.title!==o?a.title:vt(o);n.push({resolveType:o,title:l})}return n.sort((o,a)=>o.title.localeCompare(a.title))}function Yh(t,e){return b3(t,e).length}function Fd(t){return t.startsWith("deco-sites/")?t.split("/")[1]||"site":t.startsWith("$live")||t.startsWith("deco/")?"deco":t.split("/")[0]||"other"}const tV={deco:"Deco",std:"Deco Standard",website:"Website"};function sV(t){return tV[t]??t}function y3(t){const e=Fd(t);let n=t.split("/").filter(Boolean).slice(t.startsWith("deco-sites/")?2:1);return(n[0]==="loaders"||n[0]==="actions")&&(n=n.slice(1)),[e,...n.slice(0,-1)]}function nV(t,e,s){const n=[];for(const[r,o]of Object.entries(e)){if(r.includes("/")||Fl(r)||!o||typeof o!="object"||Array.isArray(o))continue;const a=o,l=a.__resolveType;typeof l=="string"&&(x3.has(Fd(l))||_3(t,l,s)&&n.push({key:r,resolveType:l,title:typeof a.name=="string"&&a.name?a.name:r}))}return n.sort((r,o)=>r.title.localeCompare(o.title))}const Jh=3e4;function L3(t){return`/api/${t.orgSlug}/sandbox/${encodeURIComponent(t.virtualMcpId)}/${encodeURIComponent(t.branch)}/preview-invoke`}function iV(t,e,s,n){const r=new URL(`/deco/invoke/${e}`,t);return r.searchParams.set("__cb",n.toString(36)),r.searchParams.set("__decoFBT","0"),r.searchParams.set("__d",`run-${n.toString(36)}`),r.searchParams.set("props",btoa(encodeURIComponent(JSON.stringify(s)))),r.href}async function rV(t,{resolveType:e,props:s}){let n;try{n=await fetch(L3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(Jh)})}catch(l){throw l instanceof DOMException&&l.name==="TimeoutError"?new Error(`Run timed out after ${Jh/1e3}s — the block may be slow or the preview unresponsive.`):l}const r=await n.text();let o=null,a=!1;try{o=r?JSON.parse(r):null,a=!0}catch{}if(!n.ok){const l=a&&o&&typeof o=="object"&&"error"in o&&typeof o.error=="string"?o.error:r||`Run failed (${n.status})`;throw new Error(l)}return a?o:r}function oV(t){const e=B.c(2);let s;return e[0]!==t?(s={mutationFn:n=>rV(t,n)},e[0]=t,e[1]=s):s=e[1],Ds(s)}function aV({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:r,decofile:o,kind:a,target:l,initialValue:c,isCreating:d,onCreate:h,onSaveReferencedBlock:u,onBack:f}){const m=kn(),p=m?.entity?.id===e?m.entity.metadata?.siteSlug??null:null,g=Ln(l.resolveType,r),x=!g&&RL(l.resolveType,r),v=x?PL(c):null,_=g??v,[b,y]=C.useState(c),[L,w]=C.useState([]),[S,j]=C.useState(0),[k,V]=C.useState(!1),[T,A]=C.useState(null),[N,E]=C.useState(!1),[I,P]=C.useState(!1),[R,D]=C.useState(!1),M=T!==null,{save:F,flush:$,isPending:O}=G2({orgSlug:t,virtualMcpId:e,branch:s}),U=oV({orgSlug:t,virtualMcpId:e,branch:s});C.useEffect(()=>()=>{$()},[]);const K=v3(a),H=l.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")??l.resolveType,q={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n??void 0,siteSlug:p},J=ee=>{y(ee),l.mode==="saved"&&F(l.blockKey,{__resolveType:l.resolveType,...ee})},G=()=>{M?(A(null),V(!1),j(ee=>ee+1)):A(JSON.stringify(b,null,2))},W=ee=>{const te=ee??"";try{const ae=JSON.parse(te);if(ae&&typeof ae=="object"&&!Array.isArray(ae)){V(!1),J(ae);return}V(!0)}catch{V(!0)}},z=async ee=>{const te=xd(ee,o);if(te){ce.error(te);return}await h(ee,{__resolveType:l.resolveType,...b}),E(!1)},X=()=>{P(!0),U.mutate({resolveType:l.resolveType,props:b})},Q=()=>{n&&window.open(iV(n,l.resolveType,b,Date.now()),"_blank","noopener")},Z=[l.title,...L],Y=ee=>{w(L.slice(0,ee)),j(te=>te+1)};return i.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col",children:[i.jsxs("div",{className:"shrink-0 border-b px-3 py-2.5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2 overflow-hidden",children:[f&&i.jsx(re,{variant:"ghost",size:"icon",className:"size-8 shrink-0",onClick:f,"aria-label":"Back to list",children:i.jsx(Tl,{size:14})}),i.jsx("nav",{"aria-label":"Editing breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:Z.map((ee,te)=>{const ae=te===Z.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[te>0&&i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>Y(te),title:ee,className:ne("min-w-0 truncate rounded-md px-1 py-0.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground",ae?"font-medium text-foreground":"text-muted-foreground"),children:ee})]},`${ee}-${te}`)})}),l.mode==="saved"&&i.jsx(Qk,{isPending:O,isError:!1}),i.jsxs(re,{size:"sm",variant:"outline",className:"h-8 shrink-0 gap-1.5",onClick:X,disabled:U.isPending,"aria-label":`Run ${K}`,children:[U.isPending?i.jsx(qe,{size:14,className:"animate-spin"}):i.jsx(fi,{size:14}),"Run"]}),l.mode==="available"&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{size:"icon",className:"size-8 shrink-0",disabled:d,onClick:()=>E(!0),"aria-label":`Save as global ${K}`,children:i.jsx(I9,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Save as global ",K]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:M?"default":"ghost",size:"icon",className:"size-8 shrink-0",onClick:G,"aria-label":M?"Close JSON editor":"Edit as JSON","aria-pressed":M,children:M?i.jsx(ms,{size:14}):i.jsx(To,{size:14})})}),i.jsx(Pe,{side:"bottom",children:M?"Close JSON editor":"Edit as JSON"})]})]}),i.jsx("p",{className:"mt-1.5 py-1 pl-1 text-sm leading-snug text-muted-foreground",children:l.mode==="saved"?`Global ${K} — changes save automatically. Run to invoke it against the live preview.`:`${H} — edits stay local until you save this as a global ${K}. Run to invoke it against the live preview.`})]}),i.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.jsxs("div",{className:ne("relative min-h-0 flex-1",I&&R&&"hidden"),children:[i.jsx(Sn,{className:"h-full [&_[data-slot=scroll-area-viewport]>div]:!block",children:i.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden px-6 py-4",children:i.jsxs("div",{className:"mx-auto max-w-2xl",children:[v&&_===v&&i.jsxs("p",{className:"mb-3 rounded-md bg-muted px-3 py-2 text-xs leading-snug text-muted-foreground",children:["This ",K," doesn't publish a props schema — fields below are inferred from its saved values. Use the JSON editor to add props not shown here."]}),_?i.jsx(Xn,{schema:_,value:b,onChange:ee=>J(ee),basePath:"",breadcrumbPath:L,onBreadcrumbChange:w,meta:r,decofile:o,onSaveReferencedBlock:u,sandbox:q},S):i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:x?`This ${K} doesn't publish a props schema. Edit its props as JSON, then run it.`:`This ${K} takes no configurable input. Run it to see its output.`})]})})}),T!==null&&i.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[k&&i.jsx("div",{className:"shrink-0 border-b bg-destructive/10 px-3 py-1.5 text-xs text-destructive",children:"Invalid JSON — changes aren't saved until it parses."}),i.jsx("div",{className:"min-h-0 flex-1",children:i.jsx(Ml,{language:"json",height:"100%",code:T,onChange:W,onSave:ee=>{W(ee),$()}})})]})]}),I&&i.jsx(lV,{singular:K,result:{isPending:U.isPending,error:U.error,data:U.data,hasRun:U.status!=="idle"},expanded:R,onToggleExpand:()=>D(ee=>!ee),onOpenInNewTab:n?Q:void 0,onClose:()=>{P(!1),D(!1)}})]}),i.jsx(Pd,{open:N,onOpenChange:E,defaultBlockId:"",isPending:d,onSubmit:z})]})}function lV(t){const e=B.c(37),{singular:s,result:n,expanded:r,onToggleExpand:o,onOpenInNewTab:a,onClose:l}=t;let c;e[0]!==n.data?(c=typeof n.data=="string"?n.data:JSON.stringify(n.data??null,null,2),e[0]=n.data,e[1]=c):c=e[1];const d=c,h=r?"flex-1":"h-[45%] shrink-0";let u;e[2]!==h?(u=ne("flex min-h-0 flex-col border-t",h),e[2]=h,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Result"}),e[4]=f):f=e[4];let m;e[5]!==a||e[6]!==s?(m=a&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:a,"aria-label":"Open result in new tab",children:i.jsx(wn,{size:14})})}),i.jsxs(Pe,{side:"bottom",children:["Open in new tab (re-runs the ",s,")"]})]}),e[5]=a,e[6]=s,e[7]=m):m=e[7];const p=r?"Collapse result":"Expand result";let g;e[8]!==r?(g=r?i.jsx(cx,{size:14}):i.jsx(rm,{size:14}),e[8]=r,e[9]=g):g=e[9];let x;e[10]!==r||e[11]!==o||e[12]!==p||e[13]!==g?(x=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:o,"aria-label":p,"aria-pressed":r,children:g})}),e[10]=r,e[11]=o,e[12]=p,e[13]=g,e[14]=x):x=e[14];const v=r?"Collapse":"Expand";let _;e[15]!==v?(_=i.jsx(Pe,{side:"bottom",children:v}),e[15]=v,e[16]=_):_=e[16];let b;e[17]!==_||e[18]!==x?(b=i.jsxs(Ie,{children:[x,_]}),e[17]=_,e[18]=x,e[19]=b):b=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(ms,{size:14}),e[20]=y):y=e[20];let L;e[21]!==l?(L=i.jsx(re,{variant:"ghost",size:"icon",className:"size-7",onClick:l,"aria-label":"Close result",children:y}),e[21]=l,e[22]=L):L=e[22];let w;e[23]!==b||e[24]!==L||e[25]!==m?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[f,i.jsxs("div",{className:"flex items-center gap-0.5",children:[m,b,L]})]}),e[23]=b,e[24]=L,e[25]=m,e[26]=w):w=e[26];let S;e[27]!==n.error||e[28]!==n.hasRun||e[29]!==n.isPending||e[30]!==d||e[31]!==s?(S=i.jsx("div",{className:"min-h-0 flex-1",children:n.isPending?i.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-muted-foreground",children:[i.jsx(qe,{size:16,className:"animate-spin"}),"Running ",s,"…"]}):n.error?i.jsxs("div",{className:"h-full overflow-auto px-4 py-3",children:[i.jsxs("p",{className:"text-xs font-medium text-destructive",children:["Failed to run ",s]}),i.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-destructive/90",children:n.error.message})]}):n.hasRun?i.jsx(Ml,{language:"json",height:"100%",code:d,readOnly:!0}):i.jsxs("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:["Press Run to invoke this ",s,"."]})}),e[27]=n.error,e[28]=n.hasRun,e[29]=n.isPending,e[30]=d,e[31]=s,e[32]=S):S=e[32];let j;return e[33]!==w||e[34]!==S||e[35]!==u?(j=i.jsxs("div",{className:u,children:[w,S]}),e[33]=w,e[34]=S,e[35]=u,e[36]=j):j=e[36],j}const cV={loaders:Fa,actions:ui},dV={loaders:"Loaders",actions:"Actions"},uV={analytics:dx,blog:Ki,commerce:D9,site:Nv,website:Yn};function hV(t,e){return e===0?uV[t.toLowerCase()]??hi:hi}function ma(t,e){return e===0?sV(t):t}function fV(t){const e=B.c(87),{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c}=t;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];const[h,u]=C.useState(d),[f,m]=C.useState(null),[p,g]=C.useState(""),[x,v]=C.useState(yV),[_,b]=C.useState(c);_!==c&&(b(c),u([]),m(null),g(""),v(new Set));let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=U=>{v(K=>{const H=new Set(K);return H.has(U)?H.delete(U):H.add(U),H})},e[1]=y):y=e[1];const L=y;let w;e[2]!==r||e[3]!==s||e[4]!==n?(w={orgSlug:s,virtualMcpId:n,branch:r},e[2]=r,e[3]=s,e[4]=n,e[5]=w):w=e[5];const S=Ul(w);let j;e[6]!==S?(j=up((U,K)=>S.mutate({blockKey:U,data:K})),e[6]=S,e[7]=j):j=e[7];const k=j;let V;e[8]!==c?(V=v3(c),e[8]=c,e[9]=V):V=e[9];const T=V,A=cV[c];let N,E,I,P,R,D,M;if(e[10]!==A||e[11]!==r||e[12]!==l||e[13]!==c||e[14]!==a||e[15]!==x||e[16]!==s||e[17]!==h||e[18]!==o||e[19]!==S||e[20]!==k||e[21]!==p||e[22]!==f||e[23]!==T||e[24]!==n){I=Symbol.for("react.early_return_sentinel");e:{const U=[...nV(a,l,c).map(bV),...b3(a,c).map(_V)],K=p.trim().toLowerCase(),H=K.length>0,q=H?U.filter(pe=>pe.title.toLowerCase().includes(K)||pe.resolveType.toLowerCase().includes(K)):[],J=new Map,G=[],W=new Map;if(!H){for(const pe of U){const Ee=pe.folderPath;if(!(Ee.length<h.length)&&h.every((De,ue)=>Ee[ue]===De))if(Ee.length===h.length)if(pe.savedKey!==void 0){const De=W.get(pe.resolveType);De?De.push(pe):W.set(pe.resolveType,[pe])}else G.push(pe);else{const De=Ee[h.length],ue=J.get(De)??{count:0,savedCount:0};pe.savedKey!==void 0?ue.savedCount=ue.savedCount+1:ue.count=ue.count+1,J.set(De,ue)}}G.sort(vV);for(const pe of W.values())pe.sort(xV)}const z=[...W.entries()].filter(pe=>{const[Ee]=pe;return!G.some(De=>De.resolveType===Ee)}).flatMap(gV).sort(pV);let X;e[32]!==h?(X=(pe,Ee)=>ma(pe.name,h.length).localeCompare(ma(Ee.name,h.length)),e[32]=h,e[33]=X):X=e[33];const Q=[...J.entries()].map(mV).sort(X);let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=pe=>{m(pe.savedKey!==void 0?{mode:"saved",key:pe.savedKey}:{mode:"available",resolveType:pe.resolveType,title:pe.title})},e[34]=Z):Z=e[34];const Y=Z;let ee;e[35]!==S||e[36]!==T?(ee=async(pe,Ee)=>{await S.mutateAsync({blockKey:pe,data:Ee}),ce.success(`Saved ${T} "${pe}"`),m({mode:"saved",key:pe})},e[35]=S,e[36]=T,e[37]=ee):ee=e[37];const te=ee;let ae;e[38]!==l||e[39]!==f?(ae=LV(f,l),e[38]=l,e[39]=f,e[40]=ae):ae=e[40];const se=ae;if(se){const pe=`${se.mode}:${se.mode==="saved"?se.blockKey:se.resolveType}`;let Ee;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>m(null),e[41]=Ee):Ee=e[41];let De;e[42]!==r||e[43]!==l||e[44]!==te||e[45]!==c||e[46]!==a||e[47]!==s||e[48]!==o||e[49]!==S.isPending||e[50]!==k||e[51]!==pe||e[52]!==se.editorTarget||e[53]!==se.initialValue||e[54]!==n?(De=i.jsx(aV,{orgSlug:s,virtualMcpId:n,branch:r,previewUrl:o,meta:a,decofile:l,kind:c,target:se.editorTarget,initialValue:se.initialValue,isCreating:S.isPending,onCreate:te,onSaveReferencedBlock:k,onBack:Ee},pe),e[42]=r,e[43]=l,e[44]=te,e[45]=c,e[46]=a,e[47]=s,e[48]=o,e[49]=S.isPending,e[50]=k,e[51]=pe,e[52]=se.editorTarget,e[53]=se.initialValue,e[54]=n,e[55]=De):De=e[55],I=De;break e}M="flex h-full w-full min-w-0 flex-col";let ie;e[56]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>u([]),e[56]=ie):ie=e[56];const fe=h.length===0?"font-medium text-foreground":"text-muted-foreground";let me;e[57]!==fe?(me=ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",fe),e[57]=fe,e[58]=me):me=e[58];const be=dV[c];let _e;e[59]!==me||e[60]!==be?(_e=i.jsx("button",{type:"button",onClick:ie,className:me,children:be}),e[59]=me,e[60]=be,e[61]=_e):_e=e[61];let xe;e[62]!==h?(xe=h.map((pe,Ee)=>{const De=Ee===h.length-1;return i.jsxs("span",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[i.jsx(cn,{className:"size-3 shrink-0 text-muted-foreground/60"}),i.jsx("button",{type:"button",onClick:()=>u(h.slice(0,Ee+1)),className:ne("min-w-0 truncate rounded-md px-1 py-0.5 transition-colors hover:bg-accent hover:text-accent-foreground",De?"font-medium text-foreground":"text-muted-foreground"),children:ma(pe,Ee)})]},`${pe}-${Ee}`)}),e[62]=h,e[63]=xe):xe=e[63];let ke;e[64]!==_e||e[65]!==xe?(ke=i.jsxs("nav",{"aria-label":"Folder breadcrumb",className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-sm",children:[_e,xe]}),e[64]=_e,e[65]=xe,e[66]=ke):ke=e[66];let Ne;e[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=i.jsx(K9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[67]=Ne):Ne=e[67];let we;e[68]===Symbol.for("react.memo_cache_sentinel")?(we=pe=>g(pe.target.value),e[68]=we):we=e[68];const ye=`Search all ${c}…`,Be=`Search all ${c}`;let Fe;e[69]!==p||e[70]!==ye||e[71]!==Be?(Fe=i.jsxs("div",{className:"flex w-56 shrink-0 items-center gap-2",children:[Ne,i.jsx("input",{type:"text",value:p,onChange:we,placeholder:ye,"aria-label":Be,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[69]=p,e[70]=ye,e[71]=Be,e[72]=Fe):Fe=e[72],e[73]!==ke||e[74]!==Fe?(E=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[ke,Fe]}),e[73]=ke,e[74]=Fe,e[75]=E):E=e[75],N=Sn,D="min-h-0 flex-1 [&_[data-slot=scroll-area-viewport]>div]:!block",P="mx-auto w-full max-w-4xl px-6 py-5",R=H?q.length===0?i.jsx(Mn,{title:`No ${c} match "${p.trim()}"`,description:"Search covers every folder — try a different term."}):i.jsx("div",{className:"flex flex-col gap-1",children:q.map(pe=>i.jsx(tn,{icon:A,accent:pe.savedKey!==void 0?"global":void 0,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Y(pe)},pe.savedKey??pe.resolveType))}):Q.length===0&&G.length===0&&z.length===0?i.jsx(Mn,{title:`No ${c} here`,description:h.length===0?"Start the preview dev server so its manifest loads.":"This folder is empty."}):i.jsxs(i.Fragment,{children:[Q.length>0&&i.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-2",children:Q.map(pe=>{const Ee=hV(pe.name,h.length);return i.jsxs("button",{type:"button",onClick:()=>u([...h,pe.name]),className:"flex items-center gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-muted cursor-pointer",children:[i.jsx(Ee,{size:18,className:"shrink-0 text-muted-foreground"}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm font-medium",children:ma(pe.name,h.length)}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:[pe.count," ",pe.count===1?T:c,pe.savedCount>0&&i.jsxs(i.Fragment,{children:[" · ",pe.savedCount," saved"]})]})]})]},pe.name)})}),(G.length>0||z.length>0)&&i.jsxs("div",{className:ne("flex flex-col gap-1",Q.length>0&&"mt-4"),children:[G.map(pe=>{const Ee=W.get(pe.resolveType)??[],De=x.has(pe.resolveType);return i.jsxs("div",{className:"flex flex-col",children:[i.jsx(tn,{icon:A,title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Y(pe)}),Ee.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",onClick:()=>L(pe.resolveType),"aria-expanded":De,className:"flex items-center gap-1 self-start rounded-md px-2.5 py-1 text-xs font-medium transition-colors hover:bg-global-section/10 cursor-pointer ml-11",style:{color:ad},children:[De?i.jsx(Ht,{size:12,className:"shrink-0"}):i.jsx(cn,{size:12,className:"shrink-0"}),De?"Hide saved":"See saved"," (",Ee.length,")"]}),De&&i.jsx("div",{className:"ml-11 flex flex-col gap-1 pb-1",children:Ee.map(ue=>i.jsx(tn,{icon:A,accent:"global",title:ue.title,subtitle:ue.resolveType,active:!1,onClick:()=>Y(ue)},ue.savedKey))})]})]},pe.resolveType)}),z.map(pe=>i.jsx(tn,{icon:A,accent:"global",title:pe.title,subtitle:pe.resolveType,active:!1,onClick:()=>Y(pe)},pe.savedKey))]})]})}e[10]=A,e[11]=r,e[12]=l,e[13]=c,e[14]=a,e[15]=x,e[16]=s,e[17]=h,e[18]=o,e[19]=S,e[20]=k,e[21]=p,e[22]=f,e[23]=T,e[24]=n,e[25]=N,e[26]=E,e[27]=I,e[28]=P,e[29]=R,e[30]=D,e[31]=M}else N=e[25],E=e[26],I=e[27],P=e[28],R=e[29],D=e[30],M=e[31];if(I!==Symbol.for("react.early_return_sentinel"))return I;let F;e[76]!==P||e[77]!==R?(F=i.jsx("div",{className:P,children:R}),e[76]=P,e[77]=R,e[78]=F):F=e[78];let $;e[79]!==N||e[80]!==F||e[81]!==D?($=i.jsx(N,{className:D,children:F}),e[79]=N,e[80]=F,e[81]=D,e[82]=$):$=e[82];let O;return e[83]!==E||e[84]!==$||e[85]!==M?(O=i.jsxs("div",{className:M,children:[E,$]}),e[83]=E,e[84]=$,e[85]=M,e[86]=O):O=e[86],O}function mV(t){const[e,s]=t;return{name:e,...s}}function pV(t,e){return t.title.localeCompare(e.title)}function gV(t){const[,e]=t;return e}function xV(t,e){return t.title.localeCompare(e.title)}function vV(t,e){return t.title.localeCompare(e.title)}function _V(t){return{resolveType:t.resolveType,title:t.title,folderPath:y3(t.resolveType)}}function bV(t){return{resolveType:t.resolveType,title:t.title,folderPath:y3(t.resolveType),savedKey:t.key}}function yV(){return new Set}function LV(t,e){if(!t)return null;if(t.mode==="available")return{mode:"available",resolveType:t.resolveType,editorTarget:{mode:"available",resolveType:t.resolveType,title:t.title},initialValue:{}};const s=e[t.key],n=s&&typeof s.__resolveType=="string"?s.__resolveType:"",{__resolveType:r,...o}=s??{},a=s&&typeof s.name=="string"&&s.name?s.name:t.key;return{mode:"saved",blockKey:t.key,resolveType:n,editorTarget:{mode:"saved",blockKey:t.key,resolveType:n,title:a},initialValue:o}}const SV={target:null,editSeoPageKey:null,previewRevision:0};function wV(t,e){switch(e.type){case"select":return{...t,target:e.target};case"edit-seo":return{...t,target:e.target,editSeoPageKey:e.target.key};case"consume-edit-seo":return{...t,editSeoPageKey:null};case"saved":return{...t,previewRevision:t.previewRevision+1}}}const S3=C.createContext(null);function jV(t){const e=B.c(9),{children:s}=t,[n,r]=C.useReducer(wV,SV);let o,a,l,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=u=>r({type:"select",target:u}),a=u=>r({type:"edit-seo",target:u}),l=()=>r({type:"consume-edit-seo"}),c=()=>r({type:"saved"}),e[0]=o,e[1]=a,e[2]=l,e[3]=c):(o=e[0],a=e[1],l=e[2],c=e[3]);let d;e[4]!==n?(d={state:n,selectTarget:o,editSeo:a,consumeEditSeo:l,notifySaved:c},e[4]=n,e[5]=d):d=e[5];let h;return e[6]!==s||e[7]!==d?(h=i.jsx(S3,{value:d,children:s}),e[6]=s,e[7]=d,e[8]=h):h=e[8],h}function w3(){const t=C.use(S3);if(!t)throw new Error("useBlocksPreviewWorkspace must be used inside BlocksPreviewWorkspaceProvider");return t}const Xh=C.lazy(()=>Ws(()=>import("./app-editor-CETJj2AM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppEditor}))),CV=C.lazy(()=>Ws(()=>import("./post-editor-DDgBqLC0.js"),__vite__mapDeps([149,1,2,51,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,105,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,109,117,150,151,107,108,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.PostEditor}))),kV=C.lazy(()=>Ws(()=>import("./record-editor-C_mvNdEN.js"),__vite__mapDeps([152,1,2,105,104,117,151,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,85,86,87,14,15,16,88,89,90,17,13,91,69,92,82,93,4,5,6,10,11,12,18,19,21,23,24,25,26,27,68,70,71,72,73,74,75,76,77,78,79,80,81,83,84,94,95,96,97,98,99,100,101,102,103,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.RecordEditor}))),VV=C.lazy(()=>Ws(()=>import("./category-editor-C-bPIYYJ.js"),__vite__mapDeps([153,1,2,35,31,28,32,33,34,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,96,105,104,150,73,74,75,76,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,97,98,99,100,101,102,103,151,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.CategoryEditor}))),NV=C.lazy(()=>Ws(()=>import("./bulk-category-panel-C4Bw4AHl.js"),__vite__mapDeps([154,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,155,5,6])).then(t=>({default:t.BulkCategoryPanel}))),AV=C.lazy(()=>Ws(()=>import("./sections-editor-Cv3sWswm.js"),__vite__mapDeps([156,1,2,8,39,3,9,31,28,32,33,34,35,36,37,38,29,7,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,126,157,135,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SectionsEditor}))),TV=C.lazy(()=>Ws(()=>import("./seo-editor-wF02jWH-.js"),__vite__mapDeps([158,1,2,3,31,28,32,33,34,35,36,37,38,39,29,7,8,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoEditor}))),EV=C.lazy(()=>Ws(()=>import("./variant-calendar-BiFKt806.js"),__vite__mapDeps([159,1,2,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,104,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,135,160])).then(t=>({default:t.VariantCalendar}))),N0="oklch(0.65 0.15 160)";function Pc(t){return t?t.kind==="page"?{collection:"pages",key:t.key,path:t.path}:{collection:"sections",key:t.key}:null}function RV(t){return t?t.kind==="page"?`page:${t.key}:${t.path}`:`section:${t.key}`:null}function PV(t){return t.split("/").pop()?.replace(/\.tsx?$/,"")||t||"Section"}function IV(t){const e=new Map;for(const s of t){const n=PV(s.resolveType),r=e.get(n);r?r.push(s):e.set(n,[s])}return[...e.entries()].map(([s,n])=>({label:s,sections:n})).sort((s,n)=>s.label.localeCompare(n.label))}function j3(t){const e=B.c(20),{mode:s}=t,n=s===void 0?"content":s,r=kn(),{data:o}=vi.useSession(),{currentBranch:a}=as(),{org:l}=Ae(),c=r?.entity?.id??null,d=o?.user?.id,h=r?.entity?.metadata,u=d&&a?Cl(h?.sandboxMap?.[d]?.[a]):{},f=Object.values(u),p=(f.find(DV)??f[0])?.previewUrl??null,g=Os(),x=r?.entity?.organization_id??"";let v;e[0]!==l.slug||e[1]!==x?(v={connectionId:k9,orgId:x,orgSlug:l.slug},e[0]=l.slug,e[1]=x,e[2]=v):v=e[2];const _=pt(v),b=td(_);let y;e[3]!==a||e[4]!==b||e[5]!==c?(y=()=>{if(!c)return;const k={virtualMcpId:c};a&&(k.branch=a),b.mutate(k)},e[3]=a,e[4]=b,e[5]=c,e[6]=y):y=e[6];const L=y,w=!!c&&!!a&&nl.isStopped(c,a),S=f2({previewUrl:p,appPaused:g.status.state==="paused",userStopped:w,startError:b.isError&&b.error?p2(b.error.message):null});if(S.kind!=="iframe"){const k=`/${l.slug}/settings/connections`;let V;return e[7]!==S||e[8]!==k||e[9]!==L||e[10]!==g.lifecycle||e[11]!==g.phase?(V=i.jsx(nN,{state:S,claimPhase:g.phase,lifecycle:g.lifecycle,onStart:L,connectionsHref:k}),e[7]=S,e[8]=k,e[9]=L,e[10]=g.lifecycle,e[11]=g.phase,e[12]=V):V=e[12],V}if(!c||!a){let k;return e[13]===Symbol.for("react.memo_cache_sentinel")?(k=i.jsx(Mn,{title:"Waiting for sandbox context…"}),e[13]=k):k=e[13],k}let j;return e[14]!==a||e[15]!==n||e[16]!==l.slug||e[17]!==p||e[18]!==c?(j=i.jsx(OV,{orgSlug:l.slug,virtualMcpId:c,branch:a,previewUrl:p,mode:n}),e[14]=a,e[15]=n,e[16]=l.slug,e[17]=p,e[18]=c,e[19]=j):j=e[19],j}function DV(t){return t.sandboxProviderKind!=="user-desktop"}const Qh=2e3,MV=15;function Zh(t,e,s,n){return typeof e!="string"||s&&(q2(e,s,n)||t.state.dataUpdateCount>=MV)?!1:Qh}function OV({orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,mode:r}){const o=w3(),a={orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n},{data:l,isLoading:c}=Bl(a),[d,h]=C.useState("pages"),[u,f]=C.useState(()=>r==="blocks"?Pc(o.state.target):null),[m,p]=C.useState(()=>r==="blocks"?o.state.editSeoPageKey:null),g=RV(o.state.target),[x,v]=C.useState(g);if(r==="blocks"&&x!==g){v(g);const oe=Pc(o.state.target);f(oe),(oe?.collection==="pages"||oe?.collection==="sections")&&h(oe.collection)}const[_,b]=C.useState(o.state.editSeoPageKey);if(r==="blocks"&&_!==o.state.editSeoPageKey&&(b(o.state.editSeoPageKey),o.state.editSeoPageKey)){const oe=o.state.target;oe?.kind==="page"&&(h("pages"),f(Pc(oe)),p(oe.key))}const[y,L]=C.useState(""),[w,S]=C.useState(null),[j,k]=C.useState(null),[V,T]=C.useState("date-desc"),[A,N]=C.useState(()=>new Set),[E,I]=C.useState(null),P=()=>{N(new Set),I(null)},R=oe=>{f(oe),p(null),!(r!=="blocks"||!oe)&&(oe.collection==="pages"?o.selectTarget({kind:"page",key:oe.key,path:oe.path}):oe.collection==="sections"&&o.selectTarget({kind:"section",key:oe.key}))},[D,M]=C.useState(d);D!==d&&(M(d),L(""),S(null),k(null),T("date-desc"),N(new Set),I(null));const{data:F,isLoading:$,isFetching:O}=zl(a,{refetchInterval:oe=>{const Le=oe.state.data;if(d==="apps"&&u&&u.collection==="apps"){const Te=l?.[u.key];return Zh(oe,typeof Te?.__resolveType=="string"?Te.__resolveType:void 0,Le)}if(d==="site"&&l){const Te=Le?L0(l,Le):null,$e=l.site,st=Te?.resolveType??(typeof $e?.__resolveType=="string"?$e.__resolveType:void 0);return Zh(oe,st,Le,["seo"])}return!1}}),U=(oe,Le)=>!q2(oe,F,Le)&&($||O),{catalog:K,isLoading:H}=i7(F??void 0,l??void 0,{enabled:d==="apps"}),q=Ul(a),J=BL(a),G=Gk(a),W=Jk(a),[z,X]=C.useState(null),[Q,Z]=C.useState(),[Y,ee]=C.useState(null),[te,ae]=C.useState(null),[se,ie]=C.useState(null);if(c||$)return i.jsx("div",{className:"h-full w-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})});if(!l||!F)return i.jsx(Mn,{title:"Could not load site data."});const fe=md(l).sort((oe,Le)=>oe.name.localeCompare(Le.name)),me=pd(l,F),be=d==="sections"?KL(F):[],_e=L0(l,F),xe=h3(l),ke=Bd.some(oe=>xe[oe].length>0),Ne=to(d)?xe[d]:[],we=(ke?bo(l,"categories"):[]).map(({key:oe,payload:Le})=>{const Te=typeof Le.slug=="string"?Le.slug:"",$e=typeof Le.name=="string"?Le.name:"";return{slug:Te||oe,name:$e||Te||oe}}).filter(oe=>oe.slug).sort((oe,Le)=>oe.name.localeCompare(Le.name)),ye=d==="posts"&&(A.size>0||E!==null),Be=ye?m3(l).filter(oe=>A.has(oe.key)):[],Fe=Yh(F,"loaders"),pe=Yh(F,"actions");if(!fd(l,F)&&!ke&&Fe===0&&pe===0)return i.jsx(Mn,{icon:fn,title:"No editable content",description:"This project doesn't expose any Deco pages, sections, apps, loaders, or actions."});const Ee={pages:fe.length,sections:me.length,apps:K.length,loaders:Fe,actions:pe,posts:xe.posts.length,authors:xe.authors.length,categories:xe.categories.length},De=new Set(fe.map(oe=>ai(oe.path))),ue=new Set(fe.map(oe=>oe.name)),le=new Set(me.map(oe=>oe.name)),Ve=async oe=>{const Le=l[oe.key];if(!Le)return;const Te=cp(l,oe.key),$e=b7(l,oe.key,Math.max(0,Te-1)),st=y7(Le.sections,$e);if(st)try{await q.mutateAsync({blockKey:oe.key,data:{...Le,sections:st}}),ce.success(`Variant added to "${oe.name}"`),f({collection:"pages",key:oe.key,path:oe.path})}catch(ht){ce.error(ht instanceof Error?ht.message:"Could not add variant")}},Me=()=>{Z(void 0),X({mode:"create",sourceKey:null,initialName:"My new page",initialPath:"/example"})},Ue=oe=>{Z(void 0),X({mode:"duplicate",sourceKey:oe.key,initialName:Kh(ue,oe.name),initialPath:yk(De,oe.path)})},it=oe=>{Z(void 0),X({mode:"rename",sourceKey:oe.key,initialName:oe.name,initialPath:oe.path})},Yt=async oe=>{if(!z)return;const{mode:Le,sourceKey:Te}=z;try{if(Le==="create"){let $e;if(oe.templateKey){const ht=l[oe.templateKey];if(!ht)throw new Error("Selected template no longer exists.");$e={...ht,name:oe.name,path:oe.path}}else $e=wk(oe.name,oe.path);const st=Ck(l,oe.name);await q.mutateAsync({blockKey:st,data:$e}),ce.success(`Created "${oe.name}"`),f({collection:"pages",key:st,path:oe.path})}else if(Le==="duplicate"&&Te){const $e=l[Te];if(!$e)throw new Error("Source page not found");const{key:st,data:ht}=Sk({source:$e,pages:fe,newName:oe.name,newPath:oe.path});await q.mutateAsync({blockKey:st,data:ht}),ce.success(`Duplicated as "${oe.name}"`),f({collection:"pages",key:st,path:oe.path})}else if(Le==="rename"&&Te){const $e=l[Te];if(!$e)throw new Error("Page not found");const st={...$e,name:oe.name,path:oe.path};await q.mutateAsync({blockKey:Te,data:st}),ce.success("Page updated"),u?.collection==="pages"&&u.key===Te&&f({collection:"pages",key:Te,path:oe.path})}X(null)}catch($e){Z($e instanceof Error?$e.message:"Save failed")}},Rt=({path:oe})=>{if(!z)return null;const Le=ai(oe);return(z.mode==="rename"?ai(z.initialPath):null)!==Le&&De.has(Le)?`A page with path "${oe}" already exists.`:null},rt=async(oe,Le,Te)=>{await q.mutateAsync({blockKey:Le,data:{...Te,name:Le,__resolveType:oe}}),ce.success(`Created section "${Le}"`),f({collection:"sections",key:Le})},gt=up((oe,Le)=>q.mutate({blockKey:oe,data:Le})),lt=async oe=>{const Le=l[oe.key];if(!Le){ce.error("Section not found.");return}const Te=Lk(l,oe.key),$e=Kh(le,oe.name),st={...Le,name:$e};try{await q.mutateAsync({blockKey:Te,data:st}),ce.success(`Duplicated "${oe.name}"`),f({collection:"sections",key:Te})}catch(ht){ce.error(ht instanceof Error?ht.message:"Duplicate failed")}},wt=async oe=>{if(!Y)return;const Le=l[Y];if(!Le){ce.error("Section not found.");return}try{await q.mutateAsync({blockKey:Y,data:{...Le,name:oe}}),ce.success("Section renamed"),ee(null)}catch(Te){ce.error(Te instanceof Error?Te.message:"Rename failed")}},ct=async oe=>{const Le=qh(l,oe),Te=fa(Le,oe,zk(oe));try{await G.mutateAsync({blockKey:Le,data:Te}),ce.success(`Created ${eo[oe]}`),f({collection:oe,key:Le})}catch($e){ce.error($e instanceof Error?$e.message:"Could not create")}},he=async oe=>{const Le=l[oe.key];if(!Le){ce.error("Record not found.");return}const Te=qh(l,oe.kind),$e=oe.kind==="posts"?"title":"name",st={...structuredClone(Na(Le,oe.kind)),[$e]:`${oe.label} (copy)`};try{await G.mutateAsync({blockKey:Te,data:fa(Te,oe.kind,st)}),ce.success(`Duplicated "${oe.label}"`),f({collection:oe.kind,key:Te})}catch(ht){ce.error(ht instanceof Error?ht.message:"Duplicate failed")}},Oe=oe=>{N(Le=>{const Te=new Set(Le);return Te.has(oe)?Te.delete(oe):Te.add(oe),Te})},et=oe=>{h("posts"),M("posts"),f(null),p(null),L(""),S(null),k(null),T("date-desc"),N(new Set),I(oe||null)},tt=async(oe,Le)=>{const Te=[...A];let $e=0;for(const st of Te){const ht=l[st],Vn=Na(ht,"posts"),Qn=oe==="add"?Ok(Vn,Le):$k(Vn,Le);Qn!==Vn&&(await G.mutateAsync({blockKey:st,data:fa(st,"posts",Qn)}),$e+=1)}return $e},vs=async(oe,Le)=>{const Te=A.size;try{const $e=await tt(oe,Le),st=oe==="add"?"Added to":"Moved",ht=Te-$e;ce.success(`${st} ${$e} ${$e===1?"post":"posts"}`+(ht>0?` (${ht} already set)`:"")),P()}catch($e){ce.error($e instanceof Error?$e.message:"Bulk update failed")}},us=async()=>{if(te)try{if(te.kind==="blog-bulk"){for(const $e of te.keys)await W.mutateAsync({blockKey:$e});ce.success(`Deleted ${te.count} ${te.count===1?"post":"posts"}`),u&&u.collection!=="available-section"&&te.keys.includes(u.key)&&f(null),P(),ae(null);return}const{kind:oe,key:Le,label:Te}=te;if(oe==="blog"){if(te.blogKind==="categories"){const $e=Na(l[Le],"categories").slug,st=typeof $e=="string"?$e:"";if(st)for(const{key:ht,payload:Vn}of bo(l,"posts")){const Qn=Bk(Vn,st);Qn!==Vn&&await G.mutateAsync({blockKey:ht,data:fa(ht,"posts",Qn)})}}await W.mutateAsync({blockKey:Le})}else await J.mutateAsync({blockKey:Le});ce.success(`Deleted "${Te}"`),u&&u.collection!=="available-section"&&u.key===Le&&f(null),ae(null)}catch(oe){ce.error(oe instanceof Error?oe.message:"Delete failed")}},Jt=J.isPending||W.isPending||G.isPending,mn=te?.kind==="blog"?eo[te.blogKind]:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"}`:te?.kind??"item";return i.jsxs("div",{className:"flex h-full w-full",children:[r==="content"&&i.jsx(BV,{active:d,counts:Ee,showBlog:ke,onSelect:oe=>{h(oe),f(null),p(null)}}),d!=="seo"&&d!=="site"&&d!=="calendar"&&d!=="loaders"&&d!=="actions"&&i.jsx(zV,{blocksMode:r==="blocks",activeCollection:d,pages:fe,sections:me,availableSections:be,appCatalog:K,appCatalogLoading:H,blogEntries:Ne,decofile:l,searchQuery:y,onSearchChange:L,postCategoryFilter:w,postAuthorFilter:j,postSort:V,onPostCategoryFilterChange:oe=>{S(oe),N(new Set)},onPostAuthorFilterChange:oe=>{k(oe),N(new Set)},onPostSortChange:T,selectedPostKeys:A,postBulkPanelOpen:ye,onTogglePostSelect:Oe,onSelectAllPosts:oe=>N(new Set(oe)),onClearPostSelection:()=>N(new Set),onExitPostSelection:P,onBulkDeletePosts:()=>ae({kind:"blog-bulk",keys:[...A],count:A.size}),selection:u,onSelect:R,onCollectionSelect:oe=>{h(oe),f(null),p(null)},onCreate:()=>{d==="pages"?Me():to(d)&&ct(d)},onDuplicatePage:Ue,onRenamePage:it,onAddPageVariant:Ve,onDeletePage:oe=>ae({kind:"page",key:oe.key,label:oe.name}),onEditPageSeo:oe=>{const Le={collection:"pages",key:oe.key,path:oe.path};f(Le),p(oe.key),r==="blocks"&&o.editSeo({kind:"page",key:oe.key,path:oe.path})},onViewPageJson:oe=>ie(oe.key),onDuplicateSection:lt,onRenameSection:oe=>ee(oe.key),onDeleteSection:oe=>ae({kind:"section",key:oe.key,label:oe.name}),onDuplicateBlog:he,onDeleteBlog:oe=>ae({kind:"blog",blogKind:oe.kind,key:oe.key,label:oe.label})}),i.jsx("div",{className:"flex-1 min-w-0",children:d==="loaders"||d==="actions"?i.jsx(fV,{orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:F,decofile:l,kind:d}):i.jsx(C.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),children:d==="calendar"?i.jsx(EV,{decofile:l}):d==="site"?_e?i.jsx(Xh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:_e.key,block:l[_e.key],decofile:l,meta:F,title:"Site",excludeFields:["seo"],schemaPending:U(_e.resolveType,["seo"]),previewBaseUrl:n},`site:${_e.key}`):i.jsx(Mn,{title:"Site settings not found",description:"This project doesn't have a site app block (site/apps/site.ts)."}):d==="seo"?i.jsx(TV,{orgSlug:t,virtualMcpId:e,branch:s,decofile:l,meta:F,target:{kind:"site"},previewBaseUrl:n}):d==="sections"?i.jsx($V,{selection:u?.collection==="sections"||u?.collection==="available-section"?u:null,orgSlug:t,virtualMcpId:e,branch:s,previewUrl:n,meta:F,decofile:l,isCreating:q.isPending,onCreateAvailable:rt,onSaveReferencedBlock:gt}):ye?i.jsx(NV,{posts:Be,categories:we,initialSlug:E,isPending:G.isPending,onApply:(oe,Le)=>{vs(oe,Le)},onClose:P},E??"selection"):u&&u.collection!=="available-section"?u.collection==="apps"?i.jsx(Xh,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:F,previewBaseUrl:n,schemaPending:U(typeof l[u.key]?.__resolveType=="string"?String(l[u.key].__resolveType):void 0)},`app:${u.key}`):u.collection==="posts"?i.jsx(CV,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:F,previewBaseUrl:n},`post:${u.key}`):u.collection==="categories"?i.jsx(VV,{orgSlug:t,virtualMcpId:e,branch:s,blockKey:u.key,block:l[u.key],decofile:l,meta:F,onManagePosts:et,onOpenPost:oe=>{h("posts"),M("posts"),f({collection:"posts",key:oe}),p(null)},previewBaseUrl:n},`category:${u.key}`):u.collection==="authors"?i.jsx(kV,{orgSlug:t,virtualMcpId:e,branch:s,kind:"authors",blockKey:u.key,block:l[u.key]},`authors:${u.key}`):i.jsx(AV,{orgSlug:t,virtualMcpId:e,branch:s,previewReady:!0,previewUrl:n??void 0,currentPath:u.collection==="pages"?u.path:"/",activePageBlockKey:u.collection==="pages"?u.key:null,activeGlobalBlockKey:u.collection==="sections"?u.key:null,initialEditSeo:u.collection==="pages"&&m===u.key,onExitSeo:()=>{p(null),r==="blocks"&&o.consumeEditSeo()},onSaved:r==="blocks"?o.notifySaved:void 0},u.collection==="pages"?`page:${u.key}`:`section:${u.key}`):i.jsx(Mn,{title:`Select ${to(d)?`a ${eo[d]}`:d==="pages"?"a page":d==="apps"?"an app":"a section"} to edit`,description:d==="apps"?"Browse all apps and select an installed one to edit its settings.":'Pick an item from the list, or click "+" to create one.'})})}),z&&i.jsx(Tk,{open:!!z,mode:z.mode,initialName:z.initialName,initialPath:z.initialPath,isPending:q.isPending,error:Q,templates:fe,validate:Rt,onSubmit:Yt,onOpenChange:oe=>{oe||(X(null),Z(void 0))}}),Y&&i.jsx(Ek,{open:!!Y,blockKey:Y,initialName:me.find(oe=>oe.key===Y)?.name??Y,isPending:q.isPending,onSubmit:wt,onOpenChange:oe=>{oe||ee(null)}}),se&&i.jsx(Xk,{open:!!se,onOpenChange:oe=>{oe||ie(null)},pageKey:se,decofile:l}),i.jsx(Wa,{open:!!te,onOpenChange:oe=>{!oe&&!Jt&&ae(null)},children:i.jsxs(qa,{children:[i.jsxs(Ga,{children:[i.jsx(Ya,{children:`Delete ${mn}?`}),i.jsx(Ja,{children:te?.kind==="section"?`"${te.label}" will be removed. Pages that still reference it will lose this section.`:te?.kind==="blog-bulk"?`${te.count} ${te.count===1?"post":"posts"} will be removed permanently. This can't be undone.`:te?`"${te.label}" will be removed permanently. This can't be undone.`:null})]}),i.jsxs(Xa,{children:[i.jsx(Qa,{disabled:Jt,children:"Cancel"}),i.jsx(Za,{onClick:oe=>{oe.preventDefault(),us()},disabled:Jt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Jt?i.jsxs(i.Fragment,{children:[i.jsx(qe,{size:14,className:"animate-spin"}),"Deleting…"]}):"Delete"})]})]})})]})}function $V(t){const e=B.c(30),{selection:s,orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,isCreating:d,onCreateAvailable:h,onSaveReferencedBlock:u}=t;if(!s){let p;return e[0]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Mn,{title:"Select a section to edit",description:"Pick a saved section to edit it, or an available one to customize and save as global."}),e[0]=p):p=e[0],p}if(s.collection==="available-section"){const p=`available:${s.resolveType}`,g=s.resolveType,x=s.title;let v;e[1]!==s.title?(v=dp(s.title),e[1]=s.title,e[2]=v):v=e[2];let _;e[3]!==h||e[4]!==s.resolveType?(_=(y,L)=>h(s.resolveType,y,L),e[3]=h,e[4]=s.resolveType,e[5]=_):_=e[5];let b;return e[6]!==o||e[7]!==c||e[8]!==d||e[9]!==l||e[10]!==u||e[11]!==n||e[12]!==a||e[13]!==s.resolveType||e[14]!==s.title||e[15]!==p||e[16]!==v||e[17]!==_||e[18]!==r?(b=i.jsx(sk,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,resolveType:g,title:x,defaultBlockId:v,isCreating:d,onCreate:_,onSaveReferencedBlock:u},p),e[6]=o,e[7]=c,e[8]=d,e[9]=l,e[10]=u,e[11]=n,e[12]=a,e[13]=s.resolveType,e[14]=s.title,e[15]=p,e[16]=v,e[17]=_,e[18]=r,e[19]=b):b=e[19],b}const f=`saved:${s.key}`;let m;return e[20]!==o||e[21]!==c||e[22]!==l||e[23]!==u||e[24]!==n||e[25]!==a||e[26]!==s.key||e[27]!==f||e[28]!==r?(m=i.jsx(ok,{orgSlug:n,virtualMcpId:r,branch:o,previewUrl:a,meta:l,decofile:c,blockKey:s.key,onSaveReferencedBlock:u},f),e[20]=o,e[21]=c,e[22]=l,e[23]=u,e[24]=n,e[25]=a,e[26]=s.key,e[27]=f,e[28]=r,e[29]=m):m=e[29],m}function ef(t){const e=B.c(8),{icon:s,label:n,className:r}=t;let o;e[0]!==r?(o=ne("flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",r),e[0]=r,e[1]=o):o=e[1];let a;e[2]!==s?(a=i.jsx(s,{size:13,className:"shrink-0"}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==n||e[5]!==o||e[6]!==a?(l=i.jsxs("div",{className:o,children:[a,n]}),e[4]=n,e[5]=o,e[6]=a,e[7]=l):l=e[7],l}function BV(t){const e=B.c(47),{active:s,counts:n,showBlog:r,onSelect:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx("div",{className:"px-3 h-12 flex items-center border-b shrink-0",children:i.jsx("span",{className:"text-sm font-medium",children:"Content"})}),e[0]=a):a=e[0];const l=s==="pages";let c;e[1]!==n.pages||e[2]!==o||e[3]!==l?(c=i.jsx($s,{id:"pages",icon:Dn,label:"Pages",count:n.pages,active:l,onSelect:o}),e[1]=n.pages,e[2]=o,e[3]=l,e[4]=c):c=e[4];const d=s==="sections";let h;e[5]!==n.sections||e[6]!==o||e[7]!==d?(h=i.jsx($s,{id:"sections",icon:on,label:"Sections",count:n.sections,active:d,onSelect:o}),e[5]=n.sections,e[6]=o,e[7]=d,e[8]=h):h=e[8];const u=s==="apps";let f;e[9]!==n.apps||e[10]!==o||e[11]!==u?(f=i.jsx($s,{id:"apps",icon:R1,label:"Apps",count:n.apps,active:u,onSelect:o}),e[9]=n.apps,e[10]=o,e[11]=u,e[12]=f):f=e[12];const m=s==="loaders";let p;e[13]!==n.loaders||e[14]!==o||e[15]!==m?(p=i.jsx($s,{id:"loaders",icon:Fa,label:"Loaders",count:n.loaders,active:m,onSelect:o}),e[13]=n.loaders,e[14]=o,e[15]=m,e[16]=p):p=e[16];const g=s==="actions";let x;e[17]!==n.actions||e[18]!==o||e[19]!==g?(x=i.jsx($s,{id:"actions",icon:ui,label:"Actions",count:n.actions,active:g,onSelect:o}),e[17]=n.actions,e[18]=o,e[19]=g,e[20]=x):x=e[20];const v=s==="site";let _;e[21]!==o||e[22]!==v?(_=i.jsx($s,{id:"site",icon:am,label:"Site",active:v,onSelect:o}),e[21]=o,e[22]=v,e[23]=_):_=e[23];const b=s==="seo";let y;e[24]!==o||e[25]!==b?(y=i.jsx($s,{id:"seo",icon:Ua,label:"SEO",active:b,onSelect:o}),e[24]=o,e[25]=b,e[26]=y):y=e[26];const L=s==="calendar";let w;e[27]!==o||e[28]!==L?(w=i.jsx($s,{id:"calendar",icon:wm,label:"Calendar",active:L,onSelect:o}),e[27]=o,e[28]=L,e[29]=w):w=e[29];let S;e[30]!==s||e[31]!==n.authors||e[32]!==n.categories||e[33]!==n.posts||e[34]!==o||e[35]!==r?(S=r&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mt-3 flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-medium text-muted-foreground/70",children:[i.jsx(Ki,{size:13,className:"shrink-0"}),"Blog"]}),i.jsx($s,{id:"posts",icon:Wi,label:"Posts",count:n.posts,active:s==="posts",onSelect:o}),i.jsx($s,{id:"authors",icon:W9,label:"Authors",count:n.authors,active:s==="authors",onSelect:o}),i.jsx($s,{id:"categories",icon:om,label:"Categories",count:n.categories,active:s==="categories",onSelect:o})]}),e[30]=s,e[31]=n.authors,e[32]=n.categories,e[33]=n.posts,e[34]=o,e[35]=r,e[36]=S):S=e[36];let j;return e[37]!==x||e[38]!==_||e[39]!==y||e[40]!==w||e[41]!==S||e[42]!==c||e[43]!==h||e[44]!==f||e[45]!==p?(j=i.jsxs("div",{className:"w-[208px] shrink-0 border-r flex flex-col",children:[a,i.jsxs("nav",{className:"flex flex-col p-1.5 gap-0.5",children:[c,h,f,p,x,_,y,w,S]})]}),e[37]=x,e[38]=_,e[39]=y,e[40]=w,e[41]=S,e[42]=c,e[43]=h,e[44]=f,e[45]=p,e[46]=j):j=e[46],j}function $s(t){const e=B.c(18),{id:s,icon:n,label:r,count:o,active:a,onSelect:l}=t;let c;e[0]!==s||e[1]!==l?(c=()=>l(s),e[0]=s,e[1]=l,e[2]=c):c=e[2];const d=a?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground";let h;e[3]!==d?(h=ne("flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors cursor-pointer",d),e[3]=d,e[4]=h):h=e[4];let u;e[5]!==n?(u=i.jsx(n,{size:16,className:"shrink-0"}),e[5]=n,e[6]=u):u=e[6];let f;e[7]!==r?(f=i.jsx("span",{className:"flex-1 truncate",children:r}),e[7]=r,e[8]=f):f=e[8];let m;e[9]!==a||e[10]!==o?(m=o!==void 0&&i.jsx("span",{className:ne("shrink-0 text-xs tabular-nums",a?"text-accent-foreground/70":"text-muted-foreground/70"),children:o}),e[9]=a,e[10]=o,e[11]=m):m=e[11];let p;return e[12]!==c||e[13]!==h||e[14]!==u||e[15]!==f||e[16]!==m?(p=i.jsxs("button",{type:"button",onClick:c,className:h,children:[u,f,m]}),e[12]=c,e[13]=h,e[14]=u,e[15]=f,e[16]=m,e[17]=p):p=e[17],p}function zV(t){const e=B.c(86),{blocksMode:s,activeCollection:n,pages:r,sections:o,availableSections:a,appCatalog:l,appCatalogLoading:c,blogEntries:d,decofile:h,searchQuery:u,onSearchChange:f,postCategoryFilter:m,postAuthorFilter:p,postSort:g,onPostCategoryFilterChange:x,onPostAuthorFilterChange:v,onPostSortChange:_,selectedPostKeys:b,postBulkPanelOpen:y,onTogglePostSelect:L,onSelectAllPosts:w,onClearPostSelection:S,onExitPostSelection:j,onBulkDeletePosts:k,selection:V,onSelect:T,onCollectionSelect:A,onCreate:N,onDuplicatePage:E,onRenamePage:I,onAddPageVariant:P,onDeletePage:R,onEditPageSeo:D,onViewPageJson:M,onDuplicateSection:F,onRenameSection:$,onDeleteSection:O,onDuplicateBlog:U,onDeleteBlog:K}=t;let H,q,J,G,W,z,X,Q;if(e[0]!==n||e[1]!==l||e[2]!==c||e[3]!==a||e[4]!==s||e[5]!==d||e[6]!==h||e[7]!==P||e[8]!==k||e[9]!==S||e[10]!==A||e[11]!==N||e[12]!==K||e[13]!==R||e[14]!==O||e[15]!==U||e[16]!==E||e[17]!==F||e[18]!==D||e[19]!==j||e[20]!==v||e[21]!==x||e[22]!==_||e[23]!==I||e[24]!==$||e[25]!==f||e[26]!==T||e[27]!==w||e[28]!==L||e[29]!==M||e[30]!==r||e[31]!==p||e[32]!==y||e[33]!==m||e[34]!==g||e[35]!==u||e[36]!==o||e[37]!==b||e[38]!==V){const te=u.toLowerCase(),ae=r.filter(he=>!te||he.name.toLowerCase().includes(te)||he.path.toLowerCase().includes(te)),se=o.filter(he=>!te||he.name.toLowerCase().includes(te)||he.key.toLowerCase().includes(te)||he.resolveType.toLowerCase().includes(te)),ie=a.filter(he=>!te||he.title.toLowerCase().includes(te)||he.resolveType.toLowerCase().includes(te)||(he.description?.toLowerCase().includes(te)??!1)),fe=IV(se),me=l.filter(he=>!te||he.title.toLowerCase().includes(te)||he.app.toLowerCase().includes(te)||he.vendor.toLowerCase().includes(te)||he.category.toLowerCase().includes(te)),be=d.filter(he=>!te||he.label.toLowerCase().includes(te)||he.subtitle.toLowerCase().includes(te)),_e=n==="posts",xe=KV,ke=_e?m3(h):[],Ne=new Map,we=new Map;for(const he of ke){for(const Oe of he.categorySlugs)Ne.set(Oe,(Ne.get(Oe)??0)+1);for(const Oe of he.authorEmails)we.set(Oe,(we.get(Oe)??0)+1)}const ye=(_e?bo(h,"categories"):[]).map(he=>{const{key:Oe,payload:et}=he,tt=xe(et.slug)||Oe;return{slug:tt,name:xe(et.name)||xe(et.slug)||Oe,count:Ne.get(tt)??0}}).filter(HV),Be=(_e?bo(h,"authors"):[]).map(he=>{const{key:Oe,payload:et}=he,tt=xe(et.email);return{email:tt,name:xe(et.name)||xe(et.email)||Oe,count:we.get(tt)??0}}).filter(UV);let Fe;e[47]!==m?(Fe=he=>!m||he.categorySlugs.includes(m),e[47]=m,e[48]=Fe):Fe=e[48];let pe;e[49]!==p?(pe=he=>!p||he.authorEmails.includes(p),e[49]=p,e[50]=pe):pe=e[50];let Ee;e[51]!==g?(Ee=(he,Oe)=>{if(g==="az")return he.title.localeCompare(Oe.title);if(g==="za")return Oe.title.localeCompare(he.title);const et=he.date.localeCompare(Oe.date);return g==="date-asc"?et:-et},e[51]=g,e[52]=Ee):Ee=e[52];const De=ke.filter(he=>!te||he.title.toLowerCase().includes(te)||he.slug.toLowerCase().includes(te)).filter(Fe).filter(pe).sort(Ee),ue=b.size,le=De.map(FV),Ve=le.length>0&&le.every(he=>b.has(he)),Me=ue>0||y,Ue=()=>{Ve?S():w(le)},it=`Search ${n}…`,Yt=to(n)?`Create new ${eo[n]}`:"Create new page",Rt=n!=="apps"&&n!=="sections",rt=s?"w-[240px]":"w-[300px]";e[53]!==rt?(W=ne("shrink-0 border-r flex flex-col min-h-0",rt),e[53]=rt,e[54]=W):W=e[54],e[55]!==n||e[56]!==s||e[57]!==A?(z=s&&i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b px-2",children:[i.jsxs(re,{variant:n==="pages"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("pages"),children:[i.jsx(Dn,{size:14}),"Pages"]}),i.jsxs(re,{variant:n==="sections"?"secondary":"ghost",size:"sm",className:"h-7 flex-1",onClick:()=>A("sections"),children:[i.jsx(on,{size:14}),"Sections"]})]}),e[55]=n,e[56]=s,e[57]=A,e[58]=z):z=e[58];let gt;e[59]===Symbol.for("react.memo_cache_sentinel")?(gt=i.jsx(K9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),e[59]=gt):gt=e[59];let lt;e[60]!==f?(lt=he=>f(he.target.value),e[60]=f,e[61]=lt):lt=e[61];let wt;e[62]!==it||e[63]!==u||e[64]!==lt?(wt=i.jsxs("div",{className:"flex flex-1 items-center gap-2 pl-1",children:[gt,i.jsx("input",{type:"text",value:u,onChange:lt,placeholder:it,"aria-label":it,className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),e[62]=it,e[63]=u,e[64]=lt,e[65]=wt):wt=e[65];let ct;e[66]!==Yt||e[67]!==N||e[68]!==Rt?(ct=Rt&&i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:N,"aria-label":Yt,children:i.jsx(Lt,{size:14})})}),i.jsx(Pe,{side:"bottom",children:Yt})]}),e[66]=Yt,e[67]=N,e[68]=Rt,e[69]=ct):ct=e[69],e[70]!==wt||e[71]!==ct?(X=i.jsxs("div",{className:"px-2 h-12 flex items-center gap-1 border-b shrink-0",children:[wt,ct]}),e[70]=wt,e[71]=ct,e[72]=X):X=e[72],Q=_e&&(Me?i.jsx(eN,{count:ue,allSelected:Ve,onToggleSelectAll:Ue,onDelete:k,onExit:j}):i.jsx(qV,{categories:ye,authors:Be,categoryFilter:m,authorFilter:p,sort:g,onCategoryFilterChange:x,onAuthorFilterChange:v,onSortChange:_})),H=Sn,G="flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]>div]:!block",q="flex flex-col gap-1 p-1.5",J=n==="pages"?ae.length===0?i.jsx(Cr,{hasItems:r.length>0,emptyLabel:"No pages yet.",emptyHint:'Click "+" to create your first page.'}):ae.map(he=>{const Oe=V?.collection==="pages"&&V.key===he.key,et=cp(h,he.key);return i.jsx(tn,{icon:Dn,title:he.name,subtitle:he.path,active:Oe,variantCount:et,onClick:()=>T({collection:"pages",key:he.key,path:he.path}),menu:i.jsx(pa,{onDuplicate:()=>E(he),onRename:()=>I(he),onAddVariant:()=>P(he),onEditSeo:()=>D(he),onViewJson:()=>M(he),onDelete:()=>R(he)})},he.key)}):n==="sections"?se.length===0&&ie.length===0?i.jsx(Cr,{hasItems:o.length>0||a.length>0,emptyLabel:"No sections yet.",emptyHint:"Save a section from a page, or start the preview dev server."}):i.jsxs(i.Fragment,{children:[fe.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(ef,{icon:on,label:"Saved sections"}),fe.map(he=>i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("div",{className:"px-2.5 pt-1 pb-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60",children:he.label}),he.sections.map(Oe=>{const et=V?.collection==="sections"&&V.key===Oe.key;return i.jsx(tn,{icon:on,accent:"global",title:Oe.name,subtitle:he.label,active:et,onClick:()=>T({collection:"sections",key:Oe.key}),menu:i.jsx(pa,{onDuplicate:()=>F(Oe),onRename:()=>$(Oe),onDelete:()=>O(Oe)})},Oe.key)})]},he.label))]}),ie.length>0&&i.jsxs(i.Fragment,{children:[i.jsx(ef,{icon:Dn,label:"Available sections",className:ne(fe.length>0&&"mt-3")}),ie.map(he=>{const Oe=V?.collection==="available-section"&&V.resolveType===he.resolveType,et=he.resolveType.split("/").pop()?.replace(/\.tsx?$/,"");return i.jsx(tn,{icon:Dn,title:he.title,subtitle:et??he.resolveType,active:Oe,onClick:()=>T({collection:"available-section",resolveType:he.resolveType,title:he.title})},he.resolveType)})]})]}):n==="apps"?c?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(qe,{size:18,className:"animate-spin text-muted-foreground"})}):me.length===0?i.jsx(Cr,{hasItems:l.length>0,emptyLabel:"No apps found.",emptyHint:"Try a different search term."}):me.map(he=>{const Oe=V?.collection==="apps"&&he.blockKey!==null&&V.key===he.blockKey;return i.jsx(tn,{icon:R1,logoUrl:he.logo,title:he.title,subtitle:he.category,active:Oe,trailing:he.installed?i.jsx("span",{className:"shrink-0 rounded-full bg-emerald-500/15 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:text-emerald-400",children:"Installed"}):void 0,onClick:()=>{if(!he.installed||!he.blockKey){ce.message(`${he.title} is not installed on this site.`);return}T({collection:"apps",key:he.blockKey})}},he.id)}):_e?De.length===0?i.jsx(Cr,{hasItems:ke.length>0,emptyLabel:"No posts yet.",emptyHint:'Click "+" to create your first post.'}):De.map(he=>{const Oe={key:he.key,kind:"posts",label:he.title,subtitle:he.slug};return i.jsx(tn,{icon:Wi,title:he.title,subtitle:he.slug,active:V?.collection==="posts"&&V.key===he.key,selectable:!0,selectionActive:Me,selected:b.has(he.key),onToggleSelect:()=>L(he.key),onClick:()=>Me?L(he.key):T({collection:"posts",key:he.key}),menu:i.jsx(pa,{onDuplicate:()=>U(Oe),onDelete:()=>K(Oe)})},he.key)}):be.length===0?i.jsx(Cr,{hasItems:d.length>0,emptyLabel:`No ${n} yet.`,emptyHint:`Click "+" to create your first ${to(n)?eo[n]:"item"}.`}):be.map(he=>{const Oe=V?.collection===he.kind&&V.key===he.key;return i.jsx(tn,{icon:he.kind==="posts"?Wi:he.kind==="authors"?W9:om,title:he.label,subtitle:he.subtitle,active:Oe,onClick:()=>T({collection:he.kind,key:he.key}),menu:i.jsx(pa,{onDuplicate:()=>U(he),onDelete:()=>K(he)})},he.key)}),e[0]=n,e[1]=l,e[2]=c,e[3]=a,e[4]=s,e[5]=d,e[6]=h,e[7]=P,e[8]=k,e[9]=S,e[10]=A,e[11]=N,e[12]=K,e[13]=R,e[14]=O,e[15]=U,e[16]=E,e[17]=F,e[18]=D,e[19]=j,e[20]=v,e[21]=x,e[22]=_,e[23]=I,e[24]=$,e[25]=f,e[26]=T,e[27]=w,e[28]=L,e[29]=M,e[30]=r,e[31]=p,e[32]=y,e[33]=m,e[34]=g,e[35]=u,e[36]=o,e[37]=b,e[38]=V,e[39]=H,e[40]=q,e[41]=J,e[42]=G,e[43]=W,e[44]=z,e[45]=X,e[46]=Q}else H=e[39],q=e[40],J=e[41],G=e[42],W=e[43],z=e[44],X=e[45],Q=e[46];let Z;e[73]!==q||e[74]!==J?(Z=i.jsx("div",{className:q,children:J}),e[73]=q,e[74]=J,e[75]=Z):Z=e[75];let Y;e[76]!==H||e[77]!==G||e[78]!==Z?(Y=i.jsx(H,{className:G,children:Z}),e[76]=H,e[77]=G,e[78]=Z,e[79]=Y):Y=e[79];let ee;return e[80]!==W||e[81]!==z||e[82]!==X||e[83]!==Q||e[84]!==Y?(ee=i.jsxs("div",{className:W,children:[z,X,Q,Y]}),e[80]=W,e[81]=z,e[82]=X,e[83]=Q,e[84]=Y,e[85]=ee):ee=e[85],ee}function FV(t){return t.key}function UV(t){return t.email}function HV(t){return t.slug}function KV(t){return typeof t=="string"?t:""}const tf="__all__",C3={"date-desc":"Newest first","date-asc":"Oldest first",az:"Title A–Z",za:"Title Z–A"},WV={"date-desc":"Newest","date-asc":"Oldest",az:"A–Z",za:"Z–A"},sf=C.forwardRef(function(e,s){const n=B.c(20);let r,o,a,l,c;n[0]!==e?({icon:r,active:o,value:c,className:a,...l}=e,n[0]=e,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=c):(r=n[1],o=n[2],a=n[3],l=n[4],c=n[5]);const d=o?"text-foreground":"text-muted-foreground";let h;n[6]!==a||n[7]!==d?(h=ne("h-7 gap-1 px-1.5 text-xs",d,a),n[6]=a,n[7]=d,n[8]=h):h=n[8];let u;n[9]!==r?(u=i.jsx(r,{size:14,className:"shrink-0"}),n[9]=r,n[10]=u):u=n[10];let f;n[11]!==c?(f=c&&i.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),n[11]=c,n[12]=f):f=n[12];let m;n[13]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Ht,{size:12,className:"shrink-0 opacity-60"}),n[13]=m):m=n[13];let p;return n[14]!==l||n[15]!==s||n[16]!==h||n[17]!==u||n[18]!==f?(p=i.jsxs(re,{ref:s,type:"button",variant:"ghost",size:"sm",className:h,...l,children:[u,f,m]}),n[14]=l,n[15]=s,n[16]=h,n[17]=u,n[18]=f,n[19]=p):p=n[19],p});function k3(t){const e=B.c(2),{count:s}=t;let n;return e[0]!==s?(n=i.jsx("span",{className:"ml-auto pl-3 text-xs text-muted-foreground tabular-nums",children:s}),e[0]=s,e[1]=n):n=e[1],n}function qV(t){const e=B.c(60),{categories:s,authors:n,categoryFilter:r,authorFilter:o,sort:a,onCategoryFilterChange:l,onAuthorFilterChange:c,onSortChange:d}=t;let h;if(e[0]!==s||e[1]!==r){let K;e[3]!==r?(K=H=>H.slug===r,e[3]=r,e[4]=K):K=e[4],h=s.find(K),e[0]=s,e[1]=r,e[2]=h}else h=e[2];const u=h;let f;if(e[5]!==o||e[6]!==n){let K;e[8]!==o?(K=H=>H.email===o,e[8]=o,e[9]=K):K=e[9],f=n.find(K),e[5]=o,e[6]=n,e[7]=f}else f=e[7];const m=f,p=!!(r||o),g=u?.name??m?.name??"Filter",x=r?`cat:${r}`:o?`author:${o}`:tf;let v;e[10]!==c||e[11]!==l?(v=()=>{l(null),c(null)},e[10]=c,e[11]=l,e[12]=v):v=e[12];const _=v;let b;e[13]!==_||e[14]!==c||e[15]!==l?(b=K=>{K.startsWith("cat:")?(c(null),l(K.slice(4))):K.startsWith("author:")?(l(null),c(K.slice(7))):_()},e[13]=_,e[14]=c,e[15]=l,e[16]=b):b=e[16];const y=b;let L;e[17]!==g||e[18]!==p?(L=i.jsx(es,{asChild:!0,children:i.jsx(sf,{icon:ux,active:p,value:g,className:"min-w-0 shrink"})}),e[17]=g,e[18]=p,e[19]=L):L=e[19];let w;e[20]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(Ir,{children:"Filter by"}),e[20]=w):w=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(Io,{value:tf,children:"All posts"}),e[21]=S):S=e[21];let j;e[22]!==s.length?(j=s.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Category"}),e[22]=s.length,e[23]=j):j=e[23];let k;e[24]!==s?(k=s.map(JV),e[24]=s,e[25]=k):k=e[25];let V;e[26]!==n.length?(V=n.length>0&&i.jsx(Ir,{className:"text-muted-foreground/70",children:"Author"}),e[26]=n.length,e[27]=V):V=e[27];let T;e[28]!==n?(T=n.map(YV),e[28]=n,e[29]=T):T=e[29];let A;e[30]!==x||e[31]!==y||e[32]!==V||e[33]!==T||e[34]!==j||e[35]!==k?(A=i.jsxs(ts,{align:"start",className:"max-h-96 w-60 overflow-y-auto",children:[w,i.jsxs(h0,{value:x,onValueChange:y,children:[S,j,k,V,T]})]}),e[30]=x,e[31]=y,e[32]=V,e[33]=T,e[34]=j,e[35]=k,e[36]=A):A=e[36];let N;e[37]!==A||e[38]!==L?(N=i.jsxs(Zt,{children:[L,A]}),e[37]=A,e[38]=L,e[39]=N):N=e[39];let E;e[40]!==_||e[41]!==p?(E=p&&i.jsx(XV,{label:"Clear filter",onClick:_}),e[40]=_,e[41]=p,e[42]=E):E=e[42];const I=WV[a];let P;e[43]!==I?(P=i.jsx(es,{asChild:!0,children:i.jsx(sf,{icon:hx,active:!0,value:I})}),e[43]=I,e[44]=P):P=e[44];let R;e[45]===Symbol.for("react.memo_cache_sentinel")?(R=i.jsx(Ir,{children:"Sort by"}),e[45]=R):R=e[45];let D;e[46]!==d?(D=K=>d(K),e[46]=d,e[47]=D):D=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=Object.keys(C3),e[48]=M):M=e[48];let F;e[49]===Symbol.for("react.memo_cache_sentinel")?(F=M.map(GV),e[49]=F):F=e[49];let $;e[50]!==a||e[51]!==D?($=i.jsxs(ts,{align:"end",className:"w-44",children:[R,i.jsx(h0,{value:a,onValueChange:D,children:F})]}),e[50]=a,e[51]=D,e[52]=$):$=e[52];let O;e[53]!==P||e[54]!==$?(O=i.jsx("div",{className:"ml-auto shrink-0",children:i.jsxs(Zt,{children:[P,$]})}),e[53]=P,e[54]=$,e[55]=O):O=e[55];let U;return e[56]!==N||e[57]!==E||e[58]!==O?(U=i.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden border-b px-2 py-1.5",children:[N,E,O]}),e[56]=N,e[57]=E,e[58]=O,e[59]=U):U=e[59],U}function GV(t){return i.jsx(Io,{value:t,children:C3[t]},t)}function YV(t){return i.jsxs(Io,{value:`author:${t.email}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(k3,{count:t.count})]},`author:${t.email}`)}function JV(t){return i.jsxs(Io,{value:`cat:${t.slug}`,children:[i.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.name}),i.jsx(k3,{count:t.count})]},`cat:${t.slug}`)}function XV(t){const e=B.c(4),{label:s,onClick:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=i.jsx(ms,{size:12}),e[0]=r):r=e[0];let o;return e[1]!==s||e[2]!==n?(o=i.jsx("button",{type:"button","aria-label":s,onClick:n,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground cursor-pointer",children:r}),e[1]=s,e[2]=n,e[3]=o):o=e[3],o}function QV(t){const e=B.c(12),{checked:s,disabled:n,onToggle:r}=t;let o;e[0]!==r?(o=()=>r(),e[0]=r,e[1]=o):o=e[1];const a=s?"Deselect all posts":"Select all posts";let l;e[2]!==s||e[3]!==n||e[4]!==o||e[5]!==a?(l=i.jsx(Re,{asChild:!0,children:i.jsx("span",{className:"flex shrink-0 items-center px-1.5",onClick:ZV,children:i.jsx(cr,{checked:s,disabled:n,onCheckedChange:o,"aria-label":a})})}),e[2]=s,e[3]=n,e[4]=o,e[5]=a,e[6]=l):l=e[6];const c=s?"Deselect all":"Select all";let d;e[7]!==c?(d=i.jsx(Pe,{side:"bottom",children:c}),e[7]=c,e[8]=d):d=e[8];let h;return e[9]!==l||e[10]!==d?(h=i.jsxs(Ie,{children:[l,d]}),e[9]=l,e[10]=d,e[11]=h):h=e[11],h}function ZV(t){return t.stopPropagation()}function eN(t){const e=B.c(25),{count:s,allSelected:n,onToggleSelectAll:r,onDelete:o,onExit:a}=t;let l;e[0]!==n||e[1]!==r?(l=i.jsx(QV,{checked:n,onToggle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;e[3]!==s?(c=i.jsxs("span",{className:"text-xs font-medium tabular-nums",children:[s," selected"]}),e[3]=s,e[4]=c):c=e[4];const d=s===0;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(ws,{size:14}),e[5]=h):h=e[5];let u;e[6]!==o||e[7]!==d?(u=i.jsx(Re,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",disabled:d,onClick:o,"aria-label":"Delete selected posts",children:h})}),e[6]=o,e[7]=d,e[8]=u):u=e[8];let f;e[9]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{side:"bottom",children:"Delete selected"}),e[9]=f):f=e[9];let m;e[10]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[10]=u,e[11]=m):m=e[11];let p;e[12]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(ms,{size:14}),e[12]=p):p=e[12];let g;e[13]!==a?(g=i.jsx(Re,{asChild:!0,children:i.jsx(re,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:a,"aria-label":"Exit selection",children:p})}),e[13]=a,e[14]=g):g=e[14];let x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Exit selection"}),e[15]=x):x=e[15];let v;e[16]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[16]=g,e[17]=v):v=e[17];let _;e[18]!==v||e[19]!==m?(_=i.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m,v]}),e[18]=v,e[19]=m,e[20]=_):_=e[20];let b;return e[21]!==l||e[22]!==_||e[23]!==c?(b=i.jsxs("div",{className:"flex items-center gap-0.5 border-b bg-accent/40 px-2 py-1.5",children:[l,c,_]}),e[21]=l,e[22]=_,e[23]=c,e[24]=b):b=e[24],b}function tn(t){const e=B.c(37),{icon:s,logoUrl:n,title:r,subtitle:o,active:a,accent:l,variantCount:c,trailing:d,selectable:h,selectionActive:u,selected:f,onToggleSelect:m,onClick:p,menu:g}=t,x=l==="global";let v;e[0]!==s||e[1]!==a||e[2]!==x||e[3]!==n||e[4]!==c?(v=c&&c>1?i.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(s,{size:16,className:"shrink-0",style:{color:N0}})}),i.jsxs(Pe,{side:"right",children:[c," variants"]})]})}):n?i.jsx("img",{src:n,alt:"",className:"size-8 shrink-0 rounded-lg object-cover bg-muted"}):i.jsx("span",{className:ne("flex size-8 shrink-0 items-center justify-center rounded-lg",x?"bg-global-section/15":"bg-muted"),children:i.jsx(s,{size:16,className:ne("shrink-0",!x&&(a?"text-accent-foreground":"text-muted-foreground")),style:x?{color:ad}:void 0})}),e[0]=s,e[1]=a,e[2]=x,e[3]=n,e[4]=c,e[5]=v):v=e[5];const _=v,b=a?x?"bg-global-section/15 text-global-section-fg dark:text-global-section-fg-dark":"bg-accent text-accent-foreground":x?"hover:bg-global-section/10":"hover:bg-muted";let y;e[6]!==b?(y=ne("group relative flex min-w-0 items-center rounded-md transition-colors",b),e[6]=b,e[7]=y):y=e[7];let L;e[8]!==m||e[9]!==h||e[10]!==f||e[11]!==u||e[12]!==r?(L=h&&i.jsx("span",{className:ne("flex shrink-0 items-center pl-2.5 transition-opacity",f||u?"opacity-100":"opacity-0 group-hover:opacity-100 focus-within:opacity-100"),onClick:tN,children:i.jsx(cr,{checked:f,onCheckedChange:()=>m?.(),"aria-label":`Select ${r}`})}),e[8]=m,e[9]=h,e[10]=f,e[11]=u,e[12]=r,e[13]=L):L=e[13];let w;e[14]!==r?(w=i.jsx("span",{className:"block truncate text-sm font-medium",children:r}),e[14]=r,e[15]=w):w=e[15];const S=a?"text-accent-foreground/70":"text-muted-foreground";let j;e[16]!==S?(j=ne("block truncate text-xs",S),e[16]=S,e[17]=j):j=e[17];let k;e[18]!==o||e[19]!==j?(k=i.jsx("span",{className:j,children:o}),e[18]=o,e[19]=j,e[20]=k):k=e[20];let V;e[21]!==w||e[22]!==k?(V=i.jsxs("span",{className:"min-w-0 flex-1",children:[w,k]}),e[21]=w,e[22]=k,e[23]=V):V=e[23];let T;e[24]!==p||e[25]!==_||e[26]!==V||e[27]!==d?(T=i.jsxs("button",{type:"button",onClick:p,className:"flex min-w-0 flex-1 items-center gap-2.5 rounded-md px-2.5 py-2 text-left cursor-pointer",children:[_,V,d]}),e[24]=p,e[25]=_,e[26]=V,e[27]=d,e[28]=T):T=e[28];let A;e[29]!==a||e[30]!==g?(A=g&&i.jsx("div",{className:ne("pr-1 opacity-0 transition-opacity group-hover:opacity-100",a&&"opacity-100"),children:g}),e[29]=a,e[30]=g,e[31]=A):A=e[31];let N;return e[32]!==T||e[33]!==A||e[34]!==y||e[35]!==L?(N=i.jsxs("div",{className:y,children:[L,T,A]}),e[32]=T,e[33]=A,e[34]=y,e[35]=L,e[36]=N):N=e[36],N}function tN(t){return t.stopPropagation()}function pa(t){const e=B.c(21),{onDuplicate:s,onRename:n,onAddVariant:r,onEditSeo:o,onViewJson:a,onDelete:l}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(es,{asChild:!0,children:i.jsx("button",{type:"button","aria-label":"More actions",className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-background hover:text-foreground cursor-pointer",onClick:sN,children:i.jsx(Gn,{size:14})})}),e[0]=c):c=e[0];let d;e[1]!==n?(d=n&&i.jsxs(He,{onClick:n,children:[i.jsx(A9,{size:14}),"Rename"]}),e[1]=n,e[2]=d):d=e[2];let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(Ss,{size:14}),e[3]=h):h=e[3];let u;e[4]!==s?(u=i.jsxs(He,{onClick:s,children:[h,"Duplicate"]}),e[4]=s,e[5]=u):u=e[5];let f;e[6]!==r?(f=r&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:r,className:"cursor-pointer",style:{color:N0},children:[i.jsx(jm,{size:14,style:{color:N0}}),"Add variant"]})]}),e[6]=r,e[7]=f):f=e[7];let m;e[8]!==o||e[9]!==a?(m=(o||a)&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),o&&i.jsxs(He,{onClick:o,children:[i.jsx(Ua,{size:14}),"Edit SEO"]}),a&&i.jsxs(He,{onClick:a,children:[i.jsx(To,{size:14}),"View JSON"]})]}),e[8]=o,e[9]=a,e[10]=m):m=e[10];let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Di,{}),e[11]=p):p=e[11];let g;e[12]===Symbol.for("react.memo_cache_sentinel")?(g=i.jsx(ws,{size:14}),e[12]=g):g=e[12];let x;e[13]!==l?(x=i.jsxs(He,{onClick:l,className:"text-destructive focus:text-destructive",children:[g,"Delete"]}),e[13]=l,e[14]=x):x=e[14];let v;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==x?(v=i.jsxs(Zt,{children:[c,i.jsxs(ts,{align:"end",className:"w-44",children:[d,u,f,m,p,x]})]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=x,e[20]=v):v=e[20],v}function sN(t){return t.stopPropagation()}function Cr(t){const e=B.c(6),{hasItems:s,emptyLabel:n,emptyHint:r}=t;let o;e[0]!==r||e[1]!==n||e[2]!==s?(o=s?"No results match your search.":i.jsxs(i.Fragment,{children:[i.jsx("div",{children:n}),i.jsx("div",{className:"mt-1 text-muted-foreground/80",children:r})]}),e[0]=r,e[1]=n,e[2]=s,e[3]=o):o=e[3];let a;return e[4]!==o?(a=i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=a):a=e[5],a}function nN(t){const e=B.c(12),{state:s,claimPhase:n,lifecycle:r,onStart:o,connectionsHref:a}=t;switch(s.kind){case"starting":{let l;e[0]!==n||e[1]!==r?(l=o3({claimPhase:n,lifecycle:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2];let c;return e[3]!==n||e[4]!==l?(c=i.jsx(Bi,{kind:"starting",progress:l,claimPhase:n}),e[3]=n,e[4]=l,e[5]=c):c=e[5],c}case"suspended":{let l;return e[6]!==o?(l=i.jsx(Bi,{kind:"suspended",onResume:o}),e[6]=o,e[7]=l):l=e[7],l}case"errored":{let l;return e[8]!==a||e[9]!==o||e[10]!==s.error?(l=i.jsx(Bi,{kind:"errored",error:s.error,onRetry:o,connectionsHref:a}),e[8]=a,e[9]=o,e[10]=s.error,e[11]=l):l=e[11],l}}}function Mn(t){const e=B.c(10),{icon:s,title:n,description:r}=t;let o;e[0]!==s?(o=s&&i.jsx(s,{size:24,className:"text-muted-foreground/60"}),e[0]=s,e[1]=o):o=e[1];let a;e[2]!==n?(a=i.jsx("div",{children:n}),e[2]=n,e[3]=a):a=e[3];let l;e[4]!==r?(l=r&&i.jsx("div",{className:"text-xs text-muted-foreground/80 max-w-sm",children:r}),e[4]=r,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==a||e[8]!==l?(c=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 p-6 text-center text-sm text-muted-foreground",children:[o,a,l]}),e[6]=o,e[7]=a,e[8]=l,e[9]=c):c=e[9],c}const iN=new Set(["clone-failed","install-failed","start-failed","crashed"]);function rN(t){return iN.has(t.lifecyclePhase)?{kind:"error",source:"sandbox"}:t.lifecyclePhase!=="running"?{kind:"loading"}:t.decofile.status==="error"&&!t.decofile.hasData||t.meta.status==="error"&&!t.meta.hasData?{kind:"error",source:"data"}:!t.decofile.hasData||!t.meta.hasData?{kind:"loading"}:t.hasEditableContent?{kind:"content"}:{kind:"empty"}}const oN="https://github.com/decocms/blocks";function aN(){const t=B.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx(fx,{size:48,className:"text-muted-foreground"}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsx(qi,{image:e,title:"No editable Blocks found",description:"This project does not expose editable Blocks content yet. Learn how to add Blocks to your project.",actions:i.jsx(re,{variant:"outline",size:"sm",asChild:!0,children:i.jsxs("a",{href:oN,target:"_blank",rel:"noreferrer",children:["View Blocks docs",i.jsx(wn,{size:14})]})})}),t[1]=s):s=t[1],s}function lN(t){const e=B.c(6),{source:s,onRetry:n}=t,r=s==="sandbox"?"The project preview could not start. Retry to make Blocks available.":"Studio could not load this project's Blocks metadata.";let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(fn,{size:48,className:"text-muted-foreground"}),e[0]=o):o=e[0];let a;e[1]!==n?(a=i.jsx(re,{variant:"outline",size:"sm",onClick:n,children:"Retry"}),e[1]=n,e[2]=a):a=e[2];let l;return e[3]!==r||e[4]!==a?(l=i.jsx(qi,{image:o,title:"Blocks unavailable",description:r,actions:a}),e[3]=r,e[4]=a,e[5]=l):l=e[5],l}function pi(){const t=B.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{"data-testid":"main-panel-loading",className:"flex h-full w-full items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),t[0]=e):e=t[0],e}function V3(t){const e=B.c(28),{virtualMcpId:s}=t,{org:n}=Ae(),{currentBranch:r}=as(),o=Os(),a=dr(),l=o.lifecycle.phase==="running";let c;e[0]!==r||e[1]!==l||e[2]!==a||e[3]!==n||e[4]!==s?(c=r&&l?{orgSlug:n.slug,virtualMcpId:s,branch:r,previewUrl:a.previewUrl}:null,e[0]=r,e[1]=l,e[2]=a,e[3]=n,e[4]=s,e[5]=c):c=e[5];const d=c;let h;e[6]!==l?(h={fetchEnabled:l},e[6]=l,e[7]=h):h=e[7];const u=Bl(d,h);let f;e[8]!==l?(f={fetchEnabled:l},e[8]=l,e[9]=f):f=e[9];const m=zl(d,f),p=u.data!==void 0;let g;e[10]!==u.data||e[11]!==u.status||e[12]!==m.data||e[13]!==m.status||e[14]!==o.lifecycle.phase||e[15]!==p?(g=rN({lifecyclePhase:o.lifecycle.phase,decofile:{status:u.status,hasData:p},meta:{status:m.status,hasData:m.data!==void 0},hasEditableContent:fd(u.data,m.data)}),e[10]=u.data,e[11]=u.status,e[12]=m.data,e[13]=m.status,e[14]=o.lifecycle.phase,e[15]=p,e[16]=g):g=e[16];const x=g;if(x.kind==="loading"){let _;return e[17]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(pi,{}),e[17]=_):_=e[17],_}if(x.kind==="empty"){let _;return e[18]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(aN,{}),e[18]=_):_=e[18],_}if(x.kind==="error"){let _;e[19]!==u||e[20]!==a||e[21]!==m||e[22]!==x.source?(_=()=>{if(x.source==="sandbox"){a.retry();return}Promise.all([u.refetch(),m.refetch()])},e[19]=u,e[20]=a,e[21]=m,e[22]=x.source,e[23]=_):_=e[23];const b=_;let y;return e[24]!==b||e[25]!==x.source?(y=i.jsx(lN,{source:x.source,onRetry:b}),e[24]=b,e[25]=x.source,e[26]=y):y=e[26],y}let v;return e[27]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx("div",{"data-testid":"blocks-panel",className:"h-full min-h-0 overflow-hidden",children:i.jsx(j3,{mode:"blocks"})}),e[27]=v):v=e[27],v}const cN=40;function N3(t,e=cN){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function dN(t){return N3(t)}function uN(){const t=B.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=v9.blocksPanelWidth(),t[0]=e):e=t[0];const[s,n]=N1(e,dN);let r;t[1]!==s?(r=N3(s),t[1]=s,t[2]=r):r=t[2];let o;return t[3]!==n||t[4]!==r?(o=[r,n],t[3]=n,t[4]=r,t[5]=o):o=t[5],o}const Ud=33;function A3(t,e=Ud){const s=typeof t=="number"?t:Number(t);return!Number.isFinite(s)||s<=0||s>=100?e:s}function hN(t){return A3(t,Ud)}function fN(){const t=B.c(6);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=v9.decoChatPanelWidth(),t[0]=e):e=t[0];const[s,n]=N1(e,hN);let r;t[1]!==s?(r=A3(s,Ud),t[1]=s,t[2]=r):r=t[2];const o=r;let a;return t[3]!==n||t[4]!==o?(a=[o,n],t[3]=n,t[4]=o,t[5]=a):a=t[5],a}function mN(t){try{return JSON.parse(t)}catch{return null}}function pN(t){if(!t||typeof t!="object")return null;const e=t,s=e.content?.find(o=>o.type==="text")?.text,n=s?mN(s):null,r=e.structuredContent;return r==null?n:typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0?n??r:r}function ji(t){const e=pN(t);return e===null?null:e}function Hd(t){if(!t)return null;const e=t.match(/\/pull\/(\d+)\b/);if(!e)return null;const s=Number(e[1]);return Number.isFinite(s)&&s>0?s:null}function gN(t){if(!t||typeof t!="object")return null;const e=t.content?.find(r=>r.type==="text")?.text;if(!e)return null;const s=e.match(/https:\/\/github\.com\/[^\s"]+\/pull\/\d+/)?.[0],n=Hd(s);return!n||!s?null:{number:n,htmlUrl:s}}const nf=/[\r\n<>]/,xN=/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;function Wo(t){const e=t?.userName?.trim();if(!e||nf.test(e))return null;const s=t?.userEmail?.trim();return!s||nf.test(s)?{userName:e}:xN.test(s)?{userName:e,userEmail:s}:{userName:e}}function vN(t){return t.split(`
25
25
  `).filter(e=>!/^Co-authored-by:\s/i.test(e)).join(`
26
26
  `).trimEnd()}function _N(t){const e=t.userName.trim(),s=t.userEmail?.trim();return s?`Co-authored-by: ${e} <${s}>`:`Co-authored-by: ${e}`}function T3(t,e){const s=Wo(e);if(!s)return t;const n=vN(t),r=_N(s);if(n.includes(r))return n;const o=n.trimEnd();return o.length>0?`${o}
27
27
 
@@ -178,7 +178,7 @@ ${X}`:X;d.setValue("metadata.instructions",Q,{shouldDirty:!0})},H=new Set(h.map(
178
178
  }
179
179
  });
180
180
  })();`;function Vi(t){return t.replace(/[`*_]/g,"\\$&")}function lP(t,e){const s=[`The user selected an element on the live preview and asked: **"${Vi(e.trim())}"**`,"","For text content changes, locate the correct source file and apply the change.","For code and CSS changes, understand which component the user is referring to and apply changes to the correct component.",""];t.manifestKey&&s.push(`**Section resolveType:** \`${Vi(t.manifestKey)}\``,"","This is a Deco resolveType, not a literal file path. The leading segment is the app name, not a directory — the actual source file lives under a sections directory whose root varies by site (commonly `sections/`, `src/sections/`, or `site/sections/`). Locate the file by searching for the trailing path (e.g. the component filename), don't assume the resolveType is a valid path on disk.","");const n=`<${t.tag}${t.classes?` class="${Vi(t.classes)}"`:""}>`;s.push(`**Clicked element:** \`${n}\``),t.parents&&s.push(`**DOM breadcrumb:** ${Vi(t.parents)} > ${t.tag}`),t.text&&s.push(`**Text content:** "${Vi(t.text)}"`),t.componentName&&s.push(`**Component name:** ${Vi(t.componentName)}`);const r=t.html.replace(/```/g,"`` `");return s.push("","**HTML snippet:**","```html",r,"```"),s.push("","Please read the source file, locate the element, and apply the requested change."),s.join(`
181
- `)}function cP(t,e,s=320,n=44,r=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/c>.68?Math.max(r,a-n-18):Math.min(a+18,c-n-r);return{leftPct:d/l*100,topPct:u/c*100}}function dP(t){const e=B.c(32),{element:s,onDismiss:n}=t,[r,o]=C.useState(""),a=C.useRef(null),{sendMessage:l}=js(),{setChatOpen:c}=No();let d;e[0]!==s||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==c?(d=()=>{if(!r.trim())return;const V=lP(s,r);c(!0),l({parts:[{type:"text",text:V}]}),n()},e[0]=s,e[1]=r,e[2]=n,e[3]=l,e[4]=c,e[5]=d):d=e[5];const h=d;let u;e[6]!==s.position||e[7]!==s.viewport?(u=cP(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let x;e[12]!==h?(x=V=>{V.preventDefault(),h()},e[12]=h,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=V=>o(V.target.value),e[14]=v):v=e[14];let _;e[15]!==n?(_=V=>{V.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let b;e[17]!==r||e[18]!==_?(b=i.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:_,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==r?(y=r.trim(),e[20]=r,e[21]=y):y=e[21];const L=!y;let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[i.jsx("title",{children:"Send"}),i.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=w):w=e[22];let S;e[23]!==L?(S=i.jsx("button",{type:"submit",disabled:L,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:w}),e[23]=L,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==x||e[27]!==b?(j=i.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:x,children:[b,S]}),e[25]=S,e[26]=x,e[27]=b,e[28]=j):j=e[28];let k;return e[29]!==j||e[30]!==g?(k=i.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:j}),e[29]=j,e[30]=g,e[31]=k):k=e[31],k}function uP(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function hP(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[r,o]of Object.entries(e.params))typeof o=="string"&&(n[r]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function fP(t){try{return hP(localStorage.getItem(t))}catch{return null}}function mP(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function _l(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(r=>encodeURIComponent(r).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const Ta={product:"vtex/loaders/intelligentSearch/productList.ts",category:"vtex/loaders/categories/tree.ts"};function pP(t,e){const s=_0(ai(t));if(e==="*")return s.some(o=>o.type==="param"&&o.name==="*")?"category":null;const n=s[s.length-1],r=s[s.length-2];return n?.type==="text"&&n.text==="/p"&&r?.type==="param"&&r.name===e?"product":null}function gP(t,e){if(t==="category")return[{resolveType:Ta.category,props:{}}];const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:Ta.product,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:Ta.product,props:{query:o,count:10}}),n}function xP(t){const e=new Set,s=[];for(const n of t)for(const r of n)e.has(r.value)||(e.add(r.value),s.push(r));return s}function Ea(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Sg(t){try{return decodeURIComponent(t)}catch{return t}}function vP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.match(/^\/([^/]+)\/p\/?$/)?.[1];return s?Sg(s):null}function _P(t){if(!Array.isArray(t))return[];const e=[],s=new Set;for(const n of t){const r=Ea(n);if(!r)continue;const o=vP(r.url);if(!o||s.has(o))continue;s.add(o);const a=Ea(r.isVariantOf),l=typeof a?.name=="string"&&a.name||typeof r.name=="string"&&r.name||o,c=Array.isArray(r.image)?Ea(r.image[0]):null,d=typeof c?.url=="string"?c.url:void 0;e.push({value:o,label:l,image:d})}return e}function bP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?Sg(s):null}function yP(t){const e=[],s=new Set,n=(r,o)=>{const a=Ea(r);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=bP(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const r of t)n(r,[]);return e}function LP(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const SP=1e4;async function wP(t,{resolveType:e,props:s}){const n=await fetch(L3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(SP)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function jP(t,e,s){const n=gP(e,s),r=await Promise.allSettled(n.map(a=>wP(t,a))),o=r.filter(a=>a.status==="fulfilled").map(a=>a.value);if(o.length===0){const a=r.find(l=>l.status==="rejected");throw a?a.reason:new Error("Failed to fetch options")}return xP(o.map(a=>e==="product"?_P(a):yP(a)))}function CP(t){const e=B.c(78),{kind:s,paramName:n,value:r,sandboxRef:o,onCommit:a}=t,[l,c]=C.useState(!1),[d,h]=C.useState(""),[u,f]=C.useState(""),m=C.useRef(null),p=s==="product"?"product":"category",g=n==="*"?"*":`:${n}`;let x;e[0]!==r?(x=ee=>{c(ee),m.current&&clearTimeout(m.current),h(ee?r:""),f(ee?r:"")},e[0]=r,e[1]=x):x=e[1];const v=x;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=ee=>{h(ee),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(ee)},300)},e[2]=_):_=e[2];const b=_;let y;e[3]!==v||e[4]!==a?(y=ee=>{a(ee),v(!1)},e[3]=v,e[4]=a,e[5]=y):y=e[5];const L=y;let w;e[6]!==u||e[7]!==s||e[8]!==o.branch||e[9]!==o.orgSlug||e[10]!==o.virtualMcpId?(w=Qe.sandboxInvoke(`${o.orgSlug}/${o.virtualMcpId}/${o.branch}`,`path-param-${s}:${s==="product"?u:""}`),e[6]=u,e[7]=s,e[8]=o.branch,e[9]=o.orgSlug,e[10]=o.virtualMcpId,e[11]=w):w=e[11];let S;e[12]!==u||e[13]!==s||e[14]!==o?(S=()=>jP(o,s,u),e[12]=u,e[13]=s,e[14]=o,e[15]=S):S=e[15];let j;e[16]!==l||e[17]!==w||e[18]!==S?(j={queryKey:w,queryFn:S,enabled:l,staleTime:6e4,retry:1},e[16]=l,e[17]=w,e[18]=S,e[19]=j):j=e[19];const k=gs(j);let V;e[20]!==s||e[21]!==k.data||e[22]!==d?(V=s==="product"?k.data??[]:LP(k.data??[],d),e[20]=s,e[21]=k.data,e[22]=d,e[23]=V):V=e[23];const T=V;let A;e[24]!==d?(A=d.trim(),e[24]=d,e[25]=A):A=e[25];const N=A,E=s==="product"?`/${N}/p`:`/${N}`,I=`Value for ${g} — click to pick a ${p}`;let P;e[26]!==v?(P=ee=>{ee.stopPropagation(),v(!0)},e[26]=v,e[27]=P):P=e[27];const R=r||g;let D;e[28]!==P||e[29]!==R||e[30]!==I?(D=i.jsx("button",{type:"button",title:I,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:P,children:R}),e[28]=P,e[29]=R,e[30]=I,e[31]=D):D=e[31];let M;e[32]!==p||e[33]!==g?(M=i.jsx(ns,{className:"sr-only",children:i.jsxs(is,{children:["Pick a ",p," or enter a value for ",g]})}),e[32]=p,e[33]=g,e[34]=M):M=e[34];let F;e[35]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(c0,{size:16,className:"shrink-0 text-foreground"}),e[35]=F):F=e[35];let $;e[36]!==g?($=i.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:g}),e[36]=g,e[37]=$):$=e[37];let O;e[38]!==p||e[39]!==$?(O=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[F,i.jsxs("span",{className:"text-sm font-medium text-foreground",children:["Pick a ",p," for"," ",$]})]}),e[38]=p,e[39]=$,e[40]=O):O=e[40];const U=s==="product"?"Search products or enter a slug...":"Search categories or enter a path...";let K;e[41]!==d||e[42]!==U?(K=i.jsx(yi,{autoFocus:!0,placeholder:U,value:d,onValueChange:b}),e[41]=d,e[42]=U,e[43]=K):K=e[43];const H=k.isLoading?"Loading...":k.isError?"Couldn't load — is the dev server running?":"No results.";let q;e[44]!==H?(q=i.jsx(Li,{children:H}),e[44]=H,e[45]=q):q=e[45];let J;e[46]!==L||e[47]!==g||e[48]!==E||e[49]!==N?(J=N&&i.jsx(Fs,{children:i.jsxs(Ps,{value:`__raw__:${N}`,className:"gap-3 py-2",onSelect:()=>L(N),children:[i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:i.jsx(Eo,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsxs("span",{className:"block truncate text-sm",children:["Use “",N,"” as ",g]}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:E})]})]})}),e[46]=L,e[47]=g,e[48]=E,e[49]=N,e[50]=J):J=e[50];let G;if(e[51]!==L||e[52]!==s||e[53]!==T){let ee;e[55]!==L||e[56]!==s?(ee=te=>i.jsxs(Ps,{value:te.value,className:"gap-3 py-2",onSelect:()=>L(te.value),children:[s==="product"&&i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:te.image?i.jsx("img",{src:te.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):i.jsx(c0,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm",children:te.label}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:["/",s==="product"?`${te.value}/p`:te.value]})]})]},te.value),e[55]=L,e[56]=s,e[57]=ee):ee=e[57],G=T.map(ee),e[51]=L,e[52]=s,e[53]=T,e[54]=G}else G=e[54];let W;e[58]!==G?(W=i.jsx(Fs,{children:G}),e[58]=G,e[59]=W):W=e[59];let z;e[60]!==q||e[61]!==J||e[62]!==W?(z=i.jsxs(Si,{className:"max-h-none flex-1",children:[q,J,W]}),e[60]=q,e[61]=J,e[62]=W,e[63]=z):z=e[63];let X;e[64]!==K||e[65]!==z?(X=i.jsxs(lr,{shouldFilter:!1,className:"min-h-0 flex-1",children:[K,z]}),e[64]=K,e[65]=z,e[66]=X):X=e[66];let Q;e[67]!==M||e[68]!==O||e[69]!==X?(Q=i.jsxs(Ft,{className:"flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",onClick:kP,children:[M,O,X]}),e[67]=M,e[68]=O,e[69]=X,e[70]=Q):Q=e[70];let Z;e[71]!==v||e[72]!==l||e[73]!==Q?(Z=i.jsx(Ut,{open:l,onOpenChange:v,children:Q}),e[71]=v,e[72]=l,e[73]=Q,e[74]=Z):Z=e[74];let Y;return e[75]!==D||e[76]!==Z?(Y=i.jsxs(i.Fragment,{children:[D,Z]}),e[75]=D,e[76]=Z,e[77]=Y):Y=e[77],Y}function kP(t){return t.stopPropagation()}function wg(t){const e=B.c(12),{orgSlug:s,virtualMcpId:n,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==n?(l=Qe.sandboxRepoDir(s,n,r),e[0]=r,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],gs(d).data??null}const VP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",NP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",AP=C.lazy(()=>Ws(()=>import("./page-seo-sheet-BeK7IuoW.js"),__vite__mapDeps([161,1,2,19,20,21,22,6,4,5,7,8,9,10,11,12,13,14,15,16,17,18,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoSheet}))),Sf=500,TP={mobile:375,tablet:768,desktop:null},Uc=["desktop","mobile","tablet"],wf={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function EP(t){const e=B.c(24),{name:s,value:n,onCommit:r}=t,[o,a]=C.useState(n),[l,c]=C.useState(!1),d=C.useRef(!1),h=s==="*"?"*":`:${s}`,u=o||h;let f;e[0]!==u?(f=i.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:u}),e[0]=u,e[1]=f):f=e[1];const m=`Value for ${h}`;let p,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=w=>a(w.target.value),g=()=>c(!0),e[2]=p,e[3]=g):(p=e[2],g=e[3]);let x;e[4]!==n?(x=w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&(d.current=!0,a(n),w.currentTarget.blur())},e[4]=n,e[5]=x):x=e[5];let v;e[6]!==o||e[7]!==r||e[8]!==n?(v=()=>{if(c(!1),d.current){d.current=!1;return}const w=o.trim();a(w),w!==n&&r(w)},e[6]=o,e[7]=r,e[8]=n,e[9]=v):v=e[9];let _;e[10]!==o||e[11]!==h||e[12]!==m||e[13]!==x||e[14]!==v?(_=i.jsx("input",{type:"text",value:o,placeholder:h,title:m,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:RP,onChange:p,onFocus:g,onKeyDown:x,onBlur:v}),e[10]=o,e[11]=h,e[12]=m,e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;e[16]!==f||e[17]!==_?(b=i.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[f,_]}),e[16]=f,e[17]=_,e[18]=b):b=e[18];let y;e[19]!==l?(y=l&&i.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[i.jsx(jx,{size:10}),"Enter to go"]}),e[19]=l,e[20]=y):y=e[20];let L;return e[21]!==b||e[22]!==y?(L=i.jsxs(i.Fragment,{children:[b,y]}),e[21]=b,e[22]=y,e[23]=L):L=e[23],L}function RP(t){return t.stopPropagation()}function PP(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function IP(){const t=kn(),e=St(),{currentBranch:s}=as(),n=w3(),r=de=>{e({to:".",search:je=>({...je,main:de}),replace:!0})},[o,a]=C.useState("preview"),[l,c]=C.useState("desktop"),[d,h]=C.useState(null),u=C.useRef(null),[f,m]=C.useState(!1),[p,g]=C.useState(""),x=C.useRef(null),[v,_]=C.useState(!1),[b,y]=C.useState(),[L,w]=C.useState(null),[S,j]=C.useState(null),[k,V]=C.useState("/"),[T,A]=C.useState(null),[N,E]=C.useState({}),[I,P]=C.useState(!1),R=C.useRef(null),D=()=>{P(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>P(!1),15e3)},M=()=>{R.current&&(clearTimeout(R.current),R.current=null),P(!1)},[F,$]=C.useState(!1),O=t?.entity?.id??null,{org:U}=Ae(),K=Os(),H=dr(),q=H.vmEntry,J=H.previewUrl,G=K.lifecycle.phase,W=G==="running",z=q?.sandboxProviderKind==="user-desktop",X=wg({orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",enabled:z&&W&&!!O&&!!s}),Q=z?X:null,Z=O&&s&&W?{orgSlug:U.slug,virtualMcpId:O,branch:s,previewUrl:J}:null,{data:Y}=Bl(Z,{fetchEnabled:W}),{data:ee}=zl(Z,{fetchEnabled:W}),te=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,ae=iP(te),se=Y?md(Y).sort((de,je)=>de.name.localeCompare(je.name)):[],ie=Y&&ee?pd(Y,ee):[],fe=ai,me=se.filter(de=>{if(!p)return!0;const je=p.toLowerCase();return de.name.toLowerCase().includes(je)||de.path.toLowerCase().includes(je)}),be=ie.filter(de=>{if(!p)return!0;const je=p.toLowerCase();return de.name.toLowerCase().includes(je)||de.key.toLowerCase().includes(je)||de.resolveType.toLowerCase().includes(je)}),_e=L?null:GL(se,k,T),xe=L?L.name:_e?.name,ke=_e?.key??null,Ne=(ke?N[ke]:void 0)??{},we=Sr(k,Ne),ye={};if(W&&J&&ee)for(const de of _0(k)){if(de.type!=="param")continue;const je=de.name,ot=pP(k,je);ot&&_3(ee,Ta[ot],"loaders")&&(ye[je]=ot)}const Be=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,Fe=C.useRef(null),pe=C.useRef(null);db(()=>{const de=u.current,je=Fe.current;!de||!je||(de.src=je)});const Ee=K.status.state==="paused",De=K.phase,ue=o3({claimPhase:De,lifecycle:K.lifecycle}),le=H.previewState,Ve=H.userStopped,Me=le.kind==="starting"||le.kind==="iframe"&&ue.status==="doing",Ue=le.kind==="iframe"?PP(S??new URL(we,le.previewUrl).href,l):null,it=O&&s?uP(U.slug,O,s):null,Yt=de=>{it&&mP(it,de)},Rt=n.state.target;C.useEffect(()=>{if(!(!Rt||!J||!ee))if(Rt.kind==="page"){const de=N[Rt.key]??{};pe.current=Sr(Rt.path,de),w(null),j(null),A(Rt.key),V(Rt.path),Yt({path:Rt.path,pageKey:Rt.key,params:de})}else{const de=ie.find(je=>je.key===Rt.key);if(de){pe.current=null;const je=b0(ee);w(de),j(Lf(J,je,de.key))}}},[Rt,J,ee,N]);const[rt,gt]=C.useState(null);if(le.kind==="iframe"&&rt!==le.previewUrl){const de=rt!==null;gt(le.previewUrl);const je=it?fP(it):null;if(je){if(pe.current=Sr(je.path,je.params),V(je.path),A(je.pageKey),j(null),w(null),je.pageKey&&Object.keys(je.params).length>0){const ot=je.pageKey;E(kt=>({...kt,[ot]:je.params}))}}else de&&(pe.current=null,V("/"),j(null),A(null),w(null))}Fe.current=Ue;const lt=!!O&&!!s&&!K.notFound&&!Ve&&!Ee&&(De?.kind==="ready"||G!=="idle"),wt=le.kind!=="iframe"&&o==="visual"?"preview":o;C.useEffect(()=>{if(!J)return;let de;try{de=new URL(J,window.location.href).origin}catch{return}const je=ot=>{if(ot.origin===de&&ot.data?.type==="visual-editor::element-clicked"){const kt=oP.safeParse(ot.data.payload);kt.success&&h(kt.data)}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[J]),C.useEffect(()=>{if(!f)return;const de=je=>{x.current?.contains(je.target)||(m(!1),g(""))};return document.addEventListener("pointerdown",de),()=>document.removeEventListener("pointerdown",de)},[f]);const ct=()=>{const de=u.current?.contentWindow;de&&de.postMessage({type:"visual-editor::activate",script:aP},"*")},he=()=>{const de=u.current?.contentWindow;de&&de.postMessage({type:"visual-editor::deactivate"},"*")},Oe=de=>{const je=o;a(de),h(null),je==="visual"&&he(),de==="visual"&&ct()},et=()=>{if(!u.current||!Ue)return;const de=u.current;de.src=Ue},tt=()=>{const de=u.current;if(!de)return;const je=document.activeElement,ot=de.tabIndex;de.tabIndex=-1,de.style.pointerEvents="none",de.blur();try{de.contentWindow?.location.reload()}catch{const Nn=Fe.current;Nn&&(de.src=Nn)}const kt=()=>{de.tabIndex=ot,de.style.pointerEvents="",je?.focus(),de.removeEventListener("load",kt)};de.addEventListener("load",kt),setTimeout(kt,3e3)},[vs,us]=C.useState(n.state.previewRevision);C.useEffect(()=>{vs!==n.state.previewRevision&&(us(n.state.previewRevision),tt())},[vs,n.state.previewRevision]);const Jt=()=>{if(!u.current||!Ue)return;const de=Ue.includes("?")?"&":"?";u.current.src=`${Ue}${de}_r=${Date.now()}`},mn=()=>{const de=Uc.indexOf(l);c(Uc[(de+1)%Uc.length])},oe=()=>{const de=u.current?.contentWindow?.location?.href??Ue??J;de&&navigator.clipboard.writeText(de)},Le=(()=>{if(!J)return"No server running";if(L)return L.name;try{const de=new URL(J),je=we==="/"?"":we;return`${de.host}${je}`}catch{return J}})(),Te=de=>{const je=N[de.key]??{},ot=Sr(de.path,je);(L||fe(ot)!==fe(we))&&D(),pe.current=ot,w(null),j(null),A(de.key),V(de.path),Yt({path:de.path,pageKey:de.key,params:je}),n.selectTarget({kind:"page",key:de.key,path:de.path})},$e=(de,je)=>{if(!ke)return;const ot=ke,kt={...Ne,[de]:je};pe.current=Sr(k,kt),E(Nn=>({...Nn,[ot]:kt})),Yt({path:k,pageKey:ot,params:kt})},st=de=>{if(!J||!ee){ce.error("Preview metadata not ready yet");return}D(),pe.current=null;const je=b0(ee),ot=Lf(J,je,de.key);w(de),j(ot),n.selectTarget({kind:"section",key:de.key})},ht=async({name:de,path:je,templateKey:ot})=>{if(!O||!s)return;const kt=ud(je);if(kt){y(kt);return}const Nn=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(se.some(An=>fe(An.path)===fe(Nn))){y(`A page with path "${Nn}" already exists.`);return}let hc;if(ot&&(hc=Y?.[ot],!hc)){y("Selected template no longer exists.");return}y(void 0);try{const An=await ae.mutateAsync({name:de,path:Nn,template:hc});_(!1),ce.success(`Page "${de}" created`),await e6(Sf),Te({key:An.key,name:An.name,path:An.path}),e({to:".",search:k4=>({...k4,blocks:1}),replace:!0})}catch(An){y(An instanceof Error?An.message:"Failed to create page")}},Vn=le.kind==="iframe",Qn=de=>Oe(o===de?"preview":de);return i.jsxs("div",{className:"flex flex-col w-full h-full",children:[lt&&le.kind==="iframe"&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:le.kind==="iframe"&&i.jsx("div",{className:"flex w-full items-center justify-center",children:i.jsxs("div",{className:"flex w-full max-w-[500px] items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:et,children:i.jsx(zi,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Refresh"})]}),i.jsxs("div",{ref:x,className:"relative min-w-0 flex-1",children:[i.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[i.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>m(de=>!de),children:[L&&i.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i.jsx(on,{size:11}),"Global"]}),i.jsx("span",{className:ne("text-[13px] font-medium text-foreground",xe==null?"min-w-0 flex-1 truncate":"shrink-0"),children:xe??Le}),!L&&xe!=null&&k&&i.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:_0(k).map((de,je)=>{if(de.type==="text")return i.jsx("span",{className:ne(je===0?"min-w-0 truncate":"shrink-0"),children:de.text},`text-${je}`);const ot=ye[de.name];return ot&&Be?i.jsx(CP,{kind:ot,paramName:de.name,value:Ne[de.name]??"",sandboxRef:Be,onCommit:kt=>$e(de.name,kt)},`${ke}:${de.name}`):i.jsx(EP,{name:de.name,value:Ne[de.name]??"",onCommit:kt=>$e(de.name,kt)},`${ke}:${de.name}`)})})]}),i.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>m(de=>!de),"aria-label":"Choose page",children:i.jsx(Ht,{size:12,className:ne("shrink-0 text-muted-foreground transition-transform",f&&"rotate-180")})})]}),f&&i.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[i.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[i.jsx(K9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{type:"text",value:p,onChange:de=>g(de.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),i.jsx("div",{className:"p-1.5 border-b",children:i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:de=>{de.preventDefault(),m(!1),g(""),y(void 0),_(!0)},children:[i.jsx(Lt,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),me.length===0&&be.length===0?i.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:se.length===0&&ie.length===0?"No pages found in this site.":"No results match your search."}):i.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[me.length>0&&i.jsx("div",{className:"p-1.5",children:me.map(de=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),Te(de)},children:[i.jsx(Dn,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:de.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:de.path})]},de.key))}),be.length>0&&i.jsxs("div",{className:ne("p-1.5",me.length>0&&"border-t"),children:[i.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),be.map(de=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),st(de)},children:[i.jsx(on,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:de.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:de.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},de.key))]})]})]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:()=>{const de=Ue??le.previewUrl;de&&window.open(de,"_blank","noopener")},children:i.jsx(wn,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in new tab"})]}),i.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center md:right-4",children:i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",children:i.jsx(Gn,{size:14})})}),i.jsxs(ts,{align:"end",className:"w-44",children:[i.jsx(He,{onClick:Jt,children:"Hard Reload"}),i.jsx(He,{onClick:oe,children:"Copy Current URL"}),Y&&ee&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),ke&&i.jsxs(He,{onClick:()=>{n.editSeo({kind:"page",key:ke,path:k}),e({to:".",search:de=>({...de,blocks:1}),replace:!0})},children:[i.jsx(Ua,{size:14}),"Edit SEO"]}),ke&&i.jsxs(He,{onClick:()=>{try{r(Lv(tv(ke)))}catch{ce.error("Invalid page block key")}},children:[i.jsx(To,{size:14}),"View JSON"]}),i.jsxs(He,{onClick:()=>$(!0),children:[i.jsx(Ua,{size:14}),"Site SEO"]})]}),Q&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:()=>window.open(_l("vscode",Q)),children:[i.jsx("img",{src:VP,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),i.jsxs(He,{onClick:()=>window.open(_l("cursor",Q)),children:[i.jsx("img",{src:NP,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})})]})})}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs("div",{className:ne("flex-1 relative overflow-hidden",l!=="desktop"&&le.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[I&&le.kind==="iframe"&&i.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:i.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),Me&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"starting",progress:ue,claimPhase:De})}),le.kind==="suspended"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"suspended",onResume:H.resume})}),le.kind==="errored"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"errored",error:le.error,onRetry:H.retry,connectionsHref:`/${U.slug}/settings/connections`})}),wt==="visual"&&!d&&i.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[i.jsx(Su,{size:12}),"Click any element to ask the AI"]}),wt==="visual"&&d&&i.jsx(dP,{element:d,onDismiss:()=>h(null)}),Vn&&i.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:i.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Vu,{onClick:()=>Qn("visual"),"aria-pressed":o==="visual","aria-label":"Visual editor",active:o==="visual",children:i.jsx(Su,{size:16})})}),i.jsx(Pe,{side:"top",children:"Visual editor"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Vu,{onClick:mn,"aria-label":wf[l],children:i.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[l==="mobile"&&i.jsx(Lx,{size:16}),l==="tablet"&&i.jsx(Sx,{size:16}),l==="desktop"&&i.jsx(wx,{size:16})]},l)})}),i.jsx(Pe,{side:"top",children:wf[l]})]})]})}),le.kind==="iframe"&&Ue&&i.jsx("div",{className:ne("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",l!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:l==="desktop"?"100%":`${TP[l]}px`},children:i.jsx("iframe",{ref:u,src:Ue,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{if(M(),Ce("vm_preview_loaded",{view_mode:o,vm_id:q?.sandboxHandle??null}),!L)try{const de=u.current?.contentWindow?.location?.pathname;if(!de)return;const je=pe.current;if(je!==null&&(pe.current=null,fe(de)!==fe(je))||fe(de)===fe(we))return;V(de),Yt({path:de,pageKey:T,params:Ne})}catch{}o==="visual"&&ct()}},le.previewUrl)})]})}),i.jsx(rP,{open:v,onOpenChange:_,isPending:ae.isPending,error:b,templates:se,onSubmit:ht}),F&&Y&&ee&&i.jsx(C.Suspense,{fallback:null,children:i.jsx(AP,{open:F,onOpenChange:$,orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",decofile:Y,meta:ee,onSaved:()=>{setTimeout(()=>{const de=u.current;if(de)try{de.contentWindow?.location.reload()}catch{const je=Fe.current;je&&(de.src=je)}},Sf)},target:{kind:"site"}})})]})}function DP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No source to preview."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(IP,{}),e[1]=o):o=e[1],o}const MP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",OP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",$P=C.lazy(()=>Ws(()=>import("./file-explorer-B1c6Fj3p.js"),__vite__mapDeps([162,1,2,84,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,127,123,128,129,126,117,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,124,125,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.FileExplorer})));function BP(t){const e=B.c(17),{openPath:s}=t,n=kn(),{org:r}=Ae(),{currentBranch:o}=as(),a=n?.entity?.id??null,l=dr(),c=Os(),d=l.vmEntry,h=c.lifecycle.phase==="running",u=d?.sandboxProviderKind==="user-desktop",f=a??"",m=o??"",p=u&&h&&!!a&&!!o;let g;e[0]!==r.slug||e[1]!==f||e[2]!==m||e[3]!==p?(g={orgSlug:r.slug,virtualMcpId:f,branch:m,enabled:p},e[0]=r.slug,e[1]=f,e[2]=m,e[3]=p,e[4]=g):g=e[4];const x=wg(g),v=u?x:null;if(!a||!o){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No sandbox to browse."}),e[5]=w):w=e[5],w}let _;e[6]!==v?(_=v&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:i.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(_l("vscode",v)),children:i.jsx("img",{src:MP,alt:"VSCode",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in VSCode"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(_l("cursor",v)),children:i.jsx("img",{src:OP,alt:"Cursor",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in Cursor"})]})]})}),e[6]=v,e[7]=_):_=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),e[8]=b):b=e[8];let y;e[9]!==o||e[10]!==s||e[11]!==r.slug||e[12]!==a?(y=i.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:i.jsx(C.Suspense,{fallback:b,children:i.jsx($P,{orgSlug:r.slug,virtualMcpId:a,branch:o,openPath:s})})}),e[9]=o,e[10]=s,e[11]=r.slug,e[12]=a,e[13]=y):y=e[13];let L;return e[14]!==_||e[15]!==y?(L=i.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,y]}),e[14]=_,e[15]=y,e[16]=L):L=e[16],L}function zP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No content to edit."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(j3,{}),e[1]=o):o=e[1],o}const Hc={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:P9},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Bn},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:tm}},FP=["fast","smart","thinking"];function UP(t){const e=B.c(15),{tier:s,onSelect:n}=t,[r,o]=C.useState(!1),a=Hc[s].icon;let l;e[0]!==a?(l=i.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const c=Hc[s];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[2]=d):d=e[2];let h;e[3]!==l||e[4]!==c.label?(h=i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,c.label,d]})}),e[3]=l,e[4]=c.label,e[5]=h):h=e[5];let u;e[6]!==n||e[7]!==s?(u=FP.map(p=>{const g=Hc[p],x=g.icon;return i.jsxs("button",{type:"button",onClick:()=>{n(p),o(!1)},className:ne("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[i.jsx(x,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:g.label}),i.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&i.jsx(Tt,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=n,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=i.jsx(ks,{align:"start",className:"p-1 w-64",children:i.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=i.jsxs(Vs,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function HP(t){const e=B.c(15),{tier:s,onTierChange:n,override:r,onOverrideChange:o}=t,[a,l]=C.useState(r!==null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a?(d=a?i.jsx(C.Suspense,{fallback:i.jsx(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:i.jsx(KP,{override:r,onOverrideChange:o})}):i.jsx(UP,{tier:s,onSelect:n}),e[1]=o,e[2]=n,e[3]=r,e[4]=s,e[5]=a,e[6]=d):d=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=i.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(ho,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d,u]})]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function KP(t){const e=B.c(10),{override:s,onOverrideChange:n}=t,r=Sm(),o=r[0]?.id??null,[a,l]=C.useState(s?.credentialId??o);let c;e[0]!==s?(c=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=c):c=e[1];const d=c;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==n?(h=f=>{const m=f.keyId??a??"";l(m),n({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=n,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==d||e[8]!==h?(u=i.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:i.jsx(Hx,{variant:"bordered",placeholder:"Pick a model",model:d,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=d,e[8]=h,e[9]=u):u=e[9],u}const jg=[{key:"capabilities",heading:"Built-in capabilities",icon:T9,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Yn},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:_n},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:an},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:Cx}]},{key:"files",heading:"Files & code",icon:hi,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Tm},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:A9},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:E9},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:fo},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:hi},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:kx}]},{key:"context",heading:"Context",icon:Fa,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Fa},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:Ki},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:Ki}]},{key:"browser",heading:"Browser",icon:on,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:ar},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:on},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:To}]}],WP=jg.flatMap(t=>t.tools.map(e=>e.name));function qP(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function GP(t){const e=B.c(5),{agentId:s,value:n,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==n?(a=i.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?i.jsx(C.Suspense,{fallback:i.jsxs(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[i.jsx(T9,{size:14}),"Loading tools…"]}),children:i.jsx(YP,{agentId:s,value:n,onChange:r})}):i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=n,e[4]=a):a=e[4],a}function jf(t){const e=B.c(17),{value:s,checked:n,onToggle:r,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=i.jsx(cr,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&i.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=i.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&i.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=i.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=i.jsxs(Ps,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=r,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function Cf(t){const e=B.c(20),{conn:s,label:n,icon:r,on:o,total:a,onToggle:l}=t,c=o===a;let d;e[0]!==r||e[1]!==s?(d=s?i.jsx(Gs,{icon:s.icon,name:s.title,size:"2xs"}):r?i.jsx(r,{size:14,className:"text-muted-foreground"}):i.jsx(Vx,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=d):d=e[2];const h=s?.title??n??"Other tools";let u;e[3]!==h?(u=i.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=i.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=_=>{_.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=c?"None":"All";let g;e[10]!==m||e[11]!==p?(g=i.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==f||e[14]!==g?(x=i.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=x):x=e[15];let v;return e[16]!==d||e[17]!==u||e[18]!==x?(v=i.jsxs("div",{className:"flex items-center gap-2",children:[d,u,x]}),e[16]=d,e[17]=u,e[18]=x,e[19]=v):v=e[19],v}function YP(t){const e=B.c(70),{agentId:s,value:n,onChange:r}=t,{org:o}=Ae(),[a,l]=C.useState(!1);let c;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(c={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=c):c=e[3];const d=pt(c);let h;e[4]!==d?(h={client:d},e[4]=d,e[5]=h):h=e[5];const{data:u,isLoading:f}=G9(h),m=Mo();let p,g,x,v,_,b,y,L,w,S,j,k,V;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==n){const I=new Map(m.map(eI)),P=new Map;for(const se of u?.tools??[]){const ie=rn(se._meta)??"__other__",fe=rr(se.name,ie==="__other__"?void 0:ie),me=se.title,be=me&&me!==se.name?me:qP(fe);P.has(ie)||P.set(ie,{clientId:ie,conn:I.get(ie),tools:[]}),P.get(ie).tools.push({name:se.name,display:be,description:se.description})}const R=[...P.values()].sort(ZP),D=(u?.tools??[]).map(QP),M=[...WP,...D],F=n===null?new Set(M):new Set(n),$=M.every(se=>F.has(se)),O=se=>r(M.every(ie=>se.has(ie))?null:[...se]),U=se=>{const ie=new Set(F);ie.has(se)?ie.delete(se):ie.add(se),O(ie)},K=(se,ie)=>{const fe=new Set(F);for(const me of se)ie?fe.add(me):fe.delete(me);O(fe)};v=Vs,V=a,_=l;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=i.jsx(T9,{size:14,className:"text-muted-foreground"}),e[25]=H):H=e[25];const q=$?"All tools":"Tools",J=!$&&i.jsxs(t6,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",M.length]});let G;e[26]===Symbol.for("react.memo_cache_sentinel")?(G=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[26]=G):G=e[26],e[27]!==q||e[28]!==J?(b=i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[H,q,J,G]})}),e[27]=q,e[28]=J,e[29]=b):b=e[29],x=ks,j="p-0 w-80",k="start",g=lr,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(yi,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const W=$?`All ${M.length} tools enabled`:`${F.size} of ${M.length} enabled`;let z;e[31]!==W?(z=i.jsx("span",{className:"text-xs text-muted-foreground",children:W}),e[31]=W,e[32]=z):z=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let Q;e[35]!==$||e[36]!==X?(Q=i.jsx("button",{type:"button",onClick:X,disabled:$,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=$,e[36]=X,e[37]=Q):Q=e[37];let Z;e[38]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Z):Z=e[38];let Y;e[39]!==r?(Y=()=>r([]),e[39]=r,e[40]=Y):Y=e[40];const ee=F.size===0;let te;e[41]!==Y||e[42]!==ee?(te=i.jsx("button",{type:"button",onClick:Y,disabled:ee,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=Y,e[42]=ee,e[43]=te):te=e[43];let ae;e[44]!==Q||e[45]!==te?(ae=i.jsxs("div",{className:"flex items-center gap-2",children:[Q,Z,te]}),e[44]=Q,e[45]=te,e[46]=ae):ae=e[46],e[47]!==z||e[48]!==ae?(S=i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[z,ae]}),e[47]=z,e[48]=ae,e[49]=S):S=e[49],p=Si,y="max-h-80",L=f?i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):i.jsxs(i.Fragment,{children:[i.jsx(Li,{children:"No tools found"}),jg.map(se=>{const ie=se.tools.map(XP),fe=ie.filter(me=>F.has(me)).length;return i.jsx(Fs,{heading:i.jsx(Cf,{label:se.heading,icon:se.icon,on:fe,total:ie.length,onToggle:()=>K(ie,fe!==ie.length)}),children:se.tools.map(me=>i.jsx(jf,{value:`${me.title} ${me.name}`,checked:F.has(me.name),onToggle:()=>U(me.name),title:me.title,description:me.description,leading:i.jsx(me.icon,{size:16,className:"text-muted-foreground"})},me.name))},se.key)}),R.map(se=>{const ie=se.tools.map(JP),fe=ie.filter(me=>F.has(me)).length;return i.jsx(Fs,{heading:i.jsx(Cf,{conn:se.conn,on:fe,total:ie.length,onToggle:()=>K(ie,fe!==ie.length)}),children:se.tools.map(me=>i.jsx(jf,{value:`${me.display} ${me.name} ${se.conn?.title??""}`,checked:F.has(me.name),onToggle:()=>U(me.name),title:me.display,description:me.description},me.name))},se.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=n,e[12]=p,e[13]=g,e[14]=x,e[15]=v,e[16]=_,e[17]=b,e[18]=y,e[19]=L,e[20]=w,e[21]=S,e[22]=j,e[23]=k,e[24]=V}else p=e[12],g=e[13],x=e[14],v=e[15],_=e[16],b=e[17],y=e[18],L=e[19],w=e[20],S=e[21],j=e[22],k=e[23],V=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==L?(T=i.jsx(p,{className:y,children:L}),e[50]=p,e[51]=y,e[52]=L,e[53]=T):T=e[53];let A;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==S?(A=i.jsxs(g,{children:[w,S,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=S,e[58]=A):A=e[58];let N;e[59]!==x||e[60]!==A||e[61]!==j||e[62]!==k?(N=i.jsx(x,{className:j,align:k,children:A}),e[59]=x,e[60]=A,e[61]=j,e[62]=k,e[63]=N):N=e[63];let E;return e[64]!==v||e[65]!==_||e[66]!==b||e[67]!==N||e[68]!==V?(E=i.jsxs(v,{open:V,onOpenChange:_,children:[b,N]}),e[64]=v,e[65]=_,e[66]=b,e[67]=N,e[68]=V,e[69]=E):E=e[69],E}function JP(t){return t.name}function XP(t){return t.name}function QP(t){return t.name}function ZP(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function eI(t){return[t.id,t]}function so(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function tI(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function sI(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function nI(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return r?{count:parseInt(r[1]),unit:"days"}:null}function iI(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const rI=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function oI({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Oo(),[l,c]=C.useState(!1),d=e??l,h=m=>{s?s(m):c(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),ce.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";ce.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):ce.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";ce.error(p)}};return i.jsxs(Zt,{open:d,onOpenChange:h,children:[i.jsx(es,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",children:[i.jsx(Lt,{size:14}),"Add Starter"]})}),i.jsxs(ts,{align:"end",className:"w-[200px]",children:[i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2.5",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),i.jsx(lo,{className:"w-[160px]",children:rI.map(m=>i.jsxs(He,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),n?.()},children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[i.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Cg(t){const e=B.c(31),{open:s,onOpenChange:n,url:r,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=C.useState(null),[f,m]=C.useState("curl"),[p,g]=C.useState("header"),x=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(I,P)=>{try{await navigator.clipboard.writeText(I),u(P),ce.success("Copied"),setTimeout(()=>u(null),1500)}catch{ce.error("Failed to copy")}},e[0]=v):v=e[0];const _=v;let b;e[1]!==p||e[2]!==o||e[3]!==r?(b=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=b):b=e[4];const y=b,L=r&&o?p==="header"?`curl -X POST "${y}" \\
181
+ `)}function cP(t,e,s=320,n=44,r=12){const{x:o,y:a}=t,{width:l,height:c}=e,d=Math.max(r,Math.min(o-s/2,l-s-r)),u=a/c>.68?Math.max(r,a-n-18):Math.min(a+18,c-n-r);return{leftPct:d/l*100,topPct:u/c*100}}function dP(t){const e=B.c(32),{element:s,onDismiss:n}=t,[r,o]=C.useState(""),a=C.useRef(null),{sendMessage:l}=js(),{setChatOpen:c}=No();let d;e[0]!==s||e[1]!==r||e[2]!==n||e[3]!==l||e[4]!==c?(d=()=>{if(!r.trim())return;const V=lP(s,r);c(!0),l({parts:[{type:"text",text:V}]}),n()},e[0]=s,e[1]=r,e[2]=n,e[3]=l,e[4]=c,e[5]=d):d=e[5];const h=d;let u;e[6]!==s.position||e[7]!==s.viewport?(u=cP(s.position,s.viewport),e[6]=s.position,e[7]=s.viewport,e[8]=u):u=e[8];const f=u,m=`${f.leftPct}%`,p=`${f.topPct}%`;let g;e[9]!==m||e[10]!==p?(g={left:m,top:p,width:"320px"},e[9]=m,e[10]=p,e[11]=g):g=e[11];let x;e[12]!==h?(x=V=>{V.preventDefault(),h()},e[12]=h,e[13]=x):x=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=V=>o(V.target.value),e[14]=v):v=e[14];let _;e[15]!==n?(_=V=>{V.key==="Escape"&&n()},e[15]=n,e[16]=_):_=e[16];let b;e[17]!==r||e[18]!==_?(b=i.jsx("input",{ref:a,autoFocus:!0,type:"text",value:r,onChange:v,onKeyDown:_,placeholder:"Ask the AI...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e[17]=r,e[18]=_,e[19]=b):b=e[19];let y;e[20]!==r?(y=r.trim(),e[20]=r,e[21]=y):y=e[21];const L=!y;let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:[i.jsx("title",{children:"Send"}),i.jsx("path",{d:"M5 9V1M1 5l4-4 4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e[22]=w):w=e[22];let S;e[23]!==L?(S=i.jsx("button",{type:"submit",disabled:L,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background transition-opacity disabled:opacity-30",title:"Send",children:w}),e[23]=L,e[24]=S):S=e[24];let j;e[25]!==S||e[26]!==x||e[27]!==b?(j=i.jsxs("form",{className:"pointer-events-auto flex w-full items-center gap-1.5 rounded-xl border border-border bg-background/95 px-3 py-1.5 shadow-lg backdrop-blur",onSubmit:x,children:[b,S]}),e[25]=S,e[26]=x,e[27]=b,e[28]=j):j=e[28];let k;return e[29]!==j||e[30]!==g?(k=i.jsx("div",{className:"absolute z-30 pointer-events-none",style:g,children:j}),e[29]=j,e[30]=g,e[31]=k):k=e[31],k}function uP(t,e,s){return`deco:preview:last-page:${t}:${e}:${s}`}function hP(t){if(!t)return null;try{const e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e)||typeof e.path!="string"||!e.path.startsWith("/"))return null;const s=typeof e.pageKey=="string"?e.pageKey:null,n={};if(e.params&&typeof e.params=="object")for(const[r,o]of Object.entries(e.params))typeof o=="string"&&(n[r]=o);return{path:e.path,pageKey:s,params:n}}catch{return null}}function fP(t){try{return hP(localStorage.getItem(t))}catch{return null}}function mP(t,e){try{localStorage.setItem(t,JSON.stringify(e))}catch{}}function _l(t,e){const n=e.replace(/\\/g,"/").replace(/^(?!\/)/,"/").split("/").map(r=>encodeURIComponent(r).replace(/%3A/gi,":")).join("/");return`${t}://file${n}?windowId=_blank`}const Ta={product:"vtex/loaders/intelligentSearch/productList.ts",category:"vtex/loaders/categories/tree.ts"};function pP(t,e){const s=_0(ai(t));if(e==="*")return s.some(o=>o.type==="param"&&o.name==="*")?"category":null;const n=s[s.length-1],r=s[s.length-2];return n?.type==="text"&&n.text==="/p"&&r?.type==="param"&&r.name===e?"product":null}function gP(t,e){if(t==="category")return[{resolveType:Ta.category,props:{}}];const s=e.trim(),n=[];/^\d+$/.test(s)&&n.push({resolveType:Ta.product,props:{ids:[s]}});const o=s.includes("-")&&!/\s/.test(s)?s.replace(/-+/g," "):s;return n.push({resolveType:Ta.product,props:{query:o,count:10}}),n}function xP(t){const e=new Set,s=[];for(const n of t)for(const r of n)e.has(r.value)||(e.add(r.value),s.push(r));return s}function Ea(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Sg(t){try{return decodeURIComponent(t)}catch{return t}}function vP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.match(/^\/([^/]+)\/p\/?$/)?.[1];return s?Sg(s):null}function _P(t){if(!Array.isArray(t))return[];const e=[],s=new Set;for(const n of t){const r=Ea(n);if(!r)continue;const o=vP(r.url);if(!o||s.has(o))continue;s.add(o);const a=Ea(r.isVariantOf),l=typeof a?.name=="string"&&a.name||typeof r.name=="string"&&r.name||o,c=Array.isArray(r.image)?Ea(r.image[0]):null,d=typeof c?.url=="string"?c.url:void 0;e.push({value:o,label:l,image:d})}return e}function bP(t){if(typeof t!="string"||!t)return null;let e;try{e=new URL(t,"https://placeholder.invalid").pathname}catch{return null}const s=e.replace(/^\/+|\/+$/g,"");return s?Sg(s):null}function yP(t){const e=[],s=new Set,n=(r,o)=>{const a=Ea(r);if(!a)return;const l=typeof a.name=="string"&&a.name?a.name:"",c=l?[...o,l]:o,d=bP(a.url);if(d&&!s.has(d)&&(s.add(d),e.push({value:d,label:c.join(" › ")||d})),Array.isArray(a.children))for(const h of a.children)n(h,c)};if(Array.isArray(t))for(const r of t)n(r,[]);return e}function LP(t,e,s=50){const n=e.trim().toLowerCase();return(n?t.filter(o=>o.label.toLowerCase().includes(n)||o.value.toLowerCase().includes(n)):t).slice(0,s)}const SP=1e4;async function wP(t,{resolveType:e,props:s}){const n=await fetch(L3(t),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({__resolveType:e,...s}),signal:AbortSignal.timeout(SP)});if(!n.ok)throw new Error(`Failed to fetch options: ${n.status}`);return n.json()}async function jP(t,e,s){const n=gP(e,s),r=await Promise.allSettled(n.map(a=>wP(t,a))),o=r.filter(a=>a.status==="fulfilled").map(a=>a.value);if(o.length===0){const a=r.find(l=>l.status==="rejected");throw a?a.reason:new Error("Failed to fetch options")}return xP(o.map(a=>e==="product"?_P(a):yP(a)))}function CP(t){const e=B.c(78),{kind:s,paramName:n,value:r,sandboxRef:o,onCommit:a}=t,[l,c]=C.useState(!1),[d,h]=C.useState(""),[u,f]=C.useState(""),m=C.useRef(null),p=s==="product"?"product":"category",g=n==="*"?"*":`:${n}`;let x;e[0]!==r?(x=ee=>{c(ee),m.current&&clearTimeout(m.current),h(ee?r:""),f(ee?r:"")},e[0]=r,e[1]=x):x=e[1];const v=x;let _;e[2]===Symbol.for("react.memo_cache_sentinel")?(_=ee=>{h(ee),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(ee)},300)},e[2]=_):_=e[2];const b=_;let y;e[3]!==v||e[4]!==a?(y=ee=>{a(ee),v(!1)},e[3]=v,e[4]=a,e[5]=y):y=e[5];const L=y;let w;e[6]!==u||e[7]!==s||e[8]!==o.branch||e[9]!==o.orgSlug||e[10]!==o.virtualMcpId?(w=Qe.sandboxInvoke(`${o.orgSlug}/${o.virtualMcpId}/${o.branch}`,`path-param-${s}:${s==="product"?u:""}`),e[6]=u,e[7]=s,e[8]=o.branch,e[9]=o.orgSlug,e[10]=o.virtualMcpId,e[11]=w):w=e[11];let S;e[12]!==u||e[13]!==s||e[14]!==o?(S=()=>jP(o,s,u),e[12]=u,e[13]=s,e[14]=o,e[15]=S):S=e[15];let j;e[16]!==l||e[17]!==w||e[18]!==S?(j={queryKey:w,queryFn:S,enabled:l,staleTime:6e4,retry:1},e[16]=l,e[17]=w,e[18]=S,e[19]=j):j=e[19];const k=gs(j);let V;e[20]!==s||e[21]!==k.data||e[22]!==d?(V=s==="product"?k.data??[]:LP(k.data??[],d),e[20]=s,e[21]=k.data,e[22]=d,e[23]=V):V=e[23];const T=V;let A;e[24]!==d?(A=d.trim(),e[24]=d,e[25]=A):A=e[25];const N=A,E=s==="product"?`/${N}/p`:`/${N}`,I=`Value for ${g} — click to pick a ${p}`;let P;e[26]!==v?(P=ee=>{ee.stopPropagation(),v(!0)},e[26]=v,e[27]=P):P=e[27];const R=r||g;let D;e[28]!==P||e[29]!==R||e[30]!==I?(D=i.jsx("button",{type:"button",title:I,className:"max-w-64 shrink-0 cursor-pointer truncate rounded-sm bg-violet-500/15 px-1 py-0.5 text-[12px] text-violet-600 hover:bg-violet-500/25 dark:text-violet-400",onClick:P,children:R}),e[28]=P,e[29]=R,e[30]=I,e[31]=D):D=e[31];let M;e[32]!==p||e[33]!==g?(M=i.jsx(ns,{className:"sr-only",children:i.jsxs(is,{children:["Pick a ",p," or enter a value for ",g]})}),e[32]=p,e[33]=g,e[34]=M):M=e[34];let F;e[35]===Symbol.for("react.memo_cache_sentinel")?(F=i.jsx(c0,{size:16,className:"shrink-0 text-foreground"}),e[35]=F):F=e[35];let $;e[36]!==g?($=i.jsx("span",{className:"rounded-sm bg-violet-500/15 px-1 py-0.5 font-mono text-[12px] text-violet-600 dark:text-violet-400",children:g}),e[36]=g,e[37]=$):$=e[37];let O;e[38]!==p||e[39]!==$?(O=i.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border px-4",children:[F,i.jsxs("span",{className:"text-sm font-medium text-foreground",children:["Pick a ",p," for"," ",$]})]}),e[38]=p,e[39]=$,e[40]=O):O=e[40];const U=s==="product"?"Search products or enter a slug...":"Search categories or enter a path...";let K;e[41]!==d||e[42]!==U?(K=i.jsx(yi,{autoFocus:!0,placeholder:U,value:d,onValueChange:b}),e[41]=d,e[42]=U,e[43]=K):K=e[43];const H=k.isLoading?"Loading...":k.isError?"Couldn't load — is the dev server running?":"No results.";let q;e[44]!==H?(q=i.jsx(Li,{children:H}),e[44]=H,e[45]=q):q=e[45];let J;e[46]!==L||e[47]!==g||e[48]!==E||e[49]!==N?(J=N&&i.jsx(Fs,{children:i.jsxs(Ps,{value:`__raw__:${N}`,className:"gap-3 py-2",onSelect:()=>L(N),children:[i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted",children:i.jsx(Eo,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsxs("span",{className:"block truncate text-sm",children:["Use “",N,"” as ",g]}),i.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:E})]})]})}),e[46]=L,e[47]=g,e[48]=E,e[49]=N,e[50]=J):J=e[50];let G;if(e[51]!==L||e[52]!==s||e[53]!==T){let ee;e[55]!==L||e[56]!==s?(ee=te=>i.jsxs(Ps,{value:te.value,className:"gap-3 py-2",onSelect:()=>L(te.value),children:[s==="product"&&i.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:te.image?i.jsx("img",{src:te.image,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full object-cover"}):i.jsx(c0,{size:14,className:"text-muted-foreground"})}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"block truncate text-sm",children:te.label}),i.jsxs("span",{className:"block truncate text-xs text-muted-foreground",children:["/",s==="product"?`${te.value}/p`:te.value]})]})]},te.value),e[55]=L,e[56]=s,e[57]=ee):ee=e[57],G=T.map(ee),e[51]=L,e[52]=s,e[53]=T,e[54]=G}else G=e[54];let W;e[58]!==G?(W=i.jsx(Fs,{children:G}),e[58]=G,e[59]=W):W=e[59];let z;e[60]!==q||e[61]!==J||e[62]!==W?(z=i.jsxs(Si,{className:"max-h-none flex-1",children:[q,J,W]}),e[60]=q,e[61]=J,e[62]=W,e[63]=z):z=e[63];let X;e[64]!==K||e[65]!==z?(X=i.jsxs(lr,{shouldFilter:!1,className:"min-h-0 flex-1",children:[K,z]}),e[64]=K,e[65]=z,e[66]=X):X=e[66];let Q;e[67]!==M||e[68]!==O||e[69]!==X?(Q=i.jsxs(Ft,{className:"flex h-[85svh] flex-col gap-0 overflow-hidden p-0 sm:h-[520px] sm:max-w-[560px]",onClick:kP,children:[M,O,X]}),e[67]=M,e[68]=O,e[69]=X,e[70]=Q):Q=e[70];let Z;e[71]!==v||e[72]!==l||e[73]!==Q?(Z=i.jsx(Ut,{open:l,onOpenChange:v,children:Q}),e[71]=v,e[72]=l,e[73]=Q,e[74]=Z):Z=e[74];let Y;return e[75]!==D||e[76]!==Z?(Y=i.jsxs(i.Fragment,{children:[D,Z]}),e[75]=D,e[76]=Z,e[77]=Y):Y=e[77],Y}function kP(t){return t.stopPropagation()}function wg(t){const e=B.c(12),{orgSlug:s,virtualMcpId:n,branch:r,enabled:o}=t,a=o===void 0?!0:o;let l;e[0]!==r||e[1]!==s||e[2]!==n?(l=Qe.sandboxRepoDir(s,n,r),e[0]=r,e[1]=s,e[2]=n,e[3]=l):l=e[3];let c;e[4]!==r||e[5]!==s||e[6]!==n?(c=async()=>{const u=`/api/${s}/sandbox/${encodeURIComponent(n)}/${encodeURIComponent(r)}/config`,f=await fetch(u);return f.ok?(await f.json()).repoDir??null:null},e[4]=r,e[5]=s,e[6]=n,e[7]=c):c=e[7];let d;return e[8]!==a||e[9]!==l||e[10]!==c?(d={queryKey:l,queryFn:c,enabled:a,staleTime:1/0},e[8]=a,e[9]=l,e[10]=c,e[11]=d):d=e[11],gs(d).data??null}const VP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",NP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",AP=C.lazy(()=>Ws(()=>import("./page-seo-sheet-BcKckI0p.js"),__vite__mapDeps([161,1,2,19,20,21,22,6,4,5,7,8,9,10,11,12,13,14,15,16,17,18,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,157,135,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.SeoSheet}))),Sf=500,TP={mobile:375,tablet:768,desktop:null},Uc=["desktop","mobile","tablet"],wf={mobile:"Mobile (375px)",tablet:"Tablet (768px)",desktop:"Desktop"};function EP(t){const e=B.c(24),{name:s,value:n,onCommit:r}=t,[o,a]=C.useState(n),[l,c]=C.useState(!1),d=C.useRef(!1),h=s==="*"?"*":`:${s}`,u=o||h;let f;e[0]!==u?(f=i.jsx("span",{"aria-hidden":!0,className:"invisible whitespace-pre px-1 py-0.5 text-[12px]",children:u}),e[0]=u,e[1]=f):f=e[1];const m=`Value for ${h}`;let p,g;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=w=>a(w.target.value),g=()=>c(!0),e[2]=p,e[3]=g):(p=e[2],g=e[3]);let x;e[4]!==n?(x=w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&(d.current=!0,a(n),w.currentTarget.blur())},e[4]=n,e[5]=x):x=e[5];let v;e[6]!==o||e[7]!==r||e[8]!==n?(v=()=>{if(c(!1),d.current){d.current=!1;return}const w=o.trim();a(w),w!==n&&r(w)},e[6]=o,e[7]=r,e[8]=n,e[9]=v):v=e[9];let _;e[10]!==o||e[11]!==h||e[12]!==m||e[13]!==x||e[14]!==v?(_=i.jsx("input",{type:"text",value:o,placeholder:h,title:m,spellCheck:!1,className:"absolute inset-0 rounded-sm bg-violet-500/15 px-1 text-[12px] text-violet-600 outline-none placeholder:text-violet-500/60 focus:bg-violet-500/25 dark:text-violet-400",onClick:RP,onChange:p,onFocus:g,onKeyDown:x,onBlur:v}),e[10]=o,e[11]=h,e[12]=m,e[13]=x,e[14]=v,e[15]=_):_=e[15];let b;e[16]!==f||e[17]!==_?(b=i.jsxs("span",{className:"relative inline-flex max-w-64 shrink-0 items-center overflow-hidden",children:[f,_]}),e[16]=f,e[17]=_,e[18]=b):b=e[18];let y;e[19]!==l?(y=l&&i.jsxs("span",{className:"pointer-events-none ml-1.5 flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-border bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[i.jsx(jx,{size:10}),"Enter to go"]}),e[19]=l,e[20]=y):y=e[20];let L;return e[21]!==b||e[22]!==y?(L=i.jsxs(i.Fragment,{children:[b,y]}),e[21]=b,e[22]=y,e[23]=L):L=e[23],L}function RP(t){return t.stopPropagation()}function PP(t,e){const s=new URL(t,window.location.href);return s.searchParams.set("deviceHint",e),s.href}function IP(){const t=kn(),e=St(),{currentBranch:s}=as(),n=w3(),r=de=>{e({to:".",search:je=>({...je,main:de}),replace:!0})},[o,a]=C.useState("preview"),[l,c]=C.useState("desktop"),[d,h]=C.useState(null),u=C.useRef(null),[f,m]=C.useState(!1),[p,g]=C.useState(""),x=C.useRef(null),[v,_]=C.useState(!1),[b,y]=C.useState(),[L,w]=C.useState(null),[S,j]=C.useState(null),[k,V]=C.useState("/"),[T,A]=C.useState(null),[N,E]=C.useState({}),[I,P]=C.useState(!1),R=C.useRef(null),D=()=>{P(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>P(!1),15e3)},M=()=>{R.current&&(clearTimeout(R.current),R.current=null),P(!1)},[F,$]=C.useState(!1),O=t?.entity?.id??null,{org:U}=Ae(),K=Os(),H=dr(),q=H.vmEntry,J=H.previewUrl,G=K.lifecycle.phase,W=G==="running",z=q?.sandboxProviderKind==="user-desktop",X=wg({orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",enabled:z&&W&&!!O&&!!s}),Q=z?X:null,Z=O&&s&&W?{orgSlug:U.slug,virtualMcpId:O,branch:s,previewUrl:J}:null,{data:Y}=Bl(Z,{fetchEnabled:W}),{data:ee}=zl(Z,{fetchEnabled:W}),te=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,ae=iP(te),se=Y?md(Y).sort((de,je)=>de.name.localeCompare(je.name)):[],ie=Y&&ee?pd(Y,ee):[],fe=ai,me=se.filter(de=>{if(!p)return!0;const je=p.toLowerCase();return de.name.toLowerCase().includes(je)||de.path.toLowerCase().includes(je)}),be=ie.filter(de=>{if(!p)return!0;const je=p.toLowerCase();return de.name.toLowerCase().includes(je)||de.key.toLowerCase().includes(je)||de.resolveType.toLowerCase().includes(je)}),_e=L?null:GL(se,k,T),xe=L?L.name:_e?.name,ke=_e?.key??null,Ne=(ke?N[ke]:void 0)??{},we=Sr(k,Ne),ye={};if(W&&J&&ee)for(const de of _0(k)){if(de.type!=="param")continue;const je=de.name,ot=pP(k,je);ot&&_3(ee,Ta[ot],"loaders")&&(ye[je]=ot)}const Be=O&&s?{orgSlug:U.slug,virtualMcpId:O,branch:s}:null,Fe=C.useRef(null),pe=C.useRef(null);db(()=>{const de=u.current,je=Fe.current;!de||!je||(de.src=je)});const Ee=K.status.state==="paused",De=K.phase,ue=o3({claimPhase:De,lifecycle:K.lifecycle}),le=H.previewState,Ve=H.userStopped,Me=le.kind==="starting"||le.kind==="iframe"&&ue.status==="doing",Ue=le.kind==="iframe"?PP(S??new URL(we,le.previewUrl).href,l):null,it=O&&s?uP(U.slug,O,s):null,Yt=de=>{it&&mP(it,de)},Rt=n.state.target;C.useEffect(()=>{if(!(!Rt||!J||!ee))if(Rt.kind==="page"){const de=N[Rt.key]??{};pe.current=Sr(Rt.path,de),w(null),j(null),A(Rt.key),V(Rt.path),Yt({path:Rt.path,pageKey:Rt.key,params:de})}else{const de=ie.find(je=>je.key===Rt.key);if(de){pe.current=null;const je=b0(ee);w(de),j(Lf(J,je,de.key))}}},[Rt,J,ee,N]);const[rt,gt]=C.useState(null);if(le.kind==="iframe"&&rt!==le.previewUrl){const de=rt!==null;gt(le.previewUrl);const je=it?fP(it):null;if(je){if(pe.current=Sr(je.path,je.params),V(je.path),A(je.pageKey),j(null),w(null),je.pageKey&&Object.keys(je.params).length>0){const ot=je.pageKey;E(kt=>({...kt,[ot]:je.params}))}}else de&&(pe.current=null,V("/"),j(null),A(null),w(null))}Fe.current=Ue;const lt=!!O&&!!s&&!K.notFound&&!Ve&&!Ee&&(De?.kind==="ready"||G!=="idle"),wt=le.kind!=="iframe"&&o==="visual"?"preview":o;C.useEffect(()=>{if(!J)return;let de;try{de=new URL(J,window.location.href).origin}catch{return}const je=ot=>{if(ot.origin===de&&ot.data?.type==="visual-editor::element-clicked"){const kt=oP.safeParse(ot.data.payload);kt.success&&h(kt.data)}};return window.addEventListener("message",je),()=>window.removeEventListener("message",je)},[J]),C.useEffect(()=>{if(!f)return;const de=je=>{x.current?.contains(je.target)||(m(!1),g(""))};return document.addEventListener("pointerdown",de),()=>document.removeEventListener("pointerdown",de)},[f]);const ct=()=>{const de=u.current?.contentWindow;de&&de.postMessage({type:"visual-editor::activate",script:aP},"*")},he=()=>{const de=u.current?.contentWindow;de&&de.postMessage({type:"visual-editor::deactivate"},"*")},Oe=de=>{const je=o;a(de),h(null),je==="visual"&&he(),de==="visual"&&ct()},et=()=>{if(!u.current||!Ue)return;const de=u.current;de.src=Ue},tt=()=>{const de=u.current;if(!de)return;const je=document.activeElement,ot=de.tabIndex;de.tabIndex=-1,de.style.pointerEvents="none",de.blur();try{de.contentWindow?.location.reload()}catch{const Nn=Fe.current;Nn&&(de.src=Nn)}const kt=()=>{de.tabIndex=ot,de.style.pointerEvents="",je?.focus(),de.removeEventListener("load",kt)};de.addEventListener("load",kt),setTimeout(kt,3e3)},[vs,us]=C.useState(n.state.previewRevision);C.useEffect(()=>{vs!==n.state.previewRevision&&(us(n.state.previewRevision),tt())},[vs,n.state.previewRevision]);const Jt=()=>{if(!u.current||!Ue)return;const de=Ue.includes("?")?"&":"?";u.current.src=`${Ue}${de}_r=${Date.now()}`},mn=()=>{const de=Uc.indexOf(l);c(Uc[(de+1)%Uc.length])},oe=()=>{const de=u.current?.contentWindow?.location?.href??Ue??J;de&&navigator.clipboard.writeText(de)},Le=(()=>{if(!J)return"No server running";if(L)return L.name;try{const de=new URL(J),je=we==="/"?"":we;return`${de.host}${je}`}catch{return J}})(),Te=de=>{const je=N[de.key]??{},ot=Sr(de.path,je);(L||fe(ot)!==fe(we))&&D(),pe.current=ot,w(null),j(null),A(de.key),V(de.path),Yt({path:de.path,pageKey:de.key,params:je}),n.selectTarget({kind:"page",key:de.key,path:de.path})},$e=(de,je)=>{if(!ke)return;const ot=ke,kt={...Ne,[de]:je};pe.current=Sr(k,kt),E(Nn=>({...Nn,[ot]:kt})),Yt({path:k,pageKey:ot,params:kt})},st=de=>{if(!J||!ee){ce.error("Preview metadata not ready yet");return}D(),pe.current=null;const je=b0(ee),ot=Lf(J,je,de.key);w(de),j(ot),n.selectTarget({kind:"section",key:de.key})},ht=async({name:de,path:je,templateKey:ot})=>{if(!O||!s)return;const kt=ud(je);if(kt){y(kt);return}const Nn=je.trim().startsWith("/")?je.trim():`/${je.trim()}`;if(se.some(An=>fe(An.path)===fe(Nn))){y(`A page with path "${Nn}" already exists.`);return}let hc;if(ot&&(hc=Y?.[ot],!hc)){y("Selected template no longer exists.");return}y(void 0);try{const An=await ae.mutateAsync({name:de,path:Nn,template:hc});_(!1),ce.success(`Page "${de}" created`),await e6(Sf),Te({key:An.key,name:An.name,path:An.path}),e({to:".",search:k4=>({...k4,blocks:1}),replace:!0})}catch(An){y(An instanceof Error?An.message:"Failed to create page")}},Vn=le.kind==="iframe",Qn=de=>Oe(o===de?"preview":de);return i.jsxs("div",{className:"flex flex-col w-full h-full",children:[lt&&le.kind==="iframe"&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center gap-4 border-b border-border/60 px-3 md:px-4",children:le.kind==="iframe"&&i.jsx("div",{className:"flex w-full items-center justify-center",children:i.jsxs("div",{className:"flex w-full max-w-[500px] items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:et,children:i.jsx(zi,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Refresh"})]}),i.jsxs("div",{ref:x,className:"relative min-w-0 flex-1",children:[i.jsxs("div",{className:"flex h-8 w-full min-w-0 items-center rounded-md border border-border bg-background transition-colors duration-200 hover:bg-accent",children:[i.jsxs("div",{className:"flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1 pl-2 pr-1",onClick:()=>m(de=>!de),children:[L&&i.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 rounded bg-global-section/14 px-1.5 py-0.5 text-[11px] font-medium text-global-section-fg dark:text-global-section-fg-dark",children:[i.jsx(on,{size:11}),"Global"]}),i.jsx("span",{className:ne("text-[13px] font-medium text-foreground",xe==null?"min-w-0 flex-1 truncate":"shrink-0"),children:xe??Le}),!L&&xe!=null&&k&&i.jsx("span",{className:"flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap text-[12px] text-muted-foreground",children:_0(k).map((de,je)=>{if(de.type==="text")return i.jsx("span",{className:ne(je===0?"min-w-0 truncate":"shrink-0"),children:de.text},`text-${je}`);const ot=ye[de.name];return ot&&Be?i.jsx(CP,{kind:ot,paramName:de.name,value:Ne[de.name]??"",sandboxRef:Be,onCommit:kt=>$e(de.name,kt)},`${ke}:${de.name}`):i.jsx(EP,{name:de.name,value:Ne[de.name]??"",onCommit:kt=>$e(de.name,kt)},`${ke}:${de.name}`)})})]}),i.jsx("button",{type:"button",className:"flex h-full shrink-0 items-center pl-1 pr-2",onClick:()=>m(de=>!de),"aria-label":"Choose page",children:i.jsx(Ht,{size:12,className:ne("shrink-0 text-muted-foreground transition-transform",f&&"rotate-180")})})]}),f&&i.jsxs("div",{className:"absolute left-0 right-0 top-full z-50 mt-1.5 overflow-hidden rounded-lg border bg-popover shadow-lg",children:[i.jsxs("div",{className:"px-2 h-10 flex items-center gap-2 border-b",children:[i.jsx(K9,{size:14,className:"shrink-0 text-muted-foreground","aria-hidden":!0}),i.jsx("input",{type:"text",value:p,onChange:de=>g(de.target.value),placeholder:"Search pages and components...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),i.jsx("div",{className:"p-1.5 border-b",children:i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:de=>{de.preventDefault(),m(!1),g(""),y(void 0),_(!0)},children:[i.jsx(Lt,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"flex-1 font-medium",children:"Create new page"})]})}),me.length===0&&be.length===0?i.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:se.length===0&&ie.length===0?"No pages found in this site.":"No results match your search."}):i.jsxs("div",{className:"max-h-80 overflow-y-auto overscroll-contain",children:[me.length>0&&i.jsx("div",{className:"p-1.5",children:me.map(de=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),Te(de)},children:[i.jsx(Dn,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:de.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:de.path})]},de.key))}),be.length>0&&i.jsxs("div",{className:ne("p-1.5",me.length>0&&"border-t"),children:[i.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground",children:"Global components"}),be.map(de=>i.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",onMouseDown:je=>{je.preventDefault(),m(!1),g(""),st(de)},children:[i.jsx(on,{size:16,className:"shrink-0 text-muted-foreground"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:de.name}),i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:de.resolveType.split("/").pop()?.replace(/\.tsx?$/,"")})]},de.key))]})]})]})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:()=>{const de=Ue??le.previewUrl;de&&window.open(de,"_blank","noopener")},children:i.jsx(wn,{size:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in new tab"})]}),i.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center md:right-4",children:i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",children:i.jsx(Gn,{size:14})})}),i.jsxs(ts,{align:"end",className:"w-44",children:[i.jsx(He,{onClick:Jt,children:"Hard Reload"}),i.jsx(He,{onClick:oe,children:"Copy Current URL"}),Y&&ee&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),ke&&i.jsxs(He,{onClick:()=>{n.editSeo({kind:"page",key:ke,path:k}),e({to:".",search:de=>({...de,blocks:1}),replace:!0})},children:[i.jsx(Ua,{size:14}),"Edit SEO"]}),ke&&i.jsxs(He,{onClick:()=>{try{r(Lv(tv(ke)))}catch{ce.error("Invalid page block key")}},children:[i.jsx(To,{size:14}),"View JSON"]}),i.jsxs(He,{onClick:()=>$(!0),children:[i.jsx(Ua,{size:14}),"Site SEO"]})]}),Q&&i.jsxs(i.Fragment,{children:[i.jsx(Di,{}),i.jsxs(He,{onClick:()=>window.open(_l("vscode",Q)),children:[i.jsx("img",{src:VP,alt:"VSCode",width:14,height:14}),"Open in VSCode"]}),i.jsxs(He,{onClick:()=>window.open(_l("cursor",Q)),children:[i.jsx("img",{src:NP,alt:"Cursor",width:14,height:14}),"Open in Cursor"]})]})]})]})})]})})}),i.jsx("div",{className:"flex-1 flex overflow-hidden",children:i.jsxs("div",{className:ne("flex-1 relative overflow-hidden",l!=="desktop"&&le.kind==="iframe"&&"flex justify-center bg-muted/30"),children:[I&&le.kind==="iframe"&&i.jsx("div",{className:"absolute inset-x-0 top-0 z-40 h-0.5 overflow-hidden bg-primary/15",children:i.jsx("div",{className:"absolute inset-y-0 w-2/5 rounded-full bg-primary animate-preview-nav"})}),Me&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"starting",progress:ue,claimPhase:De})}),le.kind==="suspended"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"suspended",onResume:H.resume})}),le.kind==="errored"&&i.jsx("div",{className:"absolute inset-0 z-30",children:i.jsx(Bi,{kind:"errored",error:le.error,onRetry:H.retry,connectionsHref:`/${U.slug}/settings/connections`})}),wt==="visual"&&!d&&i.jsxs("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 flex items-center gap-1.5 rounded-full border border-violet-400/40 bg-violet-500/90 px-3 py-1 text-xs font-medium text-white shadow-md backdrop-blur-sm pointer-events-none select-none",children:[i.jsx(Su,{size:12}),"Click any element to ask the AI"]}),wt==="visual"&&d&&i.jsx(dP,{element:d,onDismiss:()=>h(null)}),Vn&&i.jsx("div",{className:"absolute bottom-4 left-1/2 z-20 -translate-x-1/2",children:i.jsxs("div",{className:"flex items-center gap-0.5 rounded-full border bg-background/90 p-1 shadow-lg backdrop-blur-sm",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Vu,{onClick:()=>Qn("visual"),"aria-pressed":o==="visual","aria-label":"Visual editor",active:o==="visual",children:i.jsx(Su,{size:16})})}),i.jsx(Pe,{side:"top",children:"Visual editor"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Vu,{onClick:mn,"aria-label":wf[l],children:i.jsxs("span",{className:"flex items-center justify-center animate-device-icon-pop",children:[l==="mobile"&&i.jsx(Lx,{size:16}),l==="tablet"&&i.jsx(Sx,{size:16}),l==="desktop"&&i.jsx(wx,{size:16})]},l)})}),i.jsx(Pe,{side:"top",children:wf[l]})]})]})}),le.kind==="iframe"&&Ue&&i.jsx("div",{className:ne("h-full transition-[width] duration-250 [transition-timing-function:var(--ease-in-out-cubic)]",l!=="desktop"&&"w-full max-w-full border-x border-border bg-background shadow-sm"),style:{width:l==="desktop"?"100%":`${TP[l]}px`},children:i.jsx("iframe",{ref:u,src:Ue,className:"w-full h-full border-0",title:"Dev Server Preview",onLoad:()=>{if(M(),Ce("vm_preview_loaded",{view_mode:o,vm_id:q?.sandboxHandle??null}),!L)try{const de=u.current?.contentWindow?.location?.pathname;if(!de)return;const je=pe.current;if(je!==null&&(pe.current=null,fe(de)!==fe(je))||fe(de)===fe(we))return;V(de),Yt({path:de,pageKey:T,params:Ne})}catch{}o==="visual"&&ct()}},le.previewUrl)})]})}),i.jsx(rP,{open:v,onOpenChange:_,isPending:ae.isPending,error:b,templates:se,onSubmit:ht}),F&&Y&&ee&&i.jsx(C.Suspense,{fallback:null,children:i.jsx(AP,{open:F,onOpenChange:$,orgSlug:U.slug,virtualMcpId:O??"",branch:s??"",decofile:Y,meta:ee,onSaved:()=>{setTimeout(()=>{const de=u.current;if(de)try{de.contentWindow?.location.reload()}catch{const je=Fe.current;je&&(de.src=je)}},Sf)},target:{kind:"site"}})})]})}function DP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No source to preview."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Connections tab to enable Preview."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(IP,{}),e[1]=o):o=e[1],o}const MP="https://decoims.com/decocms/01b321bd-4613-4b2c-9348-35058444d210/Visual_Studio_Code_1.35_icon.svg.png",OP="https://decoims.com/decocms/7583d3b5-81d0-4afb-becf-6a59bbb3a68e/cursor-logo-icon-freelogovectors.net_.png",$P=C.lazy(()=>Ws(()=>import("./file-explorer-C0HkCv56.js"),__vite__mapDeps([162,1,2,84,31,28,32,33,34,35,36,37,38,39,29,7,8,3,9,30,40,41,42,43,44,45,46,47,48,49,50,20,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,22,67,4,5,6,10,11,12,13,14,15,16,17,18,19,21,23,24,25,26,27,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,127,123,128,129,126,117,107,108,109,110,111,112,113,114,115,116,118,119,120,121,122,124,125,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.FileExplorer})));function BP(t){const e=B.c(17),{openPath:s}=t,n=kn(),{org:r}=Ae(),{currentBranch:o}=as(),a=n?.entity?.id??null,l=dr(),c=Os(),d=l.vmEntry,h=c.lifecycle.phase==="running",u=d?.sandboxProviderKind==="user-desktop",f=a??"",m=o??"",p=u&&h&&!!a&&!!o;let g;e[0]!==r.slug||e[1]!==f||e[2]!==m||e[3]!==p?(g={orgSlug:r.slug,virtualMcpId:f,branch:m,enabled:p},e[0]=r.slug,e[1]=f,e[2]=m,e[3]=p,e[4]=g):g=e[4];const x=wg(g),v=u?x:null;if(!a||!o){let w;return e[5]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No sandbox to browse."}),e[5]=w):w=e[5],w}let _;e[6]!==v?(_=v&&i.jsx("div",{className:"relative flex h-12 shrink-0 items-center border-b border-border/60 px-3 md:px-4",children:i.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in VSCode",onClick:()=>window.open(_l("vscode",v)),children:i.jsx("img",{src:MP,alt:"VSCode",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in VSCode"})]}),i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon","aria-label":"Open in Cursor",onClick:()=>window.open(_l("cursor",v)),children:i.jsx("img",{src:OP,alt:"Cursor",width:14,height:14})})}),i.jsx(Pe,{side:"bottom",children:"Open in Cursor"})]})]})}),e[6]=v,e[7]=_):_=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsx(qe,{size:20,className:"animate-spin text-muted-foreground"})}),e[8]=b):b=e[8];let y;e[9]!==o||e[10]!==s||e[11]!==r.slug||e[12]!==a?(y=i.jsx("div",{className:"flex-1 relative overflow-hidden bg-background",children:i.jsx(C.Suspense,{fallback:b,children:i.jsx($P,{orgSlug:r.slug,virtualMcpId:a,branch:o,openPath:s})})}),e[9]=o,e[10]=s,e[11]=r.slug,e[12]=a,e[13]=y):y=e[13];let L;return e[14]!==_||e[15]!==y?(L=i.jsxs("div",{className:"flex flex-col w-full h-full",children:[_,y]}),e[14]=_,e[15]=y,e[16]=L):L=e[16],L}function zP(t){const e=B.c(2),{virtualMcpId:s}=t,n=qs(s);if(!bn(n?.metadata)){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground p-6",children:[i.jsx(fn,{size:24,className:"text-muted-foreground/60"}),i.jsx("div",{children:"No content to edit."}),i.jsx("div",{className:"text-xs text-muted-foreground/80",children:"Connect a GitHub repository from the Settings tab to enable Content."})]}),e[0]=a):a=e[0],a}let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(j3,{}),e[1]=o):o=e[1],o}const Hc={fast:{label:"Fast",subtitle:"Quick responses for simple tasks",icon:P9},smart:{label:"Smart",subtitle:"Balanced quality and speed",icon:Bn},thinking:{label:"Thinking",subtitle:"Deeper reasoning for hard tasks",icon:tm}},FP=["fast","smart","thinking"];function UP(t){const e=B.c(15),{tier:s,onSelect:n}=t,[r,o]=C.useState(!1),a=Hc[s].icon;let l;e[0]!==a?(l=i.jsx(a,{size:14,className:"text-muted-foreground"}),e[0]=a,e[1]=l):l=e[1];const c=Hc[s];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[2]=d):d=e[2];let h;e[3]!==l||e[4]!==c.label?(h=i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[l,c.label,d]})}),e[3]=l,e[4]=c.label,e[5]=h):h=e[5];let u;e[6]!==n||e[7]!==s?(u=FP.map(p=>{const g=Hc[p],x=g.icon;return i.jsxs("button",{type:"button",onClick:()=>{n(p),o(!1)},className:ne("flex items-start gap-2 px-2 py-1.5 rounded-md text-left hover:bg-muted"),children:[i.jsx(x,{size:16,className:"shrink-0 text-muted-foreground mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"text-sm",children:g.label}),i.jsx("div",{className:"text-xs text-muted-foreground",children:g.subtitle})]}),p===s&&i.jsx(Tt,{size:14,className:"text-foreground mt-0.5"})]},p)}),e[6]=n,e[7]=s,e[8]=u):u=e[8];let f;e[9]!==u?(f=i.jsx(ks,{align:"start",className:"p-1 w-64",children:i.jsx("div",{className:"flex flex-col",children:u})}),e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==h||e[13]!==f?(m=i.jsxs(Vs,{open:r,onOpenChange:o,children:[h,f]}),e[11]=r,e[12]=h,e[13]=f,e[14]=m):m=e[14],m}function HP(t){const e=B.c(15),{tier:s,onTierChange:n,override:r,onOverrideChange:o}=t,[a,l]=C.useState(r!==null);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Model"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a?(d=a?i.jsx(C.Suspense,{fallback:i.jsx(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:"Loading models…"}),children:i.jsx(KP,{override:r,onOverrideChange:o})}):i.jsx(UP,{tier:s,onSelect:n}),e[1]=o,e[2]=n,e[3]=r,e[4]=s,e[5]=a,e[6]=d):d=e[6];let h;e[7]!==o?(h=m=>{l(m),m||o(null)},e[7]=o,e[8]=h):h=e[8];let u;e[9]!==h||e[10]!==a?(u=i.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(ho,{checked:a,onCheckedChange:h,className:"cursor-pointer"}),"Specific model"]}),e[9]=h,e[10]=a,e[11]=u):u=e[11];let f;return e[12]!==d||e[13]!==u?(f=i.jsxs("div",{className:"flex flex-col gap-2",children:[c,i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[d,u]})]}),e[12]=d,e[13]=u,e[14]=f):f=e[14],f}function KP(t){const e=B.c(10),{override:s,onOverrideChange:n}=t,r=Sm(),o=r[0]?.id??null,[a,l]=C.useState(s?.credentialId??o);let c;e[0]!==s?(c=s?{modelId:s.modelId,title:s.title||s.modelId,keyId:s.credentialId,providerId:"deco",description:null,logo:null,capabilities:[],limits:null,costs:null}:null,e[0]=s,e[1]=c):c=e[1];const d=c;if(r.length===0){let f;return e[2]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Connect an AI provider in settings to pick a specific model."}),e[2]=f):f=e[2],f}let h;e[3]!==a||e[4]!==n?(h=f=>{const m=f.keyId??a??"";l(m),n({modelId:f.modelId,credentialId:m,title:f.title??f.modelId})},e[3]=a,e[4]=n,e[5]=h):h=e[5];let u;return e[6]!==a||e[7]!==d||e[8]!==h?(u=i.jsx("div",{className:"w-fit max-w-full [&_button]:rounded-md",children:i.jsx(Hx,{variant:"bordered",placeholder:"Pick a model",model:d,credentialId:a,onCredentialChange:l,onModelChange:h})}),e[6]=a,e[7]=d,e[8]=h,e[9]=u):u=e[9],u}const jg=[{key:"capabilities",heading:"Built-in capabilities",icon:T9,tools:[{name:"web_search",title:"Web search",description:"Look up current information on the web",icon:Yn},{name:"generate_image",title:"Generate image",description:"Create images from a text prompt",icon:_n},{name:"subtask",title:"Subtask",description:"Spawn a focused sub-agent to handle part of the work",icon:an},{name:"user_ask",title:"Ask the user",description:"Pause to ask the user a clarifying question",icon:Cx}]},{key:"files",heading:"Files & code",icon:hi,tools:[{name:"read",title:"Read File",description:"Read a file from the workspace",icon:Tm},{name:"write",title:"Write File",description:"Create or overwrite a file",icon:A9},{name:"edit",title:"Edit File",description:"Make targeted edits to an existing file",icon:E9},{name:"grep",title:"Search Content",description:"Search file contents by pattern",icon:fo},{name:"glob",title:"Find Files",description:"Find files by name pattern",icon:hi},{name:"bash",title:"Run Command",description:"Run shell commands in the sandbox",icon:kx}]},{key:"context",heading:"Context",icon:Fa,tools:[{name:"read_resource",title:"Read Resource",description:"Read an MCP resource by URI",icon:Fa},{name:"read_prompt",title:"Read Prompt",description:"Read an MCP prompt definition",icon:Ki},{name:"skill",title:"Load Skill",description:"Load a skill's full instructions (SKILL.md) by id",icon:Ki}]},{key:"browser",heading:"Browser",icon:on,tools:[{name:"take_screenshot",title:"Take Screenshot",description:"Capture a screenshot of a web page",icon:ar},{name:"scrape_url",title:"Scrape URL",description:"Fetch and extract content from a URL",icon:on},{name:"inspect_page",title:"Inspect Page",description:"Inspect a web page's structure",icon:To}]}],WP=jg.flatMap(t=>t.tools.map(e=>e.name));function qP(t){const e=t.replace(/[_-]+/g," ").trim();return e?e.toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):t}function GP(t){const e=B.c(5),{agentId:s,value:n,onChange:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Tools"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==r||e[3]!==n?(a=i.jsxs("div",{className:"flex flex-col gap-2",children:[o,s?i.jsx(C.Suspense,{fallback:i.jsxs(re,{variant:"outline",size:"sm",disabled:!0,className:"w-fit",children:[i.jsx(T9,{size:14}),"Loading tools…"]}),children:i.jsx(YP,{agentId:s,value:n,onChange:r})}):i.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Pick an agent first"})]}),e[1]=s,e[2]=r,e[3]=n,e[4]=a):a=e[4],a}function jf(t){const e=B.c(17),{value:s,checked:n,onToggle:r,title:o,description:a,leading:l}=t;let c;e[0]!==n?(c=i.jsx(cr,{checked:n,className:"pointer-events-none mt-0.5"}),e[0]=n,e[1]=c):c=e[1];let d;e[2]!==l?(d=l&&i.jsx("span",{className:"mt-px shrink-0",children:l}),e[2]=l,e[3]=d):d=e[3];let h;e[4]!==o?(h=i.jsx("span",{className:"truncate text-sm leading-tight",children:o}),e[4]=o,e[5]=h):h=e[5];let u;e[6]!==a?(u=a&&i.jsx("span",{className:"line-clamp-2 text-xs leading-snug text-muted-foreground",children:a}),e[6]=a,e[7]=u):u=e[7];let f;e[8]!==h||e[9]!==u?(f=i.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[h,u]}),e[8]=h,e[9]=u,e[10]=f):f=e[10];let m;return e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==f||e[15]!==s?(m=i.jsxs(Ps,{value:s,onSelect:r,className:"items-start gap-2.5 py-2",children:[c,d,f]}),e[11]=r,e[12]=c,e[13]=d,e[14]=f,e[15]=s,e[16]=m):m=e[16],m}function Cf(t){const e=B.c(20),{conn:s,label:n,icon:r,on:o,total:a,onToggle:l}=t,c=o===a;let d;e[0]!==r||e[1]!==s?(d=s?i.jsx(Gs,{icon:s.icon,name:s.title,size:"2xs"}):r?i.jsx(r,{size:14,className:"text-muted-foreground"}):i.jsx(Vx,{size:14,className:"text-muted-foreground"}),e[0]=r,e[1]=s,e[2]=d):d=e[2];const h=s?.title??n??"Other tools";let u;e[3]!==h?(u=i.jsx("span",{className:"truncate",children:h}),e[3]=h,e[4]=u):u=e[4];let f;e[5]!==o||e[6]!==a?(f=i.jsxs("span",{className:"text-[11px] font-normal tabular-nums text-muted-foreground/70",children:[o,"/",a]}),e[5]=o,e[6]=a,e[7]=f):f=e[7];let m;e[8]!==l?(m=_=>{_.stopPropagation(),l()},e[8]=l,e[9]=m):m=e[9];const p=c?"None":"All";let g;e[10]!==m||e[11]!==p?(g=i.jsx("button",{type:"button",onClick:m,className:"text-[11px] font-medium text-primary hover:underline",children:p}),e[10]=m,e[11]=p,e[12]=g):g=e[12];let x;e[13]!==f||e[14]!==g?(x=i.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[f,g]}),e[13]=f,e[14]=g,e[15]=x):x=e[15];let v;return e[16]!==d||e[17]!==u||e[18]!==x?(v=i.jsxs("div",{className:"flex items-center gap-2",children:[d,u,x]}),e[16]=d,e[17]=u,e[18]=x,e[19]=v):v=e[19],v}function YP(t){const e=B.c(70),{agentId:s,value:n,onChange:r}=t,{org:o}=Ae(),[a,l]=C.useState(!1);let c;e[0]!==s||e[1]!==o.id||e[2]!==o.slug?(c={connectionId:s,orgId:o.id,orgSlug:o.slug},e[0]=s,e[1]=o.id,e[2]=o.slug,e[3]=c):c=e[3];const d=pt(c);let h;e[4]!==d?(h={client:d},e[4]=d,e[5]=h):h=e[5];const{data:u,isLoading:f}=G9(h),m=Mo();let p,g,x,v,_,b,y,L,w,S,j,k,V;if(e[6]!==m||e[7]!==u?.tools||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==n){const I=new Map(m.map(eI)),P=new Map;for(const se of u?.tools??[]){const ie=rn(se._meta)??"__other__",fe=rr(se.name,ie==="__other__"?void 0:ie),me=se.title,be=me&&me!==se.name?me:qP(fe);P.has(ie)||P.set(ie,{clientId:ie,conn:I.get(ie),tools:[]}),P.get(ie).tools.push({name:se.name,display:be,description:se.description})}const R=[...P.values()].sort(ZP),D=(u?.tools??[]).map(QP),M=[...WP,...D],F=n===null?new Set(M):new Set(n),$=M.every(se=>F.has(se)),O=se=>r(M.every(ie=>se.has(ie))?null:[...se]),U=se=>{const ie=new Set(F);ie.has(se)?ie.delete(se):ie.add(se),O(ie)},K=(se,ie)=>{const fe=new Set(F);for(const me of se)ie?fe.add(me):fe.delete(me);O(fe)};v=Vs,V=a,_=l;let H;e[25]===Symbol.for("react.memo_cache_sentinel")?(H=i.jsx(T9,{size:14,className:"text-muted-foreground"}),e[25]=H):H=e[25];const q=$?"All tools":"Tools",J=!$&&i.jsxs(t6,{variant:"secondary",className:"ml-0.5 h-5 px-1.5 text-[11px] tabular-nums",children:[F.size,"/",M.length]});let G;e[26]===Symbol.for("react.memo_cache_sentinel")?(G=i.jsx(Ht,{size:14,className:"text-muted-foreground"}),e[26]=G):G=e[26],e[27]!==q||e[28]!==J?(b=i.jsx(Cs,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",className:"w-fit gap-1.5",children:[H,q,J,G]})}),e[27]=q,e[28]=J,e[29]=b):b=e[29],x=ks,j="p-0 w-80",k="start",g=lr,e[30]===Symbol.for("react.memo_cache_sentinel")?(w=i.jsx(yi,{placeholder:"Search tools..."}),e[30]=w):w=e[30];const W=$?`All ${M.length} tools enabled`:`${F.size} of ${M.length} enabled`;let z;e[31]!==W?(z=i.jsx("span",{className:"text-xs text-muted-foreground",children:W}),e[31]=W,e[32]=z):z=e[32];let X;e[33]!==r?(X=()=>r(null),e[33]=r,e[34]=X):X=e[34];let Q;e[35]!==$||e[36]!==X?(Q=i.jsx("button",{type:"button",onClick:X,disabled:$,className:"text-xs font-medium text-primary hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Select all"}),e[35]=$,e[36]=X,e[37]=Q):Q=e[37];let Z;e[38]===Symbol.for("react.memo_cache_sentinel")?(Z=i.jsx("span",{className:"text-muted-foreground/30",children:"·"}),e[38]=Z):Z=e[38];let Y;e[39]!==r?(Y=()=>r([]),e[39]=r,e[40]=Y):Y=e[40];const ee=F.size===0;let te;e[41]!==Y||e[42]!==ee?(te=i.jsx("button",{type:"button",onClick:Y,disabled:ee,className:"text-xs font-medium text-muted-foreground hover:underline disabled:cursor-default disabled:opacity-40 disabled:no-underline",children:"Clear"}),e[41]=Y,e[42]=ee,e[43]=te):te=e[43];let ae;e[44]!==Q||e[45]!==te?(ae=i.jsxs("div",{className:"flex items-center gap-2",children:[Q,Z,te]}),e[44]=Q,e[45]=te,e[46]=ae):ae=e[46],e[47]!==z||e[48]!==ae?(S=i.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[z,ae]}),e[47]=z,e[48]=ae,e[49]=S):S=e[49],p=Si,y="max-h-80",L=f?i.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"Loading tools…"}):i.jsxs(i.Fragment,{children:[i.jsx(Li,{children:"No tools found"}),jg.map(se=>{const ie=se.tools.map(XP),fe=ie.filter(me=>F.has(me)).length;return i.jsx(Fs,{heading:i.jsx(Cf,{label:se.heading,icon:se.icon,on:fe,total:ie.length,onToggle:()=>K(ie,fe!==ie.length)}),children:se.tools.map(me=>i.jsx(jf,{value:`${me.title} ${me.name}`,checked:F.has(me.name),onToggle:()=>U(me.name),title:me.title,description:me.description,leading:i.jsx(me.icon,{size:16,className:"text-muted-foreground"})},me.name))},se.key)}),R.map(se=>{const ie=se.tools.map(JP),fe=ie.filter(me=>F.has(me)).length;return i.jsx(Fs,{heading:i.jsx(Cf,{conn:se.conn,on:fe,total:ie.length,onToggle:()=>K(ie,fe!==ie.length)}),children:se.tools.map(me=>i.jsx(jf,{value:`${me.display} ${me.name} ${se.conn?.title??""}`,checked:F.has(me.name),onToggle:()=>U(me.name),title:me.display,description:me.description},me.name))},se.clientId)})]}),e[6]=m,e[7]=u?.tools,e[8]=f,e[9]=r,e[10]=a,e[11]=n,e[12]=p,e[13]=g,e[14]=x,e[15]=v,e[16]=_,e[17]=b,e[18]=y,e[19]=L,e[20]=w,e[21]=S,e[22]=j,e[23]=k,e[24]=V}else p=e[12],g=e[13],x=e[14],v=e[15],_=e[16],b=e[17],y=e[18],L=e[19],w=e[20],S=e[21],j=e[22],k=e[23],V=e[24];let T;e[50]!==p||e[51]!==y||e[52]!==L?(T=i.jsx(p,{className:y,children:L}),e[50]=p,e[51]=y,e[52]=L,e[53]=T):T=e[53];let A;e[54]!==g||e[55]!==T||e[56]!==w||e[57]!==S?(A=i.jsxs(g,{children:[w,S,T]}),e[54]=g,e[55]=T,e[56]=w,e[57]=S,e[58]=A):A=e[58];let N;e[59]!==x||e[60]!==A||e[61]!==j||e[62]!==k?(N=i.jsx(x,{className:j,align:k,children:A}),e[59]=x,e[60]=A,e[61]=j,e[62]=k,e[63]=N):N=e[63];let E;return e[64]!==v||e[65]!==_||e[66]!==b||e[67]!==N||e[68]!==V?(E=i.jsxs(v,{open:V,onOpenChange:_,children:[b,N]}),e[64]=v,e[65]=_,e[66]=b,e[67]=N,e[68]=V,e[69]=E):E=e[69],E}function JP(t){return t.name}function XP(t){return t.name}function QP(t){return t.name}function ZP(t,e){return(t.conn?.title??t.clientId).localeCompare(e.conn?.title??e.clientId)}function eI(t){return[t.id,t]}function so(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function tI(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return`Every ${n[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const o=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(o){const l=(o[2]??"0").padStart(2,"0"),c=(o[1]??"0").padStart(2,"0");return`Every day at ${l}:${c} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",d=(a[2]??"0").padStart(2,"0"),h=(a[1]??"0").padStart(2,"0");return`Every ${c} at ${d}:${h} UTC`}return t}function sI(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function nI(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const n=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(n)return{count:parseInt(n[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);return r?{count:parseInt(r[1]),unit:"days"}:null}function iI(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const rI=[{label:"5 minutes",cron:"*/5 * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function oI({automationId:t,open:e,onOpenChange:s,onCustomSelect:n,onEventSelect:r,onWebhookCreated:o}){const{triggerAdd:a}=Oo(),[l,c]=C.useState(!1),d=e??l,h=m=>{s?s(m):c(m)},u=async m=>{try{await a.mutateAsync({automation_id:t,type:"cron",cron_expression:m}),ce.success("Starter added"),h(!1)}catch(p){const g=p instanceof Error?p.message:"Failed to add starter";ce.error(g)}},f=async()=>{try{const m=await a.mutateAsync({automation_id:t,type:"webhook"});h(!1),m.webhook?o?.(m.webhook):ce.success("Webhook starter added")}catch(m){const p=m instanceof Error?m.message:"Failed to add webhook starter";ce.error(p)}};return i.jsxs(Zt,{open:d,onOpenChange:h,children:[i.jsx(es,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",children:[i.jsx(Lt,{size:14}),"Add Starter"]})}),i.jsxs(ts,{align:"end",className:"w-[200px]",children:[i.jsxs(oo,{children:[i.jsxs(ao,{className:"gap-2.5",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),i.jsx(lo,{className:"w-[160px]",children:rI.map(m=>i.jsxs(He,{className:"gap-2.5",onSelect:()=>u(m.cron),disabled:a.isPending,children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",m.label]},m.cron))})]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),n?.()},children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),"Custom (cron)"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{h(!1),r?.()},children:[i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),"Event"]}),i.jsxs(He,{className:"gap-2.5",onSelect:()=>{f()},disabled:a.isPending,children:[i.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}),"Webhook"]})]})]})}function Cg(t){const e=B.c(31),{open:s,onOpenChange:n,url:r,token:o,title:a,description:l}=t,c=a===void 0?"Webhook ready":a,d=l===void 0?"Send a POST to this URL with the bearer token to fire the automation. The token is shown once — copy it now.":l,[h,u]=C.useState(null),[f,m]=C.useState("curl"),[p,g]=C.useState("header"),x=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=async(I,P)=>{try{await navigator.clipboard.writeText(I),u(P),ce.success("Copied"),setTimeout(()=>u(null),1500)}catch{ce.error("Failed to copy")}},e[0]=v):v=e[0];const _=v;let b;e[1]!==p||e[2]!==o||e[3]!==r?(b=r&&o&&p==="url"?`${r.replace(/\/$/,"")}/${o}`:r??"",e[1]=p,e[2]=o,e[3]=r,e[4]=b):b=e[4];const y=b,L=r&&o?p==="header"?`curl -X POST "${y}" \\
182
182
  -H "Authorization: Bearer ${o}" \\
183
183
  -H "Content-Type: application/json" \\
184
184
  -d '{"hello":"world"}'`:`curl -X POST "${y}" \\
@@ -197,7 +197,7 @@ ${X}`:X;d.setValue("metadata.instructions",Q,{shouldDirty:!0})},H=new Set(h.map(
197
197
  },
198
198
  body: JSON.stringify({ hello: "world" }),
199
199
  });`:"",S=f==="curl"?L:w;let j;e[5]!==c?(j=i.jsx(is,{children:c}),e[5]=c,e[6]=j):j=e[6];let k;e[7]!==d?(k=i.jsx(qn,{children:d}),e[7]=d,e[8]=k):k=e[8];let V;e[9]!==j||e[10]!==k?(V=i.jsxs(ns,{children:[j,k]}),e[9]=j,e[10]=k,e[11]=V):V=e[11];let T;e[12]!==p||e[13]!==h||e[14]!==y||e[15]!==f||e[16]!==S||e[17]!==o||e[18]!==x||e[19]!==r?(T=r&&o?i.jsxs("div",{className:"flex flex-col gap-3 min-w-0",children:[i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"URL"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:y}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>_(y,"url"),children:[i.jsx(Ss,{size:13}),h==="url"?"Copied":"Copy"]})]})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Token (shown once)"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 min-w-0 text-xs font-mono bg-muted rounded-md px-2 py-1.5 truncate",children:o}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>_(o,"token"),children:[i.jsx(Ss,{size:13}),h==="token"?"Copied":"Copy"]})]})]}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground",children:"Snippet"}),i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ro,{value:f,onValueChange:I=>m(I),children:i.jsxs(El,{className:"h-8 p-[2px]",children:[i.jsx($n,{value:"curl",className:"h-7 px-2.5 text-xs",children:"curl"}),i.jsx($n,{value:"fetch",className:"h-7 px-2.5 text-xs",children:"fetch"})]})}),i.jsxs("label",{htmlFor:x,className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[i.jsx(cr,{id:x,checked:p==="url",onCheckedChange:I=>g(I?"url":"header")}),"Token in URL"]})]}),i.jsxs(re,{size:"sm",variant:"outline",onClick:()=>_(S,"example"),children:[i.jsx(Ss,{size:13}),h==="example"?"Copied":"Copy"]})]}),i.jsx("div",{className:"rounded-md border overflow-hidden min-w-0",children:i.jsx(Ml,{code:S,language:f==="curl"?"shell":"typescript",readOnly:!0,disableDiagnostics:!0,height:180})})]})]}):null,e[12]=p,e[13]=h,e[14]=y,e[15]=f,e[16]=S,e[17]=o,e[18]=x,e[19]=r,e[20]=T):T=e[20];let A;e[21]!==n?(A=i.jsx(_i,{children:i.jsx(re,{onClick:()=>n(!1),children:"Done"})}),e[21]=n,e[22]=A):A=e[22];let N;e[23]!==V||e[24]!==T||e[25]!==A?(N=i.jsxs(Ft,{className:"max-w-lg",children:[V,T,A]}),e[23]=V,e[24]=T,e[25]=A,e[26]=N):N=e[26];let E;return e[27]!==n||e[28]!==s||e[29]!==N?(E=i.jsx(Ut,{open:s,onOpenChange:n,children:N}),e[27]=n,e[28]=s,e[29]=N,e[30]=E):E=e[30],E}function aI(t){const e=B.c(83),{trigger:s,automationId:n,connectionName:r}=t,{triggerAdd:o,triggerRemove:a,triggerRotateToken:l}=Oo(),[c,d]=C.useState(!1),[h,u]=C.useState(!1),[f,m]=C.useState(null);let p;e[0]!==s.cron_expression?(p=s.cron_expression?nI(s.cron_expression):null,e[0]=s.cron_expression,e[1]=p):p=e[1];const g=p,[x,v]=C.useState(g?.count??1),[_,b]=C.useState(!1),[y,L]=C.useState(s.cron_expression??""),w=a.isPending||o.isPending||l.isPending,S=s.type==="cron",j=s.type==="webhook";let k;e[2]!==n||e[3]!==a||e[4]!==s.id?(k=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:n}),ce.success("Starter removed")}catch{ce.error("Failed to remove starter")}d(!1)},e[2]=n,e[3]=a,e[4]=s.id,e[5]=k):k=e[5];const V=k;let T;e[6]!==o||e[7]!==n||e[8]!==y||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(T=async()=>{const ie=y.trim();if(!ie||!so(ie)||ie===s.cron_expression){b(!1),L(s.cron_expression??"");return}try{await o.mutateAsync({automation_id:n,type:"cron",cron_expression:ie}),await a.mutateAsync({trigger_id:s.id,automation_id:n}),b(!1)}catch{ce.error("Failed to update starter"),L(s.cron_expression??""),b(!1)}},e[6]=o,e[7]=n,e[8]=y,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=T):T=e[12];const A=T;let N;e[13]!==n||e[14]!==l||e[15]!==s.id?(N=async()=>{u(!1);try{const ie=await l.mutateAsync({trigger_id:s.id,automation_id:n});m({url:ie.url,token:ie.token})}catch(ie){const fe=ie,me=fe instanceof Error?fe.message:"Failed to rotate token";ce.error(me)}},e[13]=n,e[14]=l,e[15]=s.id,e[16]=N):N=e[16];const E=N;let I;e[17]!==o||e[18]!==n||e[19]!==g||e[20]!==a||e[21]!==s.cron_expression||e[22]!==s.id?(I=async ie=>{if(!g)return;const fe=g.unit==="minutes"?5:1,me=Math.max(fe,ie);me!==ie&&v(me);const be=sI(me,g.unit);if(be!==s.cron_expression)try{await o.mutateAsync({automation_id:n,type:"cron",cron_expression:be}),await a.mutateAsync({trigger_id:s.id,automation_id:n})}catch{ce.error("Failed to update starter"),v(g.count)}},e[17]=o,e[18]=n,e[19]=g,e[20]=a,e[21]=s.cron_expression,e[22]=s.id,e[23]=I):I=e[23];const P=I;let R;e[24]!==S||e[25]!==j?(R=S?i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}):j?i.jsx(Yn,{size:14,className:"text-muted-foreground shrink-0"}):i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),e[24]=S,e[25]=j,e[26]=R):R=e[26];let D;e[27]!==r||e[28]!==x||e[29]!==y||e[30]!==P||e[31]!==A||e[32]!==g||e[33]!==S||e[34]!==_||e[35]!==w||e[36]!==j||e[37]!==s.cron_expression||e[38]!==s.event_type||e[39]!==s.params?(D=g&&S?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),i.jsx("input",{type:"number",min:g.unit==="minutes"?5:1,value:x,onChange:ie=>v(parseInt(ie.target.value)||1),onBlur:()=>P(x),onKeyDown:ie=>{ie.key==="Enter"&&ie.target.blur(),ie.key==="Escape"&&v(g.count)},disabled:w,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),i.jsx("span",{className:"text-sm",children:iI(g.unit,x)})]}):S&&_?i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:y,onChange:ie=>L(ie.target.value),onBlur:A,onKeyDown:ie=>{ie.key==="Enter"&&ie.target.blur(),ie.key==="Escape"&&(b(!1),L(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),y&&!so(y)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):i.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[i.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:S?tI(s.cron_expression??""):j?"Webhook · POST to fire":`${s.event_type}${r?` · ${r}`:""}`}),!S&&!j&&s.params&&Object.keys(s.params).length>0&&i.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(lI).join(", ")})]}),e[27]=r,e[28]=x,e[29]=y,e[30]=P,e[31]=A,e[32]=g,e[33]=S,e[34]=_,e[35]=w,e[36]=j,e[37]=s.cron_expression,e[38]=s.event_type,e[39]=s.params,e[40]=D):D=e[40];let M;e[41]!==w?(M=w&&i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground"}),e[41]=w,e[42]=M):M=e[42];let F;e[43]!==g||e[44]!==S||e[45]!==_||e[46]!==s.cron_expression?(F=S&&!g&&!_&&i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{L(s.cron_expression??""),b(!0)},children:i.jsx(A9,{size:13,className:"text-muted-foreground"})}),e[43]=g,e[44]=S,e[45]=_,e[46]=s.cron_expression,e[47]=F):F=e[47];let $;e[48]!==j?($=j&&i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",title:"Rotate token",onClick:()=>u(!0),children:i.jsx(zi,{size:13,className:"text-muted-foreground"})}),e[48]=j,e[49]=$):$=e[49];let O;e[50]===Symbol.for("react.memo_cache_sentinel")?(O=i.jsx(re,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(!0),children:i.jsx(yn,{size:13,className:"text-muted-foreground"})}),e[50]=O):O=e[50];let U;e[51]!==$||e[52]!==M||e[53]!==F?(U=i.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[M,F,$,O]}),e[51]=$,e[52]=M,e[53]=F,e[54]=U):U=e[54];let K;e[55]!==U||e[56]!==R||e[57]!==D?(K=i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[R,D,U]}),e[55]=U,e[56]=R,e[57]=D,e[58]=K):K=e[58];let H;e[59]===Symbol.for("react.memo_cache_sentinel")?(H=i.jsxs(Ga,{children:[i.jsx(Ya,{children:"Remove Starter"}),i.jsx(Ja,{children:"Are you sure you want to remove this starter?"})]}),e[59]=H):H=e[59];let q;e[60]===Symbol.for("react.memo_cache_sentinel")?(q=i.jsx(Qa,{children:"Cancel"}),e[60]=q):q=e[60];let J;e[61]!==V?(J=i.jsxs(qa,{children:[H,i.jsxs(Xa,{children:[q,i.jsx(Za,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[61]=V,e[62]=J):J=e[62];let G;e[63]!==c||e[64]!==J?(G=i.jsx(Wa,{open:c,onOpenChange:d,children:J}),e[63]=c,e[64]=J,e[65]=G):G=e[65];let W;e[66]===Symbol.for("react.memo_cache_sentinel")?(W=i.jsxs(Ga,{children:[i.jsx(Ya,{children:"Rotate webhook token"}),i.jsx(Ja,{children:"A new token will be generated and the current token will stop working. Any senders using the old token must be updated."})]}),e[66]=W):W=e[66];let z;e[67]===Symbol.for("react.memo_cache_sentinel")?(z=i.jsx(Qa,{children:"Cancel"}),e[67]=z):z=e[67];let X;e[68]!==E?(X=i.jsxs(qa,{children:[W,i.jsxs(Xa,{children:[z,i.jsx(Za,{onClick:E,children:"Rotate"})]})]}),e[68]=E,e[69]=X):X=e[69];let Q;e[70]!==h||e[71]!==X?(Q=i.jsx(Wa,{open:h,onOpenChange:u,children:X}),e[70]=h,e[71]=X,e[72]=Q):Q=e[72];const Z=f!==null;let Y;e[73]===Symbol.for("react.memo_cache_sentinel")?(Y=ie=>{ie||m(null)},e[73]=Y):Y=e[73];const ee=f?.url??null,te=f?.token??null;let ae;e[74]!==Z||e[75]!==ee||e[76]!==te?(ae=i.jsx(Cg,{open:Z,onOpenChange:Y,url:ee,token:te,title:"New webhook token",description:"The previous token has been revoked. Copy the new token now — it will not be shown again."}),e[74]=Z,e[75]=ee,e[76]=te,e[77]=ae):ae=e[77];let se;return e[78]!==K||e[79]!==G||e[80]!==Q||e[81]!==ae?(se=i.jsxs(i.Fragment,{children:[K,G,Q,ae]}),e[78]=K,e[79]=G,e[80]=Q,e[81]=ae,e[82]=se):se=e[82],se}function lI(t){const[e,s]=t;return`${e}: ${s}`}const cI=30;function dI(t,e){switch(e.type){case"accumulate":{const s=t??{start:e.now,fields:new Set,saveCount:0},n=new Set(s.fields);for(const r of e.fields)n.add(r);return{...s,fields:n,saveCount:s.saveCount+1}}case"reset":return null}}function uI(t){const e=B.c(55),{automationId:s,onDone:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const o=Mo(r),[a,l]=C.useState(),[c,d]=C.useState();let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h={},e[1]=h):h=e[1];const[u,f]=C.useState(h),{triggerAdd:m}=Oo(),{data:p,isLoading:g}=s6(a);let x,v,_,b,y,L;if(e[2]!==m||e[3]!==s||e[4]!==a||e[5]!==c||e[6]!==g||e[7]!==n||e[8]!==u||e[9]!==o||e[10]!==p){const j=p?.find(D=>D.type===c);let k;e[17]!==m||e[18]!==s||e[19]!==a||e[20]!==c||e[21]!==n||e[22]!==u?(k=async()=>{if(!(!a||!c))try{await m.mutateAsync({automation_id:s,type:"event",event_type:c,connection_id:a,params:u}),Ce("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:c}),ce.success("Event trigger added"),n()}catch{ce.error("Failed to add event trigger")}},e[17]=m,e[18]=s,e[19]=a,e[20]=c,e[21]=n,e[22]=u,e[23]=k):k=e[23],x=k,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let V,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(ui,{size:14,className:"text-muted-foreground shrink-0"}),V=i.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=V,e[25]=T):(V=e[24],T=e[25]);let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=i.jsx(yn,{size:13}),e[26]=A):A=e[26],e[27]!==n?(_=i.jsxs("div",{className:"flex items-center gap-2",children:[T,V,i.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:n,children:A})]}),e[27]=n,e[28]=_):_=e[28];const N=a??"";let E;e[29]===Symbol.for("react.memo_cache_sentinel")?(E=D=>{l(D),d(void 0),f({})},e[29]=E):E=e[29];let I;e[30]===Symbol.for("react.memo_cache_sentinel")?(I=i.jsx(zt,{className:"w-full",children:i.jsx(Gt,{placeholder:"Select connection..."})}),e[30]=I):I=e[30];let P;e[31]!==o?(P=o.length===0?i.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):o.map(mI),e[31]=o,e[32]=P):P=e[32];let R;e[33]!==P?(R=i.jsx($t,{children:P}),e[33]=P,e[34]=R):R=e[34],e[35]!==N||e[36]!==R?(b=i.jsxs(Bt,{value:N,onValueChange:E,children:[I,R]}),e[35]=N,e[36]=R,e[37]=b):b=e[37],e[38]!==a||e[39]!==c||e[40]!==g||e[41]!==p?(y=a&&i.jsxs(Bt,{value:c??"",onValueChange:D=>{d(D),f({})},children:[i.jsx(zt,{className:"w-full",children:g?i.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[i.jsx(qe,{size:13,className:"animate-spin"}),"Loading events..."]}):i.jsx(Gt,{placeholder:"Select event type...",children:c??"Select event type..."})}),i.jsx($t,{children:p?.map(fI)})]}),e[38]=a,e[39]=c,e[40]=g,e[41]=p,e[42]=y):y=e[42],L=j?.paramsSchema&&Object.keys(j.paramsSchema).length>0&&i.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(j.paramsSchema).map(D=>{const[M,F]=D;return i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsxs("label",{className:"text-xs text-muted-foreground",children:[M,F.description&&i.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",F.description]})]}),F.enum?i.jsxs(Bt,{value:u[M]??"",onValueChange:$=>f(O=>({...O,[M]:$})),children:[i.jsx(zt,{className:"w-full",children:i.jsx(Gt,{placeholder:`Select ${M}...`})}),i.jsx($t,{children:F.enum.map(hI)})]}):i.jsx("input",{type:"text",value:u[M]??"",onChange:$=>f(O=>({...O,[M]:$.target.value})),placeholder:F.description??M,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},M)})}),e[2]=m,e[3]=s,e[4]=a,e[5]=c,e[6]=g,e[7]=n,e[8]=u,e[9]=o,e[10]=p,e[11]=x,e[12]=v,e[13]=_,e[14]=b,e[15]=y,e[16]=L}else x=e[11],v=e[12],_=e[13],b=e[14],y=e[15],L=e[16];let w;e[43]!==m||e[44]!==a||e[45]!==c||e[46]!==x?(w=a&&c&&i.jsx(re,{size:"sm",onClick:x,disabled:m.isPending,children:m.isPending?i.jsx(qe,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=m,e[44]=a,e[45]=c,e[46]=x,e[47]=w):w=e[47];let S;return e[48]!==v||e[49]!==_||e[50]!==b||e[51]!==y||e[52]!==L||e[53]!==w?(S=i.jsxs("div",{className:v,children:[_,b,y,L,w]}),e[48]=v,e[49]=_,e[50]=b,e[51]=y,e[52]=L,e[53]=w,e[54]=S):S=e[54],S}function hI(t){return i.jsx(nt,{value:t,children:t},t)}function fI(t){return i.jsx(nt,{value:t.type,children:i.jsxs("div",{className:"flex flex-col",children:[i.jsx("span",{children:t.type}),i.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function mI(t){return i.jsx(nt,{value:t.id,children:t.title},t.id)}function pI({automationId:t,automation:e,onBack:s,onDelete:n}){const r=e.virtual_mcp_id,{org:o}=Ae(),{update:a,triggerAdd:l,run:c}=Oo(),d=Mo(),h=new Map(d.map(Y=>[Y.id,Y.title])),{openTask:u}=as(),{setChatOpen:f}=No(),{sendMessage:m}=js(),p=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[g,x]=C.useState(p),[v,_]=C.useState(!1),[b,y]=C.useState(!1),[L,w]=C.useState(!1),[S,j]=C.useState(""),[k,V]=C.useState(!1),[T,A]=C.useState(null),[N,E]=C.useState(!1),[I,P]=C.useState(!1),[R,D]=C.useState(!1),M=async()=>{if(N)return;const ee=d5(g).filter(te=>te.type==="text").map(te=>te.text).join(`
200
- `);if(ee.trim()){E(!0);try{X(),Ce("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ee.length}),f(!0),await m({tiptapDoc:O3({managerAgentId:q1.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ee})})}finally{E(!1)}}},F=e.models?.tier??"smart",$=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,O=_9({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:$,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=O.watch("active"),[K,H]=C.useReducer(dI,null),q=()=>{K!==null&&(Ce("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(K.fields),save_count:K.saveCount,edit_duration_ms:Date.now()-K.start}),H({type:"reset"}))},J=async()=>{const Y=O.control._formState.dirtyFields,ee=Object.keys(Y);if(ee.length===0&&!R)return!0;const te=O.getValues(),ae=O.control._defaultValues;O.reset(te,{keepValues:!0});const se=R;D(!1);const ie={tier:te.tier,...te.modelOverride?{modelId:te.modelOverride.modelId,credentialId:te.modelOverride.credentialId,modelTitle:te.modelOverride.title}:{}},fe={id:t,name:te.name,active:te.active,models:ie,tools:te.tools,maxAgentSteps:te.maxAgentSteps,messages:c5(g),temperature:0};try{await a.mutateAsync(fe)}catch{return O.reset(ae,{keepValues:!0}),se&&D(!0),!1}const me=[...ee];return se&&me.push("messages"),H({type:"accumulate",now:Date.now(),fields:me}),z(),!0},{schedule:G,flush:W}=tl({save:J}),{schedule:z,flush:X}=tl({delayMs:3e4,save:async()=>q()});C.useEffect(()=>{const Y=O.watch(()=>G());return()=>Y.unsubscribe()},[]);const Q=Y=>{if(x(Y),!I){P(!0);return}D(!0),G()},Z=async()=>{Ce("automation_test_clicked",{automation_id:t,agent_id:r});const Y=await W();if(X(),!!Y){if(!g){ce.error("No instructions configured for this automation");return}try{const ee=await c.mutateAsync(t);ee.threadId&&(f(!0),u(ee.threadId))}catch{}}};return i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex items-center pb-4 shrink-0",children:i.jsxs(re,{variant:"ghost",size:"sm",onClick:s,children:[i.jsx(Tl,{size:14}),"Back to list"]})}),i.jsxs("div",{className:"flex flex-col gap-8",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx(fs,{control:O.control,name:"name",render:({field:Y})=>i.jsx(Ye,{...Y,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&&i.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:i.jsx(ws,{size:14})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(fs,{control:O.control,name:"active",render:({field:Y})=>i.jsx(ho,{checked:Y.value,onCheckedChange:ee=>{Y.onChange(ee),W()},className:"cursor-pointer"})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),i.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),i.jsx($3,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),i.jsx(oI,{automationId:t,open:v,onOpenChange:_,onCustomSelect:()=>{w(!0),V(!1),j("")},onEventSelect:()=>{V(!0),w(!1)},onWebhookCreated:Y=>{Ce("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),A(Y)}})]}),e.triggers.length===0&&!L?i.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:i.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",i.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:"Add a starter"})," ","to get going."]})}):i.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(Y=>i.jsx(aI,{trigger:Y,automationId:t,connectionName:Y.connection_id?h.get(Y.connection_id):void 0},Y.id))}),L&&i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),i.jsx("input",{type:"text",value:S,onChange:Y=>j(Y.target.value),onBlur:async()=>{const Y=S.trim();if(!(!Y||!so(Y)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:Y}),Ce("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ce.success("Starter added"),w(!1),j("")}catch{ce.error("Failed to add starter")}},onKeyDown:async Y=>{const ee=S.trim();Y.key==="Enter"&&ee&&so(ee)&&Y.target.blur(),Y.key==="Escape"&&(w(!1),j(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!so(S)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),i.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),j("")},children:i.jsx(yn,{size:13})})]}),k&&i.jsx(C.Suspense,{fallback:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:i.jsx(uI,{automationId:t,onDone:()=>V(!1)})}),i.jsx(Cg,{open:T!==null,onOpenChange:Y=>{Y||A(null)},url:T?.url??null,token:T?.token??null})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),i.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:N||!g,onClick:M,children:[i.jsx(Bn,{size:13}),"Improve"]})]}),i.jsx(P2,{tiptapDoc:g,setTiptapDoc:Q,placeholder:"What should this automation do?",children:i.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[i.jsx(I2,{virtualMcpId:r||null,className:"max-h-[45vh]"}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!r,children:[i.jsx(S9,{size:16}),"Test"]})}),i.jsx(Pe,{children:"Test Automation"})]})})]})})]}),i.jsxs(P5,{open:b,onOpenChange:y,className:"flex flex-col gap-2.5",children:[i.jsxs(I5,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),i.jsx(Ht,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),i.jsxs(D5,{className:"flex flex-col gap-5 pt-0.5",children:[i.jsx(HP,{tier:O.watch("tier"),onTierChange:Y=>O.setValue("tier",Y,{shouldDirty:!0}),override:O.watch("modelOverride"),onOverrideChange:Y=>O.setValue("modelOverride",Y,{shouldDirty:!0})}),i.jsx(GP,{agentId:r||null,value:O.watch("tools"),onChange:Y=>O.setValue("tools",Y,{shouldDirty:!0})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),i.jsx(Ye,{type:"number",min:1,max:100,className:"w-40",placeholder:`${cI} (default)`,value:O.watch("maxAgentSteps")??"",onChange:Y=>{const ee=Y.target.value.trim(),te=ee===""?null:Number(ee);O.setValue("maxAgentSteps",te===null||Number.isNaN(te)?null:te,{shouldDirty:!0})}})]})]})]})]})]})}const kg=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function Vg(t){const e=kg.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function gI(t){const e=B.c(12),{automationId:s,triggerIds:n}=t,[r,o]=C.useState("30d"),[a,l]=C.useState(vI);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=p=>{const g=p;o(g),l(Vg(g))},e[0]=c):c=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(zt,{className:"w-44",children:i.jsx(Gt,{})}),e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx($t,{children:kg.map(xI)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=i.jsx("div",{className:"flex items-center justify-end",children:i.jsxs(Bt,{value:r,onValueChange:c,children:[d,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==n?(f=i.jsx(M5,{automationId:s,triggerIds:n,range:a}),e[5]=s,e[6]=a,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=i.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function xI(t){return i.jsx(nt,{value:t.key,children:t.label},t.key)}function vI(){return Vg("30d")}function _I(t){const e=B.c(5),{tabId:s}=t;let n;e[0]!==s?(n=Cm(s),e[0]=s,e[1]=n):n=e[1];const r=n;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(pi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=i.jsx(C.Suspense,{fallback:o,children:i.jsx(bI,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function bI(t){const e=B.c(24),{id:s}=t,n=St(),{data:r,isLoading:o}=n6(s),[a,l]=C.useState("settings");let c;e[0]!==n?(c=()=>{n({to:".",search:LI,replace:!0})},e[0]=n,e[1]=c):c=e[1];const d=c;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(pi,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(yI),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Tl,{size:14}),e[6]=f):f=e[6];let m;e[7]!==d?(m=i.jsxs(re,{variant:"ghost",size:"sm",onClick:d,children:[f,"Back to list"]}),e[7]=d,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let x;e[11]!==a?(x=i.jsx(Bm,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,x]}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(_=a==="settings"?i.jsx(pI,{automationId:s,automation:r}):i.jsx(gI,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=_):_=e[20];let b;return e[21]!==v||e[22]!==_?(b=i.jsx(zs,{children:i.jsx(zs.Content,{children:i.jsxs(zs.Body,{children:[v,_]})})}),e[21]=v,e[22]=_,e[23]=b):b=e[23],b}function yI(t){return t.id}function LI(t){return{...t,main:"automations"}}function SI(t){const e=B.c(20),{virtualMcpId:s}=t,n=St(),{data:r}=i6(s),o=r===void 0?[]:r,{create:a}=Oo(),[l,c]=C.useState(""),d=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(d));let u;e[0]!==n?(u=T=>n({to:".",search:A=>({...A,main:"automation:"+T}),replace:!0}),e[0]=n,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ce("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(r6(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Lt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=i.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const x=g,v=zs,_=zs,b=zs;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(zs.Title,{children:"Automations"}),e[6]=y):y=e[6];const L=o.length>0&&i.jsx(X9,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==x||e[8]!==L?(w=i.jsxs("div",{className:"flex flex-col gap-6",children:[y,i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[L,x]})]}),e[7]=x,e[8]=L,e[9]=w):w=e[9];const S=o.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{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:x})}):h.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):i.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(T=>i.jsx(o6,{automation:T,onClick:()=>f(T.id)},T.id))});let j;e[10]!==S||e[11]!==b.Body||e[12]!==w?(j=i.jsxs(b.Body,{children:[w,S]}),e[10]=S,e[11]=b.Body,e[12]=w,e[13]=j):j=e[13];let k;e[14]!==j||e[15]!==_.Content?(k=i.jsx(_.Content,{children:j}),e[14]=j,e[15]=_.Content,e[16]=k):k=e[16];let V;return e[17]!==v||e[18]!==k?(V=i.jsx(v,{children:k}),e[17]=v,e[18]=k,e[19]=V):V=e[19],V}function wI(t){const e=B.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(pi,{}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(C.Suspense,{fallback:n,children:i.jsx(SI,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function jI(t){const e=B.c(37),{file:s,onClose:n}=t;let r,o;e[0]!==s.filename?(r=i.jsx(Gi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=iv(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let c;e[7]!==r||e[8]!==o||e[9]!==l?(c=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Tv,{size:14}),e[11]=d):d=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",asChild:!0,children:i.jsx("a",{href:s.downloadUrl,download:s.filename,children:d})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Pe,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=i.jsxs(Ie,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(wn,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Open in new tab"}),e[23]=x):x=e[23];let v;e[24]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[24]=g,e[25]=v):v=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yn,{size:14}),e[26]=_):_=e[26];let b;e[27]!==n?(b=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:n,children:_})}),e[27]=n,e[28]=b):b=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Pe,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let L;e[30]!==b?(L=i.jsxs(Ie,{children:[b,y]}),e[30]=b,e[31]=L):L=e[31];let w;return e[32]!==v||e[33]!==L||e[34]!==c||e[35]!==f?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,f,v,L]}),e[32]=v,e[33]=L,e[34]=c,e[35]=f,e[36]=w):w=e[36],w}function CI(t){const e=B.c(24),{fileKey:s,taskId:n}=t,r=St(),{data:o,isPending:a}=F1(n);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==r?(d=()=>r({to:".",search:kI,replace:!0}),e[3]=r,e[4]=d):d=e[4];const h=d;if(!c){if(a){let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full w-full bg-background",children:i.jsx(sv,{})}),e[5]=b):b=e[5],b}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=i.jsx(Gi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(re,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=v):v=e[12];let _;return e[13]!==g||e[14]!==v?(_=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,x,v]}),e[13]=g,e[14]=v,e[15]=_):_=e[15],_}let u;e[16]!==c||e[17]!==h?(u=i.jsx(jI,{file:c,onClose:h}),e[16]=c,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==c?(f=i.jsx("div",{className:"relative min-h-0 flex-1",children:i.jsx(nv,{file:c})}),e[19]=c,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=i.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function kI(t){return{...t,main:0}}const Kc="home";function VI(t){const e=B.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(yt,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let r;e[1]!==s?(r=s&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,r]}),e[3]=r,e[4]=o):o=e[4],o}function NI(t){const e=B.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const r=rv(Kc,s,n),o=ov(Kc)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=i.jsx(VI,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=av(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",c=r.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=i.jsx(lv,{volume:Kc,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=i.jsx(cv,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function AI(t){const e=B.c(5),{path:s}=t,n=St();let r;e[0]!==n?(r=()=>n({to:".",search:TI,replace:!0}),e[0]=n,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=i.jsx(dv,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function TI(t){return{...t,main:0}}function EI(){const t=B.c(12),e=St(),[s,n]=C.useState(null),[r,o]=C.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=i.jsx(uv,{onOpenFile:f=>l(Sv(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&i.jsx(hv,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==r?(h=r&&i.jsx(fv,{brandPath:r,onClose:()=>o(null)},r),t[6]=r,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=i.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const kf=C.lazy(()=>Ws(()=>import("./project-app-view-mdWvAUSo.js"),__vite__mapDeps([163,1,2,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,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,132,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppViewContent})));function RI(t){const e=B.c(60),{activeTab:s,virtualMcpId:n,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(eR,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:i.jsx(Wv,{})}),e[1]=L):L=e[1],L}if(wv(s)){let L;return e[2]!==n?(L=i.jsx(ff,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=i.jsx(tP,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=i.jsx(wI,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=i.jsx(DP,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=jv(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=i.jsx(BP,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=i.jsx(zP,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(EI,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=i.jsx(_I,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=Vm(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=i.jsx(NI,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=km(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==r?(L=i.jsx(CI,{fileKey:m.key,taskId:r}),e[25]=m.key,e[26]=r,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=Nm(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=i.jsx(AI,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=Cv(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let V;e[38]!==v.connectionId||e[39]!==v.toolName?(V=T=>T.appId===v.connectionId&&T.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=V):V=e[40],L=a.find(V),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let S;e[41]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(pi,{}),e[41]=S):S=e[41];const j=w?.args;let k;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==j?(k=i.jsx(C.Suspense,{fallback:S,children:i.jsx(kf,{connectionId:v.connectionId,toolName:v.toolName,args:j},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=j,e[46]=k):k=e[46],k}let _;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],_=o.find(L),e[47]=s,e[48]=o,e[49]=_}else _=e[49];const b=_;if(b){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(pi,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==b.id||e[55]!==b.view.appId||e[56]!==b.view.args?(w=i.jsx(C.Suspense,{fallback:L,children:i.jsx(kf,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[53]=s,e[54]=b.id,e[55]=b.view.appId,e[56]=b.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=i.jsx(ff,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function PI(t){const e=B.c(14),{taskId:s,virtualMcpId:n}=t;let r;e[0]!==s||e[1]!==n?(r={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=Yd(r);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(pi,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=i.jsx(C.Suspense,{fallback:d,children:i.jsx(RI,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=i.jsx(ps,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const li="setup";function II(t){const e=B.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const n=s;let r;e[5]!==t?(r=()=>{t.active===li?t.onToggle():t.onSelectTab(li)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===li;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=i.jsx(DI,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==t?(c=t.scriptTabs.map(m=>i.jsx(OI,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=c):c=e[12];let d;e[13]!==n||e[14]!==t.onAddScript?(d=i.jsx($I,{scripts:n,onRun:t.onAddScript}),e[13]=n,e[14]=t.onAddScript,e[15]=d):d=e[15];let h;e[16]!==l||e[17]!==c||e[18]!==d?(h=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,c,d]}),e[16]=l,e[17]=c,e[18]=d,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?i.jsx(BI,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):i.jsx(MI,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function DI(t){const e=B.c(8),{active:s,open:n,onClick:r}=t,o=s&&n,a=s&&n,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let c;e[0]!==l?(c=ne("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Nx,{className:"size-3.5"}),e[2]=d):d=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c?(h=i.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:c,children:[d,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=h):h=e[7],h}function MI(t){const e=B.c(24),{status:s,onStart:n,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[0]=c):c=e[0];let d;return e[1]!==n?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:n,children:[c," Start"]}),e[1]=n,e[2]=d):d=e[2],d}if(s==="suspended"&&a){let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[3]=c):c=e[3];let d;return e[4]!==a?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:a,children:[c," Resume"]}),e[4]=a,e[5]=d):d=e[5],d}if(s==="errored"&&l){let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(zi,{className:"size-3.5"}),e[6]=c):c=e[6];let d;return e[7]!==l?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:l,children:[c," Retry"]}),e[7]=l,e[8]=d):d=e[8],d}if(s==="starting"||s==="running"){const c=s==="running"&&!!o,d=c?"rounded-r-none border-r-0":void 0;let h;e[9]!==d?(h=ne(d),e[9]=d,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(hm,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=i.jsx(Re,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Pe,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=i.jsxs(Ie,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==c?(g=c&&i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(re,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:i.jsx(Ht,{className:"size-3"})})}),i.jsx(ts,{align:"end",children:i.jsxs(He,{onClick:o,children:[i.jsx(zi,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=c,e[20]=g):g=e[20];let x;return e[21]!==p||e[22]!==g?(x=i.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=x):x=e[23],x}return null}function OI(t){const e=B.c(16),{active:s,onClick:n,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ne("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const c=r?"pl-2.5 pr-1":"px-2.5",d=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==c||e[3]!==d?(h=ne("flex h-full items-center",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==n||e[7]!==h?(u=i.jsx("button",{type:"button",onClick:n,className:h,children:o}),e[5]=o,e[6]=n,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&i.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:i.jsx(ms,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=i.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function $I(t){const e=B.c(10),{scripts:s,onRun:n}=t,[r,o]=C.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Cs,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"sm","aria-label":"Run script",children:i.jsx(Lt,{className:"size-3.5"})})})}),i.jsx(Pe,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==s?(c=s.length===0?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>i.jsxs("button",{type:"button",onClick:()=>{o(!1),n(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=n,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==c?(d=i.jsxs(ks,{align:"start",className:"p-1 w-56",children:[l,c]}),e[5]=c,e[6]=d):d=e[6];let h;return e[7]!==r||e[8]!==d?(h=i.jsxs(Vs,{open:r,onOpenChange:o,children:[a,d]}),e[7]=r,e[8]=d,e[9]=h):h=e[9],h}function BI(t){const e=B.c(13),{isRunning:s,isKilling:n,onRun:r,onStop:o}=t;if(n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[i.jsx(qe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(fi,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=i.jsx(Re,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(hm,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=i.jsx(Re,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Pe,{children:"Stop process"}),e[10]=c):c=e[10];let d;return e[11]!==l?(d=i.jsxs(Ie,{children:[l,c]}),e[11]=l,e[12]=d):d=e[12],d}var Ng=Object.defineProperty,zI=Object.getOwnPropertyDescriptor,FI=(t,e)=>{for(var s in e)Ng(t,s,{get:e[s],enumerable:!0})},_t=(t,e,s,n)=>{for(var r=n>1?void 0:n?zI(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(e,s,r):a(r))||r);return n&&r&&Ng(e,s,r),r},Se=(t,e)=>(s,n)=>e(s,n,t),Vf="Terminal input",P0={get:()=>Vf,set:t=>Vf=t},Nf="Too much output to announce, navigate to rows manually to read",I0={get:()=>Nf,set:t=>Nf=t};function UI(t){return t.replace(/\r?\n/g,"\r")}function HI(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function KI(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function WI(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Ag(r,e,s,n)}}function Ag(t,e,s,n){t=UI(t),t=HI(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Tg(t,e,s){let n=s.getBoundingClientRect(),r=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function Af(t,e,s,n,r){Tg(t,e,s),r&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function In(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function lc(t,e=0,s=t.length){let n="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var qI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},GI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=r,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(r=t[u++],r<128)e[n++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},Eg="",On=" ",Go=class Rg{constructor(){this.fg=0,this.bg=0,this.extended=new bl}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new Rg;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},bl=class Pg{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Pg(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Is=class Ig extends Go{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new bl,this.combinedData=""}static fromCharData(e){let s=new Ig;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?In(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Tf="di$target",D0="di$dependencies",Wc=new Map;function YI(t){return t[D0]||[]}function Kt(t){if(Wc.has(t))return Wc.get(t);let e=function(s,n,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");JI(e,s,r)};return e._id=t,Wc.set(t,e),e}function JI(t,e,s){e[Tf]===e?e[D0].push({id:t,index:s}):(e[D0]=[{id:t,index:s}],e[Tf]=e)}var cs=Kt("BufferService"),Dg=Kt("CoreMouseService"),ki=Kt("CoreService"),XI=Kt("CharsetService"),au=Kt("InstantiationService"),Mg=Kt("LogService"),ds=Kt("OptionsService"),Og=Kt("OscLinkService"),QI=Kt("UnicodeService"),Yo=Kt("DecorationService"),M0=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],r=this._optionsService.rawOptions.linkHandler,o=new Is,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):ZI(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};M0=_t([Se(0,cs),Se(1,ds),Se(2,Og)],M0);function ZI(t,e){if(confirm(`Do you want to navigate to ${e}?
200
+ `);if(ee.trim()){E(!0);try{X(),Ce("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:ee.length}),f(!0),await m({tiptapDoc:O3({managerAgentId:q1.AUTOMATION_MANAGER(o.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:ee})})}finally{E(!1)}}},F=e.models?.tier??"smart",$=e.models?.modelId&&e.models?.credentialId?{modelId:e.models.modelId,credentialId:e.models.credentialId,title:e.models.modelTitle??e.models.modelId}:null,O=_9({defaultValues:{name:e.name,active:e.active,tier:F,modelOverride:$,tools:e.tools??null,maxAgentSteps:e.maxAgentSteps??null}}),U=O.watch("active"),[K,H]=C.useReducer(dI,null),q=()=>{K!==null&&(Ce("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(K.fields),save_count:K.saveCount,edit_duration_ms:Date.now()-K.start}),H({type:"reset"}))},J=async()=>{const Y=O.control._formState.dirtyFields,ee=Object.keys(Y);if(ee.length===0&&!R)return!0;const te=O.getValues(),ae=O.control._defaultValues;O.reset(te,{keepValues:!0});const se=R;D(!1);const ie={tier:te.tier,...te.modelOverride?{modelId:te.modelOverride.modelId,credentialId:te.modelOverride.credentialId,modelTitle:te.modelOverride.title}:{}},fe={id:t,name:te.name,active:te.active,models:ie,tools:te.tools,maxAgentSteps:te.maxAgentSteps,messages:c5(g),temperature:0};try{await a.mutateAsync(fe)}catch{return O.reset(ae,{keepValues:!0}),se&&D(!0),!1}const me=[...ee];return se&&me.push("messages"),H({type:"accumulate",now:Date.now(),fields:me}),z(),!0},{schedule:G,flush:W}=tl({save:J}),{schedule:z,flush:X}=tl({delayMs:3e4,save:async()=>q()});C.useEffect(()=>{const Y=O.watch(()=>G());return()=>Y.unsubscribe()},[]);const Q=Y=>{if(x(Y),!I){P(!0);return}D(!0),G()},Z=async()=>{Ce("automation_test_clicked",{automation_id:t,agent_id:r});const Y=await W();if(X(),!!Y){if(!g){ce.error("No instructions configured for this automation");return}try{const ee=await c.mutateAsync(t);ee.threadId&&(f(!0),u(ee.threadId))}catch{}}};return i.jsxs(i.Fragment,{children:[s&&i.jsx("div",{className:"flex items-center pb-4 shrink-0",children:i.jsxs(re,{variant:"ghost",size:"sm",onClick:s,children:[i.jsx(Tl,{size:14}),"Back to list"]})}),i.jsxs("div",{className:"flex flex-col gap-8",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4",children:[i.jsx(fs,{control:O.control,name:"name",render:({field:Y})=>i.jsx(Ye,{...Y,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&&i.jsx(re,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:n,children:i.jsx(ws,{size:14})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(fs,{control:O.control,name:"active",render:({field:Y})=>i.jsx(ho,{checked:Y.value,onCheckedChange:ee=>{Y.onChange(ee),W()},className:"cursor-pointer"})}),i.jsx("span",{className:"text-sm text-muted-foreground",children:U?"Active":"Inactive"}),i.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),i.jsx($3,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),i.jsx(oI,{automationId:t,open:v,onOpenChange:_,onCustomSelect:()=>{w(!0),V(!1),j("")},onEventSelect:()=>{V(!0),w(!1)},onWebhookCreated:Y=>{Ce("automation_trigger_added",{automation_id:t,trigger_type:"webhook"}),A(Y)}})]}),e.triggers.length===0&&!L?i.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:i.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",i.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>_(!0),children:"Add a starter"})," ","to get going."]})}):i.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(Y=>i.jsx(aI,{trigger:Y,automationId:t,connectionName:Y.connection_id?h.get(Y.connection_id):void 0},Y.id))}),L&&i.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[i.jsx(Wr,{size:14,className:"text-muted-foreground shrink-0"}),i.jsx("input",{type:"text",value:S,onChange:Y=>j(Y.target.value),onBlur:async()=>{const Y=S.trim();if(!(!Y||!so(Y)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:Y}),Ce("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),ce.success("Starter added"),w(!1),j("")}catch{ce.error("Failed to add starter")}},onKeyDown:async Y=>{const ee=S.trim();Y.key==="Enter"&&ee&&so(ee)&&Y.target.blur(),Y.key==="Escape"&&(w(!1),j(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),S&&!so(S)&&i.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),i.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{w(!1),j("")},children:i.jsx(yn,{size:13})})]}),k&&i.jsx(C.Suspense,{fallback:i.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[i.jsx(qe,{size:13,className:"animate-spin text-muted-foreground"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:i.jsx(uI,{automationId:t,onDone:()=>V(!1)})}),i.jsx(Cg,{open:T!==null,onOpenChange:Y=>{Y||A(null)},url:T?.url??null,token:T?.token??null})]}),i.jsxs("div",{className:"flex flex-col gap-2.5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),i.jsxs(re,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:N||!g,onClick:M,children:[i.jsx(Bn,{size:13}),"Improve"]})]}),i.jsx(P2,{tiptapDoc:g,setTiptapDoc:Q,placeholder:"What should this automation do?",children:i.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[i.jsx(I2,{virtualMcpId:r||null,className:"max-h-[45vh]"}),i.jsx("div",{className:"@container/chat-bottom flex items-center justify-end gap-1.5 p-2.5",children:i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsxs(re,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:Z,disabled:!r,children:[i.jsx(S9,{size:16}),"Test"]})}),i.jsx(Pe,{children:"Test Automation"})]})})]})})]}),i.jsxs(P5,{open:b,onOpenChange:y,className:"flex flex-col gap-2.5",children:[i.jsxs(I5,{className:"group flex w-fit cursor-pointer items-center gap-1.5",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Advanced"}),i.jsx(Ht,{size:14,className:"text-muted-foreground/60 transition-transform group-data-[state=open]:rotate-180"})]}),i.jsxs(D5,{className:"flex flex-col gap-5 pt-0.5",children:[i.jsx(HP,{tier:O.watch("tier"),onTierChange:Y=>O.setValue("tier",Y,{shouldDirty:!0}),override:O.watch("modelOverride"),onOverrideChange:Y=>O.setValue("modelOverride",Y,{shouldDirty:!0})}),i.jsx(GP,{agentId:r||null,value:O.watch("tools"),onChange:Y=>O.setValue("tools",Y,{shouldDirty:!0})}),i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Max steps"}),i.jsx(Ye,{type:"number",min:1,max:100,className:"w-40",placeholder:`${cI} (default)`,value:O.watch("maxAgentSteps")??"",onChange:Y=>{const ee=Y.target.value.trim(),te=ee===""?null:Number(ee);O.setValue("maxAgentSteps",te===null||Number.isNaN(te)?null:te,{shouldDirty:!0})}})]})]})]})]})]})}const kg=[{key:"24h",label:"Last 24 hours",ms:1440*60*1e3},{key:"7d",label:"Last 7 days",ms:10080*60*1e3},{key:"30d",label:"Last 30 days",ms:720*60*60*1e3}];function Vg(t){const e=kg.find(n=>n.key===t).ms,s=Date.now();return{startDate:new Date(s-e).toISOString(),endDate:new Date(s).toISOString()}}function gI(t){const e=B.c(12),{automationId:s,triggerIds:n}=t,[r,o]=C.useState("30d"),[a,l]=C.useState(vI);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=p=>{const g=p;o(g),l(Vg(g))},e[0]=c):c=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(zt,{className:"w-44",children:i.jsx(Gt,{})}),e[1]=d):d=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx($t,{children:kg.map(xI)}),e[2]=h):h=e[2];let u;e[3]!==r?(u=i.jsx("div",{className:"flex items-center justify-end",children:i.jsxs(Bt,{value:r,onValueChange:c,children:[d,h]})}),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==s||e[6]!==a||e[7]!==n?(f=i.jsx(M5,{automationId:s,triggerIds:n,range:a}),e[5]=s,e[6]=a,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=i.jsxs("div",{className:"flex flex-col gap-5",children:[u,f]}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function xI(t){return i.jsx(nt,{value:t.key,children:t.label},t.key)}function vI(){return Vg("30d")}function _I(t){const e=B.c(5),{tabId:s}=t;let n;e[0]!==s?(n=Cm(s),e[0]=s,e[1]=n):n=e[1];const r=n;if(!r)return null;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsx(pi,{}),e[2]=o):o=e[2];let a;return e[3]!==r.id?(a=i.jsx(C.Suspense,{fallback:o,children:i.jsx(bI,{id:r.id})}),e[3]=r.id,e[4]=a):a=e[4],a}function bI(t){const e=B.c(24),{id:s}=t,n=St(),{data:r,isLoading:o}=n6(s),[a,l]=C.useState("settings");let c;e[0]!==n?(c=()=>{n({to:".",search:LI,replace:!0})},e[0]=n,e[1]=c):c=e[1];const d=c;if(o){let y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(pi,{}),e[2]=y):y=e[2],y}if(!r){let y;return e[3]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=y):y=e[3],y}let h;e[4]!==r.triggers?(h=r.triggers.map(yI),e[4]=r.triggers,e[5]=h):h=e[5];const u=h;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Tl,{size:14}),e[6]=f):f=e[6];let m;e[7]!==d?(m=i.jsxs(re,{variant:"ghost",size:"sm",onClick:d,children:[f,"Back to list"]}),e[7]=d,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=[{id:"settings",label:"Settings"},{id:"runs",label:"Runs"}],e[9]=p):p=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=y=>l(y),e[10]=g):g=e[10];let x;e[11]!==a?(x=i.jsx(Bm,{tabs:p,activeTab:a,onTabChange:g}),e[11]=a,e[12]=x):x=e[12];let v;e[13]!==m||e[14]!==x?(v=i.jsxs("div",{className:"flex items-center justify-between pb-4 shrink-0",children:[m,x]}),e[13]=m,e[14]=x,e[15]=v):v=e[15];let _;e[16]!==r||e[17]!==s||e[18]!==a||e[19]!==u?(_=a==="settings"?i.jsx(pI,{automationId:s,automation:r}):i.jsx(gI,{automationId:s,triggerIds:u}),e[16]=r,e[17]=s,e[18]=a,e[19]=u,e[20]=_):_=e[20];let b;return e[21]!==v||e[22]!==_?(b=i.jsx(zs,{children:i.jsx(zs.Content,{children:i.jsxs(zs.Body,{children:[v,_]})})}),e[21]=v,e[22]=_,e[23]=b):b=e[23],b}function yI(t){return t.id}function LI(t){return{...t,main:"automations"}}function SI(t){const e=B.c(20),{virtualMcpId:s}=t,n=St(),{data:r}=i6(s),o=r===void 0?[]:r,{create:a}=Oo(),[l,c]=C.useState(""),d=l.toLowerCase(),h=o.filter(T=>T.name.toLowerCase().includes(d));let u;e[0]!==n?(u=T=>n({to:".",search:A=>({...A,main:"automation:"+T}),replace:!0}),e[0]=n,e[1]=u):u=e[1];const f=u,m=async()=>{if(a.isPending)return;Ce("automation_new_clicked",{virtual_mcp_id:s,existing_count:o.length});const T=await a.mutateAsync(r6(s));f(T.id)};let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Lt,{size:14}),e[2]=p):p=e[2];let g;e[3]!==a.isPending||e[4]!==m?(g=i.jsxs(re,{size:"sm",onClick:m,disabled:a.isPending,children:[p,"New automation"]}),e[3]=a.isPending,e[4]=m,e[5]=g):g=e[5];const x=g,v=zs,_=zs,b=zs;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(zs.Title,{children:"Automations"}),e[6]=y):y=e[6];const L=o.length>0&&i.jsx(X9,{value:l,onChange:c,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let w;e[7]!==x||e[8]!==L?(w=i.jsxs("div",{className:"flex flex-col gap-6",children:[y,i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[L,x]})]}),e[7]=x,e[8]=L,e[9]=w):w=e[9];const S=o.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{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:x})}):h.length===0?i.jsx("div",{className:"flex items-center justify-center py-20",children:i.jsx(qi,{image:i.jsx(ui,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):i.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:h.map(T=>i.jsx(o6,{automation:T,onClick:()=>f(T.id)},T.id))});let j;e[10]!==S||e[11]!==b.Body||e[12]!==w?(j=i.jsxs(b.Body,{children:[w,S]}),e[10]=S,e[11]=b.Body,e[12]=w,e[13]=j):j=e[13];let k;e[14]!==j||e[15]!==_.Content?(k=i.jsx(_.Content,{children:j}),e[14]=j,e[15]=_.Content,e[16]=k):k=e[16];let V;return e[17]!==v||e[18]!==k?(V=i.jsx(v,{children:k}),e[17]=v,e[18]=k,e[19]=V):V=e[19],V}function wI(t){const e=B.c(3),{virtualMcpId:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(pi,{}),e[0]=n):n=e[0];let r;return e[1]!==s?(r=i.jsx(C.Suspense,{fallback:n,children:i.jsx(SI,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}function jI(t){const e=B.c(37),{file:s,onClose:n}=t;let r,o;e[0]!==s.filename?(r=i.jsx(Gi,{filename:s.filename,className:"h-4.5 w-3.5 shrink-0"}),o=i.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:s.filename}),e[0]=s.filename,e[1]=r,e[2]=o):(r=e[1],o=e[2]);let a;e[3]!==s.size?(a=iv(s.size),e[3]=s.size,e[4]=a):a=e[4];let l;e[5]!==a?(l=i.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:a}),e[5]=a,e[6]=l):l=e[6];let c;e[7]!==r||e[8]!==o||e[9]!==l?(c=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2",children:[r,o,l]}),e[7]=r,e[8]=o,e[9]=l,e[10]=c):c=e[10];let d;e[11]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Tv,{size:14}),e[11]=d):d=e[11];let h;e[12]!==s.downloadUrl||e[13]!==s.filename?(h=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",asChild:!0,children:i.jsx("a",{href:s.downloadUrl,download:s.filename,children:d})})}),e[12]=s.downloadUrl,e[13]=s.filename,e[14]=h):h=e[14];let u;e[15]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(Pe,{side:"bottom",children:"Download"}),e[15]=u):u=e[15];let f;e[16]!==h?(f=i.jsxs(Ie,{children:[h,u]}),e[16]=h,e[17]=f):f=e[17];let m;e[18]!==s.downloadUrl?(m=()=>window.open(s.downloadUrl,"_blank","noopener"),e[18]=s.downloadUrl,e[19]=m):m=e[19];let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(wn,{size:14}),e[20]=p):p=e[20];let g;e[21]!==m?(g=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:m,children:p})}),e[21]=m,e[22]=g):g=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx(Pe,{side:"bottom",children:"Open in new tab"}),e[23]=x):x=e[23];let v;e[24]!==g?(v=i.jsxs(Ie,{children:[g,x]}),e[24]=g,e[25]=v):v=e[25];let _;e[26]===Symbol.for("react.memo_cache_sentinel")?(_=i.jsx(yn,{size:14}),e[26]=_):_=e[26];let b;e[27]!==n?(b=i.jsx(Re,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"icon",onClick:n,children:_})}),e[27]=n,e[28]=b):b=e[28];let y;e[29]===Symbol.for("react.memo_cache_sentinel")?(y=i.jsx(Pe,{side:"bottom",children:"Close"}),e[29]=y):y=e[29];let L;e[30]!==b?(L=i.jsxs(Ie,{children:[b,y]}),e[30]=b,e[31]=L):L=e[31];let w;return e[32]!==v||e[33]!==L||e[34]!==c||e[35]!==f?(w=i.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-border/60 px-2",children:[c,f,v,L]}),e[32]=v,e[33]=L,e[34]=c,e[35]=f,e[36]=w):w=e[36],w}function CI(t){const e=B.c(24),{fileKey:s,taskId:n}=t,r=St(),{data:o,isPending:a}=F1(n);let l;e[0]!==s||e[1]!==o?(l=o?.find(p=>p.key===s)??null,e[0]=s,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==r?(d=()=>r({to:".",search:kI,replace:!0}),e[3]=r,e[4]=d):d=e[4];const h=d;if(!c){if(a){let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i.jsx("div",{className:"h-full w-full bg-background",children:i.jsx(sv,{})}),e[5]=b):b=e[5],b}let p;e[6]!==s?(p=s.split("/").pop()??s,e[6]=s,e[7]=p):p=e[7];let g;e[8]!==p?(g=i.jsx(Gi,{filename:p,className:"h-7.5 w-6"}),e[8]=p,e[9]=g):g=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=i.jsx("span",{className:"text-sm text-muted-foreground",children:"This file is no longer available."}),e[10]=x):x=e[10];let v;e[11]!==h?(v=i.jsx(re,{variant:"ghost",size:"sm",onClick:h,children:"Close"}),e[11]=h,e[12]=v):v=e[12];let _;return e[13]!==g||e[14]!==v?(_=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background",children:[g,x,v]}),e[13]=g,e[14]=v,e[15]=_):_=e[15],_}let u;e[16]!==c||e[17]!==h?(u=i.jsx(jI,{file:c,onClose:h}),e[16]=c,e[17]=h,e[18]=u):u=e[18];let f;e[19]!==c?(f=i.jsx("div",{className:"relative min-h-0 flex-1",children:i.jsx(nv,{file:c})}),e[19]=c,e[20]=f):f=e[20];let m;return e[21]!==u||e[22]!==f?(m=i.jsxs("div",{className:"flex h-full w-full flex-col bg-background",children:[u,f]}),e[21]=u,e[22]=f,e[23]=m):m=e[23],m}function kI(t){return{...t,main:0}}const Kc="home";function VI(t){const e=B.c(5),{label:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(yt,{className:"aspect-video w-2/3 max-w-xl"}),e[0]=n):n=e[0];let r;e[1]!==s?(r=s&&i.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e[1]=s,e[2]=r):r=e[2];let o;return e[3]!==r?(o=i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-background",children:[n,r]}),e[3]=r,e[4]=o):o=e[4],o}function NI(t){const e=B.c(15),{path:s}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n={refetchIntervalWhenAbsent:2e3},e[0]=n):n=e[0];const r=rv(Kc,s,n),o=ov(Kc)(s);if(r.isPending||!r.data){const f=!r.isPending&&!r.data?"Waiting for the deck to sync…":void 0;let m;return e[1]!==f?(m=i.jsx(VI,{label:f}),e[1]=f,e[2]=m):m=e[2],m}let a;e[3]!==r.data?(a=av(r.data),e[3]=r.data,e[4]=a):a=e[4];const l=r.data.shareMode??"private",c=r.data.effectivePublic??!1,d=window.location.origin+o;let h;e[5]!==s||e[6]!==l||e[7]!==c||e[8]!==d?(h=i.jsx(lv,{volume:Kc,path:s,shareMode:l,effectivePublic:c,url:d}),e[5]=s,e[6]=l,e[7]=c,e[8]=d,e[9]=h):h=e[9];let u;return e[10]!==s||e[11]!==o||e[12]!==a||e[13]!==h?(u=i.jsx(cv,{readUrl:o,marker:a,title:s,savePath:s,trailing:h}),e[10]=s,e[11]=o,e[12]=a,e[13]=h,e[14]=u):u=e[14],u}function AI(t){const e=B.c(5),{path:s}=t,n=St();let r;e[0]!==n?(r=()=>n({to:".",search:TI,replace:!0}),e[0]=n,e[1]=r):r=e[1];const o=r;let a;return e[2]!==o||e[3]!==s?(a=i.jsx(dv,{previewPath:s,onClose:o,showSeeInLibrary:!0}),e[2]=o,e[3]=s,e[4]=a):a=e[4],a}function TI(t){return{...t,main:0}}function EI(){const t=B.c(12),e=St(),[s,n]=C.useState(null),[r,o]=C.useState(null);let a;t[0]!==e?(a=f=>e({to:".",search:m=>({...m,main:f}),replace:!0}),t[0]=e,t[1]=a):a=t[1];const l=a;let c;t[2]!==l?(c=i.jsx(uv,{onOpenFile:f=>l(Sv(f)),onOpenSkill:n,onOpenBrand:o}),t[2]=l,t[3]=c):c=t[3];let d;t[4]!==s?(d=s&&i.jsx(hv,{skillPath:s,onClose:()=>n(null)},s),t[4]=s,t[5]=d):d=t[5];let h;t[6]!==r?(h=r&&i.jsx(fv,{brandPath:r,onClose:()=>o(null)},r),t[6]=r,t[7]=h):h=t[7];let u;return t[8]!==c||t[9]!==d||t[10]!==h?(u=i.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[c,d,h]}),t[8]=c,t[9]=d,t[10]=h,t[11]=u):u=t[11],u}const kf=C.lazy(()=>Ws(()=>import("./project-app-view-BBJU6aKw.js"),__vite__mapDeps([163,1,2,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,3,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,132,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148])).then(t=>({default:t.AppViewContent})));function RI(t){const e=B.c(60),{activeTab:s,virtualMcpId:n,taskId:r,layoutTabs:o,expandedTools:a,automationTabParsed:l}=t;if(s==="overview"){let L;return e[0]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(eR,{}),e[0]=L):L=e[0],L}if(s==="board"){let L;return e[1]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:i.jsx(Wv,{})}),e[1]=L):L=e[1],L}if(wv(s)){let L;return e[2]!==n?(L=i.jsx(ff,{virtualMcpId:n}),e[2]=n,e[3]=L):L=e[3],L}if(s==="git"){let L;return e[4]!==n?(L=i.jsx(tP,{virtualMcpId:n}),e[4]=n,e[5]=L):L=e[5],L}if(s==="automations"){let L;return e[6]!==n?(L=i.jsx(wI,{virtualMcpId:n}),e[6]=n,e[7]=L):L=e[7],L}if(s==="preview"){let L;return e[8]!==n?(L=i.jsx(DP,{virtualMcpId:n}),e[8]=n,e[9]=L):L=e[9],L}let c;e[10]!==s?(c=jv(s),e[10]=s,e[11]=c):c=e[11];const d=c;if(d){let L;return e[12]!==d.path?(L=i.jsx(BP,{openPath:d.path}),e[12]=d.path,e[13]=L):L=e[13],L}if(s==="content"){let L;return e[14]!==n?(L=i.jsx(zP,{virtualMcpId:n}),e[14]=n,e[15]=L):L=e[15],L}if(s==="files"){let L;return e[16]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(EI,{}),e[16]=L):L=e[16],L}if(l){let L;return e[17]!==s?(L=i.jsx(_I,{tabId:s}),e[17]=s,e[18]=L):L=e[18],L}let h;e[19]!==s?(h=Vm(s),e[19]=s,e[20]=h):h=e[20];const u=h;if(u){let L;return e[21]!==u.path?(L=i.jsx(NI,{path:u.path},u.path),e[21]=u.path,e[22]=L):L=e[22],L}let f;e[23]!==s?(f=km(s),e[23]=s,e[24]=f):f=e[24];const m=f;if(m){let L;return e[25]!==m.key||e[26]!==r?(L=i.jsx(CI,{fileKey:m.key,taskId:r}),e[25]=m.key,e[26]=r,e[27]=L):L=e[27],L}let p;e[28]!==s?(p=Nm(s),e[28]=s,e[29]=p):p=e[29];const g=p;if(g){let L;return e[30]!==g.path?(L=i.jsx(AI,{path:g.path},g.path),e[30]=g.path,e[31]=L):L=e[31],L}let x;e[32]!==s?(x=Cv(s),e[32]=s,e[33]=x):x=e[33];const v=x;if(v){let L;if(e[34]!==a||e[35]!==v.connectionId||e[36]!==v.toolName){let V;e[38]!==v.connectionId||e[39]!==v.toolName?(V=T=>T.appId===v.connectionId&&T.toolName===v.toolName,e[38]=v.connectionId,e[39]=v.toolName,e[40]=V):V=e[40],L=a.find(V),e[34]=a,e[35]=v.connectionId,e[36]=v.toolName,e[37]=L}else L=e[37];const w=L;let S;e[41]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsx(pi,{}),e[41]=S):S=e[41];const j=w?.args;let k;return e[42]!==s||e[43]!==v.connectionId||e[44]!==v.toolName||e[45]!==j?(k=i.jsx(C.Suspense,{fallback:S,children:i.jsx(kf,{connectionId:v.connectionId,toolName:v.toolName,args:j},s)}),e[42]=s,e[43]=v.connectionId,e[44]=v.toolName,e[45]=j,e[46]=k):k=e[46],k}let _;if(e[47]!==s||e[48]!==o){let L;e[50]!==s?(L=w=>w.id===s,e[50]=s,e[51]=L):L=e[51],_=o.find(L),e[47]=s,e[48]=o,e[49]=_}else _=e[49];const b=_;if(b){let L;e[52]===Symbol.for("react.memo_cache_sentinel")?(L=i.jsx(pi,{}),e[52]=L):L=e[52];let w;return e[53]!==s||e[54]!==b.id||e[55]!==b.view.appId||e[56]!==b.view.args?(w=i.jsx(C.Suspense,{fallback:L,children:i.jsx(kf,{connectionId:b.view.appId,toolName:b.id,args:b.view.args},s)}),e[53]=s,e[54]=b.id,e[55]=b.view.appId,e[56]=b.view.args,e[57]=w):w=e[57],w}let y;return e[58]!==n?(y=i.jsx(ff,{virtualMcpId:n}),e[58]=n,e[59]=y):y=e[59],y}function PI(t){const e=B.c(14),{taskId:s,virtualMcpId:n}=t;let r;e[0]!==s||e[1]!==n?(r={virtualMcpId:n,taskId:s},e[0]=s,e[1]=n,e[2]=r):r=e[2];const{activeTab:o,layoutTabs:a,expandedTools:l,automationTabParsed:c}=Yd(r);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(pi,{}),e[3]=d):d=e[3];let h;e[4]!==o||e[5]!==c||e[6]!==l||e[7]!==a||e[8]!==s||e[9]!==n?(h=i.jsx(C.Suspense,{fallback:d,children:i.jsx(RI,{activeTab:o,virtualMcpId:n,taskId:s,layoutTabs:a,expandedTools:l,automationTabParsed:c})}),e[4]=o,e[5]=c,e[6]=l,e[7]=a,e[8]=s,e[9]=n,e[10]=h):h=e[10];let u;return e[11]!==o||e[12]!==h?(u=i.jsx(ps,{children:h},o),e[11]=o,e[12]=h,e[13]=u):u=e[13],u}const li="setup";function II(t){const e=B.c(35);let s;if(e[0]!==t.scriptTabs||e[1]!==t.scripts){let m;e[3]!==t.scriptTabs?(m=p=>!t.scriptTabs.includes(p),e[3]=t.scriptTabs,e[4]=m):m=e[4],s=t.scripts.filter(m),e[0]=t.scriptTabs,e[1]=t.scripts,e[2]=s}else s=e[2];const n=s;let r;e[5]!==t?(r=()=>{t.active===li?t.onToggle():t.onSelectTab(li)},e[5]=t,e[6]=r):r=e[6];const o=r,a=t.active===li;let l;e[7]!==o||e[8]!==t.open||e[9]!==a?(l=i.jsx(DI,{active:a,open:t.open,onClick:o}),e[7]=o,e[8]=t.open,e[9]=a,e[10]=l):l=e[10];let c;e[11]!==t?(c=t.scriptTabs.map(m=>i.jsx(OI,{active:t.active===m,onClick:()=>{t.active===m?t.onToggle():t.onSelectTab(m)},onClose:()=>t.onCloseScript(m),children:m},m)),e[11]=t,e[12]=c):c=e[12];let d;e[13]!==n||e[14]!==t.onAddScript?(d=i.jsx($I,{scripts:n,onRun:t.onAddScript}),e[13]=n,e[14]=t.onAddScript,e[15]=d):d=e[15];let h;e[16]!==l||e[17]!==c||e[18]!==d?(h=i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:[l,c,d]}),e[16]=l,e[17]=c,e[18]=d,e[19]=h):h=e[19];let u;e[20]!==t.onRestart||e[21]!==t.onResume||e[22]!==t.onRetry||e[23]!==t.onRunActiveScript||e[24]!==t.onStart||e[25]!==t.onStop||e[26]!==t.onStopActiveScript||e[27]!==t.scriptIsKilling||e[28]!==t.scriptIsRunning||e[29]!==t.showScriptControls||e[30]!==t.status?(u=t.showScriptControls?i.jsx(BI,{isRunning:t.scriptIsRunning,isKilling:t.scriptIsKilling,onRun:t.onRunActiveScript,onStop:t.onStopActiveScript}):i.jsx(MI,{status:t.status,onStart:t.onStart,onStop:t.onStop,onRestart:t.onRestart,onResume:t.onResume,onRetry:t.onRetry}),e[20]=t.onRestart,e[21]=t.onResume,e[22]=t.onRetry,e[23]=t.onRunActiveScript,e[24]=t.onStart,e[25]=t.onStop,e[26]=t.onStopActiveScript,e[27]=t.scriptIsKilling,e[28]=t.scriptIsRunning,e[29]=t.showScriptControls,e[30]=t.status,e[31]=u):u=e[31];let f;return e[32]!==h||e[33]!==u?(f=i.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-t border-b border-border bg-muted/60 px-3",children:[h,u]}),e[32]=h,e[33]=u,e[34]=f):f=e[34],f}function DI(t){const e=B.c(8),{active:s,open:n,onClick:r}=t,o=s&&n,a=s&&n,l=s?"border-border bg-background font-medium text-foreground shadow-sm":"border-transparent text-muted-foreground hover:bg-background/50 hover:text-foreground";let c;e[0]!==l?(c=ne("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs",l),e[0]=l,e[1]=c):c=e[1];let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i.jsx(Nx,{className:"size-3.5"}),e[2]=d):d=e[2];let h;return e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==c?(h=i.jsxs("button",{type:"button","aria-pressed":o,"aria-expanded":a,onClick:r,className:c,children:[d,"sandbox"]}),e[3]=r,e[4]=o,e[5]=a,e[6]=c,e[7]=h):h=e[7],h}function MI(t){const e=B.c(24),{status:s,onStart:n,onStop:r,onRestart:o,onResume:a,onRetry:l}=t;if(s==="idle"&&n){let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[0]=c):c=e[0];let d;return e[1]!==n?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:n,children:[c," Start"]}),e[1]=n,e[2]=d):d=e[2],d}if(s==="suspended"&&a){let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(fi,{className:"size-3.5"}),e[3]=c):c=e[3];let d;return e[4]!==a?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:a,children:[c," Resume"]}),e[4]=a,e[5]=d):d=e[5],d}if(s==="errored"&&l){let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(zi,{className:"size-3.5"}),e[6]=c):c=e[6];let d;return e[7]!==l?(d=i.jsxs(re,{variant:"outline",size:"sm",onClick:l,children:[c," Retry"]}),e[7]=l,e[8]=d):d=e[8],d}if(s==="starting"||s==="running"){const c=s==="running"&&!!o,d=c?"rounded-r-none border-r-0":void 0;let h;e[9]!==d?(h=ne(d),e[9]=d,e[10]=h):h=e[10];let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=i.jsx(hm,{className:"size-3.5"}),e[11]=u):u=e[11];let f;e[12]!==r||e[13]!==h?(f=i.jsx(Re,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:r,className:h,children:[u," Stop"]})}),e[12]=r,e[13]=h,e[14]=f):f=e[14];let m;e[15]===Symbol.for("react.memo_cache_sentinel")?(m=i.jsx(Pe,{children:"Stop sandbox"}),e[15]=m):m=e[15];let p;e[16]!==f?(p=i.jsxs(Ie,{children:[f,m]}),e[16]=f,e[17]=p):p=e[17];let g;e[18]!==o||e[19]!==c?(g=c&&i.jsxs(Zt,{children:[i.jsx(es,{asChild:!0,children:i.jsx(re,{variant:"outline",size:"sm",className:"rounded-l-none px-1",children:i.jsx(Ht,{className:"size-3"})})}),i.jsx(ts,{align:"end",children:i.jsxs(He,{onClick:o,children:[i.jsx(zi,{className:"size-3.5"})," Restart"]})})]}),e[18]=o,e[19]=c,e[20]=g):g=e[20];let x;return e[21]!==p||e[22]!==g?(x=i.jsxs("div",{className:"flex items-center",children:[p,g]}),e[21]=p,e[22]=g,e[23]=x):x=e[23],x}return null}function OI(t){const e=B.c(16),{active:s,onClick:n,onClose:r,children:o}=t,a=s?"border-border bg-background shadow-sm":"border-transparent hover:bg-background/50";let l;e[0]!==a?(l=ne("flex h-7 items-center rounded-md border text-xs",a),e[0]=a,e[1]=l):l=e[1];const c=r?"pl-2.5 pr-1":"px-2.5",d=s?"font-medium text-foreground":"text-muted-foreground hover:text-foreground";let h;e[2]!==c||e[3]!==d?(h=ne("flex h-full items-center",c,d),e[2]=c,e[3]=d,e[4]=h):h=e[4];let u;e[5]!==o||e[6]!==n||e[7]!==h?(u=i.jsx("button",{type:"button",onClick:n,className:h,children:o}),e[5]=o,e[6]=n,e[7]=h,e[8]=u):u=e[8];let f;e[9]!==o||e[10]!==r?(f=r&&i.jsx("button",{type:"button","aria-label":`Close ${o}`,onClick:r,className:"pr-1.5 text-muted-foreground hover:text-foreground",children:i.jsx(ms,{className:"size-3"})}),e[9]=o,e[10]=r,e[11]=f):f=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==f?(m=i.jsxs("div",{className:l,children:[u,f]}),e[12]=l,e[13]=u,e[14]=f,e[15]=m):m=e[15],m}function $I(t){const e=B.c(10),{scripts:s,onRun:n}=t,[r,o]=C.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsxs(Ie,{children:[i.jsx(Re,{asChild:!0,children:i.jsx(Cs,{asChild:!0,children:i.jsx(re,{variant:"ghost",size:"sm","aria-label":"Run script",children:i.jsx(Lt,{className:"size-3.5"})})})}),i.jsx(Pe,{children:"Run script"})]}),e[0]=a):a=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wide text-muted-foreground",children:"run a script"}),e[1]=l):l=e[1];let c;e[2]!==n||e[3]!==s?(c=s.length===0?i.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No scripts found"}):s.map(u=>i.jsxs("button",{type:"button",onClick:()=>{o(!1),n(u)},className:"w-full rounded-md px-2 py-1.5 text-left text-xs hover:bg-accent",children:["▸ ",u]},u)),e[2]=n,e[3]=s,e[4]=c):c=e[4];let d;e[5]!==c?(d=i.jsxs(ks,{align:"start",className:"p-1 w-56",children:[l,c]}),e[5]=c,e[6]=d):d=e[6];let h;return e[7]!==r||e[8]!==d?(h=i.jsxs(Vs,{open:r,onOpenChange:o,children:[a,d]}),e[7]=r,e[8]=d,e[9]=h):h=e[9],h}function BI(t){const e=B.c(13),{isRunning:s,isKilling:n,onRun:r,onStop:o}=t;if(n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[i.jsx(qe,{className:"size-3.5 animate-spin"})," Stopping…"]}),e[0]=h):h=e[0],h}if(!s){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=i.jsx(fi,{className:"size-3.5"}),e[1]=h):h=e[1];let u;e[2]!==r?(u=i.jsx(Re,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:r,children:[h," Run"]})}),e[2]=r,e[3]=u):u=e[3];let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=i.jsx(Pe,{children:"Start process"}),e[4]=f):f=e[4];let m;return e[5]!==u?(m=i.jsxs(Ie,{children:[u,f]}),e[5]=u,e[6]=m):m=e[6],m}let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=i.jsx(hm,{className:"size-3.5"}),e[7]=a):a=e[7];let l;e[8]!==o?(l=i.jsx(Re,{asChild:!0,children:i.jsxs(re,{variant:"outline",size:"sm",onClick:o,children:[a," Stop"]})}),e[8]=o,e[9]=l):l=e[9];let c;e[10]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsx(Pe,{children:"Stop process"}),e[10]=c):c=e[10];let d;return e[11]!==l?(d=i.jsxs(Ie,{children:[l,c]}),e[11]=l,e[12]=d):d=e[12],d}var Ng=Object.defineProperty,zI=Object.getOwnPropertyDescriptor,FI=(t,e)=>{for(var s in e)Ng(t,s,{get:e[s],enumerable:!0})},_t=(t,e,s,n)=>{for(var r=n>1?void 0:n?zI(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(e,s,r):a(r))||r);return n&&r&&Ng(e,s,r),r},Se=(t,e)=>(s,n)=>e(s,n,t),Vf="Terminal input",P0={get:()=>Vf,set:t=>Vf=t},Nf="Too much output to announce, navigate to rows manually to read",I0={get:()=>Nf,set:t=>Nf=t};function UI(t){return t.replace(/\r?\n/g,"\r")}function HI(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function KI(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function WI(t,e,s,n){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Ag(r,e,s,n)}}function Ag(t,e,s,n){t=UI(t),t=HI(t,s.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(t,!0),e.value=""}function Tg(t,e,s){let n=s.getBoundingClientRect(),r=t.clientX-n.left-10,o=t.clientY-n.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${o}px`,e.style.zIndex="1000",e.focus()}function Af(t,e,s,n,r){Tg(t,e,s),r&&n.rightClickSelect(t),e.value=n.selectionText,e.select()}function In(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function lc(t,e=0,s=t.length){let n="";for(let r=e;r<s;++r){let o=t[r];o>65535?(o-=65536,n+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):n+=String.fromCharCode(o)}return n}var qI=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r=0;if(this._interim){let o=t.charCodeAt(r++);56320<=o&&o<=57343?e[n++]=(this._interim-55296)*1024+o-56320+65536:(e[n++]=this._interim,e[n++]=o),this._interim=0}for(let o=r;o<s;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,n;let l=t.charCodeAt(o);56320<=l&&l<=57343?e[n++]=(a-55296)*1024+l-56320+65536:(e[n++]=a,e[n++]=l);continue}a!==65279&&(e[n++]=a)}return n}},GI=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let s=t.length;if(!s)return 0;let n=0,r,o,a,l,c=0,d=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)m<<=6,m|=g;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=x-p;for(;d<v;){if(d>=s)return 0;if(g=t[d++],(g&192)!==128){d--,f=!0;break}else this.interim[p++]=g,m<<=6,m|=g&63}f||(x===2?m<128?d--:e[n++]=m:x===3?m<2048||m>=55296&&m<=57343||m===65279||(e[n++]=m):m<65536||m>1114111||(e[n++]=m)),this.interim.fill(0)}let h=s-4,u=d;for(;u<s;){for(;u<h&&!((r=t[u])&128)&&!((o=t[u+1])&128)&&!((a=t[u+2])&128)&&!((l=t[u+3])&128);)e[n++]=r,e[n++]=o,e[n++]=a,e[n++]=l,u+=4;if(r=t[u++],r<128)e[n++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}e[n++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;e[n++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,n;if(o=t[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,n;if(a=t[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,n;if(l=t[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;e[n++]=c}}return n}},Eg="",On=" ",Go=class Rg{constructor(){this.fg=0,this.bg=0,this.extended=new bl}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new Rg;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},bl=class Pg{constructor(e=0,s=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Pg(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Is=class Ig extends Go{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new bl,this.combinedData=""}static fromCharData(e){let s=new Ig;return s.setFromCharData(e),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?In(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let s=!1;if(e[1].length>2)s=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:s=!0}else s=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;s&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Tf="di$target",D0="di$dependencies",Wc=new Map;function YI(t){return t[D0]||[]}function Kt(t){if(Wc.has(t))return Wc.get(t);let e=function(s,n,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");JI(e,s,r)};return e._id=t,Wc.set(t,e),e}function JI(t,e,s){e[Tf]===e?e[D0].push({id:t,index:s}):(e[D0]=[{id:t,index:s}],e[Tf]=e)}var cs=Kt("BufferService"),Dg=Kt("CoreMouseService"),ki=Kt("CoreService"),XI=Kt("CharsetService"),au=Kt("InstantiationService"),Mg=Kt("LogService"),ds=Kt("OptionsService"),Og=Kt("OscLinkService"),QI=Kt("UnicodeService"),Yo=Kt("DecorationService"),M0=class{constructor(t,e,s){this._bufferService=t,this._optionsService=e,this._oscLinkService=s}provideLinks(t,e){let s=this._bufferService.buffer.lines.get(t-1);if(!s){e(void 0);return}let n=[],r=this._optionsService.rawOptions.linkHandler,o=new Is,a=s.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<a;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,l=o.extended.urlId;continue}else d=o.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let f={start:{x:c+1,y:t},end:{x:h+(!d&&h===a-1?1:0),y:t}},m=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(u);["http:","https:"].includes(p.protocol)||(m=!0)}catch{m=!0}m||n.push({text:u,range:f,activate:(p,g)=>r?r.activate(p,g,f):ZI(p,g),hover:(p,g)=>r?.hover?.(p,g,f),leave:(p,g)=>r?.leave?.(p,g,f)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,l=o.extended.urlId):(c=-1,l=-1)}}e(n)}};M0=_t([Se(0,cs),Se(1,ds),Se(2,Og)],M0);function ZI(t,e){if(confirm(`Do you want to navigate to ${e}?
201
201
 
202
202
  WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var cc=Kt("CharSizeService"),jn=Kt("CoreBrowserService"),lu=Kt("MouseService"),Cn=Kt("RenderService"),eD=Kt("SelectionService"),$g=Kt("CharacterJoinerService"),_r=Kt("ThemeService"),Bg=Kt("LinkProviderService"),tD=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Ef.isErrorNoTelemetry(t)?new Ef(t.message+`
203
203