decocms 4.364.0 → 4.364.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/dist/client/assets/{AlertCircle-EniJtD8E.js → AlertCircle-CfOItn1b.js} +1 -1
  2. package/dist/client/assets/{AreaChart-DZpAPo6a.js → AreaChart-B9tk92oC.js} +1 -1
  3. package/dist/client/assets/{ArrowLeft-Clu1mSdY.js → ArrowLeft-B4kTLC80.js} +1 -1
  4. package/dist/client/assets/{ArrowRight-Cu8UuHNR.js → ArrowRight-B4GAIQKI.js} +1 -1
  5. package/dist/client/assets/{ArrowUp-C0eratGp.js → ArrowUp-Be_FwN-E.js} +1 -1
  6. package/dist/client/assets/{Check-BWpBE9uf.js → Check-_wGz2-IJ.js} +1 -1
  7. package/dist/client/assets/{CheckCircle-cinYKmPU.js → CheckCircle-BQEdmdLU.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-DzRB-rdO.js → ChevronRight-DfnK-irb.js} +1 -1
  9. package/dist/client/assets/{ChevronSelectorVertical-BiIbFU31.js → ChevronSelectorVertical-DTb5009V.js} +1 -1
  10. package/dist/client/assets/{ChevronUp-DGrguvGW.js → ChevronUp-SbK1Bh_A.js} +1 -1
  11. package/dist/client/assets/{Copy01-DayLu0dF.js → Copy01-DoHw-_s5.js} +1 -1
  12. package/dist/client/assets/{CreditCard01-4OsjIT5f.js → CreditCard01-CkbbYVCy.js} +1 -1
  13. package/dist/client/assets/{Database01-2gG_9E30.js → Database01-DDqP2OWW.js} +1 -1
  14. package/dist/client/assets/{DotsVertical-CucJCL9y.js → DotsVertical-Ct2yI8vr.js} +1 -1
  15. package/dist/client/assets/{Download01-BC2rKbuh.js → Download01-IytcAces.js} +1 -1
  16. package/dist/client/assets/{ErrorBarContext-CRh7XbJc.js → ErrorBarContext-Cgip1CtP.js} +1 -1
  17. package/dist/client/assets/{Eye-dnrP5DkM.js → Eye-Ccu8gsxq.js} +1 -1
  18. package/dist/client/assets/{File02-BhckHV8N.js → File02-CODRlzC9.js} +1 -1
  19. package/dist/client/assets/{GitBranch01-BBn4dN5f.js → GitBranch01-y6_LtrpC.js} +1 -1
  20. package/dist/client/assets/{Globe01-SLAc63wC.js → Globe01-BHsBANMN.js} +1 -1
  21. package/dist/client/assets/{HardDrive-FlnOYA_8.js → HardDrive-Cr2Uhzo6.js} +1 -1
  22. package/dist/client/assets/{Image01-BrHSH-Vi.js → Image01-PUenBySa.js} +1 -1
  23. package/dist/client/assets/{Key01-CKcg8G1v.js → Key01-ugSjw0sl.js} +1 -1
  24. package/dist/client/assets/{Link01-3t9JrUgl.js → Link01-CUXePRyB.js} +1 -1
  25. package/dist/client/assets/{LinkExternal01-Cp7uxK1i.js → LinkExternal01-DLDyK_TN.js} +1 -1
  26. package/dist/client/assets/{Monitor01-BUruMK2r.js → Monitor01-J9g_ep-X.js} +1 -1
  27. package/dist/client/assets/{Package-CdfyZYxN.js → Package-Dm9TBHk7.js} +1 -1
  28. package/dist/client/assets/{Palette-CglyAOTg.js → Palette-BywMlwsu.js} +1 -1
  29. package/dist/client/assets/{Play-rnw1eV52.js → Play-HfzzXB20.js} +1 -1
  30. package/dist/client/assets/{Plus-Bxp02MWl.js → Plus-zXs3aP31.js} +1 -1
  31. package/dist/client/assets/{Printer-fz_zwxfT.js → Printer-kkmv6XzS.js} +1 -1
  32. package/dist/client/assets/{SearchLg-FC9suxna.js → SearchLg-BkMCmJSN.js} +1 -1
  33. package/dist/client/assets/{SearchMd-DRRptSJN.js → SearchMd-uhtNwnF8.js} +1 -1
  34. package/dist/client/assets/{Sector-CJIPfQ5Z.js → Sector-DNcwKKFv.js} +1 -1
  35. package/dist/client/assets/{Settings02-D2oiGU4q.js → Settings02-DPUnnUpS.js} +1 -1
  36. package/dist/client/assets/{Share07-D_kiq5Fr.js → Share07-ezwRb3nU.js} +1 -1
  37. package/dist/client/assets/{Shield01-CjyLhqlS.js → Shield01-BcXJFwaP.js} +1 -1
  38. package/dist/client/assets/{Stars01-COChWymR.js → Stars01-DdrI1AvW.js} +1 -1
  39. package/dist/client/assets/{Sun-nKOZMh9n.js → Sun-DZjMucTf.js} +1 -1
  40. package/dist/client/assets/{SwitchHorizontal01-CxlKjkIX.js → SwitchHorizontal01-Dne29Upz.js} +1 -1
  41. package/dist/client/assets/{Tool01-BnKd95Y1.js → Tool01-duhLcQNq.js} +1 -1
  42. package/dist/client/assets/{Tool02-C_xRWqQk.js → Tool02-CnClhfmX.js} +1 -1
  43. package/dist/client/assets/{Trash01-DqUm2RRh.js → Trash01-CH5l96iG.js} +1 -1
  44. package/dist/client/assets/{TrendUp01-PFzYDizC.js → TrendUp01-fYoe36da.js} +1 -1
  45. package/dist/client/assets/{Upload01-CqWnAR1-.js → Upload01-DksJHtIE.js} +1 -1
  46. package/dist/client/assets/{User01-BJoNdkjl.js → User01-DZs8rqql.js} +1 -1
  47. package/dist/client/assets/{UserSquare-CCDsU001.js → UserSquare-CXNfIfPy.js} +1 -1
  48. package/dist/client/assets/{Users01-DSQPwtP5.js → Users01-DZlg18P8.js} +1 -1
  49. package/dist/client/assets/{Users03-CRtXqa1Q.js → Users03-pPPKVW_h.js} +1 -1
  50. package/dist/client/assets/{XCircle-9Cb0khfg.js → XCircle-CoSRJnuK.js} +1 -1
  51. package/dist/client/assets/{XClose-Cw4b4Uag.js → XClose-BYsCvLXW.js} +1 -1
  52. package/dist/client/assets/{Zap-ChVc0p76.js → Zap-BLQffepl.js} +1 -1
  53. package/dist/client/assets/{ZoomOut-BXPGwF_O.js → ZoomOut-B6xnZLKD.js} +1 -1
  54. package/dist/client/assets/{access-gate-BZbNb1lq.js → access-gate-Cc7o9awR.js} +1 -1
  55. package/dist/client/assets/{add-connection-dialog-s1GRGQ63.js → add-connection-dialog-ColILHSg.js} +1 -1
  56. package/dist/client/assets/{agent-analytics-C4aHsqYV.js → agent-analytics-BuUA9_zB.js} +1 -1
  57. package/dist/client/assets/agent-app-CvjgfHdj.js +1 -0
  58. package/dist/client/assets/{agent-assets-B6lPIA_2.js → agent-assets-CHRAa4hr.js} +1 -1
  59. package/dist/client/assets/{agent-automation-Bmdy2mNK.js → agent-automation-COYuXB1l.js} +1 -1
  60. package/dist/client/assets/{agent-automations-5exIOZ--.js → agent-automations-CVa9zvpd.js} +1 -1
  61. package/dist/client/assets/{agent-connect-sources-ozaEzrP4.js → agent-connect-sources-D-qScFZM.js} +1 -1
  62. package/dist/client/assets/agent-deck-CtPxHug1.js +1 -0
  63. package/dist/client/assets/{agent-e2e-s-Nk1F2Y.js → agent-e2e-BJ7p3EFw.js} +1 -1
  64. package/dist/client/assets/agent-file-r5wJ9MHq.js +1 -0
  65. package/dist/client/assets/{agent-git-Bu3r6tWp.js → agent-git-RSuMQ7we.js} +1 -1
  66. package/dist/client/assets/{agent-hosting-CdYzW_dA.js → agent-hosting-C6HCUd84.js} +1 -1
  67. package/dist/client/assets/{agent-icon-DrlilhFJ.js → agent-icon-DlT0cyOd.js} +1 -1
  68. package/dist/client/assets/agent-library-file-CDc9dHKg.js +1 -0
  69. package/dist/client/assets/{agent-monitor-DEQ-34KF.js → agent-monitor-Yob-hhJJ.js} +1 -1
  70. package/dist/client/assets/{agent-overview-BQIF-rwN.js → agent-overview-Cmt3_HNP.js} +1 -1
  71. package/dist/client/assets/agent-settings-E30r5sKL.js +1 -0
  72. package/dist/client/assets/{agent-site-editor-DtPpWjDD.js → agent-site-editor-C9RAIEyo.js} +1 -1
  73. package/dist/client/assets/agent-site-editor-code-hlPdL0sy.js +2 -0
  74. package/dist/client/assets/{agent-site-editor-content-6zQLGSyR.js → agent-site-editor-content-5xiQM6XU.js} +2 -2
  75. package/dist/client/assets/{agent-site-editor-preview-D8mxBZIU.js → agent-site-editor-preview-CEEI7DH8.js} +3 -3
  76. package/dist/client/assets/agent-view-DclyqFK6.js +1 -0
  77. package/dist/client/assets/{agent-view-guard-nj1TYVsk.js → agent-view-guard-BYjSQEWP.js} +1 -1
  78. package/dist/client/assets/{agents-list-hiZ_XS0O.js → agents-list-D-V7lKYi.js} +1 -1
  79. package/dist/client/assets/{ai-providers-oY9ilqJZ.js → ai-providers-CnrPu6-b.js} +1 -1
  80. package/dist/client/assets/{alert-D-emvPaG.js → alert-CKcqWgEA.js} +1 -1
  81. package/dist/client/assets/{alert-dialog-BE9ltHtr.js → alert-dialog-B19dFL0f.js} +1 -1
  82. package/dist/client/assets/{api-keys-4NMR09V3.js → api-keys-B82gXphc.js} +1 -1
  83. package/dist/client/assets/api-keys-C5nyTMkG.js +1 -0
  84. package/dist/client/assets/app-editor-Ce9aJoOB.js +1 -0
  85. package/dist/client/assets/{asset-utils-CR65HphV.js → asset-utils-DCSDKdD5.js} +1 -1
  86. package/dist/client/assets/{auth-RjDDTUUT.js → auth-BRT05k6V.js} +1 -1
  87. package/dist/client/assets/{auth-catchall-qxwSZGuB.js → auth-catchall-CKtZG-ZL.js} +1 -1
  88. package/dist/client/assets/{auth-entry-ddblLMjc.js → auth-entry-B04CeC2I.js} +1 -1
  89. package/dist/client/assets/{auth-split-layout-oGs_kK_4.js → auth-split-layout-Cr7N993d.js} +1 -1
  90. package/dist/client/assets/{authenticate-and-persist-oauth-DXlrPDSv.js → authenticate-and-persist-oauth-VFbyMRtb.js} +1 -1
  91. package/dist/client/assets/{automation-list-row-XibuWgpW.js → automation-list-row-Cpi5Xmll.js} +1 -1
  92. package/dist/client/assets/{automation-runs-nZP284NC.js → automation-runs-pUP2_-kz.js} +1 -1
  93. package/dist/client/assets/automations-DsASrpQ_.js +1 -0
  94. package/dist/client/assets/{autosend-HdosN86x.js → autosend-BfRMZFUN.js} +1 -1
  95. package/dist/client/assets/{avatar-DcDvs8Zz.js → avatar-CAI2JETZ.js} +1 -1
  96. package/dist/client/assets/{badge-DJpaBl8u.js → badge-ByfZPYh0.js} +1 -1
  97. package/dist/client/assets/{block-document-LCYQj9PJ.js → block-document-DBxhUTBx.js} +1 -1
  98. package/dist/client/assets/{breadcrumb-BOAVRiAa.js → breadcrumb-CFkPvTBR.js} +1 -1
  99. package/dist/client/assets/{buckets-Ze5fok7v.js → buckets-DKSvTBD6.js} +1 -1
  100. package/dist/client/assets/{build-improve-prompt-doc-Dn9xs_5X.js → build-improve-prompt-doc-Bni1nFjn.js} +1 -1
  101. package/dist/client/assets/{bulk-category-panel-D-Hh71MB.js → bulk-category-panel-B7Aw8gAs.js} +1 -1
  102. package/dist/client/assets/{calendar-DTnssie4.js → calendar-BPRd4cON.js} +1 -1
  103. package/dist/client/assets/{capability-load-error-CJ3e1sqb.js → capability-load-error-B39q7sVS.js} +1 -1
  104. package/dist/client/assets/{cards-DTFINi5r.js → cards-C9H7r60q.js} +1 -1
  105. package/dist/client/assets/category-editor-C6NG-7y-.js +1 -0
  106. package/dist/client/assets/{chart-Jb0gHMLD.js → chart-ChK_Oq3k.js} +1 -1
  107. package/dist/client/assets/{chat-context-CXknhaDs.js → chat-context-BdJniD3E.js} +1 -1
  108. package/dist/client/assets/{checkbox-D8Ab2Vb-.js → checkbox-Cx7-cMI2.js} +1 -1
  109. package/dist/client/assets/{choose-editor-Chy2VB_F.js → choose-editor-BFMfKqGX.js} +1 -1
  110. package/dist/client/assets/{cli-auth-success-B27gos5d.js → cli-auth-success-BXUI2QIq.js} +1 -1
  111. package/dist/client/assets/{client-icons-CoIMqlIz.js → client-icons-DH8XqhqX.js} +1 -1
  112. package/dist/client/assets/{collapsible-DH_CZdwE.js → collapsible-DWXt85UZ.js} +1 -1
  113. package/dist/client/assets/{collection-detail-D8Sq0PzS.js → collection-detail-yuoxb5ei.js} +1 -1
  114. package/dist/client/assets/{collection-display-button-P_aK73Om.js → collection-display-button-CYeWeHPn.js} +1 -1
  115. package/dist/client/assets/{collection-search-CzGq8Uso.js → collection-search-DBiZveMp.js} +1 -1
  116. package/dist/client/assets/{collection-table-wrapper-ChqJqpKo.js → collection-table-wrapper-GiH-7xKS.js} +1 -1
  117. package/dist/client/assets/{collection-tabs-BLgGMB42.js → collection-tabs-BxTayoNr.js} +1 -1
  118. package/dist/client/assets/{command-palette-store-BwHku_Zt.js → command-palette-store-D4d7ysBD.js} +1 -1
  119. package/dist/client/assets/{command-B6LMVdkQ.js → command-vCLlEnld.js} +1 -1
  120. package/dist/client/assets/{commerce-onboarding-EmIMFBqV.js → commerce-onboarding-DOo_j1fY.js} +1 -1
  121. package/dist/client/assets/{companion-mcps-section-BszDkkOp.js → companion-mcps-section-RMajitXP.js} +1 -1
  122. package/dist/client/assets/{connect-CM-97gwN.js → connect-DIZq-DN2.js} +1 -1
  123. package/dist/client/assets/{connect-layout-C_MQVbrT.js → connect-layout-CcZHYYLs.js} +1 -1
  124. package/dist/client/assets/{connection-OmoYXqZk.js → connection-D3sgkgc8.js} +1 -1
  125. package/dist/client/assets/{connection-card-Cy-GdKQl.js → connection-card-BUk8IuWl.js} +1 -1
  126. package/dist/client/assets/{connection-detail-CuBiFvjK.js → connection-detail-DI7dS0mq.js} +1 -1
  127. package/dist/client/assets/{connection-form-helpers-D3hdN_Pk.js → connection-form-helpers-CjZ0gF9p.js} +1 -1
  128. package/dist/client/assets/{connections-BnO49Vti.js → connections-DtcRjsIv.js} +1 -1
  129. package/dist/client/assets/{create-organization-dialog--p2RMsV5.js → create-organization-dialog-D3-ZW85P.js} +1 -1
  130. package/dist/client/assets/{decode-html-entities-DDqE27I4.js → decode-html-entities-DI0z1GlS.js} +1 -1
  131. package/dist/client/assets/{decopilot-sse-pool-CfYFArSW.js → decopilot-sse-pool-C4pTRblZ.js} +1 -1
  132. package/dist/client/assets/{dialog-otnvxVN0.js → dialog-BAfLND_C.js} +1 -1
  133. package/dist/client/assets/{discover-BZKxvY_j.js → discover-CgETi5Ba.js} +1 -1
  134. package/dist/client/assets/{domain-settings-QORwmdcG.js → domain-settings-DGeWS67L.js} +1 -1
  135. package/dist/client/assets/{download-app-dialog-BqNRF4Sn.js → download-app-dialog-inqOoiFR.js} +1 -1
  136. package/dist/client/assets/{drawer-s7gtDrb4.js → drawer-CftCt6Vc.js} +1 -1
  137. package/dist/client/assets/{dropdown-menu-BxKUbUkE.js → dropdown-menu-DlZDenrk.js} +1 -1
  138. package/dist/client/assets/{editor-DCxsAs7o.js → editor-VCziEYAl.js} +1 -1
  139. package/dist/client/assets/{empty-state-CL4F2BS4.js → empty-state-85cr_pDj.js} +1 -1
  140. package/dist/client/assets/{empty-state-Cz1DkYZE.js → empty-state-DrLFtqMC.js} +1 -1
  141. package/dist/client/assets/{extract-connection-data-CqGCTPdZ.js → extract-connection-data-DuAiwl2M.js} +1 -1
  142. package/dist/client/assets/{file-explorer-Uvp7ogK8.js → file-explorer-Dd6bLbvS.js} +1 -1
  143. package/dist/client/assets/{file-preview-18IJQMnU.js → file-preview-B9gO9A7B.js} +1 -1
  144. package/dist/client/assets/{file-share-button-Cef5f1VZ.js → file-share-button-Zm0jPBUd.js} +1 -1
  145. package/dist/client/assets/{file-type-icon-DGllFDOf.js → file-type-icon-ChixCG5B.js} +1 -1
  146. package/dist/client/assets/{folder-icon-p8jB76CU.js → folder-icon-jWW7DiXp.js} +1 -1
  147. package/dist/client/assets/{form-KjPevg0A.js → form-B2aJ1tMr.js} +1 -1
  148. package/dist/client/assets/{general-t-IB2WC3.js → general-Dbd-M2oy.js} +1 -1
  149. package/dist/client/assets/{github-icon-D51q_6S8.js → github-icon-BHD2Mc12.js} +1 -1
  150. package/dist/client/assets/{home-Bhl8U_ph.js → home-DRVwgYU_.js} +1 -1
  151. package/dist/client/assets/{hooks-BhviOOpn.js → hooks-CrGRDkCO.js} +1 -1
  152. package/dist/client/assets/{hooks-k1OxvonE.js → hooks-D-bAuZ0C.js} +1 -1
  153. package/dist/client/assets/{index-Bwc7J041.js → index-5lUn2NYU.js} +1 -1
  154. package/dist/client/assets/{index-CRCvoACn.js → index-BFLLIz5j.js} +1 -1
  155. package/dist/client/assets/{index-m01im2kT.js → index-Bm0CRiXJ.js} +1 -1
  156. package/dist/client/assets/{index-B3yBTWEk.js → index-BodvdIMk.js} +3 -3
  157. package/dist/client/assets/{index-w1d_dmEj.js → index-CFD2Tmax.js} +1 -1
  158. package/dist/client/assets/{index-D4YJGrDI.js → index-CMW740A7.js} +3 -3
  159. package/dist/client/assets/{index-fTs6ROSj.js → index-CV73SUyV.js} +1 -1
  160. package/dist/client/assets/{index-DD-r2o4M.js → index-CenLE2Y1.js} +1 -1
  161. package/dist/client/assets/{index-C1N-CFMR.js → index-CgWFi-UY.js} +1 -1
  162. package/dist/client/assets/{index-DlQKfvnq.js → index-D7HQX0oQ.js} +1 -1
  163. package/dist/client/assets/{index-C7WIaN4y.js → index-DFPd3Z7H.js} +1 -1
  164. package/dist/client/assets/{index-DOk05MCp.js → index-DTnAWEs3.js} +1 -1
  165. package/dist/client/assets/{index-DqX9hbqM.js → index-b0vxPrwt.js} +1 -1
  166. package/dist/client/assets/{index-xVQnUsdi.js → index-o8mv6JmO.js} +1 -1
  167. package/dist/client/assets/{index-redirect-e7Kr1hOd.js → index-redirect-CAUT4Gir.js} +1 -1
  168. package/dist/client/assets/{infiniteQueryObserver-DgAoAIrN.js → infiniteQueryObserver-BXxOeKaH.js} +1 -1
  169. package/dist/client/assets/{infra-billing-B2HwpfSN.js → infra-billing-C6s3jgkP.js} +1 -1
  170. package/dist/client/assets/{input-BnbYz5_9.js → input-2i3nmZXT.js} +1 -1
  171. package/dist/client/assets/{input-DxAgQLPa.js → input-7HsiiE3O.js} +1 -1
  172. package/dist/client/assets/{input-HFOrJf5B.js → input-CyCfmV2v.js} +1 -1
  173. package/dist/client/assets/{integration-icon-BPwWRlNG.js → integration-icon-BqCQeMla.js} +1 -1
  174. package/dist/client/assets/{invite-member-dialog-vPcEYe6v.js → invite-member-dialog-l7jaUM00.js} +1 -1
  175. package/dist/client/assets/{label-CqlSWrLn.js → label-oySBL-hw.js} +1 -1
  176. package/dist/client/assets/{layout-aU1eoqDA.js → layout-C_9zPyLB.js} +1 -1
  177. package/dist/client/assets/{legacy-agents-deep-CpKjJlPs.js → legacy-agents-deep-BGj1G-G6.js} +1 -1
  178. package/dist/client/assets/{legacy-main-redirect-ZPChWdtD.js → legacy-main-redirect-BAMIoUmF.js} +1 -1
  179. package/dist/client/assets/{library-uYIcEGdr.js → library-jBDBHa3X.js} +1 -1
  180. package/dist/client/assets/{login-CfxNz6kc.js → login-jcZJlm87.js} +1 -1
  181. package/dist/client/assets/{markdown-B1038zFJ.js → markdown-CuYSLr0D.js} +1 -1
  182. package/dist/client/assets/{mcp-app-renderer-Cb8Ud-E7.js → mcp-app-renderer-CAyJEYdf.js} +1 -1
  183. package/dist/client/assets/{mcp-oauth-D6isOO_s.js → mcp-oauth-D4sc2QRH.js} +1 -1
  184. package/dist/client/assets/{members-DHLsomPg.js → members-DZnhlZB5.js} +1 -1
  185. package/dist/client/assets/{mini-report-page-iTjakIrU.js → mini-report-page-DZcKIwCW.js} +1 -1
  186. package/dist/client/assets/{monaco-editor-WNMTPDp9.js → monaco-editor-miL0A9cI.js} +1 -1
  187. package/dist/client/assets/{monitoring-stats-row-B_mR1zw-.js → monitoring-stats-row-Bkr0yo_k.js} +1 -1
  188. package/dist/client/assets/{multi-select-D54pM3d4.js → multi-select-HV-sxpT4.js} +1 -1
  189. package/dist/client/assets/{mustache-r9snVmI4.js → mustache-8iDNlOWo.js} +1 -1
  190. package/dist/client/assets/{oauth-callback-GAK1H0Is.js → oauth-callback-CdbS4grS.js} +1 -1
  191. package/dist/client/assets/{oauth-callback-ai-provider-sdaHeEFx.js → oauth-callback-ai-provider-B6UEwW8h.js} +1 -1
  192. package/dist/client/assets/{onboarding-BKPW4du6.js → onboarding-CXn2uZdK.js} +1 -1
  193. package/dist/client/assets/{optimistic-project-sidebar-views-yrtk59Mo.js → optimistic-project-sidebar-views-Crt809gH.js} +1 -1
  194. package/dist/client/assets/{org-layout-BNIg984j.js → org-layout-Bh2799KC.js} +1 -1
  195. package/dist/client/assets/{organization-choice-DvXG7tgx.js → organization-choice-Dim_EV8w.js} +1 -1
  196. package/dist/client/assets/{orgs-NTyzCYi-.js → orgs-BiHhUqle.js} +1 -1
  197. package/dist/client/assets/{page-seo-form-DAkbVQPg.js → page-seo-form-Byw6I6v1.js} +1 -1
  198. package/dist/client/assets/{pair-C08OPQNP.js → pair-BryCAS3L.js} +1 -1
  199. package/dist/client/assets/{popover-DIqZ2IKF.js → popover-BaPHFXoA.js} +1 -1
  200. package/dist/client/assets/{post-calendar-DuH_hA9y.js → post-calendar-CX_aQZ9o.js} +1 -1
  201. package/dist/client/assets/{post-editor-BAf6FqSQ.js → post-editor-Bik9xGuM.js} +1 -1
  202. package/dist/client/assets/{preview-content-B5xB74fu.js → preview-content-C25g1Qjg.js} +1 -1
  203. package/dist/client/assets/{preview-dialog-b2QyOGzU.js → preview-dialog-Bd71VPLl.js} +1 -1
  204. package/dist/client/assets/{primitives-4_D03rJK.js → primitives-C2ZKBNVE.js} +1 -1
  205. package/dist/client/assets/{profile-COT-hKKD.js → profile-Cvk7HYLO.js} +1 -1
  206. package/dist/client/assets/{project-app-view-DJ_q7UHg.js → project-app-view-BBFfxMn2.js} +1 -1
  207. package/dist/client/assets/{project-feed-DJ_jJM3E.js → project-feed-CuafBwOd.js} +1 -1
  208. package/dist/client/assets/{project-icon-Bl3bXnhv.js → project-icon-D14m61tO.js} +1 -1
  209. package/dist/client/assets/project-reports-FoQBd9tt.js +1 -0
  210. package/dist/client/assets/project-tasks-CtrmnVYd.js +1 -0
  211. package/dist/client/assets/{prompts-CI44HEcf.js → prompts-CdPbev6G.js} +1 -1
  212. package/dist/client/assets/record-editor-BeEtgfek.js +1 -0
  213. package/dist/client/assets/redirect-editor-qcgiHklQ.js +1 -0
  214. package/dist/client/assets/registry-DINMxyfR.js +2 -0
  215. package/dist/client/assets/{registry-layout-CvRfdld3.js → registry-layout-C94XAKOB.js} +1 -1
  216. package/dist/client/assets/{reports-C-eaYxW3.js → reports-CxUD1psy.js} +1 -1
  217. package/dist/client/assets/reports-DbvBqGHI.js +1 -0
  218. package/dist/client/assets/{reports-tab-qffeKlGd.js → reports-tab-BpUXLiNq.js} +2 -2
  219. package/dist/client/assets/{repositories-ao250fUH.js → repositories-cLgzNGhX.js} +1 -1
  220. package/dist/client/assets/{repository-import-picker-Bg_h8YsG.js → repository-import-picker-Bz4mO0xC.js} +1 -1
  221. package/dist/client/assets/{repository-picker-BDWGy2xY.js → repository-picker-aHa7Yens.js} +1 -1
  222. package/dist/client/assets/{require-capability-CmR_46yt.js → require-capability-CGWy1zcW.js} +1 -1
  223. package/dist/client/assets/{required-auth-layout-BEc3NUsQ.js → required-auth-layout-C8ueG7DN.js} +1 -1
  224. package/dist/client/assets/{reset-password-BlF157J6.js → reset-password-Dfhn1DHs.js} +1 -1
  225. package/dist/client/assets/{review-settings-BBciVvfB.js → review-settings-yj2xfDNH.js} +1 -1
  226. package/dist/client/assets/{rich-text-link-control-CrwbAR31.js → rich-text-link-control-D8pkIadD.js} +1 -1
  227. package/dist/client/assets/{roles-CuHUTdKb.js → roles-CtsHlJ7R.js} +1 -1
  228. package/dist/client/assets/{runnable-block-editor-2CMWc-S3.js → runnable-block-editor-DQQgPGex.js} +1 -1
  229. package/dist/client/assets/{sandbox-lifecycle-context-CXd9Um8u.js → sandbox-lifecycle-context-KgLleS3y.js} +1 -1
  230. package/dist/client/assets/{schema-BQbhQoxs.js → schema-DVRYVU-6.js} +1 -1
  231. package/dist/client/assets/{scroll-area-BgZjjLM3.js → scroll-area-DrpmDXmv.js} +1 -1
  232. package/dist/client/assets/{search-input-uXtJ6IU8.js → search-input-BEuwwr9P.js} +1 -1
  233. package/dist/client/assets/{secrets-C1mCKV1g.js → secrets-BfNyBKtt.js} +1 -1
  234. package/dist/client/assets/{sections-editor-Bv2odcBq.js → sections-editor-CyOHOz8a.js} +1 -1
  235. package/dist/client/assets/{select-Bc5UZb4n.js → select-bwhAgSkw.js} +1 -1
  236. package/dist/client/assets/{select-model-BDGEzt-Y.js → select-model-BUtG_o-5.js} +1 -1
  237. package/dist/client/assets/{seo-editor-DJw3ydvJ.js → seo-editor-liBqGoJ2.js} +1 -1
  238. package/dist/client/assets/settings-layout-8_4ivRpO.js +1 -0
  239. package/dist/client/assets/{settings-sidebar-DswZBMwm.js → settings-sidebar-D1CImlJ7.js} +1 -1
  240. package/dist/client/assets/{settings-tab-Ru2atFmZ.js → settings-tab-DfPM9bhj.js} +1 -1
  241. package/dist/client/assets/{shell-controls-DkLEUvEw.js → shell-controls-oSe12Dvv.js} +1 -1
  242. package/dist/client/assets/{shell-layout-1dFmVwYI.js → shell-layout-DfKFME9s.js} +1 -1
  243. package/dist/client/assets/{skill-preview-CGe8kUoa.js → skill-preview-e4uQz0Dy.js} +1 -1
  244. package/dist/client/assets/{skills-BGdKR-aF.js → skills-C-9wX-VV.js} +1 -1
  245. package/dist/client/assets/{sso-M-OsbEtw.js → sso-BRhlLrJf.js} +1 -1
  246. package/dist/client/assets/{store-BY4ZRY7y.js → store-BESxBvzo.js} +1 -1
  247. package/dist/client/assets/store-registry-C5Y2YACE.js +2 -0
  248. package/dist/client/assets/{switch-CJ5Ir2Zx.js → switch-B1nJbGCG.js} +1 -1
  249. package/dist/client/assets/{synced-repos-9D-CfhL7.js → synced-repos-DSIN0NR4.js} +1 -1
  250. package/dist/client/assets/{table-Di_WRNkb.js → table-y_mRJ9Zn.js} +1 -1
  251. package/dist/client/assets/{tabs-DV8akPGb.js → tabs-BUVbbLAT.js} +1 -1
  252. package/dist/client/assets/{task-board-CXsHf2Zn.js → task-board-B_FYv6yr.js} +1 -1
  253. package/dist/client/assets/{task-route-D79aS9d_.js → task-route-D8DTrzfK.js} +1 -1
  254. package/dist/client/assets/{task-status-DIr_2V94.js → task-status-Cm28QQwf.js} +1 -1
  255. package/dist/client/assets/tasks-C2bVBzhE.js +1 -0
  256. package/dist/client/assets/{tasks-CiIHA5f1.js → tasks-CIHytgaT.js} +1 -1
  257. package/dist/client/assets/{textarea-CneoU2lJ.js → textarea-2MjTWIvv.js} +1 -1
  258. package/dist/client/assets/{thread-intent-DVKldCEq.js → thread-intent-C_TUHShU.js} +1 -1
  259. package/dist/client/assets/{thread-route-CKY-dKC0.js → thread-route-BPX5b65a.js} +1 -1
  260. package/dist/client/assets/{thread-sheet-body-CcUGPZXB.js → thread-sheet-body-hrROtD20.js} +1 -1
  261. package/dist/client/assets/{toggle-group-9HQCpj-q.js → toggle-group-yY_Yhls6.js} +1 -1
  262. package/dist/client/assets/{tool-namespace-BVMQcKlk.js → tool-namespace-CCb8MkTr.js} +1 -1
  263. package/dist/client/assets/{toolbar-D0oe2g2b.js → toolbar-DK-dWmgo.js} +1 -1
  264. package/dist/client/assets/{toolbar-icon-button-EOE8J-Ai.js → toolbar-icon-button-D7IEoYBH.js} +1 -1
  265. package/dist/client/assets/{track-BzMi8kcZ.js → track-CzfYfVMq.js} +1 -1
  266. package/dist/client/assets/{types-Csu6Ims7.js → types-CJQ5rOJz.js} +1 -1
  267. package/dist/client/assets/{usage-stats-BNse37Wk.js → usage-stats-Cp4Mqdjr.js} +1 -1
  268. package/dist/client/assets/{use-ai-providers-qnkcjapR.js → use-ai-providers-BHw3Z_he.js} +1 -1
  269. package/dist/client/assets/{use-automations-CYOC_eS5.js → use-automations-B_2Eci9k.js} +1 -1
  270. package/dist/client/assets/{use-autosave-CCprSQ13.js → use-autosave-CGgcTeeH.js} +1 -1
  271. package/dist/client/assets/{use-commerce-diagnostic-mdvL2BW-.js → use-commerce-diagnostic-BQRYyoWw.js} +1 -1
  272. package/dist/client/assets/{use-connect-companion-2fL060lG.js → use-connect-companion-0NSfsYdR.js} +1 -1
  273. package/dist/client/assets/{use-connection-DCLPda2h.js → use-connection-B0HreEyO.js} +1 -1
  274. package/dist/client/assets/{use-copy-14DzRp8J.js → use-copy-Cc2PzrxF.js} +1 -1
  275. package/dist/client/assets/{use-create-virtual-mcp-DoCSQs95.js → use-create-virtual-mcp-GYM-p3SY.js} +1 -1
  276. package/dist/client/assets/{use-date-fns-locale-DYzMvrWB.js → use-date-fns-locale-C1uUurom.js} +1 -1
  277. package/dist/client/assets/{use-debounced-autosave-BRAVEUZc.js → use-debounced-autosave-D2DtaMQY.js} +1 -1
  278. package/dist/client/assets/{use-debounced-value-Cud3o3Fq.js → use-debounced-value-Dci7_Qwe.js} +1 -1
  279. package/dist/client/assets/{use-deco-credits-rwNQ1gMg.js → use-deco-credits-CQYk77NF.js} +1 -1
  280. package/dist/client/assets/{use-decopilot-events-DYRVevWg.js → use-decopilot-events-HctMj33h.js} +1 -1
  281. package/dist/client/assets/{use-delete-connection-ueGIYWMK.js → use-delete-connection-Do6SoZ3c.js} +1 -1
  282. package/dist/client/assets/{use-deployment-admin-D6IzoXV0.js → use-deployment-admin-CRRFLUPy.js} +1 -1
  283. package/dist/client/assets/{use-file-configs-BwD1CaWo.js → use-file-configs-CMLhU-Fj.js} +1 -1
  284. package/dist/client/assets/{use-infinite-scroll-DkLPxlOu.js → use-infinite-scroll-TMy8eEjN.js} +1 -1
  285. package/dist/client/assets/{use-join-requests-DTGTfD21.js → use-join-requests-DxlLP6Wr.js} +1 -1
  286. package/dist/client/assets/{use-main-panel-tabs-EW6rbxam.js → use-main-panel-tabs-CbcTcl9J.js} +1 -1
  287. package/dist/client/assets/{use-mcp-auth-status-CPh3Lmzs.js → use-mcp-auth-status-gxHqvxAC.js} +1 -1
  288. package/dist/client/assets/{use-mcp-client-DsJzBus3.js → use-mcp-client-DO1cH-Rq.js} +1 -1
  289. package/dist/client/assets/{use-mcp-prompts-i0LZ2nQA.js → use-mcp-prompts-DZqLLTvQ.js} +1 -1
  290. package/dist/client/assets/{use-mcp-tools-Dc3F6Krl.js → use-mcp-tools-BIFTy-Ao.js} +1 -1
  291. package/dist/client/assets/{use-members-C0MdJrYz.js → use-members-Ca1m7gk-.js} +1 -1
  292. package/dist/client/assets/{use-navigate-to-agent-Bbq0oQ0Y.js → use-navigate-to-agent-DbrSvmvC.js} +1 -1
  293. package/dist/client/assets/{use-open-billing-url-DvTk9GH0.js → use-open-billing-url-CpZXluVO.js} +1 -1
  294. package/dist/client/assets/{use-org-auth-client-4o0wRx2Q.js → use-org-auth-client-S952sZID.js} +1 -1
  295. package/dist/client/assets/{use-org-fs-BEoPvlnI.js → use-org-fs-C1ai334S.js} +1 -1
  296. package/dist/client/assets/{use-org-notice-CXYMfMUq.js → use-org-notice-CJiZMwf2.js} +1 -1
  297. package/dist/client/assets/{use-org-sso-CdSz0xa8.js → use-org-sso-CFwon6Ac.js} +1 -1
  298. package/dist/client/assets/{use-organization-roles-DzWM9Nv-.js → use-organization-roles--bC30gnD.js} +1 -1
  299. package/dist/client/assets/{use-organization-settings-BAVHurZk.js → use-organization-settings-C7uzGCkO.js} +1 -1
  300. package/dist/client/assets/{use-panel-navigate-Byvx0cbx.js → use-panel-navigate-BgqqPVEC.js} +1 -1
  301. package/dist/client/assets/{use-project-native-view-presence-D-AyEulW.js → use-project-native-view-presence-DqW-vLSC.js} +1 -1
  302. package/dist/client/assets/{use-project-scope-B2cuvtTy.js → use-project-scope-cOFjIv3F.js} +1 -1
  303. package/dist/client/assets/{use-registry-connections-DikbDR8w.js → use-registry-connections-XlfVpqo2.js} +1 -1
  304. package/dist/client/assets/{use-secrets-D-c1ciPZ.js → use-secrets-DEa3ZFkm.js} +1 -1
  305. package/dist/client/assets/{use-section-preview-base-CwIWGkgy.js → use-section-preview-base-DfU-w-9v.js} +1 -1
  306. package/dist/client/assets/{use-session-runtime-BHahDP0E.js → use-session-runtime-D2nv6bTI.js} +1 -1
  307. package/dist/client/assets/{use-status-sounds-CnCb1h48.js → use-status-sounds-CBYC79_Y.js} +1 -1
  308. package/dist/client/assets/{use-tags-C2LhenRb.js → use-tags-6rI6kyxz.js} +1 -1
  309. package/dist/client/assets/{use-task-metadata-CB3EJ29f.js → use-task-metadata-DuwC-TmK.js} +1 -1
  310. package/dist/client/assets/{use-thread-outputs-9oZhiYbB.js → use-thread-outputs-DwE-nO-h.js} +1 -1
  311. package/dist/client/assets/{use-view-mode-BvOL5I4W.js → use-view-mode-2goLAQJg.js} +1 -1
  312. package/dist/client/assets/{use-virtual-mcp-Bk09OpEg.js → use-virtual-mcp-DY2qk06G.js} +1 -1
  313. package/dist/client/assets/useInfiniteQuery-B3TKIUIz.js +1 -0
  314. package/dist/client/assets/{useQueries-qr8TAkZc.js → useQueries-CDFEvGc1.js} +1 -1
  315. package/dist/client/assets/useSuspenseInfiniteQuery-BuAksfER.js +1 -0
  316. package/dist/client/assets/{users-C1ExMDuM.js → users-xM0kvyFO.js} +1 -1
  317. package/dist/client/assets/{utils-B14U8IKK.js → utils-DPVkkzea.js} +1 -1
  318. package/dist/client/assets/{variant-calendar-urd0wE-3.js → variant-calendar-C1Gzo9bi.js} +1 -1
  319. package/dist/client/assets/{variant-matcher-override-DvY-JiuY.js → variant-matcher-override-GDeATfJn.js} +1 -1
  320. package/dist/client/assets/{view-mode-toggle-swSorpD7.js → view-mode-toggle-VHYgVEtv.js} +1 -1
  321. package/dist/client/assets/{virtual-mcp-DGQbDtgM.js → virtual-mcp-CSoIE5pZ.js} +1 -1
  322. package/dist/client/index.html +1 -1
  323. package/dist/server/cli.js +1 -1
  324. package/dist/server/server.js +1 -1
  325. package/package.json +1 -1
  326. package/dist/client/assets/agent-app-CzbKRw1_.js +0 -1
  327. package/dist/client/assets/agent-deck-D5-mvZ5i.js +0 -1
  328. package/dist/client/assets/agent-file-DkGApBvp.js +0 -1
  329. package/dist/client/assets/agent-library-file-CK85m8fH.js +0 -1
  330. package/dist/client/assets/agent-settings-gb3smN_4.js +0 -1
  331. package/dist/client/assets/agent-site-editor-code-DkcL_YVi.js +0 -2
  332. package/dist/client/assets/agent-view-D9WzU94g.js +0 -1
  333. package/dist/client/assets/api-keys-BQayHq-8.js +0 -1
  334. package/dist/client/assets/app-editor-DeI0TeES.js +0 -1
  335. package/dist/client/assets/automations-CDxxuCym.js +0 -1
  336. package/dist/client/assets/category-editor-4KcN0JRt.js +0 -1
  337. package/dist/client/assets/project-reports-q4w3pT5T.js +0 -1
  338. package/dist/client/assets/project-tasks-DqlAyIfE.js +0 -1
  339. package/dist/client/assets/record-editor-n0M7yiQw.js +0 -1
  340. package/dist/client/assets/redirect-editor-CK3YSOdb.js +0 -1
  341. package/dist/client/assets/registry-DkzCUqTc.js +0 -2
  342. package/dist/client/assets/reports-C2LVTrmJ.js +0 -1
  343. package/dist/client/assets/settings-layout-DlH0gQXK.js +0 -1
  344. package/dist/client/assets/store-registry-DQHLJpOA.js +0 -2
  345. package/dist/client/assets/tasks-C6DyE2q-.js +0 -1
  346. package/dist/client/assets/useInfiniteQuery-GKCP1c_7.js +0 -1
  347. package/dist/client/assets/useSuspenseInfiniteQuery-DmEiIBI4.js +0 -1
@@ -1 +1 @@
1
- import{j as B,a0 as D,a1 as We,T as H,a2 as je,a3 as A,a4 as U,k as W,a5 as G,a6 as J,a7 as me,a8 as qe,a9 as we,aa as Xe,E as be,ab as Ye,ac as Ge,f as ve}from"./usage-stats-BNse37Wk.js";import{eW as ye,f0 as Ce,eV as Se,f1 as Re,f2 as Ee,f3 as Te,f4 as Oe,f5 as Ie,eX as Ae,aI as Me,r as C,ar as ze}from"./index-B3yBTWEk.js";let Z,Q;if(typeof WeakMap<"u"){let e=new WeakMap;Z=t=>e.get(t),Q=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;Z=o=>{for(let i=0;i<e.length;i+=2)if(e[i]==o)return e[i+1]},Q=(o,i)=>(n==10&&(n=0),e[n++]=o,e[n++]=i)}var v=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const o=t%this.width,i=t/this.width|0;let s=o+1,l=i+1;for(let r=1;s<this.width&&this.map[t+r]==n;r++)s++;for(let r=1;l<this.height&&this.map[t+this.width*r]==n;r++)l++;return{left:o,top:i,right:s,bottom:l}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:o,right:i,top:s,bottom:l}=this.findCell(e);return t=="horiz"?(n<0?o==0:i==this.width)?null:this.map[s*this.width+(n<0?o-1:i)]:(n<0?s==0:l==this.height)?null:this.map[o+this.width*(n<0?s-1:l)]}rectBetween(e,t){const{left:n,right:o,top:i,bottom:s}=this.findCell(e),{left:l,right:r,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,l),top:Math.min(i,a),right:Math.max(o,r),bottom:Math.max(s,c)}}cellsInRect(e){const t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let i=e.left;i<e.right;i++){const s=o*this.width+i,l=this.map[s];n[l]||(n[l]=!0,!(i==e.left&&i&&this.map[s-1]==l||o==e.top&&o&&this.map[s-this.width]==l)&&t.push(l))}return t}positionAt(e,t,n){for(let o=0,i=0;;o++){const s=i+n.child(o).nodeSize;if(o==e){let l=t+e*this.width;const r=(e+1)*this.width;for(;l<r&&this.map[l]<i;)l++;return l==r?s-1:this.map[l]}i=s}}static get(e){return Z(e)||Q(e,Je(e))}};function Je(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=Ze(e),n=e.childCount,o=[];let i=0,s=null;const l=[];for(let c=0,u=t*n;c<u;c++)o[c]=0;for(let c=0,u=0;c<n;c++){const d=e.child(c);u++;for(let p=0;;p++){for(;i<o.length&&o[i]!=0;)i++;if(p==d.childCount)break;const g=d.child(p),{colspan:m,rowspan:w,colwidth:R}=g.attrs;for(let y=0;y<w;y++){if(y+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-y});break}const T=i+y*t;for(let O=0;O<m;O++){o[T+O]==0?o[T+O]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:m-O});const L=R&&R[O];if(L){const $=(T+O)%t*2,q=l[$];q==null||q!=L&&l[$+1]==1?(l[$]=L,l[$+1]=1):q==L&&l[$+1]++}}}i+=m,u+=g.nodeSize}const h=(c+1)*t;let f=0;for(;i<h;)o[i++]==0&&f++;f&&(s||(s=[])).push({type:"missing",row:c,n:f}),u++}(t===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const r=new v(t,n,o,s);let a=!1;for(let c=0;!a&&c<l.length;c+=2)l[c]!=null&&l[c+1]<n&&(a=!0);return a&&Qe(r,l,e),r}function Ze(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){const i=e.child(o);let s=0;if(n)for(let l=0;l<o;l++){const r=e.child(l);for(let a=0;a<r.childCount;a++){const c=r.child(a);l+c.attrs.rowspan>o&&(s+=c.attrs.colspan)}}for(let l=0;l<i.childCount;l++){const r=i.child(l);s+=r.attrs.colspan,r.attrs.rowspan>1&&(n=!0)}t==-1?t=s:t!=s&&(t=Math.max(t,s))}return t}function Qe(e,t,n){e.problems||(e.problems=[]);const o={};for(let i=0;i<e.map.length;i++){const s=e.map[i];if(o[s])continue;o[s]=!0;const l=n.nodeAt(s);if(!l)throw new RangeError(`No cell with offset ${s} found`);let r=null;const a=l.attrs;for(let c=0;c<a.colspan;c++){const u=t[(i+c)%e.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((r||(r=et(a)))[c]=u)}r&&e.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:r})}}function et(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function S(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const o=e.nodes[n],i=o.spec.tableRole;i&&(t[i]=o)}}return t}const x=new B("selectingCells");function N(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function tt(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function I(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function j(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=N(t.$head)||nt(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function nt(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function ee(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function ot(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ie(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function De(e,t,n){const o=e.node(-1),i=v.get(o),s=e.start(-1),l=i.nextCell(e.pos-s,t,n);return l==null?null:e.node(0).resolve(s+l)}function P(e,t,n=1){const o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some(i=>i>0)||(o.colwidth=null)),o}function xe(e,t,n=1){const o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let i=0;i<n;i++)o.colwidth.splice(t,0,0)}return o}function it(e,t,n){const o=S(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=o)return!1;return!0}var b=class z extends D{constructor(t,n=t){const o=t.node(-1),i=v.get(o),s=t.start(-1),l=i.rectBetween(t.pos-s,n.pos-s),r=t.node(0),a=i.cellsInRect(l).filter(u=>u!=n.pos-s);a.unshift(n.pos-s);const c=a.map(u=>{const d=o.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=s+u+1;return new je(r.resolve(h),r.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(ee(o)&&ee(i)&&ie(o,i)){const s=this.$anchorCell.node(-1)!=o.node(-1);return s&&this.isRowSelection()?z.rowSelection(o,i):s&&this.isColSelection()?z.colSelection(o,i):new z(o,i)}return H.between(o,i)}content(){const t=this.$anchorCell.node(-1),n=v.get(t),o=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),s={},l=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*n.width+i.left,d=i.left;d<i.right;d++,u++){const h=n.map[u];if(s[h])continue;s[h]=!0;const f=n.findCell(h);let p=t.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const g=i.left-f.left,m=f.right-i.right;if(g>0||m>0){let w=p.attrs;if(g>0&&(w=P(w,0,g)),m>0&&(w=P(w,w.colspan-m,m)),f.left<i.left){if(p=p.type.createAndFill(w),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(f.top<i.top||f.bottom>i.bottom){const w={...p.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}l.push(t.child(a).copy(A.from(c)))}const r=this.isColSelection()&&this.isRowSelection()?t:l;return new U(A.from(r),1,1)}replace(t,n=U.empty){const o=t.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){const{$from:r,$to:a}=i[l],c=t.mapping.slice(o);t.replace(c.map(r.pos),c.map(a.pos),l?U.empty:n)}const s=D.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);s&&t.setSelection(s)}replaceWith(t,n){this.replace(t,new U(A.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),o=v.get(n),i=this.$anchorCell.start(-1),s=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let l=0;l<s.length;l++)t(n.nodeAt(s[l]),i+s[l])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const o=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const o=t.node(-1),i=v.get(o),s=t.start(-1),l=i.findCell(t.pos-s),r=i.findCell(n.pos-s),a=t.node(0);return l.top<=r.top?(l.top>0&&(t=a.resolve(s+i.map[l.left])),r.bottom<i.height&&(n=a.resolve(s+i.map[i.width*(i.height-1)+r.right-1]))):(r.top>0&&(n=a.resolve(s+i.map[r.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))),new z(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=v.get(t),o=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-o),s=n.colCount(this.$headCell.pos-o);if(Math.min(i,s)>0)return!1;const l=i+this.$anchorCell.nodeAfter.attrs.colspan,r=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,r)==n.width}eq(t){return t instanceof z&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const o=t.node(-1),i=v.get(o),s=t.start(-1),l=i.findCell(t.pos-s),r=i.findCell(n.pos-s),a=t.node(0);return l.left<=r.left?(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),r.right<i.width&&(n=a.resolve(s+i.map[i.width*(r.top+1)-1]))):(r.left>0&&(n=a.resolve(s+i.map[r.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))),new z(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new z(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new z(t.resolve(n),t.resolve(o))}getBookmark(){return new st(this.$anchorCell.pos,this.$headCell.pos)}};b.prototype.visible=!1;D.jsonID("cell",b);var st=class Ue{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Ue(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),o=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&ie(n,o)?new b(n,o):D.near(o,1)}};function lt(e){if(!(e.selection instanceof b))return null;const t=[];return e.selection.forEachCell((n,o)=>{t.push(J.node(o,o+n.nodeSize,{class:"selectedCell"}))}),G.create(e.doc,t)}function rt({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let s=t.depth;s>=0&&!(t.before(s+1)>t.start(s));s--,o--);return n==o&&/row|table/.test(e.node(i).type.spec.tableRole)}function at({$from:e,$to:t}){let n,o;for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){o=s;break}}return n!==o&&t.parentOffset===0}function ct(e,t,n){const o=(t||e).selection,i=(t||e).doc;let s,l;if(o instanceof me&&(l=o.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")s=b.create(i,o.from);else if(l=="row"){const r=i.resolve(o.from+1);s=b.rowSelection(r,r)}else if(!n){const r=v.get(o.node),a=o.from+1,c=a+r.map[r.width*r.height-1];s=b.create(i,a+1,c)}}else o instanceof H&&rt(o)?s=H.create(i,o.from):o instanceof H&&at(o)&&(s=H.create(i,o.$from.start(),o.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}const dt=new B("fix-tables");function He(e,t,n,o){const i=e.childCount,s=t.childCount;e:for(let l=0,r=0;l<s;l++){const a=t.child(l);for(let c=r,u=Math.min(i,l+3);c<u;c++)if(e.child(c)==a){r=c+1,n+=a.nodeSize;continue e}o(a,n),r<i&&e.child(r).sameMarkup(a)?He(e.child(r),a,n+1,o):a.nodesBetween(0,a.content.size,o,n+1),n+=a.nodeSize}}function ut(e,t){let n;const o=(i,s)=>{i.type.spec.tableRole=="table"&&(n=ht(e,i,s,n))};return t?t.doc!=e.doc&&He(t.doc,e.doc,0,o):e.doc.descendants(o),n}function ht(e,t,n,o){const i=v.get(t);if(!i.problems)return o;o||(o=e.tr);const s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const u=t.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)s[c.row+h]+=c.n;o.setNodeMarkup(o.mapping.map(n+1+c.pos),null,P(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=t.nodeAt(c.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=t.nodeAt(c.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=o.mapping.map(n);o.delete(u,u+t.nodeSize)}}let l,r;for(let a=0;a<s.length;a++)s[a]&&(l==null&&(l=a),r=a);for(let a=0,c=n+1;a<i.height;a++){const u=t.child(a),d=c+u.nodeSize,h=s[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let m=0;m<h;m++){const w=S(e.schema)[f].createAndFill();w&&p.push(w)}const g=(a==0||l==a-1)&&r==a?c+1:d-1;o.insert(o.mapping.map(g),p)}c=d}return o.setMeta(dt,{fixTables:!0})}function M(e){const t=e.selection,n=j(e),o=n.node(-1),i=n.start(-1),s=v.get(o);return{...t instanceof b?s.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:o}}function Ne(e,{map:t,tableStart:n,table:o},i){let s=i>0?-1:0;it(t,o,i+s)&&(s=i==0||i==t.width?null:0);for(let l=0;l<t.height;l++){const r=l*t.width+i;if(i>0&&i<t.width&&t.map[r-1]==t.map[r]){const a=t.map[r],c=o.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,xe(c.attrs,i-t.colCount(a))),l+=c.attrs.rowspan-1}else{const a=s==null?S(o.type.schema).cell:o.nodeAt(t.map[r+s]).type,c=t.positionAt(l,i,o);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function an(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Ne(e.tr,n,n.left))}return!0}function cn(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Ne(e.tr,n,n.right))}return!0}function ft(e,{map:t,table:n,tableStart:o},i){const s=e.mapping.maps.length;for(let l=0;l<t.height;){const r=l*t.width+i,a=t.map[r],c=n.nodeAt(a),u=c.attrs;if(i>0&&t.map[r-1]==a||i<t.width-1&&t.map[r+1]==a)e.setNodeMarkup(e.mapping.slice(s).map(o+a),null,P(u,i-t.colCount(a)));else{const d=e.mapping.slice(s).map(o+a);e.delete(d,d+c.nodeSize)}l+=u.rowspan}}function dn(e,t){if(!I(e))return!1;if(t){const n=M(e),o=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;ft(o,n,i),i!=n.left;i--){const s=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=v.get(s)}t(o)}return!0}function pt(e,t,n){var o;const i=S(t.type.schema).header_cell;for(let s=0;s<e.width;s++)if(((o=t.nodeAt(e.map[s+n*e.width]))===null||o===void 0?void 0:o.type)!=i)return!1;return!0}function Pe(e,{map:t,tableStart:n,table:o},i){let s=n;for(let c=0;c<i;c++)s+=o.child(c).nodeSize;const l=[];let r=i>0?-1:0;pt(t,o,i+r)&&(r=i==0||i==t.height?null:0);for(let c=0,u=t.width*i;c<t.width;c++,u++)if(i>0&&i<t.height&&t.map[u]==t.map[u-t.width]){const d=t.map[u],h=o.nodeAt(d).attrs;e.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var a;const d=r==null?S(o.type.schema).cell:(a=o.nodeAt(t.map[u+r*t.width]))===null||a===void 0?void 0:a.type,h=d?.createAndFill();h&&l.push(h)}return e.insert(s,S(o.type.schema).row.create(null,l)),e}function un(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Pe(e.tr,n,n.top))}return!0}function hn(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Pe(e.tr,n,n.bottom))}return!0}function gt(e,{map:t,table:n,tableStart:o},i){let s=0;for(let c=0;c<i;c++)s+=n.child(c).nodeSize;const l=s+n.child(i).nodeSize,r=e.mapping.maps.length;e.delete(s+o,l+o);const a=new Set;for(let c=0,u=i*t.width;c<t.width;c++,u++){const d=t.map[u];if(!a.has(d)){if(a.add(d),i>0&&d==t.map[u-t.width]){const h=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(r).map(d+o),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<t.height&&d==t.map[u+t.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=t.positionAt(i+1,c,n);e.insert(e.mapping.slice(r).map(o+g),p),c+=f.colspan-1}}}}function fn(e,t){if(!I(e))return!1;if(t){const n=M(e),o=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;gt(o,n,i),i!=n.top;i--){const s=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=v.get(n.table)}t(o)}return!0}function le(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function mt({width:e,height:t,map:n},o){let i=o.top*e+o.left,s=i,l=(o.bottom-1)*e+o.left,r=i+(o.right-o.left-1);for(let a=o.top;a<o.bottom;a++){if(o.left>0&&n[s]==n[s-1]||o.right<e&&n[r]==n[r+1])return!0;s+=e,r+=e}for(let a=o.left;a<o.right;a++){if(o.top>0&&n[i]==n[i-e]||o.bottom<t&&n[l]==n[l+e])return!0;i++,l++}return!1}function pn(e,t){const n=e.selection;if(!(n instanceof b)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=M(e),{map:i}=o;if(mt(i,o))return!1;if(t){const s=e.tr,l={};let r=A.empty,a,c;for(let u=o.top;u<o.bottom;u++)for(let d=o.left;d<o.right;d++){const h=i.map[u*i.width+d],f=o.table.nodeAt(h);if(!(l[h]||!f))if(l[h]=!0,a==null)a=h,c=f;else{le(f)||(r=r.append(f.content));const p=s.mapping.map(h+o.tableStart);s.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+o.tableStart,null,{...xe(c.attrs,c.attrs.colspan,o.right-o.left-c.attrs.colspan),rowspan:o.bottom-o.top}),r.size>0){const u=a+1+c.content.size,d=le(c)?a+1:u;s.replaceWith(d+o.tableStart,u+o.tableStart,r)}s.setSelection(new b(s.doc.resolve(a+o.tableStart))),t(s)}return!0}function gn(e,t){const n=S(e.schema);return wt(({node:o})=>n[o.type.spec.tableRole])(e,t)}function wt(e){return(t,n)=>{const o=t.selection;let i,s;if(o instanceof b){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{var l;if(i=tt(o.$from),!i)return!1;s=(l=N(o.$from))===null||l===void 0?void 0:l.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let r=i.attrs;const a=[],c=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const u=M(t),d=t.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...r,colwidth:c&&c[f]?[c[f]]:null}:r);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=i.nodeSize);for(let g=u.left,m=0;g<u.right;g++,m++)g==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),e({node:i,row:f,col:g}).createAndFill(a[m]))}d.setNodeMarkup(s,e({node:i,row:u.top,col:u.left}),a[0]),o instanceof b&&d.setSelection(new b(d.doc.resolve(o.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function mn(e,t){return function(n,o){if(!I(n))return!1;const i=j(n);if(i.nodeAfter.attrs[e]===t)return!1;if(o){const s=n.tr;n.selection instanceof b?n.selection.forEachCell((l,r)=>{l.attrs[e]!==t&&s.setNodeMarkup(r,null,{...l.attrs,[e]:t})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),o(s)}return!0}}function bt(e){return function(t,n){if(!I(t))return!1;if(n){const o=S(t.schema),i=M(t),s=t.tr,l=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),r=l.map(a=>i.table.nodeAt(a));for(let a=0;a<l.length;a++)r[a].type==o.header_cell&&s.setNodeMarkup(i.tableStart+l[a],o.cell,r[a].attrs);if(s.steps.length===0)for(let a=0;a<l.length;a++)s.setNodeMarkup(i.tableStart+l[a],o.header_cell,r[a].attrs);n(s)}return!0}}function re(e,t,n){const o=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<o.length;i++){const s=t.table.nodeAt(o[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function se(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?bt(e):function(n,o){if(!I(n))return!1;if(o){const i=S(n.schema),s=M(n),l=n.tr,r=re("row",s,i),a=re("column",s,i),c=(e==="column"?r:e==="row"&&a)?1:0,u=e=="column"?{left:0,top:c,right:1,bottom:s.map.height}:e=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,d=e=="column"?a?i.cell:i.header_cell:e=="row"?r?i.cell:i.header_cell:i.cell;s.map.cellsInRect(u).forEach(h=>{const f=h+s.tableStart,p=l.doc.nodeAt(f);p&&l.setNodeMarkup(f,d,p.attrs)}),o(l)}return!0}}se("row",{useDeprecatedLogic:!0});se("column",{useDeprecatedLogic:!0});const wn=se("cell",{useDeprecatedLogic:!0});function vt(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let o=e.index(-1)-1,i=e.before();o>=0;o--){const s=e.node(-1).child(o),l=s.lastChild;if(l)return i-1-l.nodeSize;i-=s.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let o=e.indexAfter(-1),i=e.after();o<n.childCount;o++){const s=n.child(o);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function bn(e){return function(t,n){if(!I(t))return!1;const o=vt(j(t),e);if(o==null)return!1;if(n){const i=t.doc.resolve(o);n(t.tr.setSelection(H.between(i,ot(i))).scrollIntoView())}return!0}}function vn(e,t){const n=e.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function V(e,t){const n=e.selection;if(!(n instanceof b))return!1;if(t){const o=e.tr,i=S(e.schema).cell.createAndFill().content;n.forEachCell((s,l)=>{s.content.eq(i)||o.replace(o.mapping.map(l+1),o.mapping.map(l+s.nodeSize-1),new U(i,0,0))}),o.docChanged&&t(o)}return!0}function yt(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:o}=e;for(;t.childCount==1&&(n>0&&o>0||t.child(0).type.spec.tableRole=="table");)n--,o--,t=t.child(0).content;const i=t.child(0),s=i.type.spec.tableRole,l=i.type.schema,r=[];if(s=="row")for(let a=0;a<t.childCount;a++){let c=t.child(a).content;const u=a?0:Math.max(0,n-1),d=a<t.childCount-1?0:Math.max(0,o-1);(u||d)&&(c=te(S(l).row,new U(c,u,d)).content),r.push(c)}else if(s=="cell"||s=="header_cell")r.push(n||o?te(S(l).row,new U(t,n,o)).content:t);else return null;return Ct(l,r)}function Ct(e,t){const n=[];for(let i=0;i<t.length;i++){const s=t[i];for(let l=s.childCount-1;l>=0;l--){const{rowspan:r,colspan:a}=s.child(l).attrs;for(let c=i;c<i+r;c++)n[c]=(n[c]||0)+a}}let o=0;for(let i=0;i<n.length;i++)o=Math.max(o,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(A.empty),n[i]<o){const s=S(e).cell.createAndFill(),l=[];for(let r=n[i];r<o;r++)l.push(s);t[i]=t[i].append(A.from(l))}return{height:t.length,width:o,rows:t}}function te(e,t){const n=e.createAndFill();return new qe(n).replace(0,n.content.size,t).doc}function St({width:e,height:t,rows:n},o,i){if(e!=o){const s=[],l=[];for(let r=0;r<n.length;r++){const a=n[r],c=[];for(let u=s[r]||0,d=0;u<o;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>o&&(h=h.type.createChecked(P(h.attrs,h.attrs.colspan,u+h.attrs.colspan-o),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)s[r+f]=(s[r+f]||0)+h.attrs.colspan}l.push(A.from(c))}n=l,e=o}if(t!=i){const s=[];for(let l=0,r=0;l<i;l++,r++){const a=[],c=n[r%t];for(let u=0;u<c.childCount;u++){let d=c.child(u);l+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),a.push(d)}s.push(A.from(a))}n=s,t=i}return{width:e,height:t,rows:n}}function Rt(e,t,n,o,i,s,l){const r=e.doc.type.schema,a=S(r);let c,u;if(i>t.width)for(let d=0,h=0;d<t.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let m=t.width;m<i;m++)p.push(g);e.insert(e.mapping.slice(l).map(h-1+o),p)}if(s>t.height){const d=[];for(let p=0,g=(t.height-1)*t.width;p<Math.max(t.width,i);p++){const m=p>=t.width?!1:n.nodeAt(t.map[g+p]).type==a.header_cell;d.push(m?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,A.from(d)),f=[];for(let p=t.height;p<s;p++)f.push(h);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),f)}return!!(c||u)}function ae(e,t,n,o,i,s,l,r){if(l==0||l==t.height)return!1;let a=!1;for(let c=i;c<s;c++){const u=l*t.width+c,d=t.map[u];if(t.map[u-t.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(r).map(d+o),null,{...h.attrs,rowspan:l-f}),e.insert(e.mapping.slice(r).map(t.positionAt(l,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-l})),c+=h.attrs.colspan-1}}return a}function ce(e,t,n,o,i,s,l,r){if(l==0||l==t.width)return!1;let a=!1;for(let c=i;c<s;c++){const u=c*t.width+l,d=t.map[u];if(t.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=t.colCount(d),p=e.mapping.slice(r).map(d+o);e.setNodeMarkup(p,null,P(h.attrs,l-f,h.attrs.colspan-(l-f))),e.insert(p+h.nodeSize,h.type.createAndFill(P(h.attrs,0,l-f))),c+=h.attrs.rowspan-1}}return a}function de(e,t,n,o,i){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let l=v.get(s);const{top:r,left:a}=o,c=a+i.width,u=r+i.height,d=e.tr;let h=0;function f(){if(s=n?d.doc.nodeAt(n-1):d.doc,!s)throw new Error("No table found");l=v.get(s),h=d.mapping.maps.length}Rt(d,l,s,n,c,u,h)&&f(),ae(d,l,s,n,a,c,r,h)&&f(),ae(d,l,s,n,a,c,u,h)&&f(),ce(d,l,s,n,r,u,a,h)&&f(),ce(d,l,s,n,r,u,c,h)&&f();for(let p=r;p<u;p++){const g=l.positionAt(p,a,s),m=l.positionAt(p,c,s);d.replace(d.mapping.slice(h).map(g+n),d.mapping.slice(h).map(m+n),new U(i.rows[p-r],0,0))}f(),d.setSelection(new b(d.doc.resolve(n+l.positionAt(r,a,s)),d.doc.resolve(n+l.positionAt(u-1,c-1,s)))),t(d)}const Et=We({ArrowLeft:K("horiz",-1),ArrowRight:K("horiz",1),ArrowUp:K("vert",-1),ArrowDown:K("vert",1),"Shift-ArrowLeft":k("horiz",-1),"Shift-ArrowRight":k("horiz",1),"Shift-ArrowUp":k("vert",-1),"Shift-ArrowDown":k("vert",1),Backspace:V,"Mod-Backspace":V,Delete:V,"Mod-Delete":V});function _(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function K(e,t){return(n,o,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof b)return _(n,o,D.near(s.$headCell,t));if(e!="horiz"&&!s.empty)return!1;const l=Le(i,e,t);if(l==null)return!1;if(e=="horiz")return _(n,o,D.near(n.doc.resolve(s.head+t),t));{const r=n.doc.resolve(l),a=De(r,e,t);let c;return a?c=D.near(a,1):t<0?c=D.near(n.doc.resolve(r.before(-1)),-1):c=D.near(n.doc.resolve(r.after(-1)),1),_(n,o,c)}}}function k(e,t){return(n,o,i)=>{if(!i)return!1;const s=n.selection;let l;if(s instanceof b)l=s;else{const a=Le(i,e,t);if(a==null)return!1;l=new b(n.doc.resolve(a))}const r=De(l.$headCell,e,t);return r?_(n,o,new b(l.$anchorCell,r)):!1}}function Tt(e,t){const n=e.state.doc,o=N(n.resolve(t));return o?(e.dispatch(e.state.tr.setSelection(new b(o))),!0):!1}function Ot(e,t,n){if(!I(e.state))return!1;let o=yt(n);const i=e.state.selection;if(i instanceof b){o||(o={width:1,height:1,rows:[A.from(te(S(e.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),l=i.$anchorCell.start(-1),r=v.get(s).rectBetween(i.$anchorCell.pos-l,i.$headCell.pos-l);return o=St(o,r.right-r.left,r.bottom-r.top),de(e.state,e.dispatch,l,r,o),!0}else if(o){const s=j(e.state),l=s.start(-1);return de(e.state,e.dispatch,l,v.get(s.node(-1)).findCell(s.pos-l),o),!0}else return!1}function It(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;const o=ue(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof b)s(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&(i=N(e.state.selection.$anchor))!=null&&((n=X(e,t))===null||n===void 0?void 0:n.pos)!=i.pos)s(i,t),t.preventDefault();else if(!o)return;function s(a,c){let u=X(e,c);const d=x.getState(e.state)==null;if(!u||!ie(a,u))if(d)u=a;else return;const h=new b(a,u);if(d||!e.state.selection.eq(h)){const f=e.state.tr.setSelection(h);d&&f.setMeta(x,a.pos),e.dispatch(f)}}function l(){e.root.removeEventListener("mouseup",l),e.root.removeEventListener("dragstart",l),e.root.removeEventListener("mousemove",r),x.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(x,-1))}function r(a){const c=a,u=x.getState(e.state);let d;if(u!=null)d=e.state.doc.resolve(u);else if(ue(e,c.target)!=o&&(d=X(e,t),!d))return l();d&&s(d,c)}e.root.addEventListener("mouseup",l),e.root.addEventListener("dragstart",l),e.root.addEventListener("mousemove",r)}function Le(e,t,n){if(!(e.state.selection instanceof H))return null;const{$head:o}=e.state.selection;for(let i=o.depth-1;i>=0;i--){const s=o.node(i);if((n<0?o.index(i):o.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=o.before(i),r=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(r)?l:null}}return null}function ue(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function X(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:o,pos:i}=n;return o>=0&&N(e.state.doc.resolve(o))||N(e.state.doc.resolve(i))}var At=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ne(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ne(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ne(e,t,n,o,i,s){let l=0,r=!0,a=t.firstChild;const c=e.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let g=0;g<f;g++,h++){const m=i==h?s:p&&p[g],w=m?m+"px":"";if(l+=m||o,m||(r=!1),a)a.style.width!=w&&(a.style.width=w),a=a.nextSibling;else{const R=document.createElement("col");R.style.width=w,t.appendChild(R)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}r?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}const E=new B("tableColumnResizing");function yn({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=At,lastColumnResizable:i=!0}={}){const s=new W({key:E,state:{init(l,r){var a;const c=(a=s.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=S(r.schema).table.name;return o&&c&&(c[u]=(d,h)=>new o(d,n,h)),new Mt(-1,!1)},apply(l,r){return r.apply(l)}},props:{attributes:l=>{const r=E.getState(l);return r&&r.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,r)=>{zt(l,r,e,i)},mouseleave:l=>{Dt(l)},mousedown:(l,r)=>{xt(l,r,t,n)}},decorations:l=>{const r=E.getState(l);if(r&&r.activeHandle>-1)return Lt(l,r.activeHandle)},nodeViews:{}}});return s}var Mt=class F{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,o=t.getMeta(E);if(o&&o.setHandle!=null)return new F(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new F(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return ee(t.doc.resolve(i))||(i=-1),new F(i,n.dragging)}return n}};function zt(e,t,n,o){if(!e.editable)return;const i=E.getState(e.state);if(i&&!i.dragging){const s=Ht(t.target);let l=-1;if(s){const{left:r,right:a}=s.getBoundingClientRect();t.clientX-r<=n?l=he(e,t,"left",n):a-t.clientX<=n&&(l=he(e,t,"right",n))}if(l!=i.activeHandle){if(!o&&l!==-1){const r=e.state.doc.resolve(l),a=r.node(-1),c=v.get(a),u=r.start(-1);if(c.colCount(r.pos-u)+r.nodeAfter.attrs.colspan-1==c.width-1)return}Be(e,l)}}}function Dt(e){if(!e.editable)return;const t=E.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Be(e,-1)}function xt(e,t,n,o){var i;if(!e.editable)return!1;const s=(i=e.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,l=E.getState(e.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const r=e.state.doc.nodeAt(l.activeHandle),a=Ut(e,l.activeHandle,r.attrs);e.dispatch(e.state.tr.setMeta(E,{setDragging:{startX:t.clientX,startWidth:a}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);const h=E.getState(e.state);h?.dragging&&(Nt(e,h.activeHandle,fe(h.dragging,d,n)),e.dispatch(e.state.tr.setMeta(E,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=E.getState(e.state);if(h&&h.dragging){const f=fe(h.dragging,d,n);pe(e,h.activeHandle,f,o)}}return pe(e,l.activeHandle,a,o),s.addEventListener("mouseup",c),s.addEventListener("mousemove",u),t.preventDefault(),!0}function Ut(e,t,{colspan:n,colwidth:o}){const i=o&&o[o.length-1];if(i)return i;const s=e.domAtPos(t);let l=s.node.childNodes[s.offset].offsetWidth,r=n;if(o)for(let a=0;a<n;a++)o[a]&&(l-=o[a],r--);return l/r}function Ht(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function he(e,t,n,o){const i=n=="right"?-o:o,s=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!s)return-1;const{pos:l}=s,r=N(e.state.doc.resolve(l));if(!r)return-1;if(n=="right")return r.pos;const a=v.get(r.node(-1)),c=r.start(-1),u=a.map.indexOf(r.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function fe(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function Be(e,t){e.dispatch(e.state.tr.setMeta(E,{setHandle:t}))}function Nt(e,t,n){const o=e.state.doc.resolve(t),i=o.node(-1),s=v.get(i),l=o.start(-1),r=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+r;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],h=i.nodeAt(d).attrs,f=h.colspan==1?0:r-s.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():Pt(h.colspan);p[f]=n,a.setNodeMarkup(l+d,null,{...h,colwidth:p})}a.docChanged&&e.dispatch(a)}function pe(e,t,n,o){const i=e.state.doc.resolve(t),s=i.node(-1),l=i.start(-1),r=v.get(s).colCount(i.pos-l)+i.nodeAfter.attrs.colspan-1;let a=e.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ne(s,a.firstChild,a,o,r,n)}function Pt(e){return Array(e).fill(0)}function Lt(e,t){const n=[],o=e.doc.resolve(t),i=o.node(-1);if(!i)return G.empty;const s=v.get(i),l=o.start(-1),r=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const u=r+c*s.width;if((r==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){var a;const d=s.map[u],h=l+d+i.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=E.getState(e))===null||a===void 0)&&a.dragging&&n.push(J.node(l+d,l+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(J.widget(h,f))}}return G.create(e.doc,n)}function Cn({allowTableNodeSelection:e=!1}={}){return new W({key:x,state:{init(){return null},apply(t,n){const o=t.getMeta(x);if(o!=null)return o==-1?null:o;if(n==null||!t.docChanged)return n;const{deleted:i,pos:s}=t.mapping.mapResult(n);return i?null:s}},props:{decorations:lt,handleDOMEvents:{mousedown:It},createSelectionBetween(t){return x.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Tt,handleKeyDown:Et,handlePaste:Ot},appendTransaction(t,n,o){return ct(o,ut(o,n),e)}})}function Bt(e,t){const n=Math.min(e.top,t.top),o=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),s=Math.max(e.right,t.right)-i,l=o-n;return new DOMRect(i,n,s,l)}var $t=class{get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(ye(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ce(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(Se(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(Re(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Ee(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(Te(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(Oe(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(Ie(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t;const{selection:n}=this.editor.state,o=(e=this.getReferencedVirtualElement)===null||e===void 0?void 0:e.call(this);if(o)return o;if(!(!((t=this.view)===null||t===void 0||(t=t.dom)===null||t===void 0)&&t.parentNode))return;const i=we(this.view,n.from,n.to);let s={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(n instanceof me){let l=this.view.nodeDOM(n.from);const r=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");r&&(l=r),l&&(s={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(n instanceof b){const{$anchorCell:l,$headCell:r}=n,a=l?l.pos:r.pos,c=r?r.pos:l.pos,u=this.view.nodeDOM(a),d=this.view.nodeDOM(c);if(!u||!d)return;const h=u===d?u.getBoundingClientRect():Bt(u.getBoundingClientRect(),d.getBoundingClientRect());s={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return s}constructor({editor:e,element:t,view:n,pluginKey:o="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:l,appendTo:r,getReferencedVirtualElement:a,options:c}){var u;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:h,from:f,to:p})=>{const{doc:g,selection:m}=h,{empty:w}=m,R=!g.textBetween(f,p).length&&Xe(h.selection),y=this.element.contains(document.activeElement);return!(!(d.hasFocus()||y)||w||R||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var h;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}d?.relatedTarget&&(!((h=this.element.parentNode)===null||h===void 0)&&h.contains(d.relatedTarget))||d?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,h)=>{const f=!h?.selection.eq(d.state.selection),p=!h?.doc.eq(d.state.doc);!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,f,p,h)},this.updateDelay))},this.updateHandler=(d,h,f,p)=>{const{composing:g}=d;if(!(g||!h&&!f)){if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:d})=>{const h=d.getMeta(this.pluginKey);h==="updatePosition"?this.updatePosition():h&&typeof h=="object"&&h.type==="updateOptions"?this.updateOptions(h.options):h==="hide"?this.hide():h==="show"&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=o,this.updateDelay=i,this.resizeDelay=s,this.appendTo=r,this.scrollTarget=(u=c?.scrollTarget)!==null&&u!==void 0?u:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;const e=this.virtualElement;e&&Ae(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:n,strategy:o,middlewareData:i})=>{var s,l;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(!((s=i.hide)===null||s===void 0)&&s.referenceHidden||!((l=i.hide)===null||l===void 0)&&l.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${t}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){const{state:n}=e,o=n.selection.from!==n.selection.to;if(this.updateDelay>0&&o){this.handleDebouncedUpdate(e,t);return}const i=!t?.selection.eq(e.state.selection),s=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,s,t)}getShouldShow(e){var t;const{state:n}=this.view,{selection:o}=n,{ranges:i}=o,s=Math.min(...i.map(r=>r.$from.pos)),l=Math.max(...i.map(r=>r.$to.pos));return((t=this.shouldShow)===null||t===void 0?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:s,to:l}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)===null||e===void 0||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){var t;const n=(t=e.options.scrollTarget)!==null&&t!==void 0?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}};const $e=e=>new W({key:typeof e.pluginKey=="string"?new B(e.pluginKey):e.pluginKey,view:t=>new $t({view:t,...e})});be.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[$e({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var Vt=class{getTextContent(e){return Ye(e,{textSerializers:Ge(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(ye(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ce(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(Se(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(Re(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Ee(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(Te(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(Oe(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(Ie(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}constructor({editor:e,element:t,view:n,pluginKey:o="floatingMenu",updateDelay:i=250,resizeDelay:s=60,options:l,appendTo:r,shouldShow:a}){var c;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:d})=>{const{selection:h}=d,{$anchor:f,empty:p}=h,g=f.depth===1,m=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!u.hasFocus()||!p||!g||!m||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,d,h,f)=>{const{composing:p}=u;if(!(p||!d&&!h)){if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&(!((d=this.element.parentNode)===null||d===void 0)&&d.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta(this.pluginKey);d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"?this.updateOptions(d.options):d==="hide"?this.hide():d==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=o,this.updateDelay=i,this.resizeDelay=s,this.appendTo=r,this.scrollTarget=(c=l?.scrollTarget)!==null&&c!==void 0?c:window,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getShouldShow(e){var t;const{state:n}=this.view,{selection:o}=n,{ranges:i}=o,s=Math.min(...i.map(r=>r.$from.pos)),l=Math.max(...i.map(r=>r.$to.pos));return(t=this.shouldShow)===null||t===void 0?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:s,to:l})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){var t;const n=(t=e.options.scrollTarget)!==null&&t!==void 0?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e;if(!(!((e=this.view)===null||e===void 0||(e=e.dom)===null||e===void 0)&&e.parentNode))return;const{selection:t}=this.editor.state,n=we(this.view,t.from,t.to);Ae({getBoundingClientRect:()=>n,getClientRects:()=>[n]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:o,y:i,strategy:s,middlewareData:l})=>{var r,a;if(!((r=l.hide)===null||r===void 0)&&r.referenceHidden||!((a=l.hide)===null||a===void 0)&&a.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${o}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const n=!t?.selection.eq(e.state.selection),o=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,o,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)===null||e===void 0||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}};const Ve=e=>new W({key:typeof e.pluginKey=="string"?new B(e.pluginKey):e.pluginKey,view:t=>new Vt({view:t,...e})});be.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[Ve({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function Ke(e,t){return e??new B(t)}const Kt=typeof window<"u"?C.useLayoutEffect:C.useEffect,ke=new Set(["left","opacity","position","top","visibility","width"]),kt=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),_t=new Set(["children","className","style"]),Ft=new Set(["tabIndex"]),Wt=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),jt={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function oe(e,t){return/^on[A-Z]/.test(e)&&typeof t=="function"}function qt(e){return e.startsWith("aria-")||e.startsWith("data-"),e}function Xt(e){return e.startsWith("aria-")||e.startsWith("data-")||Wt.has(e)}function _e(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Yt(e){var t;const n=e.endsWith("Capture"),o=(n?e.slice(0,-7):e).slice(2);return{eventName:(t=jt[o])!==null&&t!==void 0?t:o.toLowerCase(),options:n?{capture:!0}:void 0}}function Gt(e,t){let n=t.defaultPrevented,o=!1;const i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>o},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{o=!0,t.stopPropagation()}}}),i}function Y(e){return Ft.has(e)}function ge(e,t,n){if(t==="tabIndex"){e.tabIndex=Number(n);return}e[t]=n}function Jt(e,t){if(t==="tabIndex"){e.removeAttribute("tabindex");return}const n=e[t];if(typeof n=="boolean"){e[t]=!1;return}if(typeof n=="number"){e[t]=0;return}e[t]=""}function Zt(e,t){return typeof t!="number"||t===0||e.startsWith("--")||kt.has(e)?String(t):`${t}px`}function Qt(e,t){ke.has(t)||e.style.removeProperty(_e(t))}function en(e,t,n){ke.has(t)||e.style.setProperty(_e(t),Zt(t,n))}function tn(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(o=>{if(_t.has(o)||!Xt(o)||oe(o,t[o])||oe(o,n[o]))return;const i=t[o],s=n[o];if(i===s)return;const l=qt(o);if(s==null||s===!1){Y(o)&&Jt(e,o),e.removeAttribute(l);return}if(s===!0){Y(o)&&ge(e,o,!0),e.setAttribute(l,"");return}if(Y(o)){ge(e,o,s);return}e.setAttribute(l,String(s))})}function nn(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}function on(e,t,n){const o=t??{},i=n??{};new Set([...Object.keys(o),...Object.keys(i)]).forEach(s=>{const l=o[s],r=i[s];if(l!==r){if(r==null){Qt(e,s);return}en(e,s,r)}})}function sn(e,t,n){t.forEach(({eventName:i,listener:s,options:l})=>{e.removeEventListener(i,s,l)});const o=[];return Object.entries(n).forEach(([i,s])=>{if(!oe(i,s))return;const{eventName:l,options:r}=Yt(i),a=c=>{s(Gt(e,c))};e.addEventListener(l,a,r),o.push({eventName:l,listener:a,options:r})}),o}function Fe(e,t){const n=C.useRef({}),o=C.useRef([]);Kt(()=>{const i=n.current;return nn(e,i.className,t.className),on(e,i.style,t.style),tn(e,i,t),o.current=sn(e,o.current,t),n.current=t,()=>{o.current.forEach(({eventName:s,listener:l,options:r})=>{e.removeEventListener(s,l,r)}),o.current=[]}},[e,t])}const Sn=Me.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:o,appendTo:i,shouldShow:s=null,getReferencedVirtualElement:l,options:r,children:a,...c},u)=>{const d=C.useRef(document.createElement("div")),h=C.useRef(Ke(e,"bubbleMenu")).current;Fe(d.current,c),typeof u=="function"?u(d.current):u&&(u.current=d.current);const{editor:f}=ve(),p=t||f,g={updateDelay:n,resizeDelay:o,appendTo:i,pluginKey:h,shouldShow:s,getReferencedVirtualElement:l,options:r},m=C.useRef(g);m.current=g;const[w,R]=C.useState(!1),y=C.useRef(!0);return C.useEffect(()=>{if(p?.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const T=d.current;T.style.visibility="hidden",T.style.position="absolute";const O=$e({...m.current,editor:p,element:T});p.registerPlugin(O);const L=m.current.pluginKey;return y.current=!0,R(!0),()=>{R(!1),p.unregisterPlugin(L),window.requestAnimationFrame(()=>{T.parentNode&&T.parentNode.removeChild(T)})}},[p]),C.useEffect(()=>{if(!(!w||!p||p.isDestroyed)){if(y.current){y.current=!1;return}p.view.dispatch(p.state.tr.setMeta(h,{type:"updateOptions",options:m.current}))}},[w,p,n,o,s,r,i,l,h]),ze.createPortal(a,d.current)});Me.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:o,appendTo:i,shouldShow:s=null,options:l,children:r,...a},c)=>{const u=C.useRef(document.createElement("div")),d=C.useRef(Ke(e,"floatingMenu")).current;Fe(u.current,a),typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:h}=ve(),f=t||h,p={updateDelay:n,resizeDelay:o,appendTo:i,pluginKey:d,shouldShow:s,options:l},g=C.useRef(p);g.current=p;const[m,w]=C.useState(!1),R=C.useRef(!0);return C.useEffect(()=>{if(f?.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const y=u.current;y.style.visibility="hidden",y.style.position="absolute";const T=Ve({...g.current,editor:f,element:y});f.registerPlugin(T);const O=g.current.pluginKey;return R.current=!0,w(!0),()=>{w(!1),f.unregisterPlugin(O),window.requestAnimationFrame(()=>{y.parentNode&&y.parentNode.removeChild(y)})}},[f]),C.useEffect(()=>{if(!(!m||!f||f.isDestroyed)){if(R.current){R.current=!1;return}f.view.dispatch(f.state.tr.setMeta(d,{type:"updateOptions",options:g.current}))}},[m,f,n,o,s,l,i,d]),ze.createPortal(r,u.current)});export{Sn as B,b as C,gn as a,wn as b,yn as c,se as d,vn as e,ut as f,bn as g,fn as h,hn as i,un as j,dn as k,cn as l,pn as m,an as n,mn as s,Cn as t};
1
+ import{j as B,a0 as D,a1 as We,T as H,a2 as je,a3 as A,a4 as U,k as W,a5 as G,a6 as J,a7 as me,a8 as qe,a9 as we,aa as Xe,E as be,ab as Ye,ac as Ge,f as ve}from"./usage-stats-Cp4Mqdjr.js";import{eW as ye,f0 as Ce,eV as Se,f1 as Re,f2 as Ee,f3 as Te,f4 as Oe,f5 as Ie,eX as Ae,aI as Me,r as C,ar as ze}from"./index-BodvdIMk.js";let Z,Q;if(typeof WeakMap<"u"){let e=new WeakMap;Z=t=>e.get(t),Q=(t,n)=>(e.set(t,n),n)}else{const e=[];let n=0;Z=o=>{for(let i=0;i<e.length;i+=2)if(e[i]==o)return e[i+1]},Q=(o,i)=>(n==10&&(n=0),e[n++]=o,e[n++]=i)}var v=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const o=t%this.width,i=t/this.width|0;let s=o+1,l=i+1;for(let r=1;s<this.width&&this.map[t+r]==n;r++)s++;for(let r=1;l<this.height&&this.map[t+this.width*r]==n;r++)l++;return{left:o,top:i,right:s,bottom:l}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:o,right:i,top:s,bottom:l}=this.findCell(e);return t=="horiz"?(n<0?o==0:i==this.width)?null:this.map[s*this.width+(n<0?o-1:i)]:(n<0?s==0:l==this.height)?null:this.map[o+this.width*(n<0?s-1:l)]}rectBetween(e,t){const{left:n,right:o,top:i,bottom:s}=this.findCell(e),{left:l,right:r,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,l),top:Math.min(i,a),right:Math.max(o,r),bottom:Math.max(s,c)}}cellsInRect(e){const t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let i=e.left;i<e.right;i++){const s=o*this.width+i,l=this.map[s];n[l]||(n[l]=!0,!(i==e.left&&i&&this.map[s-1]==l||o==e.top&&o&&this.map[s-this.width]==l)&&t.push(l))}return t}positionAt(e,t,n){for(let o=0,i=0;;o++){const s=i+n.child(o).nodeSize;if(o==e){let l=t+e*this.width;const r=(e+1)*this.width;for(;l<r&&this.map[l]<i;)l++;return l==r?s-1:this.map[l]}i=s}}static get(e){return Z(e)||Q(e,Je(e))}};function Je(e){if(e.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+e.type.name);const t=Ze(e),n=e.childCount,o=[];let i=0,s=null;const l=[];for(let c=0,u=t*n;c<u;c++)o[c]=0;for(let c=0,u=0;c<n;c++){const d=e.child(c);u++;for(let p=0;;p++){for(;i<o.length&&o[i]!=0;)i++;if(p==d.childCount)break;const g=d.child(p),{colspan:m,rowspan:w,colwidth:R}=g.attrs;for(let y=0;y<w;y++){if(y+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-y});break}const T=i+y*t;for(let O=0;O<m;O++){o[T+O]==0?o[T+O]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:m-O});const L=R&&R[O];if(L){const $=(T+O)%t*2,q=l[$];q==null||q!=L&&l[$+1]==1?(l[$]=L,l[$+1]=1):q==L&&l[$+1]++}}}i+=m,u+=g.nodeSize}const h=(c+1)*t;let f=0;for(;i<h;)o[i++]==0&&f++;f&&(s||(s=[])).push({type:"missing",row:c,n:f}),u++}(t===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const r=new v(t,n,o,s);let a=!1;for(let c=0;!a&&c<l.length;c+=2)l[c]!=null&&l[c+1]<n&&(a=!0);return a&&Qe(r,l,e),r}function Ze(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){const i=e.child(o);let s=0;if(n)for(let l=0;l<o;l++){const r=e.child(l);for(let a=0;a<r.childCount;a++){const c=r.child(a);l+c.attrs.rowspan>o&&(s+=c.attrs.colspan)}}for(let l=0;l<i.childCount;l++){const r=i.child(l);s+=r.attrs.colspan,r.attrs.rowspan>1&&(n=!0)}t==-1?t=s:t!=s&&(t=Math.max(t,s))}return t}function Qe(e,t,n){e.problems||(e.problems=[]);const o={};for(let i=0;i<e.map.length;i++){const s=e.map[i];if(o[s])continue;o[s]=!0;const l=n.nodeAt(s);if(!l)throw new RangeError(`No cell with offset ${s} found`);let r=null;const a=l.attrs;for(let c=0;c<a.colspan;c++){const u=t[(i+c)%e.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((r||(r=et(a)))[c]=u)}r&&e.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:r})}}function et(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function S(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const o=e.nodes[n],i=o.spec.tableRole;i&&(t[i]=o)}}return t}const x=new B("selectingCells");function N(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function tt(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if(n==="cell"||n==="header_cell")return e.node(t)}return null}function I(e){const t=e.selection.$head;for(let n=t.depth;n>0;n--)if(t.node(n).type.spec.tableRole=="row")return!0;return!1}function j(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const n=N(t.$head)||nt(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function nt(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const o=t.type.spec.tableRole;if(o=="cell"||o=="header_cell")return e.doc.resolve(n-t.nodeSize)}}function ee(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function ot(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function ie(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function De(e,t,n){const o=e.node(-1),i=v.get(o),s=e.start(-1),l=i.nextCell(e.pos-s,t,n);return l==null?null:e.node(0).resolve(s+l)}function P(e,t,n=1){const o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some(i=>i>0)||(o.colwidth=null)),o}function xe(e,t,n=1){const o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let i=0;i<n;i++)o.colwidth.splice(t,0,0)}return o}function it(e,t,n){const o=S(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=o)return!1;return!0}var b=class z extends D{constructor(t,n=t){const o=t.node(-1),i=v.get(o),s=t.start(-1),l=i.rectBetween(t.pos-s,n.pos-s),r=t.node(0),a=i.cellsInRect(l).filter(u=>u!=n.pos-s);a.unshift(n.pos-s);const c=a.map(u=>{const d=o.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=s+u+1;return new je(r.resolve(h),r.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=t,this.$headCell=n}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(ee(o)&&ee(i)&&ie(o,i)){const s=this.$anchorCell.node(-1)!=o.node(-1);return s&&this.isRowSelection()?z.rowSelection(o,i):s&&this.isColSelection()?z.colSelection(o,i):new z(o,i)}return H.between(o,i)}content(){const t=this.$anchorCell.node(-1),n=v.get(t),o=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),s={},l=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*n.width+i.left,d=i.left;d<i.right;d++,u++){const h=n.map[u];if(s[h])continue;s[h]=!0;const f=n.findCell(h);let p=t.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const g=i.left-f.left,m=f.right-i.right;if(g>0||m>0){let w=p.attrs;if(g>0&&(w=P(w,0,g)),m>0&&(w=P(w,w.colspan-m,m)),f.left<i.left){if(p=p.type.createAndFill(w),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(w)}`)}else p=p.type.create(w,p.content)}if(f.top<i.top||f.bottom>i.bottom){const w={...p.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}l.push(t.child(a).copy(A.from(c)))}const r=this.isColSelection()&&this.isRowSelection()?t:l;return new U(A.from(r),1,1)}replace(t,n=U.empty){const o=t.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){const{$from:r,$to:a}=i[l],c=t.mapping.slice(o);t.replace(c.map(r.pos),c.map(a.pos),l?U.empty:n)}const s=D.findFrom(t.doc.resolve(t.mapping.slice(o).map(this.to)),-1);s&&t.setSelection(s)}replaceWith(t,n){this.replace(t,new U(A.from(n),0,0))}forEachCell(t){const n=this.$anchorCell.node(-1),o=v.get(n),i=this.$anchorCell.start(-1),s=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let l=0;l<s.length;l++)t(n.nodeAt(s[l]),i+s[l])}isColSelection(){const t=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(t,n)>0)return!1;const o=t+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,i)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const o=t.node(-1),i=v.get(o),s=t.start(-1),l=i.findCell(t.pos-s),r=i.findCell(n.pos-s),a=t.node(0);return l.top<=r.top?(l.top>0&&(t=a.resolve(s+i.map[l.left])),r.bottom<i.height&&(n=a.resolve(s+i.map[i.width*(i.height-1)+r.right-1]))):(r.top>0&&(n=a.resolve(s+i.map[r.left])),l.bottom<i.height&&(t=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))),new z(t,n)}isRowSelection(){const t=this.$anchorCell.node(-1),n=v.get(t),o=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-o),s=n.colCount(this.$headCell.pos-o);if(Math.min(i,s)>0)return!1;const l=i+this.$anchorCell.nodeAfter.attrs.colspan,r=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,r)==n.width}eq(t){return t instanceof z&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const o=t.node(-1),i=v.get(o),s=t.start(-1),l=i.findCell(t.pos-s),r=i.findCell(n.pos-s),a=t.node(0);return l.left<=r.left?(l.left>0&&(t=a.resolve(s+i.map[l.top*i.width])),r.right<i.width&&(n=a.resolve(s+i.map[i.width*(r.top+1)-1]))):(r.left>0&&(n=a.resolve(s+i.map[r.top*i.width])),l.right<i.width&&(t=a.resolve(s+i.map[i.width*(l.top+1)-1]))),new z(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new z(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new z(t.resolve(n),t.resolve(o))}getBookmark(){return new st(this.$anchorCell.pos,this.$headCell.pos)}};b.prototype.visible=!1;D.jsonID("cell",b);var st=class Ue{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Ue(t.map(this.anchor),t.map(this.head))}resolve(t){const n=t.resolve(this.anchor),o=t.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&o.index()<o.parent.childCount&&ie(n,o)?new b(n,o):D.near(o,1)}};function lt(e){if(!(e.selection instanceof b))return null;const t=[];return e.selection.forEachCell((n,o)=>{t.push(J.node(o,o+n.nodeSize,{class:"selectedCell"}))}),G.create(e.doc,t)}function rt({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let s=t.depth;s>=0&&!(t.before(s+1)>t.start(s));s--,o--);return n==o&&/row|table/.test(e.node(i).type.spec.tableRole)}function at({$from:e,$to:t}){let n,o;for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){o=s;break}}return n!==o&&t.parentOffset===0}function ct(e,t,n){const o=(t||e).selection,i=(t||e).doc;let s,l;if(o instanceof me&&(l=o.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")s=b.create(i,o.from);else if(l=="row"){const r=i.resolve(o.from+1);s=b.rowSelection(r,r)}else if(!n){const r=v.get(o.node),a=o.from+1,c=a+r.map[r.width*r.height-1];s=b.create(i,a+1,c)}}else o instanceof H&&rt(o)?s=H.create(i,o.from):o instanceof H&&at(o)&&(s=H.create(i,o.$from.start(),o.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}const dt=new B("fix-tables");function He(e,t,n,o){const i=e.childCount,s=t.childCount;e:for(let l=0,r=0;l<s;l++){const a=t.child(l);for(let c=r,u=Math.min(i,l+3);c<u;c++)if(e.child(c)==a){r=c+1,n+=a.nodeSize;continue e}o(a,n),r<i&&e.child(r).sameMarkup(a)?He(e.child(r),a,n+1,o):a.nodesBetween(0,a.content.size,o,n+1),n+=a.nodeSize}}function ut(e,t){let n;const o=(i,s)=>{i.type.spec.tableRole=="table"&&(n=ht(e,i,s,n))};return t?t.doc!=e.doc&&He(t.doc,e.doc,0,o):e.doc.descendants(o),n}function ht(e,t,n,o){const i=v.get(t);if(!i.problems)return o;o||(o=e.tr);const s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const u=t.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)s[c.row+h]+=c.n;o.setNodeMarkup(o.mapping.map(n+1+c.pos),null,P(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=t.nodeAt(c.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=t.nodeAt(c.pos);if(!u)continue;o.setNodeMarkup(o.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=o.mapping.map(n);o.delete(u,u+t.nodeSize)}}let l,r;for(let a=0;a<s.length;a++)s[a]&&(l==null&&(l=a),r=a);for(let a=0,c=n+1;a<i.height;a++){const u=t.child(a),d=c+u.nodeSize,h=s[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let m=0;m<h;m++){const w=S(e.schema)[f].createAndFill();w&&p.push(w)}const g=(a==0||l==a-1)&&r==a?c+1:d-1;o.insert(o.mapping.map(g),p)}c=d}return o.setMeta(dt,{fixTables:!0})}function M(e){const t=e.selection,n=j(e),o=n.node(-1),i=n.start(-1),s=v.get(o);return{...t instanceof b?s.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:o}}function Ne(e,{map:t,tableStart:n,table:o},i){let s=i>0?-1:0;it(t,o,i+s)&&(s=i==0||i==t.width?null:0);for(let l=0;l<t.height;l++){const r=l*t.width+i;if(i>0&&i<t.width&&t.map[r-1]==t.map[r]){const a=t.map[r],c=o.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,xe(c.attrs,i-t.colCount(a))),l+=c.attrs.rowspan-1}else{const a=s==null?S(o.type.schema).cell:o.nodeAt(t.map[r+s]).type,c=t.positionAt(l,i,o);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function an(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Ne(e.tr,n,n.left))}return!0}function cn(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Ne(e.tr,n,n.right))}return!0}function ft(e,{map:t,table:n,tableStart:o},i){const s=e.mapping.maps.length;for(let l=0;l<t.height;){const r=l*t.width+i,a=t.map[r],c=n.nodeAt(a),u=c.attrs;if(i>0&&t.map[r-1]==a||i<t.width-1&&t.map[r+1]==a)e.setNodeMarkup(e.mapping.slice(s).map(o+a),null,P(u,i-t.colCount(a)));else{const d=e.mapping.slice(s).map(o+a);e.delete(d,d+c.nodeSize)}l+=u.rowspan}}function dn(e,t){if(!I(e))return!1;if(t){const n=M(e),o=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;ft(o,n,i),i!=n.left;i--){const s=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=v.get(s)}t(o)}return!0}function pt(e,t,n){var o;const i=S(t.type.schema).header_cell;for(let s=0;s<e.width;s++)if(((o=t.nodeAt(e.map[s+n*e.width]))===null||o===void 0?void 0:o.type)!=i)return!1;return!0}function Pe(e,{map:t,tableStart:n,table:o},i){let s=n;for(let c=0;c<i;c++)s+=o.child(c).nodeSize;const l=[];let r=i>0?-1:0;pt(t,o,i+r)&&(r=i==0||i==t.height?null:0);for(let c=0,u=t.width*i;c<t.width;c++,u++)if(i>0&&i<t.height&&t.map[u]==t.map[u-t.width]){const d=t.map[u],h=o.nodeAt(d).attrs;e.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var a;const d=r==null?S(o.type.schema).cell:(a=o.nodeAt(t.map[u+r*t.width]))===null||a===void 0?void 0:a.type,h=d?.createAndFill();h&&l.push(h)}return e.insert(s,S(o.type.schema).row.create(null,l)),e}function un(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Pe(e.tr,n,n.top))}return!0}function hn(e,t){if(!I(e))return!1;if(t){const n=M(e);t(Pe(e.tr,n,n.bottom))}return!0}function gt(e,{map:t,table:n,tableStart:o},i){let s=0;for(let c=0;c<i;c++)s+=n.child(c).nodeSize;const l=s+n.child(i).nodeSize,r=e.mapping.maps.length;e.delete(s+o,l+o);const a=new Set;for(let c=0,u=i*t.width;c<t.width;c++,u++){const d=t.map[u];if(!a.has(d)){if(a.add(d),i>0&&d==t.map[u-t.width]){const h=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(r).map(d+o),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<t.height&&d==t.map[u+t.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=t.positionAt(i+1,c,n);e.insert(e.mapping.slice(r).map(o+g),p),c+=f.colspan-1}}}}function fn(e,t){if(!I(e))return!1;if(t){const n=M(e),o=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;gt(o,n,i),i!=n.top;i--){const s=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=v.get(n.table)}t(o)}return!0}function le(e){const t=e.content;return t.childCount==1&&t.child(0).isTextblock&&t.child(0).childCount==0}function mt({width:e,height:t,map:n},o){let i=o.top*e+o.left,s=i,l=(o.bottom-1)*e+o.left,r=i+(o.right-o.left-1);for(let a=o.top;a<o.bottom;a++){if(o.left>0&&n[s]==n[s-1]||o.right<e&&n[r]==n[r+1])return!0;s+=e,r+=e}for(let a=o.left;a<o.right;a++){if(o.top>0&&n[i]==n[i-e]||o.bottom<t&&n[l]==n[l+e])return!0;i++,l++}return!1}function pn(e,t){const n=e.selection;if(!(n instanceof b)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=M(e),{map:i}=o;if(mt(i,o))return!1;if(t){const s=e.tr,l={};let r=A.empty,a,c;for(let u=o.top;u<o.bottom;u++)for(let d=o.left;d<o.right;d++){const h=i.map[u*i.width+d],f=o.table.nodeAt(h);if(!(l[h]||!f))if(l[h]=!0,a==null)a=h,c=f;else{le(f)||(r=r.append(f.content));const p=s.mapping.map(h+o.tableStart);s.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+o.tableStart,null,{...xe(c.attrs,c.attrs.colspan,o.right-o.left-c.attrs.colspan),rowspan:o.bottom-o.top}),r.size>0){const u=a+1+c.content.size,d=le(c)?a+1:u;s.replaceWith(d+o.tableStart,u+o.tableStart,r)}s.setSelection(new b(s.doc.resolve(a+o.tableStart))),t(s)}return!0}function gn(e,t){const n=S(e.schema);return wt(({node:o})=>n[o.type.spec.tableRole])(e,t)}function wt(e){return(t,n)=>{const o=t.selection;let i,s;if(o instanceof b){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{var l;if(i=tt(o.$from),!i)return!1;s=(l=N(o.$from))===null||l===void 0?void 0:l.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let r=i.attrs;const a=[],c=r.colwidth;r.rowspan>1&&(r={...r,rowspan:1}),r.colspan>1&&(r={...r,colspan:1});const u=M(t),d=t.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...r,colwidth:c&&c[f]?[c[f]]:null}:r);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=i.nodeSize);for(let g=u.left,m=0;g<u.right;g++,m++)g==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),e({node:i,row:f,col:g}).createAndFill(a[m]))}d.setNodeMarkup(s,e({node:i,row:u.top,col:u.left}),a[0]),o instanceof b&&d.setSelection(new b(d.doc.resolve(o.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function mn(e,t){return function(n,o){if(!I(n))return!1;const i=j(n);if(i.nodeAfter.attrs[e]===t)return!1;if(o){const s=n.tr;n.selection instanceof b?n.selection.forEachCell((l,r)=>{l.attrs[e]!==t&&s.setNodeMarkup(r,null,{...l.attrs,[e]:t})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),o(s)}return!0}}function bt(e){return function(t,n){if(!I(t))return!1;if(n){const o=S(t.schema),i=M(t),s=t.tr,l=i.map.cellsInRect(e=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),r=l.map(a=>i.table.nodeAt(a));for(let a=0;a<l.length;a++)r[a].type==o.header_cell&&s.setNodeMarkup(i.tableStart+l[a],o.cell,r[a].attrs);if(s.steps.length===0)for(let a=0;a<l.length;a++)s.setNodeMarkup(i.tableStart+l[a],o.header_cell,r[a].attrs);n(s)}return!0}}function re(e,t,n){const o=t.map.cellsInRect({left:0,top:0,right:e=="row"?t.map.width:1,bottom:e=="column"?t.map.height:1});for(let i=0;i<o.length;i++){const s=t.table.nodeAt(o[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function se(e,t){return t=t||{useDeprecatedLogic:!1},t.useDeprecatedLogic?bt(e):function(n,o){if(!I(n))return!1;if(o){const i=S(n.schema),s=M(n),l=n.tr,r=re("row",s,i),a=re("column",s,i),c=(e==="column"?r:e==="row"&&a)?1:0,u=e=="column"?{left:0,top:c,right:1,bottom:s.map.height}:e=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,d=e=="column"?a?i.cell:i.header_cell:e=="row"?r?i.cell:i.header_cell:i.cell;s.map.cellsInRect(u).forEach(h=>{const f=h+s.tableStart,p=l.doc.nodeAt(f);p&&l.setNodeMarkup(f,d,p.attrs)}),o(l)}return!0}}se("row",{useDeprecatedLogic:!0});se("column",{useDeprecatedLogic:!0});const wn=se("cell",{useDeprecatedLogic:!0});function vt(e,t){if(t<0){const n=e.nodeBefore;if(n)return e.pos-n.nodeSize;for(let o=e.index(-1)-1,i=e.before();o>=0;o--){const s=e.node(-1).child(o),l=s.lastChild;if(l)return i-1-l.nodeSize;i-=s.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const n=e.node(-1);for(let o=e.indexAfter(-1),i=e.after();o<n.childCount;o++){const s=n.child(o);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function bn(e){return function(t,n){if(!I(t))return!1;const o=vt(j(t),e);if(o==null)return!1;if(n){const i=t.doc.resolve(o);n(t.tr.setSelection(H.between(i,ot(i))).scrollIntoView())}return!0}}function vn(e,t){const n=e.selection.$anchor;for(let o=n.depth;o>0;o--)if(n.node(o).type.spec.tableRole=="table")return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function V(e,t){const n=e.selection;if(!(n instanceof b))return!1;if(t){const o=e.tr,i=S(e.schema).cell.createAndFill().content;n.forEachCell((s,l)=>{s.content.eq(i)||o.replace(o.mapping.map(l+1),o.mapping.map(l+s.nodeSize-1),new U(i,0,0))}),o.docChanged&&t(o)}return!0}function yt(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:o}=e;for(;t.childCount==1&&(n>0&&o>0||t.child(0).type.spec.tableRole=="table");)n--,o--,t=t.child(0).content;const i=t.child(0),s=i.type.spec.tableRole,l=i.type.schema,r=[];if(s=="row")for(let a=0;a<t.childCount;a++){let c=t.child(a).content;const u=a?0:Math.max(0,n-1),d=a<t.childCount-1?0:Math.max(0,o-1);(u||d)&&(c=te(S(l).row,new U(c,u,d)).content),r.push(c)}else if(s=="cell"||s=="header_cell")r.push(n||o?te(S(l).row,new U(t,n,o)).content:t);else return null;return Ct(l,r)}function Ct(e,t){const n=[];for(let i=0;i<t.length;i++){const s=t[i];for(let l=s.childCount-1;l>=0;l--){const{rowspan:r,colspan:a}=s.child(l).attrs;for(let c=i;c<i+r;c++)n[c]=(n[c]||0)+a}}let o=0;for(let i=0;i<n.length;i++)o=Math.max(o,n[i]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(A.empty),n[i]<o){const s=S(e).cell.createAndFill(),l=[];for(let r=n[i];r<o;r++)l.push(s);t[i]=t[i].append(A.from(l))}return{height:t.length,width:o,rows:t}}function te(e,t){const n=e.createAndFill();return new qe(n).replace(0,n.content.size,t).doc}function St({width:e,height:t,rows:n},o,i){if(e!=o){const s=[],l=[];for(let r=0;r<n.length;r++){const a=n[r],c=[];for(let u=s[r]||0,d=0;u<o;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>o&&(h=h.type.createChecked(P(h.attrs,h.attrs.colspan,u+h.attrs.colspan-o),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)s[r+f]=(s[r+f]||0)+h.attrs.colspan}l.push(A.from(c))}n=l,e=o}if(t!=i){const s=[];for(let l=0,r=0;l<i;l++,r++){const a=[],c=n[r%t];for(let u=0;u<c.childCount;u++){let d=c.child(u);l+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),a.push(d)}s.push(A.from(a))}n=s,t=i}return{width:e,height:t,rows:n}}function Rt(e,t,n,o,i,s,l){const r=e.doc.type.schema,a=S(r);let c,u;if(i>t.width)for(let d=0,h=0;d<t.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let m=t.width;m<i;m++)p.push(g);e.insert(e.mapping.slice(l).map(h-1+o),p)}if(s>t.height){const d=[];for(let p=0,g=(t.height-1)*t.width;p<Math.max(t.width,i);p++){const m=p>=t.width?!1:n.nodeAt(t.map[g+p]).type==a.header_cell;d.push(m?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,A.from(d)),f=[];for(let p=t.height;p<s;p++)f.push(h);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),f)}return!!(c||u)}function ae(e,t,n,o,i,s,l,r){if(l==0||l==t.height)return!1;let a=!1;for(let c=i;c<s;c++){const u=l*t.width+c,d=t.map[u];if(t.map[u-t.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=t.findCell(d);e.setNodeMarkup(e.mapping.slice(r).map(d+o),null,{...h.attrs,rowspan:l-f}),e.insert(e.mapping.slice(r).map(t.positionAt(l,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-l})),c+=h.attrs.colspan-1}}return a}function ce(e,t,n,o,i,s,l,r){if(l==0||l==t.width)return!1;let a=!1;for(let c=i;c<s;c++){const u=c*t.width+l,d=t.map[u];if(t.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=t.colCount(d),p=e.mapping.slice(r).map(d+o);e.setNodeMarkup(p,null,P(h.attrs,l-f,h.attrs.colspan-(l-f))),e.insert(p+h.nodeSize,h.type.createAndFill(P(h.attrs,0,l-f))),c+=h.attrs.rowspan-1}}return a}function de(e,t,n,o,i){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let l=v.get(s);const{top:r,left:a}=o,c=a+i.width,u=r+i.height,d=e.tr;let h=0;function f(){if(s=n?d.doc.nodeAt(n-1):d.doc,!s)throw new Error("No table found");l=v.get(s),h=d.mapping.maps.length}Rt(d,l,s,n,c,u,h)&&f(),ae(d,l,s,n,a,c,r,h)&&f(),ae(d,l,s,n,a,c,u,h)&&f(),ce(d,l,s,n,r,u,a,h)&&f(),ce(d,l,s,n,r,u,c,h)&&f();for(let p=r;p<u;p++){const g=l.positionAt(p,a,s),m=l.positionAt(p,c,s);d.replace(d.mapping.slice(h).map(g+n),d.mapping.slice(h).map(m+n),new U(i.rows[p-r],0,0))}f(),d.setSelection(new b(d.doc.resolve(n+l.positionAt(r,a,s)),d.doc.resolve(n+l.positionAt(u-1,c-1,s)))),t(d)}const Et=We({ArrowLeft:K("horiz",-1),ArrowRight:K("horiz",1),ArrowUp:K("vert",-1),ArrowDown:K("vert",1),"Shift-ArrowLeft":k("horiz",-1),"Shift-ArrowRight":k("horiz",1),"Shift-ArrowUp":k("vert",-1),"Shift-ArrowDown":k("vert",1),Backspace:V,"Mod-Backspace":V,Delete:V,"Mod-Delete":V});function _(e,t,n){return n.eq(e.selection)?!1:(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function K(e,t){return(n,o,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof b)return _(n,o,D.near(s.$headCell,t));if(e!="horiz"&&!s.empty)return!1;const l=Le(i,e,t);if(l==null)return!1;if(e=="horiz")return _(n,o,D.near(n.doc.resolve(s.head+t),t));{const r=n.doc.resolve(l),a=De(r,e,t);let c;return a?c=D.near(a,1):t<0?c=D.near(n.doc.resolve(r.before(-1)),-1):c=D.near(n.doc.resolve(r.after(-1)),1),_(n,o,c)}}}function k(e,t){return(n,o,i)=>{if(!i)return!1;const s=n.selection;let l;if(s instanceof b)l=s;else{const a=Le(i,e,t);if(a==null)return!1;l=new b(n.doc.resolve(a))}const r=De(l.$headCell,e,t);return r?_(n,o,new b(l.$anchorCell,r)):!1}}function Tt(e,t){const n=e.state.doc,o=N(n.resolve(t));return o?(e.dispatch(e.state.tr.setSelection(new b(o))),!0):!1}function Ot(e,t,n){if(!I(e.state))return!1;let o=yt(n);const i=e.state.selection;if(i instanceof b){o||(o={width:1,height:1,rows:[A.from(te(S(e.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),l=i.$anchorCell.start(-1),r=v.get(s).rectBetween(i.$anchorCell.pos-l,i.$headCell.pos-l);return o=St(o,r.right-r.left,r.bottom-r.top),de(e.state,e.dispatch,l,r,o),!0}else if(o){const s=j(e.state),l=s.start(-1);return de(e.state,e.dispatch,l,v.get(s.node(-1)).findCell(s.pos-l),o),!0}else return!1}function It(e,t){var n;if(t.button!=0||t.ctrlKey||t.metaKey)return;const o=ue(e,t.target);let i;if(t.shiftKey&&e.state.selection instanceof b)s(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&(i=N(e.state.selection.$anchor))!=null&&((n=X(e,t))===null||n===void 0?void 0:n.pos)!=i.pos)s(i,t),t.preventDefault();else if(!o)return;function s(a,c){let u=X(e,c);const d=x.getState(e.state)==null;if(!u||!ie(a,u))if(d)u=a;else return;const h=new b(a,u);if(d||!e.state.selection.eq(h)){const f=e.state.tr.setSelection(h);d&&f.setMeta(x,a.pos),e.dispatch(f)}}function l(){e.root.removeEventListener("mouseup",l),e.root.removeEventListener("dragstart",l),e.root.removeEventListener("mousemove",r),x.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(x,-1))}function r(a){const c=a,u=x.getState(e.state);let d;if(u!=null)d=e.state.doc.resolve(u);else if(ue(e,c.target)!=o&&(d=X(e,t),!d))return l();d&&s(d,c)}e.root.addEventListener("mouseup",l),e.root.addEventListener("dragstart",l),e.root.addEventListener("mousemove",r)}function Le(e,t,n){if(!(e.state.selection instanceof H))return null;const{$head:o}=e.state.selection;for(let i=o.depth-1;i>=0;i--){const s=o.node(i);if((n<0?o.index(i):o.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=o.before(i),r=t=="vert"?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(r)?l:null}}return null}function ue(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function X(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:o,pos:i}=n;return o>=0&&N(e.state.doc.resolve(o))||N(e.state.doc.resolve(i))}var At=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ne(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ne(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ne(e,t,n,o,i,s){let l=0,r=!0,a=t.firstChild;const c=e.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let g=0;g<f;g++,h++){const m=i==h?s:p&&p[g],w=m?m+"px":"";if(l+=m||o,m||(r=!1),a)a.style.width!=w&&(a.style.width=w),a=a.nextSibling;else{const R=document.createElement("col");R.style.width=w,t.appendChild(R)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}r?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}const E=new B("tableColumnResizing");function yn({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=At,lastColumnResizable:i=!0}={}){const s=new W({key:E,state:{init(l,r){var a;const c=(a=s.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=S(r.schema).table.name;return o&&c&&(c[u]=(d,h)=>new o(d,n,h)),new Mt(-1,!1)},apply(l,r){return r.apply(l)}},props:{attributes:l=>{const r=E.getState(l);return r&&r.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,r)=>{zt(l,r,e,i)},mouseleave:l=>{Dt(l)},mousedown:(l,r)=>{xt(l,r,t,n)}},decorations:l=>{const r=E.getState(l);if(r&&r.activeHandle>-1)return Lt(l,r.activeHandle)},nodeViews:{}}});return s}var Mt=class F{constructor(t,n){this.activeHandle=t,this.dragging=n}apply(t){const n=this,o=t.getMeta(E);if(o&&o.setHandle!=null)return new F(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new F(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let i=t.mapping.map(n.activeHandle,-1);return ee(t.doc.resolve(i))||(i=-1),new F(i,n.dragging)}return n}};function zt(e,t,n,o){if(!e.editable)return;const i=E.getState(e.state);if(i&&!i.dragging){const s=Ht(t.target);let l=-1;if(s){const{left:r,right:a}=s.getBoundingClientRect();t.clientX-r<=n?l=he(e,t,"left",n):a-t.clientX<=n&&(l=he(e,t,"right",n))}if(l!=i.activeHandle){if(!o&&l!==-1){const r=e.state.doc.resolve(l),a=r.node(-1),c=v.get(a),u=r.start(-1);if(c.colCount(r.pos-u)+r.nodeAfter.attrs.colspan-1==c.width-1)return}Be(e,l)}}}function Dt(e){if(!e.editable)return;const t=E.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Be(e,-1)}function xt(e,t,n,o){var i;if(!e.editable)return!1;const s=(i=e.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,l=E.getState(e.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const r=e.state.doc.nodeAt(l.activeHandle),a=Ut(e,l.activeHandle,r.attrs);e.dispatch(e.state.tr.setMeta(E,{setDragging:{startX:t.clientX,startWidth:a}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);const h=E.getState(e.state);h?.dragging&&(Nt(e,h.activeHandle,fe(h.dragging,d,n)),e.dispatch(e.state.tr.setMeta(E,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=E.getState(e.state);if(h&&h.dragging){const f=fe(h.dragging,d,n);pe(e,h.activeHandle,f,o)}}return pe(e,l.activeHandle,a,o),s.addEventListener("mouseup",c),s.addEventListener("mousemove",u),t.preventDefault(),!0}function Ut(e,t,{colspan:n,colwidth:o}){const i=o&&o[o.length-1];if(i)return i;const s=e.domAtPos(t);let l=s.node.childNodes[s.offset].offsetWidth,r=n;if(o)for(let a=0;a<n;a++)o[a]&&(l-=o[a],r--);return l/r}function Ht(e){for(;e&&e.nodeName!="TD"&&e.nodeName!="TH";)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}function he(e,t,n,o){const i=n=="right"?-o:o,s=e.posAtCoords({left:t.clientX+i,top:t.clientY});if(!s)return-1;const{pos:l}=s,r=N(e.state.doc.resolve(l));if(!r)return-1;if(n=="right")return r.pos;const a=v.get(r.node(-1)),c=r.start(-1),u=a.map.indexOf(r.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function fe(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function Be(e,t){e.dispatch(e.state.tr.setMeta(E,{setHandle:t}))}function Nt(e,t,n){const o=e.state.doc.resolve(t),i=o.node(-1),s=v.get(i),l=o.start(-1),r=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+r;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],h=i.nodeAt(d).attrs,f=h.colspan==1?0:r-s.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():Pt(h.colspan);p[f]=n,a.setNodeMarkup(l+d,null,{...h,colwidth:p})}a.docChanged&&e.dispatch(a)}function pe(e,t,n,o){const i=e.state.doc.resolve(t),s=i.node(-1),l=i.start(-1),r=v.get(s).colCount(i.pos-l)+i.nodeAfter.attrs.colspan-1;let a=e.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ne(s,a.firstChild,a,o,r,n)}function Pt(e){return Array(e).fill(0)}function Lt(e,t){const n=[],o=e.doc.resolve(t),i=o.node(-1);if(!i)return G.empty;const s=v.get(i),l=o.start(-1),r=s.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const u=r+c*s.width;if((r==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){var a;const d=s.map[u],h=l+d+i.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=E.getState(e))===null||a===void 0)&&a.dragging&&n.push(J.node(l+d,l+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(J.widget(h,f))}}return G.create(e.doc,n)}function Cn({allowTableNodeSelection:e=!1}={}){return new W({key:x,state:{init(){return null},apply(t,n){const o=t.getMeta(x);if(o!=null)return o==-1?null:o;if(n==null||!t.docChanged)return n;const{deleted:i,pos:s}=t.mapping.mapResult(n);return i?null:s}},props:{decorations:lt,handleDOMEvents:{mousedown:It},createSelectionBetween(t){return x.getState(t.state)!=null?t.state.selection:null},handleTripleClick:Tt,handleKeyDown:Et,handlePaste:Ot},appendTransaction(t,n,o){return ct(o,ut(o,n),e)}})}function Bt(e,t){const n=Math.min(e.top,t.top),o=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),s=Math.max(e.right,t.right)-i,l=o-n;return new DOMRect(i,n,s,l)}var $t=class{get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(ye(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ce(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(Se(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(Re(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Ee(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(Te(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(Oe(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(Ie(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t;const{selection:n}=this.editor.state,o=(e=this.getReferencedVirtualElement)===null||e===void 0?void 0:e.call(this);if(o)return o;if(!(!((t=this.view)===null||t===void 0||(t=t.dom)===null||t===void 0)&&t.parentNode))return;const i=we(this.view,n.from,n.to);let s={getBoundingClientRect:()=>i,getClientRects:()=>[i]};if(n instanceof me){let l=this.view.nodeDOM(n.from);const r=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");r&&(l=r),l&&(s={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(n instanceof b){const{$anchorCell:l,$headCell:r}=n,a=l?l.pos:r.pos,c=r?r.pos:l.pos,u=this.view.nodeDOM(a),d=this.view.nodeDOM(c);if(!u||!d)return;const h=u===d?u.getBoundingClientRect():Bt(u.getBoundingClientRect(),d.getBoundingClientRect());s={getBoundingClientRect:()=>h,getClientRects:()=>[h]}}return s}constructor({editor:e,element:t,view:n,pluginKey:o="bubbleMenu",updateDelay:i=250,resizeDelay:s=60,shouldShow:l,appendTo:r,getReferencedVirtualElement:a,options:c}){var u;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:h,from:f,to:p})=>{const{doc:g,selection:m}=h,{empty:w}=m,R=!g.textBetween(f,p).length&&Xe(h.selection),y=this.element.contains(document.activeElement);return!(!(d.hasFocus()||y)||w||R||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var h;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}d?.relatedTarget&&(!((h=this.element.parentNode)===null||h===void 0)&&h.contains(d.relatedTarget))||d?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,h)=>{const f=!h?.selection.eq(d.state.selection),p=!h?.doc.eq(d.state.doc);!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,f,p,h)},this.updateDelay))},this.updateHandler=(d,h,f,p)=>{const{composing:g}=d;if(!(g||!h&&!f)){if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:d})=>{const h=d.getMeta(this.pluginKey);h==="updatePosition"?this.updatePosition():h&&typeof h=="object"&&h.type==="updateOptions"?this.updateOptions(h.options):h==="hide"?this.hide():h==="show"&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=o,this.updateDelay=i,this.resizeDelay=s,this.appendTo=r,this.scrollTarget=(u=c?.scrollTarget)!==null&&u!==void 0?u:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;const e=this.virtualElement;e&&Ae(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:n,strategy:o,middlewareData:i})=>{var s,l;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(!((s=i.hide)===null||s===void 0)&&s.referenceHidden||!((l=i.hide)===null||l===void 0)&&l.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${t}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(e,t){const{state:n}=e,o=n.selection.from!==n.selection.to;if(this.updateDelay>0&&o){this.handleDebouncedUpdate(e,t);return}const i=!t?.selection.eq(e.state.selection),s=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,s,t)}getShouldShow(e){var t;const{state:n}=this.view,{selection:o}=n,{ranges:i}=o,s=Math.min(...i.map(r=>r.$from.pos)),l=Math.max(...i.map(r=>r.$to.pos));return((t=this.shouldShow)===null||t===void 0?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:e,from:s,to:l}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)===null||e===void 0||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){var t;const n=(t=e.options.scrollTarget)!==null&&t!==void 0?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}};const $e=e=>new W({key:typeof e.pluginKey=="string"?new B(e.pluginKey):e.pluginKey,view:t=>new $t({view:t,...e})});be.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[$e({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});var Vt=class{getTextContent(e){return Ye(e,{textSerializers:Ge(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(ye(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ce(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(Se(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(Re(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(Ee(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(Te(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(Oe(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(Ie(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}constructor({editor:e,element:t,view:n,pluginKey:o="floatingMenu",updateDelay:i=250,resizeDelay:s=60,options:l,appendTo:r,shouldShow:a}){var c;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:u,state:d})=>{const{selection:h}=d,{$anchor:f,empty:p}=h,g=f.depth===1,m=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!u.hasFocus()||!p||!g||!m||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(u,d,h,f)=>{const{composing:p}=u;if(!(p||!d&&!h)){if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&(!((d=this.element.parentNode)===null||d===void 0)&&d.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta(this.pluginKey);d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"?this.updateOptions(d.options):d==="hide"?this.hide():d==="show"&&(this.updatePosition(),this.show())},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.pluginKey=o,this.updateDelay=i,this.resizeDelay=s,this.appendTo=r,this.scrollTarget=(c=l?.scrollTarget)!==null&&c!==void 0?c:window,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getShouldShow(e){var t;const{state:n}=this.view,{selection:o}=n,{ranges:i}=o,s=Math.min(...i.map(r=>r.$from.pos)),l=Math.max(...i.map(r=>r.$to.pos));return(t=this.shouldShow)===null||t===void 0?void 0:t.call(this,{editor:this.editor,view:this.view,state:n,oldState:e,from:s,to:l})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){var t;const n=(t=e.options.scrollTarget)!==null&&t!==void 0?t:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){var e;if(!(!((e=this.view)===null||e===void 0||(e=e.dom)===null||e===void 0)&&e.parentNode))return;const{selection:t}=this.editor.state,n=we(this.view,t.from,t.to);Ae({getBoundingClientRect:()=>n,getClientRects:()=>[n]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:o,y:i,strategy:s,middlewareData:l})=>{var r,a;if(!((r=l.hide)===null||r===void 0)&&r.referenceHidden||!((a=l.hide)===null||a===void 0)&&a.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${o}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const n=!t?.selection.eq(e.state.selection),o=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,o,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)===null||e===void 0||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}};const Ve=e=>new W({key:typeof e.pluginKey=="string"?new B(e.pluginKey):e.pluginKey,view:t=>new Vt({view:t,...e})});be.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",updateDelay:void 0,resizeDelay:void 0,appendTo:void 0,shouldShow:null}},addCommands(){return{updateFloatingMenuPosition:()=>({tr:e,dispatch:t})=>(t&&e.setMeta(this.options.pluginKey,"updatePosition"),!0)}},addProseMirrorPlugins(){return this.options.element?[Ve({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,resizeDelay:this.options.resizeDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});function Ke(e,t){return e??new B(t)}const Kt=typeof window<"u"?C.useLayoutEffect:C.useEffect,ke=new Set(["left","opacity","position","top","visibility","width"]),kt=new Set(["animationIterationCount","aspectRatio","borderImageOutset","borderImageSlice","borderImageWidth","columnCount","columns","fillOpacity","flex","flexGrow","flexShrink","fontWeight","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineClamp","lineHeight","opacity","order","orphans","scale","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth","tabSize","widows","zIndex","zoom"]),_t=new Set(["children","className","style"]),Ft=new Set(["tabIndex"]),Wt=new Set(["accessKey","autoCapitalize","contentEditable","contextMenu","dir","draggable","enterKeyHint","hidden","id","lang","nonce","role","slot","spellCheck","tabIndex","title","translate"]),jt={Blur:"focusout",DoubleClick:"dblclick",Focus:"focusin",MouseEnter:"mouseenter",MouseLeave:"mouseleave"};function oe(e,t){return/^on[A-Z]/.test(e)&&typeof t=="function"}function qt(e){return e.startsWith("aria-")||e.startsWith("data-"),e}function Xt(e){return e.startsWith("aria-")||e.startsWith("data-")||Wt.has(e)}function _e(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Yt(e){var t;const n=e.endsWith("Capture"),o=(n?e.slice(0,-7):e).slice(2);return{eventName:(t=jt[o])!==null&&t!==void 0?t:o.toLowerCase(),options:n?{capture:!0}:void 0}}function Gt(e,t){let n=t.defaultPrevented,o=!1;const i=Object.create(t);return Object.defineProperties(i,{nativeEvent:{value:t},currentTarget:{value:e},target:{value:t.target},persist:{value:()=>{}},isDefaultPrevented:{value:()=>n},isPropagationStopped:{value:()=>o},preventDefault:{value:()=>{n=!0,t.preventDefault()}},stopPropagation:{value:()=>{o=!0,t.stopPropagation()}}}),i}function Y(e){return Ft.has(e)}function ge(e,t,n){if(t==="tabIndex"){e.tabIndex=Number(n);return}e[t]=n}function Jt(e,t){if(t==="tabIndex"){e.removeAttribute("tabindex");return}const n=e[t];if(typeof n=="boolean"){e[t]=!1;return}if(typeof n=="number"){e[t]=0;return}e[t]=""}function Zt(e,t){return typeof t!="number"||t===0||e.startsWith("--")||kt.has(e)?String(t):`${t}px`}function Qt(e,t){ke.has(t)||e.style.removeProperty(_e(t))}function en(e,t,n){ke.has(t)||e.style.setProperty(_e(t),Zt(t,n))}function tn(e,t,n){new Set([...Object.keys(t),...Object.keys(n)]).forEach(o=>{if(_t.has(o)||!Xt(o)||oe(o,t[o])||oe(o,n[o]))return;const i=t[o],s=n[o];if(i===s)return;const l=qt(o);if(s==null||s===!1){Y(o)&&Jt(e,o),e.removeAttribute(l);return}if(s===!0){Y(o)&&ge(e,o,!0),e.setAttribute(l,"");return}if(Y(o)){ge(e,o,s);return}e.setAttribute(l,String(s))})}function nn(e,t,n){if(t!==n){if(n){e.className=n;return}e.removeAttribute("class")}}function on(e,t,n){const o=t??{},i=n??{};new Set([...Object.keys(o),...Object.keys(i)]).forEach(s=>{const l=o[s],r=i[s];if(l!==r){if(r==null){Qt(e,s);return}en(e,s,r)}})}function sn(e,t,n){t.forEach(({eventName:i,listener:s,options:l})=>{e.removeEventListener(i,s,l)});const o=[];return Object.entries(n).forEach(([i,s])=>{if(!oe(i,s))return;const{eventName:l,options:r}=Yt(i),a=c=>{s(Gt(e,c))};e.addEventListener(l,a,r),o.push({eventName:l,listener:a,options:r})}),o}function Fe(e,t){const n=C.useRef({}),o=C.useRef([]);Kt(()=>{const i=n.current;return nn(e,i.className,t.className),on(e,i.style,t.style),tn(e,i,t),o.current=sn(e,o.current,t),n.current=t,()=>{o.current.forEach(({eventName:s,listener:l,options:r})=>{e.removeEventListener(s,l,r)}),o.current=[]}},[e,t])}const Sn=Me.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:o,appendTo:i,shouldShow:s=null,getReferencedVirtualElement:l,options:r,children:a,...c},u)=>{const d=C.useRef(document.createElement("div")),h=C.useRef(Ke(e,"bubbleMenu")).current;Fe(d.current,c),typeof u=="function"?u(d.current):u&&(u.current=d.current);const{editor:f}=ve(),p=t||f,g={updateDelay:n,resizeDelay:o,appendTo:i,pluginKey:h,shouldShow:s,getReferencedVirtualElement:l,options:r},m=C.useRef(g);m.current=g;const[w,R]=C.useState(!1),y=C.useRef(!0);return C.useEffect(()=>{if(p?.isDestroyed)return;if(!p){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const T=d.current;T.style.visibility="hidden",T.style.position="absolute";const O=$e({...m.current,editor:p,element:T});p.registerPlugin(O);const L=m.current.pluginKey;return y.current=!0,R(!0),()=>{R(!1),p.unregisterPlugin(L),window.requestAnimationFrame(()=>{T.parentNode&&T.parentNode.removeChild(T)})}},[p]),C.useEffect(()=>{if(!(!w||!p||p.isDestroyed)){if(y.current){y.current=!1;return}p.view.dispatch(p.state.tr.setMeta(h,{type:"updateOptions",options:m.current}))}},[w,p,n,o,s,r,i,l,h]),ze.createPortal(a,d.current)});Me.forwardRef(({pluginKey:e,editor:t,updateDelay:n,resizeDelay:o,appendTo:i,shouldShow:s=null,options:l,children:r,...a},c)=>{const u=C.useRef(document.createElement("div")),d=C.useRef(Ke(e,"floatingMenu")).current;Fe(u.current,a),typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:h}=ve(),f=t||h,p={updateDelay:n,resizeDelay:o,appendTo:i,pluginKey:d,shouldShow:s,options:l},g=C.useRef(p);g.current=p;const[m,w]=C.useState(!1),R=C.useRef(!0);return C.useEffect(()=>{if(f?.isDestroyed)return;if(!f){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const y=u.current;y.style.visibility="hidden",y.style.position="absolute";const T=Ve({...g.current,editor:f,element:y});f.registerPlugin(T);const O=g.current.pluginKey;return R.current=!0,w(!0),()=>{w(!1),f.unregisterPlugin(O),window.requestAnimationFrame(()=>{y.parentNode&&y.parentNode.removeChild(y)})}},[f]),C.useEffect(()=>{if(!(!m||!f||f.isDestroyed)){if(R.current){R.current=!1;return}f.view.dispatch(f.state.tr.setMeta(d,{type:"updateOptions",options:g.current}))}},[m,f,n,o,s,l,i,d]),ze.createPortal(r,u.current)});export{Sn as B,b as C,gn as a,wn as b,yn as c,se as d,vn as e,ut as f,bn as g,fn as h,hn as i,un as j,dn as k,cn as l,pn as m,an as n,mn as s,Cn as t};
@@ -1,4 +1,4 @@
1
- import{r as V,ar as at,c as Q,b as ie,j as i,ex as Ee,ey as Oe,ez as We,I as ge,ac as ke,n as we,b0 as Ve,aF as He,e as Se,ak as qe,am as be,K as ce,t as le,B as re,o as ne,h as Ae,l as ae,m as ct,as as ee,d as dt,E as ut,F as ht}from"./index-B3yBTWEk.js";import{C as mt}from"./checkbox-D8Ab2Vb-.js";import{I as xe}from"./input-HFOrJf5B.js";import{S as ft,b as pt,a as xt,d as gt,c as vt}from"./select-Bc5UZb4n.js";import{i as Ye}from"./ArrowLeft-Clu1mSdY.js";import{i as bt}from"./ChevronSelectorVertical-BiIbFU31.js";import{i as yt}from"./Key01-CKcg8G1v.js";import{i as Ge,b as jt,a as St,s as Nt}from"./Settings02-D2oiGU4q.js";import{i as Xe}from"./SearchMd-DRRptSJN.js";import{d as _e,u as kt,b as wt}from"./use-ai-providers-qnkcjapR.js";import{c as _t}from"./chat-context-CXknhaDs.js";import{g as Ce}from"./ai-providers-logos-DD3qZ33J.js";import{i as Pe}from"./Monitor01-BUruMK2r.js";import{i as Ct}from"./AlertCircle-EniJtD8E.js";import{e as Qe,D as It,b as Mt,c as Et,d as Ot,h as At}from"./dialog-otnvxVN0.js";import{i as Pt}from"./ChevronRight-DzRB-rdO.js";import{A as Tt}from"./avatar-DcDvs8Zz.js";import{s as Je}from"./Eye-dnrP5DkM.js";import{i as Lt,a as zt,D as Ft}from"./download-app-dialog-BqNRF4Sn.js";import{u as Rt}from"./use-is-desktop-app-BNujXJc_.js";import{b as Kt,a as Dt}from"./Tool01-BnKd95Y1.js";import{t as Te}from"./ChevronUp-DGrguvGW.js";import{a as $t}from"./Image01-BrHSH-Vi.js";import{t as Ut}from"./Stars01-COChWymR.js";function pe(n,e,t){let s=t.initialDeps??[],o,l=!0;function c(){var r,u,d;let a;t.key&&((r=t.debug)!=null&&r.call(t))&&(a=Date.now());const m=n();if(!(m.length!==s.length||m.some((f,v)=>s[v]!==f)))return o;s=m;let h;if(t.key&&((u=t.debug)!=null&&u.call(t))&&(h=Date.now()),o=e(...m),t.key&&((d=t.debug)!=null&&d.call(t))){const f=Math.round((Date.now()-a)*100)/100,v=Math.round((Date.now()-h)*100)/100,k=v/16,S=(j,_)=>{for(j=String(j);j.length<_;)j=" "+j;return j};console.info(`%c⏱ ${S(v,5)} /${S(f,5)} ms`,`
1
+ import{r as V,ar as at,c as Q,b as ie,j as i,ex as Ee,ey as Oe,ez as We,I as ge,ac as ke,n as we,b0 as Ve,aF as He,e as Se,ak as qe,am as be,K as ce,t as le,B as re,o as ne,h as Ae,l as ae,m as ct,as as ee,d as dt,E as ut,F as ht}from"./index-BodvdIMk.js";import{C as mt}from"./checkbox-Cx7-cMI2.js";import{I as xe}from"./input-CyCfmV2v.js";import{S as ft,b as pt,a as xt,d as gt,c as vt}from"./select-bwhAgSkw.js";import{i as Ye}from"./ArrowLeft-B4kTLC80.js";import{i as bt}from"./ChevronSelectorVertical-DTb5009V.js";import{i as yt}from"./Key01-ugSjw0sl.js";import{i as Ge,b as jt,a as St,s as Nt}from"./Settings02-DPUnnUpS.js";import{i as Xe}from"./SearchMd-uhtNwnF8.js";import{d as _e,u as kt,b as wt}from"./use-ai-providers-BHw3Z_he.js";import{c as _t}from"./chat-context-BdJniD3E.js";import{g as Ce}from"./ai-providers-logos-DD3qZ33J.js";import{i as Pe}from"./Monitor01-J9g_ep-X.js";import{i as Ct}from"./AlertCircle-CfOItn1b.js";import{e as Qe,D as It,b as Mt,c as Et,d as Ot,h as At}from"./dialog-BAfLND_C.js";import{i as Pt}from"./ChevronRight-DfnK-irb.js";import{A as Tt}from"./avatar-CAI2JETZ.js";import{s as Je}from"./Eye-Ccu8gsxq.js";import{i as Lt,a as zt,D as Ft}from"./download-app-dialog-inqOoiFR.js";import{u as Rt}from"./use-is-desktop-app-BNujXJc_.js";import{b as Kt,a as Dt}from"./Tool01-duhLcQNq.js";import{t as Te}from"./ChevronUp-SbK1Bh_A.js";import{a as $t}from"./Image01-PUenBySa.js";import{t as Ut}from"./Stars01-DdrI1AvW.js";function pe(n,e,t){let s=t.initialDeps??[],o,l=!0;function c(){var r,u,d;let a;t.key&&((r=t.debug)!=null&&r.call(t))&&(a=Date.now());const m=n();if(!(m.length!==s.length||m.some((f,v)=>s[v]!==f)))return o;s=m;let h;if(t.key&&((u=t.debug)!=null&&u.call(t))&&(h=Date.now()),o=e(...m),t.key&&((d=t.debug)!=null&&d.call(t))){const f=Math.round((Date.now()-a)*100)/100,v=Math.round((Date.now()-h)*100)/100,k=v/16,S=(j,_)=>{for(j=String(j);j.length<_;)j=" "+j;return j};console.info(`%c⏱ ${S(v,5)} /${S(f,5)} ms`,`
2
2
  font-size: .6rem;
3
3
  font-weight: bold;
4
4
  color: hsl(${Math.max(0,Math.min(120-120*k,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(l&&t.skipInitialOnChange)&&t.onChange(o),l=!1,o}return c.updateDeps=r=>{s=r},c}function Le(n,e){if(n===void 0)throw new Error("Unexpected undefined");return n}const Bt=(n,e)=>Math.abs(n-e)<1.01,Wt=(n,e,t)=>{let s;return function(...o){n.clearTimeout(s),s=n.setTimeout(()=>e.apply(this,o),t)}},ze=n=>{const{offsetWidth:e,offsetHeight:t}=n;return{width:e,height:t}},Vt=n=>n,Ht=n=>{const e=Math.max(n.startIndex-n.overscan,0),t=Math.min(n.endIndex+n.overscan,n.count-1),s=[];for(let o=e;o<=t;o++)s.push(o);return s},qt=(n,e)=>{const t=n.scrollElement;if(!t)return;const s=n.targetWindow;if(!s)return;const o=c=>{const{width:r,height:u}=c;e({width:Math.round(r),height:Math.round(u)})};if(o(ze(t)),!s.ResizeObserver)return()=>{};const l=new s.ResizeObserver(c=>{const r=()=>{const u=c[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(ze(t))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return l.observe(t,{box:"border-box"}),()=>{l.unobserve(t)}},Fe={passive:!0},Re=typeof window>"u"?!0:"onscrollend"in window,Yt=(n,e)=>{const t=n.scrollElement;if(!t)return;const s=n.targetWindow;if(!s)return;let o=0;const l=n.options.useScrollendEvent&&Re?()=>{}:Wt(s,()=>{e(o,!1)},n.options.isScrollingResetDelay),c=a=>()=>{const{horizontal:m,isRtl:p}=n.options;o=m?t.scrollLeft*(p&&-1||1):t.scrollTop,l(),e(o,a)},r=c(!0),u=c(!1);t.addEventListener("scroll",r,Fe);const d=n.options.useScrollendEvent&&Re;return d&&t.addEventListener("scrollend",u,Fe),()=>{t.removeEventListener("scroll",r),d&&t.removeEventListener("scrollend",u)}},Gt=(n,e,t)=>{if(e?.borderBoxSize){const s=e.borderBoxSize[0];if(s)return Math.round(s[t.options.horizontal?"inlineSize":"blockSize"])}return n[t.options.horizontal?"offsetWidth":"offsetHeight"]},Xt=(n,{adjustments:e=0,behavior:t},s)=>{var o,l;const c=n+e;(l=(o=s.scrollElement)==null?void 0:o.scrollTo)==null||l.call(o,{[s.options.horizontal?"left":"top"]:c,behavior:t})};class Qt{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,s,o;return((o=(s=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:s.now)==null?void 0:o.call(s))??Date.now()},this.observer=(()=>{let t=null;const s=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(o=>{o.forEach(l=>{const c=()=>{const r=l.target,u=this.indexFromElement(r);if(!r.isConnected){this.observer.unobserve(r);return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(r,l,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var o;(o=s())==null||o.disconnect(),t=null},observe:o=>{var l;return(l=s())==null?void 0:l.observe(o,{box:"border-box"})},unobserve:o=>{var l;return(l=s())==null?void 0:l.unobserve(o)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([s,o])=>{typeof o>"u"&&delete t[s]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Vt,rangeExtractor:Ht,onChange:()=>{},measureElement:Gt,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var s,o;(o=(s=this.options).onChange)==null||o.call(s,this,t)},this.maybeNotify=pe(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}this.scrollElement=s,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,l)=>{this.scrollAdjustments=0,this.scrollDirection=l?this.getScrollOffset()<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=l,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,s)=>{const o=new Map,l=new Map;for(let c=s-1;c>=0;c--){const r=t[c];if(o.has(r.lane))continue;const u=l.get(r.lane);if(u==null||r.end>u.end?l.set(r.lane,r):r.end<u.end&&o.set(r.lane,!0),o.size===this.options.lanes)break}return l.size===this.options.lanes?Array.from(l.values()).sort((c,r)=>c.end===r.end?c.index-r.index:c.end-r.end)[0]:void 0},this.getMeasurementOptions=pe(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,s,o,l,c,r,u)=>(this.prevLanes!==void 0&&this.prevLanes!==r&&(this.lanesChangedFlag=!0),this.prevLanes=r,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:s,scrollMargin:o,getItemKey:l,enabled:c,lanes:r,laneAssignmentMode:u}),{key:!1}),this.getMeasurements=pe(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:s,scrollMargin:o,getItemKey:l,enabled:c,lanes:r,laneAssignmentMode:u},d)=>{if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const h of this.laneAssignments.keys())h>=t&&this.laneAssignments.delete(h);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(h=>{this.itemSizeCache.set(h.key,h.size)}));const a=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const m=this.measurementsCache.slice(0,a),p=new Array(r).fill(void 0);for(let h=0;h<a;h++){const f=m[h];f&&(p[f.lane]=h)}for(let h=a;h<t;h++){const f=l(h),v=this.laneAssignments.get(h);let k,S;const j=u==="estimate"||d.has(f);if(v!==void 0&&this.options.lanes>1){k=v;const w=p[k],x=w!==void 0?m[w]:void 0;S=x?x.end+this.options.gap:s+o}else{const w=this.options.lanes===1?m[h-1]:this.getFurthestMeasurement(m,h);S=w?w.end+this.options.gap:s+o,k=w?w.lane:h%this.options.lanes,this.options.lanes>1&&j&&this.laneAssignments.set(h,k)}const _=d.get(f),I=typeof _=="number"?_:this.options.estimateSize(h),P=S+I;m[h]={index:h,start:S,size:I,end:P,key:f,lane:k},p[k]=h}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=pe(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,s,o,l)=>this.range=t.length>0&&s>0?Jt({measurements:t,outerSize:s,scrollOffset:o,lanes:l}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=pe(()=>{let t=null,s=null;const o=this.calculateRange();return o&&(t=o.startIndex,s=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,s]},(t,s,o,l,c)=>l===null||c===null?[]:t({startIndex:l,endIndex:c,overscan:s,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const s=this.options.indexAttribute,o=t.getAttribute(s);return o?parseInt(o,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(o!==void 0&&this.range){const l=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,o-l),r=Math.min(this.options.count-1,o+l);return t>=c&&t<=r}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((c,r)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(r))});return}const s=this.indexFromElement(t),o=this.options.getItemKey(s),l=this.elementsCache.get(o);l!==t&&(l&&this.observer.unobserve(l),this.observer.observe(t),this.elementsCache.set(o,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,s)=>{var o;const l=this.measurementsCache[t];if(!l)return;const c=this.itemSizeCache.get(l.key)??l.size,r=s-c;r!==0&&(((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(l,r,this):l.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(l.index),this.itemSizeCache=new Map(this.itemSizeCache.set(l.key,s)),this.notify(!1))},this.getVirtualItems=pe(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,s)=>{const o=[];for(let l=0,c=t.length;l<c;l++){const r=t[l],u=s[r];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const s=this.getMeasurements();if(s.length!==0)return Le(s[Ze(0,s.length-1,o=>Le(s[o]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,s,o=0)=>{if(!this.scrollElement)return 0;const l=this.getSize(),c=this.getScrollOffset();s==="auto"&&(s=t>=c+l?"end":"start"),s==="center"?t+=(o-l)/2:s==="end"&&(t-=l);const r=this.getMaxScrollOffset();return Math.max(Math.min(r,t),0)},this.getOffsetForIndex=(t,s="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const o=this.getSize(),l=this.getScrollOffset(),c=this.measurementsCache[t];if(!c)return;if(s==="auto")if(c.end>=l+o-this.options.scrollPaddingEnd)s="end";else if(c.start<=l+this.options.scrollPaddingStart)s="start";else return[l,s];if(s==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),s];const r=s==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(r,s,c.size),s]},this.scrollToOffset=(t,{align:s="start",behavior:o="auto"}={})=>{const l=this.getOffsetForAlignment(t,s),c=this.now();this.scrollState={index:null,align:s,behavior:o,startedAt:c,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:s="auto",behavior:o="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const l=this.getOffsetForIndex(t,s);if(!l)return;const[c,r]=l,u=this.now();this.scrollState={index:t,align:r,behavior:o,startedAt:u,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:s="auto"}={})=>{const o=this.getScrollOffset()+t,l=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const s=this.getMeasurements();let o;if(s.length===0)o=this.options.paddingStart;else if(this.options.lanes===1)o=((t=s[s.length-1])==null?void 0:t.end)??0;else{const l=Array(this.options.lanes).fill(null);let c=s.length-1;for(;c>=0&&l.some(r=>r===null);){const r=s[c];l[r.lane]===null&&(l[r.lane]=r.end),c--}o=Math.max(...l.filter(r=>r!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:s,behavior:o})=>{this.options.scrollToFn(t,{behavior:o,adjustments:s},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=s?s[0]:this.scrollState.lastTargetOffset,l=1,c=o!==this.scrollState.lastTargetOffset;if(!c&&Bt(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=l){this.scrollState=null;return}}else this.scrollState.stableFrames=0,c&&(this.scrollState.lastTargetOffset=o,this.scrollState.behavior="auto",this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const Ze=(n,e,t,s)=>{for(;n<=e;){const o=(n+e)/2|0,l=t(o);if(l<s)n=o+1;else if(l>s)e=o-1;else return o}return n>0?n-1:0};function Jt({measurements:n,outerSize:e,scrollOffset:t,lanes:s}){const o=n.length-1,l=u=>n[u].start;if(n.length<=s)return{startIndex:0,endIndex:o};let c=Ze(0,o,l,t),r=c;if(s===1)for(;r<o&&n[r].end<t+e;)r++;else if(s>1){const u=Array(s).fill(0);for(;r<o&&u.some(a=>a<t+e);){const a=n[r];u[a.lane]=a.end,r++}const d=Array(s).fill(t+e);for(;c>=0&&d.some(a=>a>=t);){const a=n[c];d[a.lane]=a.start,c--}c=Math.max(0,c-c%s),r=Math.min(o,r+(s-1-r%s))}return{startIndex:c,endIndex:r}}const Ke=typeof document<"u"?V.useLayoutEffect:V.useEffect;function Zt({useFlushSync:n=!0,...e}){const t=V.useReducer(()=>({}),{})[1],s={...e,onChange:(l,c)=>{var r;n&&c?at.flushSync(t):t(),(r=e.onChange)==null||r.call(e,l,c)}},[o]=V.useState(()=>new Qt(s));return o.setOptions(s),Ke(()=>o._didMount(),[]),Ke(()=>o._willUpdate()),o}function es(n){return Zt({observeElementRect:qt,observeElementOffset:Yt,scrollToFn:Xt,...n})}const et=[{id:"openai",name:"OpenAI",description:"GPT-4, GPT-5, and other OpenAI models",logo:"https://decoims.com/decocms/b51001ef-ae58-4db4-8a75-9e6d2df2dd8e/openai.png",baseUrlPlaceholder:"https://api.openai.com/v1",defaultBaseUrl:"https://api.openai.com/v1",apiKeyRecommended:!0,helpText:"Use your OpenAI API key (starts with sk-)."},{id:"litellm",name:"LiteLLM",description:"Connect to a LiteLLM gateway your team manages",logo:"https://decoims.com/decocms/e974ae05-ad64-4b4a-8444-d9705f019b85/litellm.png",baseUrlPlaceholder:"http://localhost:4000",apiKeyRecommended:!0,helpText:"Point at your LiteLLM proxy. The base URL should be the root of the proxy (we'll append /v1)."},{id:"ollama",name:"Ollama",description:"Run open-source models on your own computer",logo:"https://decoims.com/decocms/2bb2f822-5288-4b7c-a541-dcbef76525a0/ollama.png",baseUrlPlaceholder:"http://localhost:11434",apiKeyRecommended:!1,helpText:"Ollama exposes /v1 by default — no API key required for local use."},{id:"lm-studio",name:"LM Studio",description:"Open models running through LM Studio",logo:"https://decoims.com/decocms/9f0ab1a9-d2d5-4f3e-9de0-aadd4926428d/lmstudio.webp",baseUrlPlaceholder:"http://localhost:1234",apiKeyRecommended:!1,helpText:"Start the local server in LM Studio, then paste its base URL here."},{id:"vllm",name:"vLLM",description:"Connect to your team's self-hosted vLLM server",logo:"https://decoims.com/decocms/b6c60e4f-a4aa-443c-981f-ad0f31640e22/vllm.png",baseUrlPlaceholder:"http://localhost:8000",apiKeyRecommended:!1}];function ye(n){if(n)return et.find(e=>e.id===n)}const De=4;function ve(n){const e=Q.c(8),{logo:t,name:s,description:o,onClick:l}=n;let c;e[0]!==t||e[1]!==s?(c=t?i.jsx("img",{src:t,alt:s,className:"size-8 rounded-md object-contain dark:bg-white dark:p-0.5"}):i.jsx(Tt,{fallback:s.charAt(0),className:"size-8 bg-primary/10 text-primary"}),e[0]=t,e[1]=s,e[2]=c):c=e[2];let r;return e[3]!==o||e[4]!==s||e[5]!==l||e[6]!==c?(r=i.jsx(We,{onClick:l,icon:c,title:s,description:o}),e[3]=o,e[4]=s,e[5]=l,e[6]=c,e[7]=r):r=e[7],r}function tt(n){const e=Q.c(38),{providers:t,onSelect:s,onShowAll:o}=n,l=ie();let c;e[0]!==t?(c=t.find(ns),e[0]=t,e[1]=c):c=e[1];const r=c;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={openrouter:0,llmapi:1,anthropic:2,google:3},e[2]=u):u=e[2];const d=u;let a;if(e[3]!==s||e[4]!==t||e[5]!==l){let I;e[7]===Symbol.for("react.memo_cache_sentinel")?(I=(y,E)=>{const L=d[y.id]??Number.MAX_SAFE_INTEGER,T=d[E.id]??Number.MAX_SAFE_INTEGER;return L-T},e[7]=I):I=e[7];const P=t.filter(is).sort(I);let w;e[8]!==t?(w=t.find(ss),e[8]=t,e[9]=w):w=e[9];const x=w;let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=ye("openai"),e[10]=N):N=e[10];const C=N;let M;e[11]!==s?(M=y=>i.jsx(ve,{logo:y.logo,name:y.name,description:y.description,onClick:()=>s({kind:"provider",provider:y})},y.id),e[11]=s,e[12]=M):M=e[12];let g;e[13]!==s||e[14]!==x?(g=x&&C?[i.jsx(ve,{logo:C.logo,name:C.name,description:C.description,onClick:()=>s({kind:"openai-compatible",provider:x,preset:C})},C.id)]:[],e[13]=s,e[14]=x,e[15]=g):g=e[15];let b;e[16]!==s||e[17]!==x||e[18]!==l?(b=x?[...et.filter(ts).map(y=>i.jsx(ve,{logo:y.logo,name:y.name,description:y.description,onClick:()=>s({kind:"openai-compatible",provider:x,preset:y})},y.id)),i.jsx(ve,{logo:x.logo,name:l("settings.aiProviders.customOpenAiCompatible"),description:l("settings.aiProviders.customOpenAiDescription"),onClick:()=>s({kind:"openai-compatible",provider:x,preset:null})},"custom")]:[],e[16]=s,e[17]=x,e[18]=l,e[19]=b):b=e[19],a=[...P.map(M),...g,...b],e[3]=s,e[4]=t,e[5]=l,e[6]=a}else a=e[6];const m=a,p=m.length-De,h=!!o&&p>0;let f;e[20]!==m||e[21]!==h?(f=h?m.slice(0,De):m,e[20]=m,e[21]=h,e[22]=f):f=e[22];const v=f;let k;e[23]!==r||e[24]!==s||e[25]!==l?(k=r&&i.jsx(Ee,{children:i.jsxs("div",{className:"relative rounded-xl border border-violet-400/30 bg-gradient-to-br from-violet-50/50 via-transparent to-lime-50/30 dark:from-violet-950/20 dark:to-lime-950/10 p-1.5",children:[i.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-br from-violet-400/5 to-lime-400/5 pointer-events-none"}),i.jsx("p",{className:"text-xs font-medium text-violet-700 dark:text-violet-400 mb-1.5 px-2 pt-2 relative",children:l("settings.aiProviders.recommended")}),i.jsx(Oe,{className:"relative",children:i.jsx(ve,{logo:r.logo,name:r.name,description:r.description,onClick:()=>s({kind:"provider",provider:r})})})]})}),e[23]=r,e[24]=s,e[25]=l,e[26]=k):k=e[26];let S;e[27]!==p||e[28]!==o||e[29]!==h||e[30]!==l?(S=h&&i.jsx(We,{onClick:o,title:l(p===1?"settings.aiProviders.moreProvidersSingular":"settings.aiProviders.moreProvidersPlural",{count:p}),action:i.jsx(Pt,{size:16,className:"text-muted-foreground"})}),e[27]=p,e[28]=o,e[29]=h,e[30]=l,e[31]=S):S=e[31];let j;e[32]!==S||e[33]!==v?(j=i.jsx(Ee,{children:i.jsxs(Oe,{children:[v,S]})}),e[32]=S,e[33]=v,e[34]=j):j=e[34];let _;return e[35]!==k||e[36]!==j?(_=i.jsxs("div",{className:"flex flex-col gap-6",children:[k,j]}),e[35]=k,e[36]=j,e[37]=_):_=e[37],_}function ts(n){return n.id!=="openai"}function ss(n){return n.id==="openai-compatible"}function is(n){return n.id!=="deco"&&n.id!=="openai-compatible"}function ns(n){return n.id==="deco"}function ls(n){return qe({label:be().optional(),apiKey:be().min(1,n)})}function os(n){const e=Q.c(91),{providerId:t,onCancel:s,onSuccess:o}=n,{org:l}=ge(),c=ke(),r=we(),[u,d]=V.useState(!1),a=ie();let m;e[0]!==a?(m=Ve(ls(a("settings.connectForms.apiKeyRequired"))),e[0]=a,e[1]=m):m=e[1];let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p={label:"",apiKey:""},e[2]=p):p=e[2];let h;e[3]!==m?(h={resolver:m,defaultValues:p},e[3]=m,e[4]=h):h=e[4];const{register:f,handleSubmit:v,formState:k}=He(h),{errors:S}=k;let j;e[5]!==t||e[6]!==c||e[7]!==a?(j=async se=>{await c.call("AI_PROVIDER_KEY_CREATE",{providerId:t,label:se.label||a("settings.connectForms.defaultKeyLabel"),apiKey:se.apiKey})},e[5]=t,e[6]=c,e[7]=a,e[8]=j):j=e[8];let _;e[9]!==o||e[10]!==l||e[11]!==r||e[12]!==a?(_=()=>{r.invalidateQueries({queryKey:ce.aiProviderKeys(l.id)}),r.invalidateQueries({queryKey:ce.aiProviders(l.id)}),le.success(a("settings.connectForms.keySavedSuccess")),o()},e[9]=o,e[10]=l,e[11]=r,e[12]=a,e[13]=_):_=e[13];let I;e[14]!==a?(I=se=>{le.error(a("settings.connectForms.failedSaveKey",{error:se.message}))},e[14]=a,e[15]=I):I=e[15];let P;e[16]!==j||e[17]!==_||e[18]!==I?(P={mutationFn:j,onSuccess:_,onError:I},e[16]=j,e[17]=_,e[18]=I,e[19]=P):P=e[19];const{mutate:w,isPending:x,error:N}=Se(P);let C;e[20]!==w?(C=se=>w(se),e[20]=w,e[21]=C):C=e[21];let M;e[22]!==v||e[23]!==C?(M=v(C),e[22]=v,e[23]=C,e[24]=M):M=e[24];let g;e[25]!==a?(g=a("settings.connectForms.labelField"),e[25]=a,e[26]=g):g=e[26];let b;e[27]!==g?(b=i.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:g}),e[27]=g,e[28]=b):b=e[28];let y;e[29]!==a?(y=a("settings.connectForms.labelPlaceholder"),e[29]=a,e[30]=y):y=e[30];let E;e[31]!==f?(E=f("label"),e[31]=f,e[32]=E):E=e[32];let L;e[33]!==y||e[34]!==E?(L=i.jsx(xe,{placeholder:y,...E,className:"h-8 text-sm"}),e[33]=y,e[34]=E,e[35]=L):L=e[35];let T;e[36]!==b||e[37]!==L?(T=i.jsxs("div",{className:"space-y-1",children:[b,L]}),e[36]=b,e[37]=L,e[38]=T):T=e[38];let O;e[39]!==a?(O=a("settings.connectForms.apiKeyField"),e[39]=a,e[40]=O):O=e[40];let z;e[41]!==O?(z=i.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:O}),e[41]=O,e[42]=z):z=e[42];const R=u?"text":"password";let F;e[43]!==f?(F=f("apiKey"),e[43]=f,e[44]=F):F=e[44];let Y;e[45]!==R||e[46]!==F?(Y=i.jsx(xe,{type:R,placeholder:"sk-...",...F,className:"ph-no-capture h-8 text-sm pr-8"}),e[45]=R,e[46]=F,e[47]=Y):Y=e[47];let X;e[48]!==u?(X=()=>d(!u),e[48]=u,e[49]=X):X=e[49];let B;e[50]!==u||e[51]!==a?(B=a(u?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[50]=u,e[51]=a,e[52]=B):B=e[52];let H;e[53]!==u?(H=u?i.jsx(Ge,{size:14}):i.jsx(Je,{size:14}),e[53]=u,e[54]=H):H=e[54];let W;e[55]!==X||e[56]!==B||e[57]!==H?(W=i.jsx("button",{type:"button",onClick:X,"aria-label":B,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:H}),e[55]=X,e[56]=B,e[57]=H,e[58]=W):W=e[58];let J;e[59]!==Y||e[60]!==W?(J=i.jsxs("div",{className:"relative",children:[Y,W]}),e[59]=Y,e[60]=W,e[61]=J):J=e[61];let D;e[62]!==S.apiKey?(D=S.apiKey&&i.jsx("p",{className:"text-xs text-destructive",children:S.apiKey.message}),e[62]=S.apiKey,e[63]=D):D=e[63];let $;e[64]!==z||e[65]!==J||e[66]!==D?($=i.jsxs("div",{className:"space-y-1",children:[z,J,D]}),e[64]=z,e[65]=J,e[66]=D,e[67]=$):$=e[67];let G;e[68]!==N?(G=N&&i.jsx("p",{className:"text-xs text-destructive",children:N.message}),e[68]=N,e[69]=G):G=e[69];let A;e[70]!==a?(A=a("settings.connectForms.cancel"),e[70]=a,e[71]=A):A=e[71];let K;e[72]!==x||e[73]!==s||e[74]!==A?(K=i.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:s,disabled:x,children:A}),e[72]=x,e[73]=s,e[74]=A,e[75]=K):K=e[75];let U;e[76]!==x||e[77]!==a?(U=a(x?"settings.connectForms.saving":"settings.connectForms.saveKey"),e[76]=x,e[77]=a,e[78]=U):U=e[78];let q;e[79]!==x||e[80]!==U?(q=i.jsx(re,{type:"submit",size:"sm",disabled:x,children:U}),e[79]=x,e[80]=U,e[81]=q):q=e[81];let Z;e[82]!==K||e[83]!==q?(Z=i.jsxs(Qe,{children:[K,q]}),e[82]=K,e[83]=q,e[84]=Z):Z=e[84];let te;return e[85]!==M||e[86]!==T||e[87]!==$||e[88]!==G||e[89]!==Z?(te=i.jsxs("form",{onSubmit:M,className:"space-y-3",children:[T,$,G,Z]}),e[85]=M,e[86]=T,e[87]=$,e[88]=G,e[89]=Z,e[90]=te):te=e[90],te}function rs(n){return qe({label:be().optional(),baseUrl:be().min(1,n),apiKey:be().optional()})}function as(n){const e=Q.c(109),{preset:t,onCancel:s,onSuccess:o}=n,{org:l}=ge(),c=ke(),r=we(),[u,d]=V.useState(!1),a=ie();let m;e[0]!==a?(m=Ve(rs(a("settings.connectForms.baseUrlRequired"))),e[0]=a,e[1]=m):m=e[1];const p=t?.defaultBaseUrl??"";let h;e[2]!==p?(h={label:"",baseUrl:p,apiKey:""},e[2]=p,e[3]=h):h=e[3];let f;e[4]!==m||e[5]!==h?(f={resolver:m,defaultValues:h},e[4]=m,e[5]=h,e[6]=f):f=e[6];const{register:v,handleSubmit:k,formState:S}=He(f),{errors:j}=S;let _;e[7]!==t||e[8]!==c?(_=async oe=>{const rt=JSON.stringify({baseUrl:oe.baseUrl,apiKey:oe.apiKey||""});await c.call("AI_PROVIDER_KEY_CREATE",{providerId:"openai-compatible",label:oe.label||t?.name||oe.baseUrl,apiKey:rt,...t?{presetId:t.id}:{}})},e[7]=t,e[8]=c,e[9]=_):_=e[9];let I;e[10]!==o||e[11]!==l||e[12]!==r||e[13]!==a?(I=()=>{r.invalidateQueries({queryKey:ce.aiProviderKeys(l.id)}),r.invalidateQueries({queryKey:ce.aiProviders(l.id)}),le.success(a("settings.connectForms.connectionSavedSuccess")),o()},e[10]=o,e[11]=l,e[12]=r,e[13]=a,e[14]=I):I=e[14];let P;e[15]!==a?(P=oe=>{le.error(a("settings.connectForms.failedSaveConnection",{error:oe.message}))},e[15]=a,e[16]=P):P=e[16];let w;e[17]!==_||e[18]!==I||e[19]!==P?(w={mutationFn:_,onSuccess:I,onError:P},e[17]=_,e[18]=I,e[19]=P,e[20]=w):w=e[20];const{mutate:x,isPending:N,error:C}=Se(w);let M;e[21]!==t||e[22]!==a?(M=t?a("settings.connectForms.labelPlaceholderPreset",{name:t.name}):a("settings.connectForms.labelPlaceholderOpenAiCompatible"),e[21]=t,e[22]=a,e[23]=M):M=e[23];const g=M;let b;e[24]!==t?.baseUrlPlaceholder||e[25]!==a?(b=t?.baseUrlPlaceholder??a("settings.connectForms.baseUrlPlaceholder"),e[24]=t?.baseUrlPlaceholder,e[25]=a,e[26]=b):b=e[26];const y=b;let E;e[27]!==x?(E=oe=>x(oe),e[27]=x,e[28]=E):E=e[28];let L;e[29]!==k||e[30]!==E?(L=k(E),e[29]=k,e[30]=E,e[31]=L):L=e[31];let T;e[32]!==a?(T=a("settings.connectForms.labelField"),e[32]=a,e[33]=T):T=e[33];let O;e[34]!==T?(O=i.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:T}),e[34]=T,e[35]=O):O=e[35];let z;e[36]!==v?(z=v("label"),e[36]=v,e[37]=z):z=e[37];let R;e[38]!==g||e[39]!==z?(R=i.jsx(xe,{placeholder:g,...z,className:"h-8 text-sm"}),e[38]=g,e[39]=z,e[40]=R):R=e[40];let F;e[41]!==O||e[42]!==R?(F=i.jsxs("div",{className:"space-y-1",children:[O,R]}),e[41]=O,e[42]=R,e[43]=F):F=e[43];let Y;e[44]!==y||e[45]!==j||e[46]!==t?.defaultBaseUrl||e[47]!==v||e[48]!==a?(Y=t?.defaultBaseUrl?i.jsx("input",{type:"hidden",...v("baseUrl")}):i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:a("settings.connectForms.baseUrlField")}),i.jsx(xe,{type:"url",placeholder:y,...v("baseUrl"),className:"h-8 text-sm"}),j.baseUrl&&i.jsx("p",{className:"text-xs text-destructive",children:j.baseUrl.message})]}),e[44]=y,e[45]=j,e[46]=t?.defaultBaseUrl,e[47]=v,e[48]=a,e[49]=Y):Y=e[49];let X;e[50]!==a?(X=a("settings.connectForms.apiKeyField"),e[50]=a,e[51]=X):X=e[51];let B;e[52]!==t?.apiKeyRecommended||e[53]!==a?(B=t?.apiKeyRecommended?a("settings.connectForms.recommended"):a("settings.connectForms.optional"),e[52]=t?.apiKeyRecommended,e[53]=a,e[54]=B):B=e[54];let H;e[55]!==B?(H=i.jsxs("span",{className:"text-muted-foreground/60",children:["(",B,")"]}),e[55]=B,e[56]=H):H=e[56];let W;e[57]!==X||e[58]!==H?(W=i.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[X," ",H]}),e[57]=X,e[58]=H,e[59]=W):W=e[59];const J=u?"text":"password";let D;e[60]!==v?(D=v("apiKey"),e[60]=v,e[61]=D):D=e[61];let $;e[62]!==J||e[63]!==D?($=i.jsx(xe,{type:J,placeholder:"sk-...",...D,className:"ph-no-capture h-8 text-sm pr-8"}),e[62]=J,e[63]=D,e[64]=$):$=e[64];let G;e[65]!==u?(G=()=>d(!u),e[65]=u,e[66]=G):G=e[66];let A;e[67]!==u||e[68]!==a?(A=a(u?"settings.connectForms.hideApiKey":"settings.connectForms.showApiKey"),e[67]=u,e[68]=a,e[69]=A):A=e[69];let K;e[70]!==u?(K=u?i.jsx(Ge,{size:14}):i.jsx(Je,{size:14}),e[70]=u,e[71]=K):K=e[71];let U;e[72]!==G||e[73]!==A||e[74]!==K?(U=i.jsx("button",{type:"button",onClick:G,"aria-label":A,className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:K}),e[72]=G,e[73]=A,e[74]=K,e[75]=U):U=e[75];let q;e[76]!==$||e[77]!==U?(q=i.jsxs("div",{className:"relative",children:[$,U]}),e[76]=$,e[77]=U,e[78]=q):q=e[78];let Z;e[79]!==W||e[80]!==q?(Z=i.jsxs("div",{className:"space-y-1",children:[W,q]}),e[79]=W,e[80]=q,e[81]=Z):Z=e[81];let te;e[82]!==t?(te=t?.helpText&&i.jsx("p",{className:"text-xs text-muted-foreground",children:t.helpText}),e[82]=t,e[83]=te):te=e[83];let se;e[84]!==C?(se=C&&i.jsx("p",{className:"text-xs text-destructive",children:C.message}),e[84]=C,e[85]=se):se=e[85];let de;e[86]!==a?(de=a("settings.connectForms.cancel"),e[86]=a,e[87]=de):de=e[87];let ue;e[88]!==N||e[89]!==s||e[90]!==de?(ue=i.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:s,disabled:N,children:de}),e[88]=N,e[89]=s,e[90]=de,e[91]=ue):ue=e[91];let he;e[92]!==N||e[93]!==a?(he=a(N?"settings.connectForms.saving":"settings.connectForms.saveConnection"),e[92]=N,e[93]=a,e[94]=he):he=e[94];let me;e[95]!==N||e[96]!==he?(me=i.jsx(re,{type:"submit",size:"sm",disabled:N,children:he}),e[95]=N,e[96]=he,e[97]=me):me=e[97];let fe;e[98]!==ue||e[99]!==me?(fe=i.jsxs(Qe,{children:[ue,me]}),e[98]=ue,e[99]=me,e[100]=fe):fe=e[100];let je;return e[101]!==L||e[102]!==F||e[103]!==Y||e[104]!==Z||e[105]!==te||e[106]!==se||e[107]!==fe?(je=i.jsxs("form",{onSubmit:L,className:"space-y-3",children:[F,Y,Z,te,se,fe]}),e[101]=L,e[102]=F,e[103]=Y,e[104]=Z,e[105]=te,e[106]=se,e[107]=fe,e[108]=je):je=e[108],je}const cs={kind:"closed"};function ds(n,e){switch(e.type){case"open":return n.kind==="closed"?{kind:"grid"}:n;case"close":return{kind:"closed"};case"back":switch(n.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return{kind:"grid"};default:return n}case"select-form":return n.kind!=="grid"?n:{kind:"form",providerId:e.providerId,presetId:e.presetId};case"select-oauth":return n.kind!=="grid"?n:{kind:"oauth-pending",providerId:e.providerId,stateToken:e.stateToken};case"oauth-failed":return n.kind==="oauth-pending"?{kind:"grid"}:n;case"select-provision":return n.kind!=="grid"?n:{kind:"provision-pending",providerId:e.providerId};case"provision-error":return n.kind!=="provision-pending"?n:{kind:"provision-error",providerId:n.providerId,error:e.error};case"retry-provision":return n.kind!=="provision-error"?n:{kind:"provision-pending",providerId:n.providerId}}}function us(n){switch(n.kind){case"form":case"oauth-pending":case"provision-pending":case"provision-error":return n.providerId;default:return null}}function hs({open:n,onOpenChange:e,initialProvider:t}){const s=ie(),l=_e()?.providers??[],{org:c}=ge(),r=ke(),u=we(),[d,a]=V.useReducer(ds,cs),m=V.useRef(!1);V.useEffect(()=>{n&&d.kind==="closed"?a({type:"open"}):!n&&d.kind!=="closed"&&a({type:"close"})},[n,d.kind]);const p=()=>{m.current=!1,a({type:"close"}),e(!1)},h=()=>{u.invalidateQueries({queryKey:ce.aiProviderKeys(c.id)}),u.invalidateQueries({queryKey:ce.aiProviders(c.id)})},{mutate:f}=Se({mutationFn:async({providerId:g,code:b,stateToken:y,label:E})=>(await r.call("AI_PROVIDER_OAUTH_EXCHANGE",{providerId:g,code:b,stateToken:y,label:E}),g),onSuccess:g=>{ne("ai_provider_oauth_succeeded",{provider_id:g}),h();const b=l.find(y=>y.id===g);le.success(s("settings.connectProviderDialog.oauthSuccessMessage",{provider:b?.name??s("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(g,b)=>{ne("ai_provider_oauth_failed",{provider_id:b.providerId,error:g.message}),le.error(s("settings.connectProviderDialog.oauthFailedMessage",{error:g.message})),a({type:"oauth-failed"})}}),{mutate:v}=Se({mutationFn:async g=>(await r.call("AI_PROVIDER_PROVISION_KEY",{providerId:g}),g),onSuccess:g=>{ne("ai_provider_provision_succeeded",{provider_id:g}),h();const b=l.find(y=>y.id===g);le.success(s("settings.connectProviderDialog.provisionSuccessMessage",{provider:b?.name??s("settings.connectProviderDialog.defaultProviderName")})),p()},onError:(g,b)=>{ne("ai_provider_provision_failed",{provider_id:b,error:g.message}),a({type:"provision-error",error:g.message})}}),k=async g=>{const{provider:b}=g,y=g.kind==="openai-compatible"?g.preset?.id??null:null,E=b.supportedMethods.includes("oauth-pkce"),L=b.supportedMethods.includes("api-key");if(b.supportsProvision===!0){ne("ai_provider_connect_clicked",{provider_id:b.id,method:"provision"}),a({type:"select-provision",providerId:b.id}),v(b.id);return}if(E){ne("ai_provider_connect_clicked",{provider_id:b.id,method:"oauth-pkce"});try{const O=await r.call("AI_PROVIDER_OAUTH_URL",{providerId:b.id,callbackUrl:`${window.location.origin}/oauth/callback/ai-provider`});if(!O?.url)throw new Error("Invalid response from AI_PROVIDER_OAUTH_URL");a({type:"select-oauth",providerId:b.id,stateToken:O.stateToken}),window.open(O.url,"AiProviderOAuth","width=600,height=700")}catch(O){le.error(s("settings.connectProviderDialog.startOAuthFailedMessage",{error:O instanceof Error?O.message:String(O)}))}return}L&&(ne("ai_provider_connect_clicked",{provider_id:b.id,...y!==null?{preset_id:y}:{},method:"api-key"}),a({type:"select-form",providerId:b.id,presetId:y}))},S=V.useRef(k);S.current=k;const j=V.useRef(t);j.current=t,V.useEffect(()=>{!j.current||d.kind!=="grid"||m.current||(m.current=!0,S.current(j.current))},[d.kind]);const _=d.kind==="oauth-pending"?d.stateToken:null,I=d.kind==="oauth-pending"?d.providerId:null;V.useEffect(()=>{if(d.kind!=="oauth-pending")return;let g=!1;const b=d.stateToken,y=d.providerId,E=T=>{if(T.origin!==window.location.origin||T.data?.type!=="AI_PROVIDER_OAUTH_CALLBACK")return;const{code:O,stateToken:z}=T.data;if(z!==b){le.error(s("settings.connectProviderDialog.securityCheckFailedMessage")),a({type:"oauth-failed"});return}g=!0;const R=l.find(F=>F.id===y);f({providerId:y,code:O,stateToken:b,label:R?.name??y})};window.addEventListener("message",E);const L=setTimeout(()=>{g||(ne("ai_provider_oauth_timeout",{provider_id:y}),a({type:"oauth-failed"}),le.error(s("settings.connectProviderDialog.connectionTimedOutMessage")))},12e4);return()=>{window.removeEventListener("message",E),clearTimeout(L)}},[d.kind,_,I,f]);const P=us(d),w=P?l.find(g=>g.id===P):null,N=(d.kind==="form"&&d.presetId?ye(d.presetId):null)?.name??w?.name??s("settings.connectProviderDialog.defaultTitle"),C=d.kind!=="grid"&&d.kind!=="closed",M=()=>{t?p():a({type:"back"})};return i.jsx(It,{open:d.kind!=="closed",onOpenChange:g=>!g&&p(),children:i.jsxs(Mt,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[i.jsxs(Et,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[C&&i.jsx(re,{variant:"ghost",size:"icon","aria-label":s("settings.connectProviderDialog.backButtonLabel"),className:"h-7 w-7",onClick:M,children:i.jsx(Ye,{size:16})}),i.jsx(Ot,{children:N})]}),d.kind==="grid"&&!t&&i.jsx(At,{children:s("settings.connectProviderDialog.gridDescription")})]}),d.kind==="grid"&&!t&&i.jsx(tt,{providers:l,onSelect:k}),d.kind==="form"&&(d.providerId==="openai-compatible"?i.jsx(as,{preset:d.presetId?ye(d.presetId):void 0,onCancel:()=>a({type:"back"}),onSuccess:()=>{h(),p()}}):i.jsx(os,{providerId:d.providerId,onCancel:()=>a({type:"back"}),onSuccess:()=>{h(),p()}})),d.kind==="oauth-pending"&&i.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[i.jsx(Ae,{size:"lg"}),i.jsx("p",{className:"text-sm text-muted-foreground text-center",children:s("settings.connectProviderDialog.oauthPendingMessage")})]}),d.kind==="provision-pending"&&i.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[i.jsx(Ae,{size:"lg"}),i.jsx("p",{className:"text-sm text-muted-foreground",children:s("settings.connectProviderDialog.provisionPendingMessage")})]}),d.kind==="provision-error"&&i.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[i.jsx(Ct,{size:28,className:"text-destructive"}),i.jsx("p",{className:"text-sm text-foreground text-center",children:d.error}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(re,{variant:"outline",size:"sm",onClick:()=>a({type:"back"}),children:s("settings.connectProviderDialog.backButton")}),i.jsx(re,{size:"sm",onClick:()=>{a({type:"retry-provision"}),v(d.providerId)},children:s("settings.connectProviderDialog.retryButton")})]})]})]})})}function ms(){const n=Q.c(7),{org:e}=ge(),t=ke();let s;n[0]!==e.id?(s=ce.defaultBrand(e.id),n[0]=e.id,n[1]=s):s=n[1];let o;n[2]!==t?(o=async()=>{const{items:r}=await t.call("BRAND_CONTEXT_LIST",{});return(Array.isArray(r)?r:[]).find(fs)??null},n[2]=t,n[3]=o):o=n[3];let l;n[4]!==s||n[5]!==o?(l={queryKey:s,queryFn:o},n[4]=s,n[5]=o,n[6]=l):l=n[6];const{data:c}=ct(l);return c??null}function fs(n){return n.isDefault&&!n.archivedAt}function ps(n){const e=n.colors;if(!e)return null;if(Array.isArray(e)){const t=e.find(o=>typeof o=="object"&&o!==null&&"label"in o&&/primary|brand|main/i.test(o.label)),s=t?t.value:e[0]?.value;return typeof s=="string"?s:null}if(typeof e=="object"){const t=e;return t.primary??Object.values(t)[0]??null}return null}function xs(n){const e=Q.c(49);let t;e[0]!==n?(t=n===void 0?{}:n,e[0]=n,e[1]=t):t=e[1];const{title:s,description:o}=t,l=ie(),{org:c}=ge(),r=ms(),[u,d]=V.useState(null),[a,m]=V.useState(!1),[p,h]=V.useState(!1),f=Rt();let v;e[2]!==f?(v=(Lt()||zt())&&!f,e[2]=f,e[3]=v):v=e[3];const k=v,S=_e();let j;e[4]!==S?.providers?(j=S?.providers??[],e[4]=S?.providers,e[5]=j):j=e[5];const _=j,I=c.name;let P;e[6]!==r?(P=r?ps(r):null,e[6]=r,e[7]=P):P=e[7];const w=P,x=r?.favicon??r?.logo??null;let N;e[8]!==I||e[9]!==l||e[10]!==s?(N=s??(I?l("chat.noAiProviderEmptyState.headingWithOrg",{org:I}):l("chat.noAiProviderEmptyState.headingDefault")),e[8]=I,e[9]=l,e[10]=s,e[11]=N):N=e[11];const C=N;let M;e[12]!==o||e[13]!==l?(M=o??l("chat.noAiProviderEmptyState.subtitleDefault"),e[12]=o,e[13]=l,e[14]=M):M=e[14];const g=M,b=!!(x||w);let y;e[15]!==w?(y=w?{backgroundColor:`${w}18`,borderColor:`${w}30`}:void 0,e[15]=w,e[16]=y):y=e[16];const E=y,L=b?"flex items-center justify-center size-14 rounded-2xl border":"flex items-center justify-center size-14 rounded-2xl bg-muted border border-border";let T;e[17]!==L||e[18]!==E||e[19]!==x||e[20]!==k||e[21]!==w||e[22]!==l?(T=x?i.jsx("div",{className:L,style:E,children:i.jsx("img",{src:x,alt:"",className:"size-7 rounded object-contain"})}):k?i.jsx("button",{type:"button",onClick:()=>h(!0),"aria-label":l("downloadApp.openLabel"),className:ae(L,"cursor-pointer transition-colors hover:bg-accent"),style:E,children:i.jsx(Pe,{size:24,style:w?{color:w}:void 0,className:ae(!w&&"text-muted-foreground")})}):i.jsx("div",{className:L,style:E,children:i.jsx(Pe,{size:24,style:w?{color:w}:void 0,className:ae(!w&&"text-muted-foreground")})}),e[17]=L,e[18]=E,e[19]=x,e[20]=k,e[21]=w,e[22]=l,e[23]=T):T=e[23];let O;e[24]!==C?(O=i.jsx("p",{className:"text-xl font-semibold text-foreground tracking-tight",children:C}),e[24]=C,e[25]=O):O=e[25];let z;e[26]!==g?(z=i.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:g}),e[26]=g,e[27]=z):z=e[27];let R;e[28]!==z||e[29]!==O?(R=i.jsxs("div",{className:"space-y-2",children:[O,z]}),e[28]=z,e[29]=O,e[30]=R):R=e[30];let F;e[31]!==R||e[32]!==T?(F=i.jsxs("div",{className:"flex flex-col items-center gap-4 text-center",children:[T,R]}),e[31]=R,e[32]=T,e[33]=F):F=e[33];let Y,X;e[34]===Symbol.for("react.memo_cache_sentinel")?(Y=A=>d(A),X=()=>m(!0),e[34]=Y,e[35]=X):(Y=e[34],X=e[35]);let B;e[36]!==_?(B=i.jsx("div",{className:"w-full",children:i.jsx(tt,{providers:_,onSelect:Y,onShowAll:X})}),e[36]=_,e[37]=B):B=e[37];const H=u!==null||a;let W;e[38]===Symbol.for("react.memo_cache_sentinel")?(W=A=>{A||(d(null),m(!1))},e[38]=W):W=e[38];const J=u??void 0;let D;e[39]!==H||e[40]!==J?(D=i.jsx(hs,{open:H,onOpenChange:W,initialProvider:J}),e[39]=H,e[40]=J,e[41]=D):D=e[41];let $;e[42]!==p?($=i.jsx(Ft,{open:p,onOpenChange:h}),e[42]=p,e[43]=$):$=e[43];let G;return e[44]!==F||e[45]!==B||e[46]!==D||e[47]!==$?(G=i.jsxs("div",{className:"flex flex-col items-center gap-8 w-full max-w-3xl px-4",children:[F,B,D,$]}),e[44]=F,e[45]=B,e[46]=D,e[47]=$,e[48]=G):G=e[48],G}function Ie(n){const e=n.title.includes(": ");return{provider:e?n.title.split(": ")[0]??"":n.modelId.split("/")[0]??"",displayName:e?n.title.split(": ").slice(1).join(": "):n.title}}function gs(n){return n<32e3?{level:1,labelKey:"chat.shared.contextLevelSmall",descriptionKey:"chat.shared.contextLevelSmallDesc"}:n<2e5?{level:2,labelKey:"chat.shared.contextLevelMedium",descriptionKey:"chat.shared.contextLevelMediumDesc"}:n<5e5?{level:3,labelKey:"chat.shared.contextLevelLarge",descriptionKey:"chat.shared.contextLevelLargeDesc"}:{level:4,labelKey:"chat.shared.contextLevelVeryLarge",descriptionKey:"chat.shared.contextLevelVeryLargeDesc"}}const vs=["bg-destructive","bg-warning","bg-success","bg-success"],bs=["text-success","text-warning","text-warning","text-destructive"];function ys(n,e){const t=Math.round(n*.75/1e3),s=t>=1?`${t}K`:`${Math.round(n*.75)}`;return e("chat.shared.approxWords",{wordCount:s})}function js(n){return n<1?{level:1,labelKey:"chat.shared.costLevelCheap"}:n<5?{level:2,labelKey:"chat.shared.costLevelModerate"}:n<15?{level:3,labelKey:"chat.shared.costLevelHigh"}:{level:4,labelKey:"chat.shared.costLevelExpensive"}}const Ss={text:{icon:i.jsx(Dt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityText"},vision:{icon:i.jsx($t,{className:"size-3.5"}),labelKey:"chat.shared.capabilityVision"},image:{icon:i.jsx(jt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityImage"},tools:{icon:i.jsx(Kt,{className:"size-3.5"}),labelKey:"chat.shared.capabilityTools"},reasoning:{icon:i.jsx(Ut,{className:"size-3.5"}),labelKey:"chat.shared.capabilityReasoning"},"web-search":{icon:i.jsx(Xe,{className:"size-3.5"}),labelKey:"chat.shared.capabilityWebSearch"}};function Ns(n){const e=Q.c(10),{capability:t}=n,s=ie(),o=Ss[t];if(o){const u=o.icon;let d;e[0]!==o.labelKey||e[1]!==s?(d=s(o.labelKey),e[0]=o.labelKey,e[1]=s,e[2]=d):d=e[2];let a;return e[3]!==o.icon||e[4]!==d?(a=i.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground border border-border rounded px-2 py-0.5",children:[u,d]}),e[3]=o.icon,e[4]=d,e[5]=a):a=e[5],a}let l;e[6]!==t?(l=t.charAt(0).toUpperCase(),e[6]=t,e[7]=l):l=e[7];const c=l+t.slice(1);let r;return e[8]!==c?(r=i.jsx("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground border border-border rounded px-2 py-0.5",children:c}),e[8]=c,e[9]=r):r=e[9],r}function ks(n){const e=Q.c(59),{model:t,compact:s}=n,o=s===void 0?!1:s,l=ie();if(!t){let x;e[0]!==l?(x=l("chat.shared.hoverToPreview"),e[0]=l,e[1]=x):x=e[1];let N;return e[2]!==x?(N=i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:x}),e[2]=x,e[3]=N):N=e[3],N}const c=t.costs?.input!=null?t.costs.input*1e6:null,r=t.costs?.output!=null?t.costs.output*1e6:null;let u;e[4]!==t?(u=Ie(t),e[4]=t,e[5]=u):u=e[5];const{provider:d,displayName:a}=u;if(o){let x;e[6]!==t.limits||e[7]!==l?(x=t.limits?.contextWindow&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.context")}),i.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.contextWindow.toLocaleString()," ",l("chat.shared.tokens")]})]}),e[6]=t.limits,e[7]=l,e[8]=x):x=e[8];let N;e[9]!==c||e[10]!==l?(N=c!=null&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.input")}),i.jsxs("span",{className:"text-foreground font-medium",children:["$",c.toFixed(2)," / 1M"]})]}),e[9]=c,e[10]=l,e[11]=N):N=e[11];let C;e[12]!==r||e[13]!==l?(C=r!=null&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.output")}),i.jsxs("span",{className:"text-foreground font-medium",children:["$",r.toFixed(2)," / 1M"]})]}),e[12]=r,e[13]=l,e[14]=C):C=e[14];let M;e[15]!==t.limits||e[16]!==l?(M=t.limits?.maxOutputTokens&&i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-muted-foreground",children:l("chat.shared.outputLimit")}),i.jsxs("span",{className:"text-foreground font-medium",children:[t.limits.maxOutputTokens.toLocaleString()," ",l("chat.shared.tokens")]})]}),e[15]=t.limits,e[16]=l,e[17]=M):M=e[17];let g;return e[18]!==x||e[19]!==N||e[20]!==C||e[21]!==M?(g=i.jsxs("div",{className:"flex flex-col gap-2 pt-3 pb-3 px-3 text-xs",children:[x,N,C,M]}),e[18]=x,e[19]=N,e[20]=C,e[21]=M,e[22]=g):g=e[22],g}let m;e[23]!==d?(m=i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:d}),e[23]=d,e[24]=m):m=e[24];let p;e[25]!==t.logo||e[26]!==t.title?(p=t.logo&&i.jsx("img",{src:t.logo,className:"size-6 shrink-0 rounded-md dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[25]=t.logo,e[26]=t.title,e[27]=p):p=e[27];let h;e[28]!==a?(h=i.jsx("p",{className:"text-lg font-semibold leading-snug tracking-tight",children:a}),e[28]=a,e[29]=h):h=e[29];let f;e[30]!==p||e[31]!==h?(f=i.jsxs("div",{className:"flex items-center gap-2.5",children:[p,h]}),e[30]=p,e[31]=h,e[32]=f):f=e[32];let v;e[33]!==t.modelId?(v=i.jsx("p",{className:"text-xs text-muted-foreground/50 font-mono",children:t.modelId}),e[33]=t.modelId,e[34]=v):v=e[34];let k;e[35]!==m||e[36]!==f||e[37]!==v?(k=i.jsxs("div",{className:"flex flex-col gap-1 pt-1 pr-6",children:[m,f,v]}),e[35]=m,e[36]=f,e[37]=v,e[38]=k):k=e[38];let S;e[39]!==t.capabilities?(S=t.capabilities&&t.capabilities.length>0&&i.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pb-4 border-b border-border",children:[...new Set(t.capabilities)].map(ws)}),e[39]=t.capabilities,e[40]=S):S=e[40];let j;e[41]!==t.limits||e[42]!==l?(j=t.limits?.contextWindow&&(()=>{const{level:x,labelKey:N,descriptionKey:C}=gs(t.limits.contextWindow);return i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:l("chat.shared.contextWindow")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(M=>i.jsx("div",{className:ae("w-2 h-2 rounded-full",M<=x?vs[x-1]:"bg-muted")},M))}),i.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:l(N)}),i.jsxs("span",{className:"text-xs text-muted-foreground",children:["— ",l(C)]})]}),i.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.limits.contextWindow.toLocaleString()," ",l("chat.shared.tokens")]})]})})(),e[41]=t.limits,e[42]=l,e[43]=j):j=e[43];let _;e[44]!==t.limits||e[45]!==l?(_=t.limits?.maxOutputTokens&&i.jsxs("div",{className:"flex flex-col gap-1",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:l("chat.shared.outputLimit")}),i.jsxs("div",{className:"flex items-baseline gap-2",children:[i.jsxs("span",{className:"text-sm text-foreground",children:[t.limits.maxOutputTokens.toLocaleString()," ",l("chat.shared.tokens")]}),i.jsx("span",{className:"text-sm text-muted-foreground",children:ys(t.limits.maxOutputTokens,l)})]})]}),e[44]=t.limits,e[45]=l,e[46]=_):_=e[46];let I;e[47]!==c||e[48]!==r||e[49]!==l?(I=(c!=null||r!=null)&&(()=>{const{level:x,labelKey:N}=c!=null?js(c):{level:0,labelKey:null};return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:l("chat.shared.pricing")}),c!=null&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex items-center",children:[1,2,3,4].map(C=>i.jsx("span",{className:ae("text-sm font-bold leading-none",C<=x?bs[x-1]:"text-muted-foreground/20"),children:"$"},C))}),i.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:N?l(N):""})]}),i.jsxs("div",{className:"flex flex-col gap-1",children:[c!=null&&i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:l("chat.shared.input")}),i.jsxs("span",{className:"text-xs text-foreground",children:["$",c.toFixed(2)," / 1M"," ",l("chat.shared.tokens")]})]}),r!=null&&i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{className:"text-xs text-muted-foreground",children:l("chat.shared.output")}),i.jsxs("span",{className:"text-xs text-foreground",children:["$",r.toFixed(2)," / 1M"," ",l("chat.shared.tokens")]})]})]})]})})(),e[47]=c,e[48]=r,e[49]=l,e[50]=I):I=e[50];let P;e[51]!==j||e[52]!==_||e[53]!==I?(P=i.jsxs("div",{className:"flex flex-col gap-6",children:[j,_,I]}),e[51]=j,e[52]=_,e[53]=I,e[54]=P):P=e[54];let w;return e[55]!==P||e[56]!==k||e[57]!==S?(w=i.jsxs("div",{className:"flex flex-col gap-5 py-1 px-1.5",children:[k,S,P]}),e[55]=P,e[56]=k,e[57]=S,e[58]=w):w=e[58],w}function ws(n){return i.jsx(Ns,{capability:n},n)}function Si(n){const e=Q.c(22),{model:t,placeholder:s,isLoading:o}=n,l=o===void 0?!1:o,c=ie();let r;e[0]!==s||e[1]!==c?(r=s??c("chat.shared.selectModel"),e[0]=s,e[1]=c,e[2]=r):r=e[2];const u=r;if(l){let S;return e[3]===Symbol.for("react.memo_cache_sentinel")?(S=i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(ee,{className:"w-5 h-5 rounded-sm shrink-0"}),i.jsx(ee,{className:"w-16 h-3 hidden md:block"})]}),e[3]=S):S=e[3],S}if(!t){let S;e[4]!==u?(S=i.jsx("span",{className:"text-sm text-muted-foreground",children:u}),e[4]=u,e[5]=S):S=e[5];let j;e[6]===Symbol.for("react.memo_cache_sentinel")?(j=i.jsx(Te,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[6]=j):j=e[6];let _;return e[7]!==S?(_=i.jsxs("div",{className:"flex items-center gap-1.5",children:[S,j]}),e[7]=S,e[8]=_):_=e[8],_}let d;e[9]!==t?(d=Ie(t),e[9]=t,e[10]=d):d=e[10];const{displayName:a}=d;let m;e[11]!==t?(m=Ce(t),e[11]=t,e[12]=m):m=e[12];const p=m;let h;e[13]!==t.title||e[14]!==p?(h=i.jsx("img",{src:p,className:"w-3.5 h-3.5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[13]=t.title,e[14]=p,e[15]=h):h=e[15];let f;e[16]!==a?(f=i.jsx("span",{className:"text-sm truncate whitespace-nowrap text-muted-foreground max-w-[100px] sm:max-w-none",children:a}),e[16]=a,e[17]=f):f=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=i.jsx(Te,{size:14,className:"text-muted-foreground opacity-50 shrink-0"}),e[18]=v):v=e[18];let k;return e[19]!==h||e[20]!==f?(k=i.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden",children:[h,f,v]}),e[19]=h,e[20]=f,e[21]=k):k=e[21],k}const _s=["vision","image","file","audio","video"],st=["image/png","image/jpeg","image/gif","image/webp"],it=["application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];function Me(n){const e=n?.capabilities;return e?_s.some(t=>e.includes(t)):!1}function Ni(n,e){if(!n)return!1;if(n.startsWith("text/"))return!0;const t=e?.capabilities??[],s=t.includes("vision")||t.includes("image"),o=t.includes("file"),l=t.includes("audio"),c=t.includes("video");return!!(s&&st.includes(n)||o&&n==="application/pdf"||l&&n.startsWith("audio/")||c&&n.startsWith("video/")||Me(e)&&it.includes(n))}function ki(n){const e=n?.capabilities??[],t=["text/*"];return(e.includes("vision")||e.includes("image"))&&t.push(...st),e.includes("file")&&t.push("application/pdf"),e.includes("audio")&&t.push("audio/*"),e.includes("video")&&t.push("video/*"),Me(n)&&t.push(...it),t.join(",")}function wi(n){const e=n?.capabilities??[],t=[];return(e.includes("vision")||e.includes("image"))&&t.push("chat.shared.fileTypeImages"),e.includes("file")&&t.push("chat.shared.fileTypePdfs"),e.includes("audio")&&t.push("chat.shared.fileTypeAudio"),e.includes("video")&&t.push("chat.shared.fileTypeVideo"),Me(n)&&t.push("chat.shared.fileTypeOffice"),{parts:t,count:t.length}}const nt=["smarter","faster","cheaper"],Cs={smarter:"chat.decopilot.tierSmarter",faster:"chat.decopilot.tierFaster",cheaper:"chat.decopilot.tierCheaper"},Is=[{tier:"smarter",prefixes:["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","openai/gpt-5.3-codex","google/gemini-3-pro","google/gemini-2.5-pro","cohere/command-r-plus","cohere/command-a"]},{tier:"faster",prefixes:["anthropic/claude-haiku-4.5","anthropic/claude-4.5-haiku","google/gemini-3-flash","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast","x-ai/grok-3","mistralai/mistral-large","mistralai/codestral","mistralai/mistral-medium","minimax/minimax-m1"]},{tier:"cheaper",prefixes:["google/gemini-2.5-flash-lite","google/gemini-2.5-flash","google/gemini-2.0-flash","deepseek/deepseek-v3","openai/gpt-oss-120b","mistralai/mistral-small","mistralai/pixtral","cohere/command-r"]}],Ms=Is.flatMap(({tier:n,prefixes:e})=>e.map(t=>({tier:n,prefix:t}))).sort((n,e)=>e.prefix.length-n.prefix.length),Es="google/gemini-2.5-pro",$e=new Map;function Os(n){const e=$e.get(n);if(e!==void 0)return e;let t=null;if(n.endsWith(":free"))t="cheaper";else for(const{tier:s,prefix:o}of Ms)if(n.startsWith(o)){if(o===Es&&n.length>o.length&&n[o.length]==="-"){const c=n[o.length+1];if(!c||!/\d/.test(c))continue}t=s;break}return $e.set(n,t),t}function Ue(n){const e={smarter:[],faster:[],cheaper:[],other:[]};for(const t of n){const s=Os(t.modelId);e[s??"other"].push(t)}for(const t of Object.keys(e))e[t].sort((s,o)=>s.title.localeCompare(o.title));return e}const lt="studio:model-shortlist:",As=new Set(["anthropic/claude-opus-4.8","anthropic/claude-sonnet-4.6","anthropic/claude-4.6-sonnet","anthropic/claude-sonnet-4.6:extended","openai/gpt-5.3-codex","google/gemini-3-pro-preview","google/gemini-2.5-pro","anthropic/claude-haiku-4.5","anthropic/claude-haiku-4.5-20251001","anthropic/claude-4.5-haiku","google/gemini-3-flash-preview","openai/gpt-5.1-codex-mini","x-ai/grok-code-fast-1","google/gemini-2.5-flash","deepseek/deepseek-v3.2","google/gemini-2.5-flash-lite","openai/gpt-oss-120b:free"]);function Ps(n){try{const e=localStorage.getItem(lt+n);return e?new Set(JSON.parse(e)):null}catch{return null}}function Ts(n,e){localStorage.setItem(lt+n,JSON.stringify([...e]))}function Ls(n){const e=Q.c(21),{model:t,onHover:s}=n;let o;e[0]!==t?(o=Ie(t),e[0]=t,e[1]=o):o=e[1];const{displayName:l,provider:c}=o;let r;e[2]!==t?(r=Ce(t),e[2]=t,e[3]=r):r=e[3];const u=r;let d;e[4]!==t||e[5]!==s?(d=()=>s(t),e[4]=t,e[5]=s,e[6]=d):d=e[6];let a;e[7]!==t.title||e[8]!==u?(a=i.jsx("img",{src:u,className:"w-4 h-4 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[7]=t.title,e[8]=u,e[9]=a):a=e[9];let m;e[10]!==l?(m=i.jsx("span",{className:"text-sm text-foreground leading-tight truncate",children:l}),e[10]=l,e[11]=m):m=e[11];let p;e[12]!==c?(p=i.jsx("span",{className:"text-xs text-muted-foreground/60 leading-tight",children:c}),e[12]=c,e[13]=p):p=e[13];let h;e[14]!==m||e[15]!==p?(h=i.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[m,p]}),e[14]=m,e[15]=p,e[16]=h):h=e[16];let f;return e[17]!==d||e[18]!==a||e[19]!==h?(f=i.jsxs("div",{className:"flex items-center gap-2.5 py-2 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:d,children:[a,h]}),e[17]=d,e[18]=a,e[19]=h,e[20]=f):f=e[20],f}function zs(n){const e=Q.c(16),{error:t,onRetry:s}=n,o=ie();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx("div",{className:"bg-destructive/10 p-2 rounded-full",children:i.jsx(ht,{className:"size-5 text-destructive"})}),e[0]=l):l=e[0];const c=o("chat.decopilot.failedToLoadModels");let r;e[1]!==c?(r=i.jsx("p",{className:"text-sm font-medium text-foreground",children:c}),e[1]=c,e[2]=r):r=e[2];const u=t?.message||o("chat.decopilot.couldNotFetchModels"),d=" "+o("chat.decopilot.tryAnotherProviderOrRetry");let a;e[3]!==u||e[4]!==d?(a=i.jsxs("p",{className:"text-xs text-muted-foreground max-w-[260px]",children:[u,d]}),e[3]=u,e[4]=d,e[5]=a):a=e[5];let m;e[6]!==r||e[7]!==a?(m=i.jsxs("div",{className:"flex flex-col gap-1",children:[r,a]}),e[6]=r,e[7]=a,e[8]=m):m=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=i.jsx(Nt,{className:"size-3.5"}),e[9]=p):p=e[9];const h=o("chat.decopilot.retry");let f;e[10]!==s||e[11]!==h?(f=i.jsx("div",{className:"flex items-center gap-2",children:i.jsxs(re,{variant:"outline",size:"sm",onClick:s,className:"gap-1.5",children:[p,h]})}),e[10]=s,e[11]=h,e[12]=f):f=e[12];let v;return e[13]!==f||e[14]!==m?(v=i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-4 py-8 text-center",children:[l,m,f]}),e[13]=f,e[14]=m,e[15]=v):v=e[15],v}function Fs(){const n=Q.c(1);let e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:6}).map(Rs)}),n[0]=e):e=n[0],e}function Rs(n,e){return i.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[i.jsx(ee,{className:"size-5 shrink-0 rounded-sm"}),i.jsx(ee,{className:"flex-1 h-4"}),i.jsx(ee,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function Be(n){const e=Q.c(12),{label:t,models:s,onSelect:o,onHover:l}=n;if(s.length===0)return null;let c;e[0]!==t?(c=i.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:t}),e[0]=t,e[1]=c):c=e[1];let r;if(e[2]!==s||e[3]!==l||e[4]!==o){let d;e[6]!==l||e[7]!==o?(d=a=>i.jsx("button",{type:"button",onClick:()=>o(a),onFocus:()=>l(a),className:"w-full text-left cursor-pointer",children:i.jsx(Ls,{model:a,onHover:l})},a.modelId),e[6]=l,e[7]=o,e[8]=d):d=e[8],r=s.map(d),e[2]=s,e[3]=l,e[4]=o,e[5]=r}else r=e[5];let u;return e[9]!==c||e[10]!==r?(u=i.jsxs("div",{children:[c,r]}),e[9]=c,e[10]=r,e[11]=u):u=e[11],u}function Ne(n,e){return e(n==="other"?"chat.decopilot.tierOther":Cs[n])}function Ks(n){const e=Q.c(21),{model:t,isChecked:s,onToggle:o,onHover:l}=n,[c,r]=V.useState(s);c!==s&&r(s);let u;e[0]!==t?(u=Ce(t),e[0]=t,e[1]=u):u=e[1];const d=u;let a;e[2]!==t||e[3]!==l?(a=()=>l(t),e[2]=t,e[3]=l,e[4]=a):a=e[4];let m;e[5]!==t.modelId||e[6]!==o?(m=()=>{r(Ds),o(t.modelId)},e[5]=t.modelId,e[6]=o,e[7]=m):m=e[7];let p;e[8]!==c||e[9]!==m?(p=i.jsx(mt,{checked:c,onCheckedChange:m}),e[8]=c,e[9]=m,e[10]=p):p=e[10];let h;e[11]!==d||e[12]!==t.title?(h=i.jsx("img",{src:d,className:"w-5 h-5 shrink-0 rounded-sm dark:bg-white dark:rounded-sm dark:p-px",alt:t.title}),e[11]=d,e[12]=t.title,e[13]=h):h=e[13];let f;e[14]!==t.title?(f=i.jsx("span",{className:"text-sm text-foreground flex-1 min-w-0 line-clamp-1",children:t.title}),e[14]=t.title,e[15]=f):f=e[15];let v;return e[16]!==a||e[17]!==p||e[18]!==h||e[19]!==f?(v=i.jsxs("label",{className:"flex items-center gap-3 min-h-8 py-2.5 px-3 hover:bg-accent cursor-pointer rounded-lg",onMouseEnter:a,children:[p,h,f]}),e[16]=a,e[17]=p,e[18]=h,e[19]=f,e[20]=v):v=e[20],v}function Ds(n){return!n}function $s(n,e){const t=[];for(const s of nt)if(n[s].length>0){t.push({type:"header",label:Ne(s,e)});for(const o of n[s])t.push({type:"model",model:o})}if(n.other.length>0){t.push({type:"header",label:Ne("other",e)});for(const s of n.other)t.push({type:"model",model:s})}return t}function Us({items:n,shortlistSet:e,onToggle:t,onHover:s}){const o=V.useRef(null),l=es({count:n.length,getScrollElement:()=>o.current,estimateSize:c=>n[c]?.type==="header"?36:44,overscan:6});return i.jsx("div",{ref:o,className:"flex-1 overflow-y-auto",children:i.jsx("div",{className:"relative",style:{height:l.getTotalSize()},children:l.getVirtualItems().map(c=>{const r=n[c.index];return r?i.jsx("div",{"data-index":c.index,ref:l.measureElement,className:"absolute left-0 right-0 top-0 px-0.5",style:{transform:`translateY(${c.start}px)`},children:r.type==="header"?i.jsx("div",{className:"text-xs font-medium text-muted-foreground px-3 pt-3 pb-1",children:r.label}):i.jsx(Ks,{model:r.model,isChecked:e.has(r.model.modelId),onToggle:t,onHover:s})},c.key):null})})})}function Bs(n){const e=Q.c(30),{keyId:t,searchTerm:s,onHover:o,onModelSelect:l,managing:c,onToggleManage:r,filterModels:u}=n,d=ie(),{models:a}=wt(t),m=u?a.filter(u):a.filter(Ws);let p;e[0]!==t?(p=()=>(t?Ps(t):null)??As,e[0]=t,e[1]=p):p=e[1];const[h,f]=V.useState(p),[,v]=V.useTransition();let k;e[2]!==t||e[3]!==v?(k=b=>{t&&v(()=>{f(y=>{const E=new Set(y);return E.has(b)?E.delete(b):E.add(b),Ts(t,E),E})})},e[2]=t,e[3]=v,e[4]=k):k=e[4];const S=k,j=s.toLowerCase().trim(),_=b=>j?b.filter(y=>y.title.toLowerCase().includes(j)||y.modelId.toLowerCase().includes(j)):b;if(c){const b=Ue(_(m)),y=$s(b,d);let E;e[5]!==h?(E=R=>h.has(R.modelId),e[5]=h,e[6]=E):E=e[6];const L=m.filter(E).length;let T;e[7]===Symbol.for("react.memo_cache_sentinel")?(T=i.jsx(Ye,{size:14}),e[7]=T):T=e[7];let O;e[8]!==d?(O=d("chat.decopilot.back"),e[8]=d,e[9]=O):O=e[9];let z;return e[10]!==r||e[11]!==O?(z=i.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground cursor-pointer",children:[T,O]}),e[10]=r,e[11]=O,e[12]=z):z=e[12],i.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[z,i.jsx("span",{className:"text-xs text-muted-foreground",children:d("chat.decopilot.selectedCount",{count:L})})]}),i.jsx(Us,{items:y,shortlistSet:h,onToggle:S,onHover:o})]})}let I;e[13]!==h?(I=b=>h.has(b.modelId),e[13]=h,e[14]=I):I=e[14];const P=m.filter(I),w=P.length>0?P:m,x=Ue(_(w));let N;e[15]!==x||e[16]!==o||e[17]!==l||e[18]!==d?(N=nt.map(b=>i.jsx(Be,{label:Ne(b,d),models:x[b],onSelect:l,onHover:o},b)),e[15]=x,e[16]=o,e[17]=l,e[18]=d,e[19]=N):N=e[19];let C;e[20]!==d?(C=Ne("other",d),e[20]=d,e[21]=C):C=e[21];let M;e[22]!==x.other||e[23]!==o||e[24]!==l||e[25]!==C?(M=i.jsx(Be,{label:C,models:x.other,onSelect:l,onHover:o}),e[22]=x.other,e[23]=o,e[24]=l,e[25]=C,e[26]=M):M=e[26];let g;return e[27]!==N||e[28]!==M?(g=i.jsxs("div",{className:"flex-1 overflow-y-auto px-0.5 pt-1 [touch-action:pan-y]",children:[N,M]}),e[27]=N,e[28]=M,e[29]=g):g=e[29],g}function Ws(n){return n.asyncResearch!==!0}function _i(){const n=Q.c(6);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=i.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:i.jsxs("div",{className:"flex items-center gap-2.5 h-12 px-4",children:[i.jsx(ee,{className:"size-4 shrink-0"}),i.jsx(ee,{className:"flex-1 h-6"}),i.jsx(ee,{className:"w-[140px] h-8 shrink-0"})]})}),n[0]=e):e=n[0];let t;n[1]===Symbol.for("react.memo_cache_sentinel")?(t=i.jsxs("div",{className:"flex-1 flex flex-col md:border-r md:w-[420px] md:min-w-[420px] min-h-0 overflow-hidden",children:[e,i.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:Array.from({length:8}).map(Vs)})]}),n[1]=t):t=n[1];let s;n[2]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[i.jsx(ee,{className:"size-6 shrink-0"}),i.jsx(ee,{className:"h-6 w-32"})]}),n[2]=s):s=n[2];let o;n[3]===Symbol.for("react.memo_cache_sentinel")?(o=i.jsxs("div",{className:"flex flex-col gap-3 py-2 px-0",children:[s,i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ee,{className:"h-6 w-20 rounded-md"}),i.jsx(ee,{className:"h-6 w-24 rounded-md"})]})]}),n[3]=o):o=n[3];let l;n[4]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx(ee,{className:"h-4 w-24"}),i.jsx(ee,{className:"h-4 w-32"})]}),n[4]=l):l=n[4];let c;return n[5]===Symbol.for("react.memo_cache_sentinel")?(c=i.jsxs("div",{className:"flex flex-col md:flex-row h-full sm:h-[460px] min-h-0",children:[t,i.jsx("div",{className:"hidden md:block md:w-[320px] md:shrink-0 p-3",children:i.jsxs("div",{className:"flex flex-col gap-3 py-1 px-1.5",children:[o,i.jsxs("div",{className:"flex flex-col gap-4",children:[l,i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx(ee,{className:"h-4 w-16"}),i.jsx(ee,{className:"h-4 w-40"})]})]})]})})]}),n[5]=c):c=n[5],c}function Vs(n,e){return i.jsxs("div",{className:"flex items-center gap-2 min-h-8 py-3 px-3 rounded-lg",children:[i.jsx(ee,{className:"size-5 shrink-0 rounded-sm"}),i.jsx(ee,{className:"flex-1 h-4"}),i.jsx(ee,{className:"w-16 h-5 shrink-0 rounded-md"})]},e)}function ot(n){const e=Q.c(66),{onClose:t,credentialId:s,onCredentialChange:o,selectedModel:l,onModelChange:c,filterModels:r,compact:u}=n,d=ie(),[a,m]=V.useState(null),[p,h]=V.useState(""),[f,v]=V.useState(!1),k=_e(),S=kt();let j;e[0]!==k?.providers?(j=Object.fromEntries((k?.providers??[]).map(Ys)),e[0]=k?.providers,e[1]=j):j=e[1];const _=j,I=dt(),{org:P}=ge();let w;e[2]!==o?(w=A=>{o(A),m(null)},e[2]=o,e[3]=w):w=e[3];const x=w;let N;e[4]!==s||e[5]!==t||e[6]!==c?(N=A=>{s&&(c(A),h(""),t())},e[4]=s,e[5]=t,e[6]=c,e[7]=N):N=e[7];const C=N;if(S.length===0){const A=!u&&"sm:w-[740px]";let K;e[8]!==A?(K=ae("flex items-center justify-center p-8 w-full",A),e[8]=A,e[9]=K):K=e[9];let U;e[10]===Symbol.for("react.memo_cache_sentinel")?(U=i.jsx(xs,{}),e[10]=U):U=e[10];let q;return e[11]!==K?(q=i.jsx("div",{className:K,children:U}),e[11]=K,e[12]=q):q=e[12],q}const M=u?"sm:h-[420px]":"sm:h-[460px]";let g;e[13]!==M?(g=ae("flex flex-col md:flex-row h-full min-h-0",M),e[13]=M,e[14]=g):g=e[14];const b=u?"w-full":"md:border-r md:w-[420px] md:min-w-[420px]";let y;e[15]!==b?(y=ae("flex-1 flex flex-col min-h-0 overflow-hidden",b),e[15]=b,e[16]=y):y=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=i.jsx(Xe,{size:16,className:"text-muted-foreground shrink-0"}),e[17]=E):E=e[17];let L;e[18]!==f||e[19]!==d?(L=d(f?"chat.decopilot.searchAllModels":"chat.decopilot.searchForModel"),e[18]=f,e[19]=d,e[20]=L):L=e[20];let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=A=>h(A.target.value),e[21]=T):T=e[21];let O;e[22]!==p||e[23]!==L?(O=i.jsx(xe,{autoFocus:!0,type:"text",placeholder:L,value:p,onChange:T,className:"flex-1 min-w-0 border-0 !shadow-none focus-visible:ring-0 px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"}),e[22]=p,e[23]=L,e[24]=O):O=e[24];let z;e[25]!==s||e[26]!==x||e[27]!==S||e[28]!==_||e[29]!==d?(z=S.length>0&&i.jsxs(ft,{value:s??"",onValueChange:x,children:[i.jsxs(pt,{size:"sm",className:"w-auto max-w-[140px] h-8 shrink-0 gap-1.5 px-2 [&>svg:last-child]:hidden",onClick:qs,children:[i.jsx(xt,{placeholder:d("chat.decopilot.key"),children:(()=>{const A=S.find(te=>te.id===s),K=A?_[A.providerId]:void 0,U=ye(A?.presetId),q=U?.logo??K?.logo,Z=U?.name??K?.name??A?.providerId??"Key";return i.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[q?i.jsx("img",{src:q,alt:Z,className:"w-4 h-4 rounded shrink-0 dark:bg-white dark:rounded-sm dark:p-px"}):i.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary shrink-0",children:Z.slice(0,1).toUpperCase()}),i.jsx("span",{className:"text-xs truncate",children:Z})]})})()}),i.jsx(bt,{className:"size-4 opacity-50 shrink-0 pointer-events-none"})]}),i.jsx(gt,{children:S.map(A=>{const K=_[A.providerId],U=ye(A.presetId),q=U?.logo??K?.logo,Z=U?.name??K?.name??A.providerId;return i.jsx(vt,{value:A.id,children:i.jsxs("div",{className:"flex items-center gap-2",children:[q?i.jsx("img",{src:q,alt:Z,className:"w-4 h-4 rounded dark:bg-white dark:rounded-sm dark:p-px"}):i.jsx("div",{className:"w-4 h-4 rounded bg-primary/10 flex items-center justify-center text-xs font-semibold text-primary",children:Z.slice(0,1).toUpperCase()}),i.jsxs("span",{children:[Z," — ",A.label]})]})},A.id)})})]}),e[25]=s,e[26]=x,e[27]=S,e[28]=_,e[29]=d,e[30]=z):z=e[30];let R;e[31]!==O||e[32]!==z?(R=i.jsx("div",{className:"border-b border-border h-12 bg-background/95 backdrop-blur sticky top-0 z-10",children:i.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 pr-12 md:pr-4 cursor-text",children:[E,O,z]})}),e[31]=O,e[32]=z,e[33]=R):R=e[33];let F;e[34]!==s?(F=A=>{const{error:K,resetError:U}=A;return i.jsx(zs,{error:K,onRetry:U,credentialId:s??void 0})},e[34]=s,e[35]=F):F=e[35];let Y;e[36]===Symbol.for("react.memo_cache_sentinel")?(Y=i.jsx(Fs,{}),e[36]=Y):Y=e[36];const X=s??void 0;let B;e[37]===Symbol.for("react.memo_cache_sentinel")?(B=()=>v(Hs),e[37]=B):B=e[37];let H;e[38]!==r||e[39]!==C||e[40]!==f||e[41]!==p||e[42]!==X?(H=i.jsx(V.Suspense,{fallback:Y,children:i.jsx(Bs,{keyId:X,searchTerm:p,onHover:m,onModelSelect:C,managing:f,onToggleManage:B,filterModels:r})}),e[38]=r,e[39]=C,e[40]=f,e[41]=p,e[42]=X,e[43]=H):H=e[43];let W;e[44]!==s||e[45]!==F||e[46]!==H?(W=i.jsx(ut,{fallback:F,children:H},s),e[44]=s,e[45]=F,e[46]=H,e[47]=W):W=e[47];let J;e[48]!==f||e[49]!==I||e[50]!==P||e[51]!==d?(J=!f&&i.jsxs("div",{className:"border-t border-border flex",children:[i.jsxs("button",{type:"button",onClick:()=>V.startTransition(()=>v(!0)),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[i.jsx(St,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageModels")]}),i.jsx("div",{className:"w-px bg-border shrink-0"}),i.jsxs("button",{type:"button",onClick:()=>I({to:"/$org/settings/ai-providers",params:{org:P.slug}}),className:"flex items-center gap-2 flex-1 px-4 py-2.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer",children:[i.jsx(yt,{className:"size-3.5 shrink-0"}),d("chat.decopilot.manageApiKeys")]})]}),e[48]=f,e[49]=I,e[50]=P,e[51]=d,e[52]=J):J=e[52];let D;e[53]!==R||e[54]!==W||e[55]!==J||e[56]!==y?(D=i.jsxs("div",{className:y,children:[R,W,J]}),e[53]=R,e[54]=W,e[55]=J,e[56]=y,e[57]=D):D=e[57];let $;e[58]!==u||e[59]!==a||e[60]!==l?($=!u&&i.jsx("div",{className:"hidden md:flex md:flex-col md:w-[320px] md:shrink-0 p-3",children:i.jsx(ks,{model:a??l??null})}),e[58]=u,e[59]=a,e[60]=l,e[61]=$):$=e[61];let G;return e[62]!==D||e[63]!==$||e[64]!==g?(G=i.jsxs("div",{className:g,children:[D,$]}),e[62]=D,e[63]=$,e[64]=g,e[65]=G):G=e[65],G}function Hs(n){return!n}function qs(n){return n.stopPropagation()}function Ys(n){return[n.id,n]}function Gs(n){const e=Q.c(12),{onClose:t}=n,{credentialId:s,setCredentialId:o,selectedModel:l,setModel:c}=_t();let r;e[0]!==o?(r=a=>{ne("chat_credential_changed",{credential_id:a}),o(a)},e[0]=o,e[1]=r):r=e[1];let u;e[2]!==s||e[3]!==l?.modelId||e[4]!==c?(u=a=>{s&&(ne("chat_model_changed",{from_model_id:l?.modelId??null,to_model_id:a.modelId,to_model_provider:a.providerId??null,credential_id:s}),c({...a,keyId:s}))},e[2]=s,e[3]=l?.modelId,e[4]=c,e[5]=u):u=e[5];let d;return e[6]!==s||e[7]!==t||e[8]!==l||e[9]!==r||e[10]!==u?(d=i.jsx(ot,{onClose:t,credentialId:s,onCredentialChange:r,selectedModel:l,onModelChange:u}),e[6]=s,e[7]=t,e[8]=l,e[9]=r,e[10]=u,e[11]=d):d=e[11],d}function Xs(n){const e=Q.c(2),{onClose:t}=n;let s;return e[0]!==t?(s=i.jsx(Gs,{onClose:t}),e[0]=t,e[1]=s):s=e[1],s}function Qs(n){const e=Q.c(2);let t;return e[0]!==n?(t=i.jsx(ot,{...n}),e[0]=n,e[1]=t):t=e[1],t}function Ci(n){const e=Q.c(2),{onClose:t}=n;let s;return e[0]!==t?(s=i.jsx(Xs,{onClose:t}),e[0]=t,e[1]=s):s=e[1],s}function Ii(n){const e=Q.c(4);let t;e[0]!==n?({...t}=n,e[0]=n,e[1]=t):t=e[1];let s;return e[2]!==t?(s=i.jsx(Qs,{...t}),e[2]=t,e[3]=s):s=e[3],s}export{hs as C,Ii as M,xs as N,tt as P,Si as S,_i as a,wi as b,Ci as c,ye as d,ki as g,Ni as i,Me as m};
@@ -1 +1 @@
1
- import{c as E,d as U,I as N,b as w,U as k,W as R,j as e,B as T,r as y,E as P,_ as z,x as F,z as L,K as A,e as O,o as S,R as B,u as H,$ as K,O as Y}from"./index-B3yBTWEk.js";import{s as V,n as W}from"./site-url-en5df9c-.js";import{f as $,d as G,D as Q,g as q}from"./dialog-otnvxVN0.js";import{c as J}from"./use-commerce-diagnostic-mdvL2BW-.js";import{u as X}from"./use-mcp-client-DsJzBus3.js";import{i as D}from"./ArrowRight-Cu8UuHNR.js";import{u as Z}from"./use-organization-settings-BAVHurZk.js";import{C as tt,a as ot}from"./companion-mcps-section-BszDkkOp.js";import{C as et,a as rt}from"./connect-layout-C_MQVbrT.js";import{p as j}from"./self-tool-result-8OxPN9Nm.js";import{a as it}from"./index-Bwc7J041.js";import{C as nt}from"./chat-context-CXknhaDs.js";import{T as at}from"./hooks-k1OxvonE.js";import{T as _}from"./toolbar-D0oe2g2b.js";import{S as st,M as mt}from"./shell-controls-DkLEUvEw.js";import"./companions-core-CZwGf1b1.js";import"./github-D4UJ99TO.js";import"./github-repo-scope-C8GSbvaz.js";import"./metadata-dUsYcpuu.js";import"./auth-RjDDTUUT.js";import"./schema-BQbhQoxs.js";import"./task-board-CXsHf2Zn.js";import"./use-connect-companion-2fL060lG.js";import"./integration-icon-BPwWRlNG.js";import"./Tool02-C_xRWqQk.js";import"./agent-icon-DrlilhFJ.js";import"./AlertCircle-EniJtD8E.js";import"./Tool01-BnKd95Y1.js";import"./ArrowUp-C0eratGp.js";import"./ArrowLeft-Clu1mSdY.js";import"./TrendUp01-PFzYDizC.js";import"./ZoomOut-BXPGwF_O.js";import"./Users03-CRtXqa1Q.js";import"./CheckCircle-cinYKmPU.js";import"./Check-BWpBE9uf.js";import"./ChevronUp-DGrguvGW.js";import"./ChevronRight-DzRB-rdO.js";import"./ChevronSelectorVertical-BiIbFU31.js";import"./DotsVertical-CucJCL9y.js";import"./UserSquare-CCDsU001.js";import"./Copy01-DayLu0dF.js";import"./CreditCard01-4OsjIT5f.js";import"./Database01-2gG_9E30.js";import"./Download01-BC2rKbuh.js";import"./Printer-fz_zwxfT.js";import"./Settings02-D2oiGU4q.js";import"./Eye-dnrP5DkM.js";import"./File02-BhckHV8N.js";import"./Share07-D_kiq5Fr.js";import"./GitBranch01-BBn4dN5f.js";import"./Globe01-SLAc63wC.js";import"./SwitchHorizontal01-CxlKjkIX.js";import"./HardDrive-FlnOYA_8.js";import"./Image01-BrHSH-Vi.js";import"./Key01-CKcg8G1v.js";import"./Link01-3t9JrUgl.js";import"./LinkExternal01-Cp7uxK1i.js";import"./Monitor01-BUruMK2r.js";import"./Sun-nKOZMh9n.js";import"./Package-CdfyZYxN.js";import"./Palette-CglyAOTg.js";import"./Play-rnw1eV52.js";import"./Plus-Bxp02MWl.js";import"./SearchLg-FC9suxna.js";import"./SearchMd-DRRptSJN.js";import"./Shield01-CjyLhqlS.js";import"./Stars01-COChWymR.js";import"./Trash01-DqUm2RRh.js";import"./Upload01-CqWnAR1-.js";import"./User01-BJoNdkjl.js";import"./Users01-DSQPwtP5.js";import"./XCircle-9Cb0khfg.js";import"./XClose-Cw4b4Uag.js";import"./Zap-ChVc0p76.js";import"./form-KjPevg0A.js";import"./label-CqlSWrLn.js";import"./input-HFOrJf5B.js";import"./use-debounced-value-Cud3o3Fq.js";import"./provision-repo-scoped-github-connection-B6zdkC6p.js";import"./extract-connection-data-CqGCTPdZ.js";import"./connection-OmoYXqZk.js";import"./useQueries-qr8TAkZc.js";import"./authenticate-and-persist-oauth-DXlrPDSv.js";import"./mcp-oauth-D6isOO_s.js";import"./track-BzMi8kcZ.js";import"./use-project-scope-B2cuvtTy.js";import"./use-virtual-mcp-Bk09OpEg.js";import"./github-repo-C0igpkr9.js";import"./thread-route-CKY-dKC0.js";import"./settings-sidebar-DswZBMwm.js";import"./toolbar-icon-button-EOE8J-Ai.js";import"./command-B6LMVdkQ.js";import"./index-w1d_dmEj.js";import"./drawer-s7gtDrb4.js";import"./popover-DIqZ2IKF.js";import"./project-icon-Bl3bXnhv.js";import"./create-organization-dialog--p2RMsV5.js";import"./alert-dialog-BE9ltHtr.js";import"./anchors-yqDzZN4K.js";import"./use-join-requests-DTGTfD21.js";import"./avatar-DcDvs8Zz.js";import"./use-deployment-admin-D6IzoXV0.js";import"./use-is-desktop-app-BNujXJc_.js";import"./download-app-dialog-BqNRF4Sn.js";import"./invite-member-dialog-vPcEYe6v.js";import"./select-Bc5UZb4n.js";import"./textarea-CneoU2lJ.js";import"./use-org-auth-client-4o0wRx2Q.js";import"./use-organization-roles-DzWM9Nv-.js";import"./add-connection-dialog-s1GRGQ63.js";import"./collection-search-CzGq8Uso.js";import"./connection-card-Cy-GdKQl.js";import"./use-registry-connections-DikbDR8w.js";import"./use-connection-DCLPda2h.js";import"./useInfiniteQuery-GKCP1c_7.js";import"./infiniteQueryObserver-DgAoAIrN.js";import"./retry-CErkP7V6.js";import"./backoff-CrEUbyZT.js";import"./delay-CnY5UFtP.js";import"./connection-slug-CITJ0kGN.js";import"./slugify-CEUa2lfQ.js";import"./connection-form-helpers-D3hdN_Pk.js";import"./collection-tabs-BLgGMB42.js";import"./badge-DJpaBl8u.js";import"./use-infinite-scroll-DkLPxlOu.js";import"./useSuspenseInfiniteQuery-DmEiIBI4.js";import"./use-deco-credits-rwNQ1gMg.js";import"./use-ai-providers-qnkcjapR.js";import"./scroll-area-BgZjjLM3.js";import"./decopilot-sse-pool-CfYFArSW.js";import"./task-route-D79aS9d_.js";import"./use-decopilot-events-DYRVevWg.js";import"./dropdown-menu-BxKUbUkE.js";import"./github-icon-D51q_6S8.js";import"./get-initials-D-f_fDFw.js";import"./format-time-BtXRrtv4.js";import"./differenceInSeconds-C3x8sHUj.js";import"./use-project-native-view-presence-D-AyEulW.js";import"./match-site-slug-config-D3fUJ6vX.js";import"./use-file-configs-BwD1CaWo.js";import"./site-slug-uya6Wp4-.js";import"./optimistic-project-sidebar-views-yrtk59Mo.js";import"./use-navigate-to-agent-Bbq0oQ0Y.js";import"./thread-intent-DVKldCEq.js";import"./use-panel-navigate-Byvx0cbx.js";import"./source-system-tabs-CnEGUb4r.js";import"./autosend-HdosN86x.js";import"./location-oTTXFrSF.js";function lt(o){const t=E.c(21),{siteUrl:c}=o,n=U(),{org:u}=N(),a=w();let h;t[0]!==n||t[1]!==u?(h=()=>{localStorage.setItem(k.sidebarOpen(),JSON.stringify(!1));const x=J(u,R.COMMERCE_DISCOVERY(u.id));n({...x,search:{...x.search,sidepanel:!1}})},t[0]=n,t[1]=u,t[2]=h):h=t[2];const p=h;let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=e.jsx($,{className:"bg-black/15 backdrop-blur-sm"}),t[3]=C):C=t[3];let s;t[4]!==a?(s=a("routes.commerceOnboarding.connectModal.dialogTitle"),t[4]=a,t[5]=s):s=t[5];let r;t[6]!==s?(r=e.jsx(G,{className:"sr-only",children:s}),t[6]=s,t[7]=r):r=t[7];let m;t[8]!==p||t[9]!==a?(m=()=>e.jsxs("div",{className:"grid gap-4 p-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:a("routes.commerceOnboarding.connectModal.loadError")}),e.jsxs(T,{type:"button",size:"xl",className:"w-full",onClick:p,children:[a("routes.commerceOnboarding.connectModal.continueButton"),e.jsx(D,{size:18})]})]}),t[8]=p,t[9]=a,t[10]=m):m=t[10];let d;t[11]===Symbol.for("react.memo_cache_sentinel")?(d=e.jsx(tt,{}),t[11]=d):d=t[11];let i;t[12]!==p||t[13]!==c?(i=e.jsx(y.Suspense,{fallback:d,children:e.jsx(ut,{siteUrlFromUrl:c,onComplete:p})}),t[12]=p,t[13]=c,t[14]=i):i=t[14];let l;t[15]!==m||t[16]!==i?(l=e.jsx(P,{fallback:m,children:i}),t[15]=m,t[16]=i,t[17]=l):l=t[17];let b;return t[18]!==r||t[19]!==l?(b=e.jsx(Q,{open:!0,children:e.jsxs(q,{children:[C,e.jsxs(z,{"data-slot":"commerce-connect-modal",onEscapeKeyDown:dt,onPointerDownOutside:pt,onInteractOutside:ct,className:"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex h-[calc(100dvh-1rem)] w-full max-w-[calc(100%-1rem)] translate-x-[-50%] translate-y-[-50%] flex-col overflow-hidden rounded-2xl border p-0 shadow-md duration-200 sm:max-w-lg md:h-auto md:max-h-[calc(100dvh-2rem)] lg:max-h-[calc(100dvh-4rem)] lg:max-w-5xl",children:[r,l]})]})}),t[18]=r,t[19]=l,t[20]=b):b=t[20],b}function ct(o){return o.preventDefault()}function pt(o){return o.preventDefault()}function dt(o){return o.preventDefault()}function ut({siteUrlFromUrl:o,onComplete:t}){const c=w(),{org:n}=N(),u=R.COMMERCE_DISCOVERY(n.id),a=X({connectionId:F,orgId:n.id,orgSlug:n.slug}),p=L({queryKey:A.commerceDiscoveryConnection(n.id,u),queryFn:async()=>{const f=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:u}});return j(f)},retry:!1}).data.item,C=typeof p?.metadata?.siteUrl=="string"?p.metadata.siteUrl:void 0,s=o||C,r=V(s),[m,d]=y.useState(!0),[i,l]=y.useState(null),b=O({mutationFn:async f=>j(await a.callTool({name:"COMMERCE_DISCOVERY_SETUP",arguments:{siteUrl:f}})),retry:!1}),x=O({mutationFn:async f=>j(await a.callTool({name:"COMMERCE_DISCOVERY_RUN",arguments:{siteUrl:f}})),retry:!1}),v=async()=>{l(null),S("commerce_onboarding_open_report_clicked",{domain:r??void 0,organization_id:n.id});const f=s?W(s):null;if(f?.ok)try{let g=await x.mutateAsync(f.value);if(g.triggered||(S("commerce_onboarding_run_reclaim",{domain:r??void 0,organization_id:n.id,reason:g.reason??"not_upgraded"}),await b.mutateAsync(f.value),g=await x.mutateAsync(f.value)),!g.triggered){S("commerce_onboarding_run_failed",{domain:r??void 0,organization_id:n.id,error:g.reason??"not_triggered"}),l(c("routes.commerceOnboarding.connectModal.couldNotGenerateReport"));return}}catch(g){S("commerce_onboarding_run_failed",{domain:r??void 0,organization_id:n.id,error:g instanceof Error?g.message:String(g)}),l(c("routes.commerceOnboarding.connectModal.somethingWentWrong"));return}t()},I=Z("demo_mode"),M=m||I;return e.jsx(et,{siteHost:r,footer:e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"text-sm leading-5 text-destructive",role:"alert",children:i}):null,e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(rt,{ready:M,pending:x.isPending,label:x.isPending?c("routes.commerceOnboarding.connectModal.openingReport"):c("routes.commerceOnboarding.connectModal.viewDiagnostic"),onClick:()=>{v()},children:e.jsx(D,{size:18})})}),M?null:e.jsx(T,{type:"button",variant:"secondary",size:"lg",className:"h-auto min-h-12 shrink-0 rounded-lg py-3 text-base font-medium leading-tight",disabled:x.isPending,onClick:()=>{v()},children:c("routes.commerceOnboarding.connectModal.skip")})]})]}),children:e.jsx(ot,{org:n,cdConnectionId:u,siteUrl:s,onReadinessChange:d})})}function er(){const o=E.c(14),t=B();let c;o[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},o[0]=c):c=o[0];const{connect:n,siteUrl:u}=H(c),a=n==="1",h=t;let p;o[1]===Symbol.for("react.memo_cache_sentinel")?(p=e.jsx(_.Header,{className:"grid-cols-1 px-1",children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[e.jsx(st,{}),e.jsx(_.TogglesSlot,{}),e.jsx(_.TabsSlot,{className:"shrink-0"}),e.jsx(_.CenterSlot,{}),e.jsx(_.RightSlot,{})]})}),o[1]=p):p=o[1];const s=h&&p;let r;o[2]===Symbol.for("react.memo_cache_sentinel")?(r=e.jsx("div",{className:"relative flex-1 min-h-0 flex flex-row",children:e.jsx(K,{children:e.jsx(Y,{})})}),o[2]=r):r=o[2];let m;o[3]!==s?(m=e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[s,r]}),o[3]=s,o[4]=m):m=o[4];let d;o[5]!==t?(d=t&&e.jsx(mt,{renderSidebar:ft}),o[5]=t,o[6]=d):d=o[6];let i;o[7]!==u||o[8]!==a?(i=a&&e.jsx(lt,{siteUrl:u}),o[7]=u,o[8]=a,o[9]=i):i=o[9];let l;return o[10]!==m||o[11]!==d||o[12]!==i?(l=e.jsx(at,{children:e.jsx(_.Provider,{children:e.jsxs(nt,{children:[m,d,i]})})}),o[10]=m,o[11]=d,o[12]=i,o[13]=l):l=o[13],l}function ft(o){const{onClose:t}=o;return e.jsx("div",{className:"flex h-full",children:e.jsx("div",{className:"w-full bg-sidebar flex flex-col overflow-y-auto group/sidebar","data-state":"expanded",children:e.jsx(it,{onClose:t})})})}export{er as default};
1
+ import{c as E,d as U,I as N,b as w,U as k,W as R,j as e,B as T,r as y,E as P,_ as z,x as F,z as L,K as A,e as O,o as S,R as B,u as H,$ as K,O as Y}from"./index-BodvdIMk.js";import{s as V,n as W}from"./site-url-en5df9c-.js";import{f as $,d as G,D as Q,g as q}from"./dialog-BAfLND_C.js";import{c as J}from"./use-commerce-diagnostic-BQRYyoWw.js";import{u as X}from"./use-mcp-client-DO1cH-Rq.js";import{i as D}from"./ArrowRight-B4GAIQKI.js";import{u as Z}from"./use-organization-settings-C7uzGCkO.js";import{C as tt,a as ot}from"./companion-mcps-section-RMajitXP.js";import{C as et,a as rt}from"./connect-layout-CcZHYYLs.js";import{p as j}from"./self-tool-result-8OxPN9Nm.js";import{a as it}from"./index-5lUn2NYU.js";import{C as nt}from"./chat-context-BdJniD3E.js";import{T as at}from"./hooks-D-bAuZ0C.js";import{T as _}from"./toolbar-DK-dWmgo.js";import{S as st,M as mt}from"./shell-controls-oSe12Dvv.js";import"./companions-core-CZwGf1b1.js";import"./github-D4UJ99TO.js";import"./github-repo-scope-C8GSbvaz.js";import"./metadata-dUsYcpuu.js";import"./auth-BRT05k6V.js";import"./schema-DVRYVU-6.js";import"./task-board-B_FYv6yr.js";import"./use-connect-companion-0NSfsYdR.js";import"./integration-icon-BqCQeMla.js";import"./Tool02-CnClhfmX.js";import"./agent-icon-DlT0cyOd.js";import"./AlertCircle-CfOItn1b.js";import"./Tool01-duhLcQNq.js";import"./ArrowUp-Be_FwN-E.js";import"./ArrowLeft-B4kTLC80.js";import"./TrendUp01-fYoe36da.js";import"./ZoomOut-B6xnZLKD.js";import"./Users03-pPPKVW_h.js";import"./CheckCircle-BQEdmdLU.js";import"./Check-_wGz2-IJ.js";import"./ChevronUp-SbK1Bh_A.js";import"./ChevronRight-DfnK-irb.js";import"./ChevronSelectorVertical-DTb5009V.js";import"./DotsVertical-Ct2yI8vr.js";import"./UserSquare-CXNfIfPy.js";import"./Copy01-DoHw-_s5.js";import"./CreditCard01-CkbbYVCy.js";import"./Database01-DDqP2OWW.js";import"./Download01-IytcAces.js";import"./Printer-kkmv6XzS.js";import"./Settings02-DPUnnUpS.js";import"./Eye-Ccu8gsxq.js";import"./File02-CODRlzC9.js";import"./Share07-ezwRb3nU.js";import"./GitBranch01-y6_LtrpC.js";import"./Globe01-BHsBANMN.js";import"./SwitchHorizontal01-Dne29Upz.js";import"./HardDrive-Cr2Uhzo6.js";import"./Image01-PUenBySa.js";import"./Key01-ugSjw0sl.js";import"./Link01-CUXePRyB.js";import"./LinkExternal01-DLDyK_TN.js";import"./Monitor01-J9g_ep-X.js";import"./Sun-DZjMucTf.js";import"./Package-Dm9TBHk7.js";import"./Palette-BywMlwsu.js";import"./Play-HfzzXB20.js";import"./Plus-zXs3aP31.js";import"./SearchLg-BkMCmJSN.js";import"./SearchMd-uhtNwnF8.js";import"./Shield01-BcXJFwaP.js";import"./Stars01-DdrI1AvW.js";import"./Trash01-CH5l96iG.js";import"./Upload01-DksJHtIE.js";import"./User01-DZs8rqql.js";import"./Users01-DZlg18P8.js";import"./XCircle-CoSRJnuK.js";import"./XClose-BYsCvLXW.js";import"./Zap-BLQffepl.js";import"./form-B2aJ1tMr.js";import"./label-oySBL-hw.js";import"./input-CyCfmV2v.js";import"./use-debounced-value-Dci7_Qwe.js";import"./provision-repo-scoped-github-connection-B6zdkC6p.js";import"./extract-connection-data-DuAiwl2M.js";import"./connection-D3sgkgc8.js";import"./useQueries-CDFEvGc1.js";import"./authenticate-and-persist-oauth-VFbyMRtb.js";import"./mcp-oauth-D4sc2QRH.js";import"./track-CzfYfVMq.js";import"./use-project-scope-cOFjIv3F.js";import"./use-virtual-mcp-DY2qk06G.js";import"./github-repo-C0igpkr9.js";import"./thread-route-BPX5b65a.js";import"./settings-sidebar-D1CImlJ7.js";import"./toolbar-icon-button-D7IEoYBH.js";import"./command-vCLlEnld.js";import"./index-CFD2Tmax.js";import"./drawer-CftCt6Vc.js";import"./popover-BaPHFXoA.js";import"./project-icon-D14m61tO.js";import"./create-organization-dialog-D3-ZW85P.js";import"./alert-dialog-B19dFL0f.js";import"./anchors-yqDzZN4K.js";import"./use-join-requests-DxlLP6Wr.js";import"./avatar-CAI2JETZ.js";import"./use-deployment-admin-CRRFLUPy.js";import"./use-is-desktop-app-BNujXJc_.js";import"./download-app-dialog-inqOoiFR.js";import"./invite-member-dialog-l7jaUM00.js";import"./select-bwhAgSkw.js";import"./textarea-2MjTWIvv.js";import"./use-org-auth-client-S952sZID.js";import"./use-organization-roles--bC30gnD.js";import"./add-connection-dialog-ColILHSg.js";import"./collection-search-DBiZveMp.js";import"./connection-card-BUk8IuWl.js";import"./use-registry-connections-XlfVpqo2.js";import"./use-connection-B0HreEyO.js";import"./useInfiniteQuery-B3TKIUIz.js";import"./infiniteQueryObserver-BXxOeKaH.js";import"./retry-CErkP7V6.js";import"./backoff-CrEUbyZT.js";import"./delay-CnY5UFtP.js";import"./connection-slug-CITJ0kGN.js";import"./slugify-CEUa2lfQ.js";import"./connection-form-helpers-CjZ0gF9p.js";import"./collection-tabs-BxTayoNr.js";import"./badge-ByfZPYh0.js";import"./use-infinite-scroll-TMy8eEjN.js";import"./useSuspenseInfiniteQuery-BuAksfER.js";import"./use-deco-credits-CQYk77NF.js";import"./use-ai-providers-BHw3Z_he.js";import"./scroll-area-DrpmDXmv.js";import"./decopilot-sse-pool-C4pTRblZ.js";import"./task-route-D8DTrzfK.js";import"./use-decopilot-events-HctMj33h.js";import"./dropdown-menu-DlZDenrk.js";import"./github-icon-BHD2Mc12.js";import"./get-initials-D-f_fDFw.js";import"./format-time-BtXRrtv4.js";import"./differenceInSeconds-C3x8sHUj.js";import"./use-project-native-view-presence-DqW-vLSC.js";import"./match-site-slug-config-D3fUJ6vX.js";import"./use-file-configs-CMLhU-Fj.js";import"./site-slug-uya6Wp4-.js";import"./optimistic-project-sidebar-views-Crt809gH.js";import"./use-navigate-to-agent-DbrSvmvC.js";import"./thread-intent-C_TUHShU.js";import"./use-panel-navigate-BgqqPVEC.js";import"./source-system-tabs-CnEGUb4r.js";import"./autosend-BfRMZFUN.js";import"./location-oTTXFrSF.js";function lt(o){const t=E.c(21),{siteUrl:c}=o,n=U(),{org:u}=N(),a=w();let h;t[0]!==n||t[1]!==u?(h=()=>{localStorage.setItem(k.sidebarOpen(),JSON.stringify(!1));const x=J(u,R.COMMERCE_DISCOVERY(u.id));n({...x,search:{...x.search,sidepanel:!1}})},t[0]=n,t[1]=u,t[2]=h):h=t[2];const p=h;let C;t[3]===Symbol.for("react.memo_cache_sentinel")?(C=e.jsx($,{className:"bg-black/15 backdrop-blur-sm"}),t[3]=C):C=t[3];let s;t[4]!==a?(s=a("routes.commerceOnboarding.connectModal.dialogTitle"),t[4]=a,t[5]=s):s=t[5];let r;t[6]!==s?(r=e.jsx(G,{className:"sr-only",children:s}),t[6]=s,t[7]=r):r=t[7];let m;t[8]!==p||t[9]!==a?(m=()=>e.jsxs("div",{className:"grid gap-4 p-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:a("routes.commerceOnboarding.connectModal.loadError")}),e.jsxs(T,{type:"button",size:"xl",className:"w-full",onClick:p,children:[a("routes.commerceOnboarding.connectModal.continueButton"),e.jsx(D,{size:18})]})]}),t[8]=p,t[9]=a,t[10]=m):m=t[10];let d;t[11]===Symbol.for("react.memo_cache_sentinel")?(d=e.jsx(tt,{}),t[11]=d):d=t[11];let i;t[12]!==p||t[13]!==c?(i=e.jsx(y.Suspense,{fallback:d,children:e.jsx(ut,{siteUrlFromUrl:c,onComplete:p})}),t[12]=p,t[13]=c,t[14]=i):i=t[14];let l;t[15]!==m||t[16]!==i?(l=e.jsx(P,{fallback:m,children:i}),t[15]=m,t[16]=i,t[17]=l):l=t[17];let b;return t[18]!==r||t[19]!==l?(b=e.jsx(Q,{open:!0,children:e.jsxs(q,{children:[C,e.jsxs(z,{"data-slot":"commerce-connect-modal",onEscapeKeyDown:dt,onPointerDownOutside:pt,onInteractOutside:ct,className:"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex h-[calc(100dvh-1rem)] w-full max-w-[calc(100%-1rem)] translate-x-[-50%] translate-y-[-50%] flex-col overflow-hidden rounded-2xl border p-0 shadow-md duration-200 sm:max-w-lg md:h-auto md:max-h-[calc(100dvh-2rem)] lg:max-h-[calc(100dvh-4rem)] lg:max-w-5xl",children:[r,l]})]})}),t[18]=r,t[19]=l,t[20]=b):b=t[20],b}function ct(o){return o.preventDefault()}function pt(o){return o.preventDefault()}function dt(o){return o.preventDefault()}function ut({siteUrlFromUrl:o,onComplete:t}){const c=w(),{org:n}=N(),u=R.COMMERCE_DISCOVERY(n.id),a=X({connectionId:F,orgId:n.id,orgSlug:n.slug}),p=L({queryKey:A.commerceDiscoveryConnection(n.id,u),queryFn:async()=>{const f=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:u}});return j(f)},retry:!1}).data.item,C=typeof p?.metadata?.siteUrl=="string"?p.metadata.siteUrl:void 0,s=o||C,r=V(s),[m,d]=y.useState(!0),[i,l]=y.useState(null),b=O({mutationFn:async f=>j(await a.callTool({name:"COMMERCE_DISCOVERY_SETUP",arguments:{siteUrl:f}})),retry:!1}),x=O({mutationFn:async f=>j(await a.callTool({name:"COMMERCE_DISCOVERY_RUN",arguments:{siteUrl:f}})),retry:!1}),v=async()=>{l(null),S("commerce_onboarding_open_report_clicked",{domain:r??void 0,organization_id:n.id});const f=s?W(s):null;if(f?.ok)try{let g=await x.mutateAsync(f.value);if(g.triggered||(S("commerce_onboarding_run_reclaim",{domain:r??void 0,organization_id:n.id,reason:g.reason??"not_upgraded"}),await b.mutateAsync(f.value),g=await x.mutateAsync(f.value)),!g.triggered){S("commerce_onboarding_run_failed",{domain:r??void 0,organization_id:n.id,error:g.reason??"not_triggered"}),l(c("routes.commerceOnboarding.connectModal.couldNotGenerateReport"));return}}catch(g){S("commerce_onboarding_run_failed",{domain:r??void 0,organization_id:n.id,error:g instanceof Error?g.message:String(g)}),l(c("routes.commerceOnboarding.connectModal.somethingWentWrong"));return}t()},I=Z("demo_mode"),M=m||I;return e.jsx(et,{siteHost:r,footer:e.jsxs(e.Fragment,{children:[i?e.jsx("p",{className:"text-sm leading-5 text-destructive",role:"alert",children:i}):null,e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(rt,{ready:M,pending:x.isPending,label:x.isPending?c("routes.commerceOnboarding.connectModal.openingReport"):c("routes.commerceOnboarding.connectModal.viewDiagnostic"),onClick:()=>{v()},children:e.jsx(D,{size:18})})}),M?null:e.jsx(T,{type:"button",variant:"secondary",size:"lg",className:"h-auto min-h-12 shrink-0 rounded-lg py-3 text-base font-medium leading-tight",disabled:x.isPending,onClick:()=>{v()},children:c("routes.commerceOnboarding.connectModal.skip")})]})]}),children:e.jsx(ot,{org:n,cdConnectionId:u,siteUrl:s,onReadinessChange:d})})}function er(){const o=E.c(14),t=B();let c;o[0]===Symbol.for("react.memo_cache_sentinel")?(c={strict:!1},o[0]=c):c=o[0];const{connect:n,siteUrl:u}=H(c),a=n==="1",h=t;let p;o[1]===Symbol.for("react.memo_cache_sentinel")?(p=e.jsx(_.Header,{className:"grid-cols-1 px-1",children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[e.jsx(st,{}),e.jsx(_.TogglesSlot,{}),e.jsx(_.TabsSlot,{className:"shrink-0"}),e.jsx(_.CenterSlot,{}),e.jsx(_.RightSlot,{})]})}),o[1]=p):p=o[1];const s=h&&p;let r;o[2]===Symbol.for("react.memo_cache_sentinel")?(r=e.jsx("div",{className:"relative flex-1 min-h-0 flex flex-row",children:e.jsx(K,{children:e.jsx(Y,{})})}),o[2]=r):r=o[2];let m;o[3]!==s?(m=e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[s,r]}),o[3]=s,o[4]=m):m=o[4];let d;o[5]!==t?(d=t&&e.jsx(mt,{renderSidebar:ft}),o[5]=t,o[6]=d):d=o[6];let i;o[7]!==u||o[8]!==a?(i=a&&e.jsx(lt,{siteUrl:u}),o[7]=u,o[8]=a,o[9]=i):i=o[9];let l;return o[10]!==m||o[11]!==d||o[12]!==i?(l=e.jsx(at,{children:e.jsx(_.Provider,{children:e.jsxs(nt,{children:[m,d,i]})})}),o[10]=m,o[11]=d,o[12]=i,o[13]=l):l=o[13],l}function ft(o){const{onClose:t}=o;return e.jsx("div",{className:"flex h-full",children:e.jsx("div",{className:"w-full bg-sidebar flex flex-col overflow-y-auto group/sidebar","data-state":"expanded",children:e.jsx(it,{onClose:t})})})}export{er as default};